documentation.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  496. */
  497. export class PerformanceMonitor {
  498. private _enabled;
  499. private _rollingFrameTime;
  500. private _lastFrameTimeMs;
  501. /**
  502. * constructor
  503. * @param frameSampleSize The number of samples required to saturate the sliding window
  504. */
  505. constructor(frameSampleSize?: number);
  506. /**
  507. * Samples current frame
  508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  509. */
  510. sampleFrame(timeMs?: number): void;
  511. /**
  512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  513. */
  514. readonly averageFrameTime: number;
  515. /**
  516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  517. */
  518. readonly averageFrameTimeVariance: number;
  519. /**
  520. * Returns the frame time of the most recent frame
  521. */
  522. readonly instantaneousFrameTime: number;
  523. /**
  524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  525. */
  526. readonly averageFPS: number;
  527. /**
  528. * Returns the average framerate in frames per second using the most recent frame time
  529. */
  530. readonly instantaneousFPS: number;
  531. /**
  532. * Returns true if enough samples have been taken to completely fill the sliding window
  533. */
  534. readonly isSaturated: boolean;
  535. /**
  536. * Enables contributions to the sliding window sample set
  537. */
  538. enable(): void;
  539. /**
  540. * Disables contributions to the sliding window sample set
  541. * Samples will not be interpolated over the disabled period
  542. */
  543. disable(): void;
  544. /**
  545. * Returns true if sampling is enabled
  546. */
  547. readonly isEnabled: boolean;
  548. /**
  549. * Resets performance monitor
  550. */
  551. reset(): void;
  552. }
  553. /**
  554. * RollingAverage
  555. *
  556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  557. */
  558. export class RollingAverage {
  559. /**
  560. * Current average
  561. */
  562. average: number;
  563. /**
  564. * Current variance
  565. */
  566. variance: number;
  567. protected _samples: Array<number>;
  568. protected _sampleCount: number;
  569. protected _pos: number;
  570. protected _m2: number;
  571. /**
  572. * constructor
  573. * @param length The number of samples required to saturate the sliding window
  574. */
  575. constructor(length: number);
  576. /**
  577. * Adds a sample to the sample set
  578. * @param v The sample value
  579. */
  580. add(v: number): void;
  581. /**
  582. * Returns previously added values or null if outside of history or outside the sliding window domain
  583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  584. * @return Value previously recorded with add() or null if outside of range
  585. */
  586. history(i: number): number;
  587. /**
  588. * Returns true if enough samples have been taken to completely fill the sliding window
  589. * @return true if sample-set saturated
  590. */
  591. isSaturated(): boolean;
  592. /**
  593. * Resets the rolling average (equivalent to 0 samples taken so far)
  594. */
  595. reset(): void;
  596. /**
  597. * Wraps a value around the sample range boundaries
  598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  599. * @return Wrapped position in sample range
  600. */
  601. protected _wrapPosition(i: number): number;
  602. }
  603. }
  604. declare module BABYLON {
  605. /**
  606. * This class implement a typical dictionary using a string as key and the generic type T as value.
  607. * The underlying implementation relies on an associative array to ensure the best performances.
  608. * The value can be anything including 'null' but except 'undefined'
  609. */
  610. export class StringDictionary<T> {
  611. /**
  612. * This will clear this dictionary and copy the content from the 'source' one.
  613. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  614. * @param source the dictionary to take the content from and copy to this dictionary
  615. */
  616. copyFrom(source: StringDictionary<T>): void;
  617. /**
  618. * Get a value based from its key
  619. * @param key the given key to get the matching value from
  620. * @return the value if found, otherwise undefined is returned
  621. */
  622. get(key: string): T | undefined;
  623. /**
  624. * Get a value from its key or add it if it doesn't exist.
  625. * This method will ensure you that a given key/data will be present in the dictionary.
  626. * @param key the given key to get the matching value from
  627. * @param factory the factory that will create the value if the key is not present in the dictionary.
  628. * The factory will only be invoked if there's no data for the given key.
  629. * @return the value corresponding to the key.
  630. */
  631. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  632. /**
  633. * Get a value from its key if present in the dictionary otherwise add it
  634. * @param key the key to get the value from
  635. * @param val if there's no such key/value pair in the dictionary add it with this value
  636. * @return the value corresponding to the key
  637. */
  638. getOrAdd(key: string, val: T): T;
  639. /**
  640. * Check if there's a given key in the dictionary
  641. * @param key the key to check for
  642. * @return true if the key is present, false otherwise
  643. */
  644. contains(key: string): boolean;
  645. /**
  646. * Add a new key and its corresponding value
  647. * @param key the key to add
  648. * @param value the value corresponding to the key
  649. * @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
  650. */
  651. add(key: string, value: T): boolean;
  652. /**
  653. * Update a specific value associated to a key
  654. * @param key defines the key to use
  655. * @param value defines the value to store
  656. * @returns true if the value was updated (or false if the key was not found)
  657. */
  658. set(key: string, value: T): boolean;
  659. /**
  660. * Get the element of the given key and remove it from the dictionary
  661. * @param key defines the key to search
  662. * @returns the value associated with the key or null if not found
  663. */
  664. getAndRemove(key: string): Nullable<T>;
  665. /**
  666. * Remove a key/value from the dictionary.
  667. * @param key the key to remove
  668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  669. */
  670. remove(key: string): boolean;
  671. /**
  672. * Clear the whole content of the dictionary
  673. */
  674. clear(): void;
  675. /**
  676. * Gets the current count
  677. */
  678. readonly count: number;
  679. /**
  680. * Execute a callback on each key/val of the dictionary.
  681. * Note that you can remove any element in this dictionary in the callback implementation
  682. * @param callback the callback to execute on a given key/value pair
  683. */
  684. forEach(callback: (key: string, val: T) => void): void;
  685. /**
  686. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  687. * If the callback returns null or undefined the method will iterate to the next key/value pair
  688. * Note that you can remove any element in this dictionary in the callback implementation
  689. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  690. * @returns the first item
  691. */
  692. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  693. private _count;
  694. private _data;
  695. }
  696. }
  697. declare module BABYLON {
  698. /**
  699. * Class used to store gfx data (like WebGLBuffer)
  700. */
  701. export class DataBuffer {
  702. /**
  703. * Gets or sets the number of objects referencing this buffer
  704. */
  705. references: number;
  706. /** Gets or sets the size of the underlying buffer */
  707. capacity: number;
  708. /**
  709. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  710. */
  711. is32Bits: boolean;
  712. /**
  713. * Gets the underlying buffer
  714. */
  715. readonly underlyingResource: any;
  716. }
  717. }
  718. declare module BABYLON {
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module BABYLON {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. }
  1248. declare module BABYLON {
  1249. /**
  1250. * Class used to represent a viewport on screen
  1251. */
  1252. export class Viewport {
  1253. /** viewport left coordinate */
  1254. x: number;
  1255. /** viewport top coordinate */
  1256. y: number;
  1257. /**viewport width */
  1258. width: number;
  1259. /** viewport height */
  1260. height: number;
  1261. /**
  1262. * Creates a Viewport object located at (x, y) and sized (width, height)
  1263. * @param x defines viewport left coordinate
  1264. * @param y defines viewport top coordinate
  1265. * @param width defines the viewport width
  1266. * @param height defines the viewport height
  1267. */
  1268. constructor(
  1269. /** viewport left coordinate */
  1270. x: number,
  1271. /** viewport top coordinate */
  1272. y: number,
  1273. /**viewport width */
  1274. width: number,
  1275. /** viewport height */
  1276. height: number);
  1277. /**
  1278. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1279. * @param renderWidth defines the rendering width
  1280. * @param renderHeight defines the rendering height
  1281. * @returns a new Viewport
  1282. */
  1283. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1284. /**
  1285. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1286. * @param renderWidth defines the rendering width
  1287. * @param renderHeight defines the rendering height
  1288. * @param ref defines the target viewport
  1289. * @returns the current viewport
  1290. */
  1291. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1292. /**
  1293. * Returns a new Viewport copied from the current one
  1294. * @returns a new Viewport
  1295. */
  1296. clone(): Viewport;
  1297. }
  1298. }
  1299. declare module BABYLON {
  1300. /**
  1301. * Class containing a set of static utilities functions for arrays.
  1302. */
  1303. export class ArrayTools {
  1304. /**
  1305. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1306. * @param size the number of element to construct and put in the array
  1307. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1308. * @returns a new array filled with new objects
  1309. */
  1310. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /**
  1315. * @hidden
  1316. */
  1317. export interface IColor4Like {
  1318. r: float;
  1319. g: float;
  1320. b: float;
  1321. a: float;
  1322. }
  1323. /**
  1324. * @hidden
  1325. */
  1326. export interface IColor3Like {
  1327. r: float;
  1328. g: float;
  1329. b: float;
  1330. }
  1331. /**
  1332. * @hidden
  1333. */
  1334. export interface IVector4Like {
  1335. x: float;
  1336. y: float;
  1337. z: float;
  1338. w: float;
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export interface IVector3Like {
  1344. x: float;
  1345. y: float;
  1346. z: float;
  1347. }
  1348. /**
  1349. * @hidden
  1350. */
  1351. export interface IVector2Like {
  1352. x: float;
  1353. y: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IMatrixLike {
  1359. toArray(): DeepImmutable<Float32Array>;
  1360. updateFlag: int;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IViewportLike {
  1366. x: float;
  1367. y: float;
  1368. width: float;
  1369. height: float;
  1370. }
  1371. /**
  1372. * @hidden
  1373. */
  1374. export interface IPlaneLike {
  1375. normal: IVector3Like;
  1376. d: float;
  1377. normalize(): void;
  1378. }
  1379. }
  1380. declare module BABYLON {
  1381. /**
  1382. * Class representing a vector containing 2 coordinates
  1383. */
  1384. export class Vector2 {
  1385. /** defines the first coordinate */
  1386. x: number;
  1387. /** defines the second coordinate */
  1388. y: number;
  1389. /**
  1390. * Creates a new Vector2 from the given x and y coordinates
  1391. * @param x defines the first coordinate
  1392. * @param y defines the second coordinate
  1393. */
  1394. constructor(
  1395. /** defines the first coordinate */
  1396. x?: number,
  1397. /** defines the second coordinate */
  1398. y?: number);
  1399. /**
  1400. * Gets a string with the Vector2 coordinates
  1401. * @returns a string with the Vector2 coordinates
  1402. */
  1403. toString(): string;
  1404. /**
  1405. * Gets class name
  1406. * @returns the string "Vector2"
  1407. */
  1408. getClassName(): string;
  1409. /**
  1410. * Gets current vector hash code
  1411. * @returns the Vector2 hash code as a number
  1412. */
  1413. getHashCode(): number;
  1414. /**
  1415. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1416. * @param array defines the source array
  1417. * @param index defines the offset in source array
  1418. * @returns the current Vector2
  1419. */
  1420. toArray(array: FloatArray, index?: number): Vector2;
  1421. /**
  1422. * Copy the current vector to an array
  1423. * @returns a new array with 2 elements: the Vector2 coordinates.
  1424. */
  1425. asArray(): number[];
  1426. /**
  1427. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1428. * @param source defines the source Vector2
  1429. * @returns the current updated Vector2
  1430. */
  1431. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1432. /**
  1433. * Sets the Vector2 coordinates with the given floats
  1434. * @param x defines the first coordinate
  1435. * @param y defines the second coordinate
  1436. * @returns the current updated Vector2
  1437. */
  1438. copyFromFloats(x: number, y: number): Vector2;
  1439. /**
  1440. * Sets the Vector2 coordinates with the given floats
  1441. * @param x defines the first coordinate
  1442. * @param y defines the second coordinate
  1443. * @returns the current updated Vector2
  1444. */
  1445. set(x: number, y: number): Vector2;
  1446. /**
  1447. * Add another vector with the current one
  1448. * @param otherVector defines the other vector
  1449. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1450. */
  1451. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1452. /**
  1453. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1454. * @param otherVector defines the other vector
  1455. * @param result defines the target vector
  1456. * @returns the unmodified current Vector2
  1457. */
  1458. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1459. /**
  1460. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1461. * @param otherVector defines the other vector
  1462. * @returns the current updated Vector2
  1463. */
  1464. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1465. /**
  1466. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1467. * @param otherVector defines the other vector
  1468. * @returns a new Vector2
  1469. */
  1470. addVector3(otherVector: Vector3): Vector2;
  1471. /**
  1472. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1473. * @param otherVector defines the other vector
  1474. * @returns a new Vector2
  1475. */
  1476. subtract(otherVector: Vector2): Vector2;
  1477. /**
  1478. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1479. * @param otherVector defines the other vector
  1480. * @param result defines the target vector
  1481. * @returns the unmodified current Vector2
  1482. */
  1483. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1484. /**
  1485. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1486. * @param otherVector defines the other vector
  1487. * @returns the current updated Vector2
  1488. */
  1489. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1490. /**
  1491. * Multiplies in place the current Vector2 coordinates by the given ones
  1492. * @param otherVector defines the other vector
  1493. * @returns the current updated Vector2
  1494. */
  1495. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1498. * @param otherVector defines the other vector
  1499. * @returns a new Vector2
  1500. */
  1501. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1502. /**
  1503. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1504. * @param otherVector defines the other vector
  1505. * @param result defines the target vector
  1506. * @returns the unmodified current Vector2
  1507. */
  1508. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1509. /**
  1510. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1511. * @param x defines the first coordinate
  1512. * @param y defines the second coordinate
  1513. * @returns a new Vector2
  1514. */
  1515. multiplyByFloats(x: number, y: number): Vector2;
  1516. /**
  1517. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1518. * @param otherVector defines the other vector
  1519. * @returns a new Vector2
  1520. */
  1521. divide(otherVector: Vector2): Vector2;
  1522. /**
  1523. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1524. * @param otherVector defines the other vector
  1525. * @param result defines the target vector
  1526. * @returns the unmodified current Vector2
  1527. */
  1528. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1529. /**
  1530. * Divides the current Vector2 coordinates by the given ones
  1531. * @param otherVector defines the other vector
  1532. * @returns the current updated Vector2
  1533. */
  1534. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1535. /**
  1536. * Gets a new Vector2 with current Vector2 negated coordinates
  1537. * @returns a new Vector2
  1538. */
  1539. negate(): Vector2;
  1540. /**
  1541. * Multiply the Vector2 coordinates by scale
  1542. * @param scale defines the scaling factor
  1543. * @returns the current updated Vector2
  1544. */
  1545. scaleInPlace(scale: number): Vector2;
  1546. /**
  1547. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1548. * @param scale defines the scaling factor
  1549. * @returns a new Vector2
  1550. */
  1551. scale(scale: number): Vector2;
  1552. /**
  1553. * Scale the current Vector2 values by a factor to a given Vector2
  1554. * @param scale defines the scale factor
  1555. * @param result defines the Vector2 object where to store the result
  1556. * @returns the unmodified current Vector2
  1557. */
  1558. scaleToRef(scale: number, result: Vector2): Vector2;
  1559. /**
  1560. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1561. * @param scale defines the scale factor
  1562. * @param result defines the Vector2 object where to store the result
  1563. * @returns the unmodified current Vector2
  1564. */
  1565. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1566. /**
  1567. * Gets a boolean if two vectors are equals
  1568. * @param otherVector defines the other vector
  1569. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1570. */
  1571. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1572. /**
  1573. * Gets a boolean if two vectors are equals (using an epsilon value)
  1574. * @param otherVector defines the other vector
  1575. * @param epsilon defines the minimal distance to consider equality
  1576. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1577. */
  1578. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. floor(): Vector2;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. fract(): Vector2;
  1589. /**
  1590. * Gets the length of the vector
  1591. * @returns the vector length (float)
  1592. */
  1593. length(): number;
  1594. /**
  1595. * Gets the vector squared length
  1596. * @returns the vector squared length (float)
  1597. */
  1598. lengthSquared(): number;
  1599. /**
  1600. * Normalize the vector
  1601. * @returns the current updated Vector2
  1602. */
  1603. normalize(): Vector2;
  1604. /**
  1605. * Gets a new Vector2 copied from the Vector2
  1606. * @returns a new Vector2
  1607. */
  1608. clone(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(0, 0)
  1611. * @returns a new Vector2
  1612. */
  1613. static Zero(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(1, 1)
  1616. * @returns a new Vector2
  1617. */
  1618. static One(): Vector2;
  1619. /**
  1620. * Gets a new Vector2 set from the given index element of the given array
  1621. * @param array defines the data source
  1622. * @param offset defines the offset in the data source
  1623. * @returns a new Vector2
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1626. /**
  1627. * Sets "result" from the given index element of the given array
  1628. * @param array defines the data source
  1629. * @param offset defines the offset in the data source
  1630. * @param result defines the target vector
  1631. */
  1632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1633. /**
  1634. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1635. * @param value1 defines 1st point of control
  1636. * @param value2 defines 2nd point of control
  1637. * @param value3 defines 3rd point of control
  1638. * @param value4 defines 4th point of control
  1639. * @param amount defines the interpolation factor
  1640. * @returns a new Vector2
  1641. */
  1642. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1643. /**
  1644. * 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".
  1645. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1646. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1647. * @param value defines the value to clamp
  1648. * @param min defines the lower limit
  1649. * @param max defines the upper limit
  1650. * @returns a new Vector2
  1651. */
  1652. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1655. * @param value1 defines the 1st control point
  1656. * @param tangent1 defines the outgoing tangent
  1657. * @param value2 defines the 2nd control point
  1658. * @param tangent2 defines the incoming tangent
  1659. * @param amount defines the interpolation factor
  1660. * @returns a new Vector2
  1661. */
  1662. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1665. * @param start defines the start vector
  1666. * @param end defines the end vector
  1667. * @param amount defines the interpolation factor
  1668. * @returns a new Vector2
  1669. */
  1670. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1671. /**
  1672. * Gets the dot product of the vector "left" and the vector "right"
  1673. * @param left defines first vector
  1674. * @param right defines second vector
  1675. * @returns the dot product (float)
  1676. */
  1677. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1678. /**
  1679. * Returns a new Vector2 equal to the normalized given vector
  1680. * @param vector defines the vector to normalize
  1681. * @returns a new Vector2
  1682. */
  1683. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1684. /**
  1685. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1686. * @param left defines 1st vector
  1687. * @param right defines 2nd vector
  1688. * @returns a new Vector2
  1689. */
  1690. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1691. /**
  1692. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1693. * @param left defines 1st vector
  1694. * @param right defines 2nd vector
  1695. * @returns a new Vector2
  1696. */
  1697. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1698. /**
  1699. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1700. * @param vector defines the vector to transform
  1701. * @param transformation defines the matrix to apply
  1702. * @returns a new Vector2
  1703. */
  1704. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1705. /**
  1706. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1707. * @param vector defines the vector to transform
  1708. * @param transformation defines the matrix to apply
  1709. * @param result defines the target vector
  1710. */
  1711. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1712. /**
  1713. * Determines if a given vector is included in a triangle
  1714. * @param p defines the vector to test
  1715. * @param p0 defines 1st triangle point
  1716. * @param p1 defines 2nd triangle point
  1717. * @param p2 defines 3rd triangle point
  1718. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1719. */
  1720. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1721. /**
  1722. * Gets the distance between the vectors "value1" and "value2"
  1723. * @param value1 defines first vector
  1724. * @param value2 defines second vector
  1725. * @returns the distance between vectors
  1726. */
  1727. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1728. /**
  1729. * Returns the squared distance between the vectors "value1" and "value2"
  1730. * @param value1 defines first vector
  1731. * @param value2 defines second vector
  1732. * @returns the squared distance between vectors
  1733. */
  1734. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1735. /**
  1736. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1737. * @param value1 defines first vector
  1738. * @param value2 defines second vector
  1739. * @returns a new Vector2
  1740. */
  1741. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1742. /**
  1743. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1744. * @param p defines the middle point
  1745. * @param segA defines one point of the segment
  1746. * @param segB defines the other point of the segment
  1747. * @returns the shortest distance
  1748. */
  1749. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1750. }
  1751. /**
  1752. * Classed used to store (x,y,z) vector representation
  1753. * A Vector3 is the main object used in 3D geometry
  1754. * It can represent etiher the coordinates of a point the space, either a direction
  1755. * Reminder: js uses a left handed forward facing system
  1756. */
  1757. export class Vector3 {
  1758. /**
  1759. * Defines the first coordinates (on X axis)
  1760. */
  1761. x: number;
  1762. /**
  1763. * Defines the second coordinates (on Y axis)
  1764. */
  1765. y: number;
  1766. /**
  1767. * Defines the third coordinates (on Z axis)
  1768. */
  1769. z: number;
  1770. private static _UpReadOnly;
  1771. private static _ZeroReadOnly;
  1772. /**
  1773. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1774. * @param x defines the first coordinates (on X axis)
  1775. * @param y defines the second coordinates (on Y axis)
  1776. * @param z defines the third coordinates (on Z axis)
  1777. */
  1778. constructor(
  1779. /**
  1780. * Defines the first coordinates (on X axis)
  1781. */
  1782. x?: number,
  1783. /**
  1784. * Defines the second coordinates (on Y axis)
  1785. */
  1786. y?: number,
  1787. /**
  1788. * Defines the third coordinates (on Z axis)
  1789. */
  1790. z?: number);
  1791. /**
  1792. * Creates a string representation of the Vector3
  1793. * @returns a string with the Vector3 coordinates.
  1794. */
  1795. toString(): string;
  1796. /**
  1797. * Gets the class name
  1798. * @returns the string "Vector3"
  1799. */
  1800. getClassName(): string;
  1801. /**
  1802. * Creates the Vector3 hash code
  1803. * @returns a number which tends to be unique between Vector3 instances
  1804. */
  1805. getHashCode(): number;
  1806. /**
  1807. * Creates an array containing three elements : the coordinates of the Vector3
  1808. * @returns a new array of numbers
  1809. */
  1810. asArray(): number[];
  1811. /**
  1812. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1813. * @param array defines the destination array
  1814. * @param index defines the offset in the destination array
  1815. * @returns the current Vector3
  1816. */
  1817. toArray(array: FloatArray, index?: number): Vector3;
  1818. /**
  1819. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1820. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1821. */
  1822. toQuaternion(): Quaternion;
  1823. /**
  1824. * Adds the given vector to the current Vector3
  1825. * @param otherVector defines the second operand
  1826. * @returns the current updated Vector3
  1827. */
  1828. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Adds the given coordinates to the current Vector3
  1831. * @param x defines the x coordinate of the operand
  1832. * @param y defines the y coordinate of the operand
  1833. * @param z defines the z coordinate of the operand
  1834. * @returns the current updated Vector3
  1835. */
  1836. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1837. /**
  1838. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1839. * @param otherVector defines the second operand
  1840. * @returns the resulting Vector3
  1841. */
  1842. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1845. * @param otherVector defines the second operand
  1846. * @param result defines the Vector3 object where to store the result
  1847. * @returns the current Vector3
  1848. */
  1849. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1850. /**
  1851. * Subtract the given vector from the current Vector3
  1852. * @param otherVector defines the second operand
  1853. * @returns the current updated Vector3
  1854. */
  1855. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1856. /**
  1857. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1858. * @param otherVector defines the second operand
  1859. * @returns the resulting Vector3
  1860. */
  1861. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1862. /**
  1863. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1864. * @param otherVector defines the second operand
  1865. * @param result defines the Vector3 object where to store the result
  1866. * @returns the current Vector3
  1867. */
  1868. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1869. /**
  1870. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1871. * @param x defines the x coordinate of the operand
  1872. * @param y defines the y coordinate of the operand
  1873. * @param z defines the z coordinate of the operand
  1874. * @returns the resulting Vector3
  1875. */
  1876. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1877. /**
  1878. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1879. * @param x defines the x coordinate of the operand
  1880. * @param y defines the y coordinate of the operand
  1881. * @param z defines the z coordinate of the operand
  1882. * @param result defines the Vector3 object where to store the result
  1883. * @returns the current Vector3
  1884. */
  1885. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1886. /**
  1887. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1888. * @returns a new Vector3
  1889. */
  1890. negate(): Vector3;
  1891. /**
  1892. * Multiplies the Vector3 coordinates by the float "scale"
  1893. * @param scale defines the multiplier factor
  1894. * @returns the current updated Vector3
  1895. */
  1896. scaleInPlace(scale: number): Vector3;
  1897. /**
  1898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1899. * @param scale defines the multiplier factor
  1900. * @returns a new Vector3
  1901. */
  1902. scale(scale: number): Vector3;
  1903. /**
  1904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1905. * @param scale defines the multiplier factor
  1906. * @param result defines the Vector3 object where to store the result
  1907. * @returns the current Vector3
  1908. */
  1909. scaleToRef(scale: number, result: Vector3): Vector3;
  1910. /**
  1911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1912. * @param scale defines the scale factor
  1913. * @param result defines the Vector3 object where to store the result
  1914. * @returns the unmodified current Vector3
  1915. */
  1916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1917. /**
  1918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1919. * @param otherVector defines the second operand
  1920. * @returns true if both vectors are equals
  1921. */
  1922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1923. /**
  1924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1925. * @param otherVector defines the second operand
  1926. * @param epsilon defines the minimal distance to define values as equals
  1927. * @returns true if both vectors are distant less than epsilon
  1928. */
  1929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1930. /**
  1931. * Returns true if the current Vector3 coordinates equals the given floats
  1932. * @param x defines the x coordinate of the operand
  1933. * @param y defines the y coordinate of the operand
  1934. * @param z defines the z coordinate of the operand
  1935. * @returns true if both vectors are equals
  1936. */
  1937. equalsToFloats(x: number, y: number, z: number): boolean;
  1938. /**
  1939. * Multiplies the current Vector3 coordinates by the given ones
  1940. * @param otherVector defines the second operand
  1941. * @returns the current updated Vector3
  1942. */
  1943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1946. * @param otherVector defines the second operand
  1947. * @returns the new Vector3
  1948. */
  1949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1950. /**
  1951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1952. * @param otherVector defines the second operand
  1953. * @param result defines the Vector3 object where to store the result
  1954. * @returns the current Vector3
  1955. */
  1956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1959. * @param x defines the x coordinate of the operand
  1960. * @param y defines the y coordinate of the operand
  1961. * @param z defines the z coordinate of the operand
  1962. * @returns the new Vector3
  1963. */
  1964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1965. /**
  1966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1967. * @param otherVector defines the second operand
  1968. * @returns the new Vector3
  1969. */
  1970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1971. /**
  1972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1973. * @param otherVector defines the second operand
  1974. * @param result defines the Vector3 object where to store the result
  1975. * @returns the current Vector3
  1976. */
  1977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1978. /**
  1979. * Divides the current Vector3 coordinates by the given ones.
  1980. * @param otherVector defines the second operand
  1981. * @returns the current updated Vector3
  1982. */
  1983. divideInPlace(otherVector: Vector3): Vector3;
  1984. /**
  1985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1986. * @param other defines the second operand
  1987. * @returns the current updated Vector3
  1988. */
  1989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1990. /**
  1991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1992. * @param other defines the second operand
  1993. * @returns the current updated Vector3
  1994. */
  1995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1996. /**
  1997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1998. * @param x defines the x coordinate of the operand
  1999. * @param y defines the y coordinate of the operand
  2000. * @param z defines the z coordinate of the operand
  2001. * @returns the current updated Vector3
  2002. */
  2003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2004. /**
  2005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2006. * @param x defines the x coordinate of the operand
  2007. * @param y defines the y coordinate of the operand
  2008. * @param z defines the z coordinate of the operand
  2009. * @returns the current updated Vector3
  2010. */
  2011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2012. /**
  2013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2014. * Check if is non uniform within a certain amount of decimal places to account for this
  2015. * @param epsilon the amount the values can differ
  2016. * @returns if the the vector is non uniform to a certain number of decimal places
  2017. */
  2018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2019. /**
  2020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2021. */
  2022. readonly isNonUniform: boolean;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. floor(): Vector3;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. fract(): Vector3;
  2033. /**
  2034. * Gets the length of the Vector3
  2035. * @returns the length of the Vector3
  2036. */
  2037. length(): number;
  2038. /**
  2039. * Gets the squared length of the Vector3
  2040. * @returns squared length of the Vector3
  2041. */
  2042. lengthSquared(): number;
  2043. /**
  2044. * Normalize the current Vector3.
  2045. * Please note that this is an in place operation.
  2046. * @returns the current updated Vector3
  2047. */
  2048. normalize(): Vector3;
  2049. /**
  2050. * Reorders the x y z properties of the vector in place
  2051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2052. * @returns the current updated vector
  2053. */
  2054. reorderInPlace(order: string): this;
  2055. /**
  2056. * Rotates the vector around 0,0,0 by a quaternion
  2057. * @param quaternion the rotation quaternion
  2058. * @param result vector to store the result
  2059. * @returns the resulting vector
  2060. */
  2061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2062. /**
  2063. * Rotates a vector around a given point
  2064. * @param quaternion the rotation quaternion
  2065. * @param point the point to rotate around
  2066. * @param result vector to store the result
  2067. * @returns the resulting vector
  2068. */
  2069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2070. /**
  2071. * Normalize the current Vector3 with the given input length.
  2072. * Please note that this is an in place operation.
  2073. * @param len the length of the vector
  2074. * @returns the current updated Vector3
  2075. */
  2076. normalizeFromLength(len: number): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to a new vector
  2079. * @returns the new Vector3
  2080. */
  2081. normalizeToNew(): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to the reference
  2084. * @param reference define the Vector3 to update
  2085. * @returns the updated Vector3
  2086. */
  2087. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2088. /**
  2089. * Creates a new Vector3 copied from the current Vector3
  2090. * @returns the new Vector3
  2091. */
  2092. clone(): Vector3;
  2093. /**
  2094. * Copies the given vector coordinates to the current Vector3 ones
  2095. * @param source defines the source Vector3
  2096. * @returns the current updated Vector3
  2097. */
  2098. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2099. /**
  2100. * Copies the given floats to the current Vector3 coordinates
  2101. * @param x defines the x coordinate of the operand
  2102. * @param y defines the y coordinate of the operand
  2103. * @param z defines the z coordinate of the operand
  2104. * @returns the current updated Vector3
  2105. */
  2106. copyFromFloats(x: number, y: number, z: number): Vector3;
  2107. /**
  2108. * Copies the given floats to the current Vector3 coordinates
  2109. * @param x defines the x coordinate of the operand
  2110. * @param y defines the y coordinate of the operand
  2111. * @param z defines the z coordinate of the operand
  2112. * @returns the current updated Vector3
  2113. */
  2114. set(x: number, y: number, z: number): Vector3;
  2115. /**
  2116. * Copies the given float to the current Vector3 coordinates
  2117. * @param v defines the x, y and z coordinates of the operand
  2118. * @returns the current updated Vector3
  2119. */
  2120. setAll(v: number): Vector3;
  2121. /**
  2122. * Get the clip factor between two vectors
  2123. * @param vector0 defines the first operand
  2124. * @param vector1 defines the second operand
  2125. * @param axis defines the axis to use
  2126. * @param size defines the size along the axis
  2127. * @returns the clip factor
  2128. */
  2129. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2130. /**
  2131. * Get angle between two vectors
  2132. * @param vector0 angle between vector0 and vector1
  2133. * @param vector1 angle between vector0 and vector1
  2134. * @param normal direction of the normal
  2135. * @return the angle between vector0 and vector1
  2136. */
  2137. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2138. /**
  2139. * Returns a new Vector3 set from the index "offset" of the given array
  2140. * @param array defines the source array
  2141. * @param offset defines the offset in the source array
  2142. * @returns the new Vector3
  2143. */
  2144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2145. /**
  2146. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2147. * This function is deprecated. Use FromArray instead
  2148. * @param array defines the source array
  2149. * @param offset defines the offset in the source array
  2150. * @returns the new Vector3
  2151. */
  2152. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2153. /**
  2154. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2155. * @param array defines the source array
  2156. * @param offset defines the offset in the source array
  2157. * @param result defines the Vector3 where to store the result
  2158. */
  2159. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2160. /**
  2161. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2162. * This function is deprecated. Use FromArrayToRef instead.
  2163. * @param array defines the source array
  2164. * @param offset defines the offset in the source array
  2165. * @param result defines the Vector3 where to store the result
  2166. */
  2167. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2168. /**
  2169. * Sets the given vector "result" with the given floats.
  2170. * @param x defines the x coordinate of the source
  2171. * @param y defines the y coordinate of the source
  2172. * @param z defines the z coordinate of the source
  2173. * @param result defines the Vector3 where to store the result
  2174. */
  2175. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2178. * @returns a new empty Vector3
  2179. */
  2180. static Zero(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2183. * @returns a new unit Vector3
  2184. */
  2185. static One(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2188. * @returns a new up Vector3
  2189. */
  2190. static Up(): Vector3;
  2191. /**
  2192. * Gets a up Vector3 that must not be updated
  2193. */
  2194. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2195. /**
  2196. * Gets a zero Vector3 that must not be updated
  2197. */
  2198. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2201. * @returns a new down Vector3
  2202. */
  2203. static Down(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Forward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Backward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2216. * @returns a new right Vector3
  2217. */
  2218. static Right(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2221. * @returns a new left Vector3
  2222. */
  2223. static Left(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2226. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2227. * @param vector defines the Vector3 to transform
  2228. * @param transformation defines the transformation matrix
  2229. * @returns the transformed Vector3
  2230. */
  2231. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2232. /**
  2233. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2234. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2235. * @param vector defines the Vector3 to transform
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2242. * This method computes tranformed coordinates only, not transformed direction vectors
  2243. * @param x define the x coordinate of the source vector
  2244. * @param y define the y coordinate of the source vector
  2245. * @param z define the z coordinate of the source vector
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2252. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2253. * @param vector defines the Vector3 to transform
  2254. * @param transformation defines the transformation matrix
  2255. * @returns the new Vector3
  2256. */
  2257. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2258. /**
  2259. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2260. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2261. * @param vector defines the Vector3 to transform
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2268. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2269. * @param x define the x coordinate of the source vector
  2270. * @param y define the y coordinate of the source vector
  2271. * @param z define the z coordinate of the source vector
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2278. * @param value1 defines the first control point
  2279. * @param value2 defines the second control point
  2280. * @param value3 defines the third control point
  2281. * @param value4 defines the fourth control point
  2282. * @param amount defines the amount on the spline to use
  2283. * @returns the new Vector3
  2284. */
  2285. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2286. /**
  2287. * 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"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @returns the new Vector3
  2294. */
  2295. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @param result defines the Vector3 where to store the result
  2304. */
  2305. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2306. /**
  2307. * Checks if a given vector is inside a specific range
  2308. * @param v defines the vector to test
  2309. * @param min defines the minimum range
  2310. * @param max defines the maximum range
  2311. */
  2312. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2315. * @param value1 defines the first control point
  2316. * @param tangent1 defines the first tangent vector
  2317. * @param value2 defines the second control point
  2318. * @param tangent2 defines the second tangent vector
  2319. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2320. * @returns the new Vector3
  2321. */
  2322. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2325. * @param start defines the start value
  2326. * @param end defines the end value
  2327. * @param amount max defines amount between both (between 0 and 1)
  2328. * @returns the new Vector3
  2329. */
  2330. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2331. /**
  2332. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2333. * @param start defines the start value
  2334. * @param end defines the end value
  2335. * @param amount max defines amount between both (between 0 and 1)
  2336. * @param result defines the Vector3 where to store the result
  2337. */
  2338. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2339. /**
  2340. * Returns the dot product (float) between the vectors "left" and "right"
  2341. * @param left defines the left operand
  2342. * @param right defines the right operand
  2343. * @returns the dot product
  2344. */
  2345. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2346. /**
  2347. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2348. * The cross product is then orthogonal to both "left" and "right"
  2349. * @param left defines the left operand
  2350. * @param right defines the right operand
  2351. * @returns the cross product
  2352. */
  2353. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Sets the given vector "result" with the cross product of "left" and "right"
  2356. * The cross product is then orthogonal to both "left" and "right"
  2357. * @param left defines the left operand
  2358. * @param right defines the right operand
  2359. * @param result defines the Vector3 where to store the result
  2360. */
  2361. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2362. /**
  2363. * Returns a new Vector3 as the normalization of the given vector
  2364. * @param vector defines the Vector3 to normalize
  2365. * @returns the new Vector3
  2366. */
  2367. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2368. /**
  2369. * Sets the given vector "result" with the normalization of the given first vector
  2370. * @param vector defines the Vector3 to normalize
  2371. * @param result defines the Vector3 where to store the result
  2372. */
  2373. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2374. /**
  2375. * Project a Vector3 onto screen space
  2376. * @param vector defines the Vector3 to project
  2377. * @param world defines the world matrix to use
  2378. * @param transform defines the transform (view x projection) matrix to use
  2379. * @param viewport defines the screen viewport to use
  2380. * @returns the new Vector3
  2381. */
  2382. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2383. /** @hidden */
  2384. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2385. /**
  2386. * Unproject from screen space to object space
  2387. * @param source defines the screen space Vector3 to use
  2388. * @param viewportWidth defines the current width of the viewport
  2389. * @param viewportHeight defines the current height of the viewport
  2390. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2391. * @param transform defines the transform (view x projection) matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @returns the new Vector3
  2404. */
  2405. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param source defines the screen space Vector3 to use
  2409. * @param viewportWidth defines the current width of the viewport
  2410. * @param viewportHeight defines the current height of the viewport
  2411. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2412. * @param view defines the view matrix to use
  2413. * @param projection defines the projection matrix to use
  2414. * @param result defines the Vector3 where to store the result
  2415. */
  2416. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2417. /**
  2418. * Unproject from screen space to object space
  2419. * @param sourceX defines the screen space x coordinate to use
  2420. * @param sourceY defines the screen space y coordinate to use
  2421. * @param sourceZ defines the screen space z coordinate to use
  2422. * @param viewportWidth defines the current width of the viewport
  2423. * @param viewportHeight defines the current height of the viewport
  2424. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2425. * @param view defines the view matrix to use
  2426. * @param projection defines the projection matrix to use
  2427. * @param result defines the Vector3 where to store the result
  2428. */
  2429. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2430. /**
  2431. * Gets the minimal coordinate values between two Vector3
  2432. * @param left defines the first operand
  2433. * @param right defines the second operand
  2434. * @returns the new Vector3
  2435. */
  2436. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2437. /**
  2438. * Gets the maximal coordinate values between two Vector3
  2439. * @param left defines the first operand
  2440. * @param right defines the second operand
  2441. * @returns the new Vector3
  2442. */
  2443. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2444. /**
  2445. * Returns the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines the first operand
  2447. * @param value2 defines the second operand
  2448. * @returns the distance
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines the first operand
  2454. * @param value2 defines the second operand
  2455. * @returns the squared distance
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2458. /**
  2459. * Returns a new Vector3 located at the center between "value1" and "value2"
  2460. * @param value1 defines the first operand
  2461. * @param value2 defines the second operand
  2462. * @returns the new Vector3
  2463. */
  2464. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2467. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2468. * to something in order to rotate it from its local system to the given target system
  2469. * Note: axis1, axis2 and axis3 are normalized during this operation
  2470. * @param axis1 defines the first axis
  2471. * @param axis2 defines the second axis
  2472. * @param axis3 defines the third axis
  2473. * @returns a new Vector3
  2474. */
  2475. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2478. * @param axis1 defines the first axis
  2479. * @param axis2 defines the second axis
  2480. * @param axis3 defines the third axis
  2481. * @param ref defines the Vector3 where to store the result
  2482. */
  2483. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2484. }
  2485. /**
  2486. * Vector4 class created for EulerAngle class conversion to Quaternion
  2487. */
  2488. export class Vector4 {
  2489. /** x value of the vector */
  2490. x: number;
  2491. /** y value of the vector */
  2492. y: number;
  2493. /** z value of the vector */
  2494. z: number;
  2495. /** w value of the vector */
  2496. w: number;
  2497. /**
  2498. * Creates a Vector4 object from the given floats.
  2499. * @param x x value of the vector
  2500. * @param y y value of the vector
  2501. * @param z z value of the vector
  2502. * @param w w value of the vector
  2503. */
  2504. constructor(
  2505. /** x value of the vector */
  2506. x: number,
  2507. /** y value of the vector */
  2508. y: number,
  2509. /** z value of the vector */
  2510. z: number,
  2511. /** w value of the vector */
  2512. w: number);
  2513. /**
  2514. * Returns the string with the Vector4 coordinates.
  2515. * @returns a string containing all the vector values
  2516. */
  2517. toString(): string;
  2518. /**
  2519. * Returns the string "Vector4".
  2520. * @returns "Vector4"
  2521. */
  2522. getClassName(): string;
  2523. /**
  2524. * Returns the Vector4 hash code.
  2525. * @returns a unique hash code
  2526. */
  2527. getHashCode(): number;
  2528. /**
  2529. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2530. * @returns the resulting array
  2531. */
  2532. asArray(): number[];
  2533. /**
  2534. * Populates the given array from the given index with the Vector4 coordinates.
  2535. * @param array array to populate
  2536. * @param index index of the array to start at (default: 0)
  2537. * @returns the Vector4.
  2538. */
  2539. toArray(array: FloatArray, index?: number): Vector4;
  2540. /**
  2541. * Adds the given vector to the current Vector4.
  2542. * @param otherVector the vector to add
  2543. * @returns the updated Vector4.
  2544. */
  2545. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @returns the resulting vector
  2550. */
  2551. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2552. /**
  2553. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2554. * @param otherVector the vector to add
  2555. * @param result the vector to store the result
  2556. * @returns the current Vector4.
  2557. */
  2558. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2559. /**
  2560. * Subtract in place the given vector from the current Vector4.
  2561. * @param otherVector the vector to subtract
  2562. * @returns the updated Vector4.
  2563. */
  2564. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to add
  2568. * @returns the new vector with the result
  2569. */
  2570. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2571. /**
  2572. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2573. * @param otherVector the vector to subtract
  2574. * @param result the vector to store the result
  2575. * @returns the current Vector4.
  2576. */
  2577. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2578. /**
  2579. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2580. */
  2581. /**
  2582. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2583. * @param x value to subtract
  2584. * @param y value to subtract
  2585. * @param z value to subtract
  2586. * @param w value to subtract
  2587. * @returns new vector containing the result
  2588. */
  2589. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2590. /**
  2591. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2592. * @param x value to subtract
  2593. * @param y value to subtract
  2594. * @param z value to subtract
  2595. * @param w value to subtract
  2596. * @param result the vector to store the result in
  2597. * @returns the current Vector4.
  2598. */
  2599. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2602. * @returns a new vector with the negated values
  2603. */
  2604. negate(): Vector4;
  2605. /**
  2606. * Multiplies the current Vector4 coordinates by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns the updated Vector4.
  2609. */
  2610. scaleInPlace(scale: number): Vector4;
  2611. /**
  2612. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @returns a new vector with the result
  2615. */
  2616. scale(scale: number): Vector4;
  2617. /**
  2618. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2619. * @param scale the number to scale with
  2620. * @param result a vector to store the result in
  2621. * @returns the current Vector4.
  2622. */
  2623. scaleToRef(scale: number, result: Vector4): Vector4;
  2624. /**
  2625. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2626. * @param scale defines the scale factor
  2627. * @param result defines the Vector4 object where to store the result
  2628. * @returns the unmodified current Vector4
  2629. */
  2630. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2633. * @param otherVector the vector to compare against
  2634. * @returns true if they are equal
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2637. /**
  2638. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2639. * @param otherVector vector to compare against
  2640. * @param epsilon (Default: very small number)
  2641. * @returns true if they are equal
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2644. /**
  2645. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2646. * @param x x value to compare against
  2647. * @param y y value to compare against
  2648. * @param z z value to compare against
  2649. * @param w w value to compare against
  2650. * @returns true if equal
  2651. */
  2652. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2653. /**
  2654. * Multiplies in place the current Vector4 by the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns the updated Vector4.
  2657. */
  2658. multiplyInPlace(otherVector: Vector4): Vector4;
  2659. /**
  2660. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @returns resulting new vector
  2663. */
  2664. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2665. /**
  2666. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2667. * @param otherVector vector to multiple with
  2668. * @param result vector to store the result
  2669. * @returns the current Vector4.
  2670. */
  2671. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2672. /**
  2673. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2674. * @param x x value multiply with
  2675. * @param y y value multiply with
  2676. * @param z z value multiply with
  2677. * @param w w value multiply with
  2678. * @returns resulting new vector
  2679. */
  2680. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2681. /**
  2682. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @returns resulting new vector
  2685. */
  2686. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2687. /**
  2688. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2689. * @param otherVector vector to devide with
  2690. * @param result vector to store the result
  2691. * @returns the current Vector4.
  2692. */
  2693. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2694. /**
  2695. * Divides the current Vector3 coordinates by the given ones.
  2696. * @param otherVector vector to devide with
  2697. * @returns the updated Vector3.
  2698. */
  2699. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2708. * @param other defines the second operand
  2709. * @returns the current updated Vector4
  2710. */
  2711. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector4 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. floor(): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector3 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. fract(): Vector4;
  2722. /**
  2723. * Returns the Vector4 length (float).
  2724. * @returns the length
  2725. */
  2726. length(): number;
  2727. /**
  2728. * Returns the Vector4 squared length (float).
  2729. * @returns the length squared
  2730. */
  2731. lengthSquared(): number;
  2732. /**
  2733. * Normalizes in place the Vector4.
  2734. * @returns the updated Vector4.
  2735. */
  2736. normalize(): Vector4;
  2737. /**
  2738. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2739. * @returns this converted to a new vector3
  2740. */
  2741. toVector3(): Vector3;
  2742. /**
  2743. * Returns a new Vector4 copied from the current one.
  2744. * @returns the new cloned vector
  2745. */
  2746. clone(): Vector4;
  2747. /**
  2748. * Updates the current Vector4 with the given one coordinates.
  2749. * @param source the source vector to copy from
  2750. * @returns the updated Vector4.
  2751. */
  2752. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2753. /**
  2754. * Updates the current Vector4 coordinates with the given floats.
  2755. * @param x float to copy from
  2756. * @param y float to copy from
  2757. * @param z float to copy from
  2758. * @param w float to copy from
  2759. * @returns the updated Vector4.
  2760. */
  2761. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2762. /**
  2763. * Updates the current Vector4 coordinates with the given floats.
  2764. * @param x float to set from
  2765. * @param y float to set from
  2766. * @param z float to set from
  2767. * @param w float to set from
  2768. * @returns the updated Vector4.
  2769. */
  2770. set(x: number, y: number, z: number, w: number): Vector4;
  2771. /**
  2772. * Copies the given float to the current Vector3 coordinates
  2773. * @param v defines the x, y, z and w coordinates of the operand
  2774. * @returns the current updated Vector3
  2775. */
  2776. setAll(v: number): Vector4;
  2777. /**
  2778. * Returns a new Vector4 set from the starting index of the given array.
  2779. * @param array the array to pull values from
  2780. * @param offset the offset into the array to start at
  2781. * @returns the new vector
  2782. */
  2783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2784. /**
  2785. * Updates the given vector "result" from the starting index of the given array.
  2786. * @param array the array to pull values from
  2787. * @param offset the offset into the array to start at
  2788. * @param result the vector to store the result in
  2789. */
  2790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2791. /**
  2792. * Updates the given vector "result" from the starting index of the given Float32Array.
  2793. * @param array the array to pull values from
  2794. * @param offset the offset into the array to start at
  2795. * @param result the vector to store the result in
  2796. */
  2797. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2798. /**
  2799. * Updates the given vector "result" coordinates from the given floats.
  2800. * @param x float to set from
  2801. * @param y float to set from
  2802. * @param z float to set from
  2803. * @param w float to set from
  2804. * @param result the vector to the floats in
  2805. */
  2806. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2807. /**
  2808. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2809. * @returns the new vector
  2810. */
  2811. static Zero(): Vector4;
  2812. /**
  2813. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2814. * @returns the new vector
  2815. */
  2816. static One(): Vector4;
  2817. /**
  2818. * Returns a new normalized Vector4 from the given one.
  2819. * @param vector the vector to normalize
  2820. * @returns the vector
  2821. */
  2822. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2823. /**
  2824. * Updates the given vector "result" from the normalization of the given one.
  2825. * @param vector the vector to normalize
  2826. * @param result the vector to store the result in
  2827. */
  2828. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2829. /**
  2830. * Returns a vector with the minimum values from the left and right vectors
  2831. * @param left left vector to minimize
  2832. * @param right right vector to minimize
  2833. * @returns a new vector with the minimum of the left and right vector values
  2834. */
  2835. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2836. /**
  2837. * Returns a vector with the maximum values from the left and right vectors
  2838. * @param left left vector to maximize
  2839. * @param right right vector to maximize
  2840. * @returns a new vector with the maximum of the left and right vector values
  2841. */
  2842. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2843. /**
  2844. * Returns the distance (float) between the vectors "value1" and "value2".
  2845. * @param value1 value to calulate the distance between
  2846. * @param value2 value to calulate the distance between
  2847. * @return the distance between the two vectors
  2848. */
  2849. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2850. /**
  2851. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2852. * @param value1 value to calulate the distance between
  2853. * @param value2 value to calulate the distance between
  2854. * @return the distance between the two vectors squared
  2855. */
  2856. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2857. /**
  2858. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2859. * @param value1 value to calulate the center between
  2860. * @param value2 value to calulate the center between
  2861. * @return the center between the two vectors
  2862. */
  2863. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2864. /**
  2865. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2866. * This methods computes transformed normalized direction vectors only.
  2867. * @param vector the vector to transform
  2868. * @param transformation the transformation matrix to apply
  2869. * @returns the new vector
  2870. */
  2871. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2872. /**
  2873. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2874. * This methods computes transformed normalized direction vectors only.
  2875. * @param vector the vector to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the result in
  2878. */
  2879. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2882. * This methods computes transformed normalized direction vectors only.
  2883. * @param x value to transform
  2884. * @param y value to transform
  2885. * @param z value to transform
  2886. * @param w value to transform
  2887. * @param transformation the transformation matrix to apply
  2888. * @param result the vector to store the results in
  2889. */
  2890. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2891. /**
  2892. * Creates a new Vector4 from a Vector3
  2893. * @param source defines the source data
  2894. * @param w defines the 4th component (default is 0)
  2895. * @returns a new Vector4
  2896. */
  2897. static FromVector3(source: Vector3, w?: number): Vector4;
  2898. }
  2899. /**
  2900. * Class used to store quaternion data
  2901. * @see https://en.wikipedia.org/wiki/Quaternion
  2902. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2903. */
  2904. export class Quaternion {
  2905. /** defines the first component (0 by default) */
  2906. x: number;
  2907. /** defines the second component (0 by default) */
  2908. y: number;
  2909. /** defines the third component (0 by default) */
  2910. z: number;
  2911. /** defines the fourth component (1.0 by default) */
  2912. w: number;
  2913. /**
  2914. * Creates a new Quaternion from the given floats
  2915. * @param x defines the first component (0 by default)
  2916. * @param y defines the second component (0 by default)
  2917. * @param z defines the third component (0 by default)
  2918. * @param w defines the fourth component (1.0 by default)
  2919. */
  2920. constructor(
  2921. /** defines the first component (0 by default) */
  2922. x?: number,
  2923. /** defines the second component (0 by default) */
  2924. y?: number,
  2925. /** defines the third component (0 by default) */
  2926. z?: number,
  2927. /** defines the fourth component (1.0 by default) */
  2928. w?: number);
  2929. /**
  2930. * Gets a string representation for the current quaternion
  2931. * @returns a string with the Quaternion coordinates
  2932. */
  2933. toString(): string;
  2934. /**
  2935. * Gets the class name of the quaternion
  2936. * @returns the string "Quaternion"
  2937. */
  2938. getClassName(): string;
  2939. /**
  2940. * Gets a hash code for this quaternion
  2941. * @returns the quaternion hash code
  2942. */
  2943. getHashCode(): number;
  2944. /**
  2945. * Copy the quaternion to an array
  2946. * @returns a new array populated with 4 elements from the quaternion coordinates
  2947. */
  2948. asArray(): number[];
  2949. /**
  2950. * Check if two quaternions are equals
  2951. * @param otherQuaternion defines the second operand
  2952. * @return true if the current quaternion and the given one coordinates are strictly equals
  2953. */
  2954. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2955. /**
  2956. * Clone the current quaternion
  2957. * @returns a new quaternion copied from the current one
  2958. */
  2959. clone(): Quaternion;
  2960. /**
  2961. * Copy a quaternion to the current one
  2962. * @param other defines the other quaternion
  2963. * @returns the updated current quaternion
  2964. */
  2965. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2966. /**
  2967. * Updates the current quaternion with the given float coordinates
  2968. * @param x defines the x coordinate
  2969. * @param y defines the y coordinate
  2970. * @param z defines the z coordinate
  2971. * @param w defines the w coordinate
  2972. * @returns the updated current quaternion
  2973. */
  2974. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2975. /**
  2976. * Updates the current quaternion from the given float coordinates
  2977. * @param x defines the x coordinate
  2978. * @param y defines the y coordinate
  2979. * @param z defines the z coordinate
  2980. * @param w defines the w coordinate
  2981. * @returns the updated current quaternion
  2982. */
  2983. set(x: number, y: number, z: number, w: number): Quaternion;
  2984. /**
  2985. * Adds two quaternions
  2986. * @param other defines the second operand
  2987. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2988. */
  2989. add(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Add a quaternion to the current one
  2992. * @param other defines the quaternion to add
  2993. * @returns the current quaternion
  2994. */
  2995. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2996. /**
  2997. * Subtract two quaternions
  2998. * @param other defines the second operand
  2999. * @returns a new quaternion as the subtraction result of the given one from the current one
  3000. */
  3001. subtract(other: Quaternion): Quaternion;
  3002. /**
  3003. * Multiplies the current quaternion by a scale factor
  3004. * @param value defines the scale factor
  3005. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3006. */
  3007. scale(value: number): Quaternion;
  3008. /**
  3009. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3010. * @param scale defines the scale factor
  3011. * @param result defines the Quaternion object where to store the result
  3012. * @returns the unmodified current quaternion
  3013. */
  3014. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3015. /**
  3016. * Multiplies in place the current quaternion by a scale factor
  3017. * @param value defines the scale factor
  3018. * @returns the current modified quaternion
  3019. */
  3020. scaleInPlace(value: number): Quaternion;
  3021. /**
  3022. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3023. * @param scale defines the scale factor
  3024. * @param result defines the Quaternion object where to store the result
  3025. * @returns the unmodified current quaternion
  3026. */
  3027. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3028. /**
  3029. * Multiplies two quaternions
  3030. * @param q1 defines the second operand
  3031. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3032. */
  3033. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3034. /**
  3035. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3036. * @param q1 defines the second operand
  3037. * @param result defines the target quaternion
  3038. * @returns the current quaternion
  3039. */
  3040. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3041. /**
  3042. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3043. * @param q1 defines the second operand
  3044. * @returns the currentupdated quaternion
  3045. */
  3046. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3047. /**
  3048. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3049. * @param ref defines the target quaternion
  3050. * @returns the current quaternion
  3051. */
  3052. conjugateToRef(ref: Quaternion): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns the current updated quaternion
  3056. */
  3057. conjugateInPlace(): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns a new quaternion
  3061. */
  3062. conjugate(): Quaternion;
  3063. /**
  3064. * Gets length of current quaternion
  3065. * @returns the quaternion length (float)
  3066. */
  3067. length(): number;
  3068. /**
  3069. * Normalize in place the current quaternion
  3070. * @returns the current updated quaternion
  3071. */
  3072. normalize(): Quaternion;
  3073. /**
  3074. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3075. * @param order is a reserved parameter and is ignore for now
  3076. * @returns a new Vector3 containing the Euler angles
  3077. */
  3078. toEulerAngles(order?: string): Vector3;
  3079. /**
  3080. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3081. * @param result defines the vector which will be filled with the Euler angles
  3082. * @param order is a reserved parameter and is ignore for now
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toEulerAnglesToRef(result: Vector3): Quaternion;
  3086. /**
  3087. * Updates the given rotation matrix with the current quaternion values
  3088. * @param result defines the target matrix
  3089. * @returns the current unchanged quaternion
  3090. */
  3091. toRotationMatrix(result: Matrix): Quaternion;
  3092. /**
  3093. * Updates the current quaternion from the given rotation matrix values
  3094. * @param matrix defines the source matrix
  3095. * @returns the current updated quaternion
  3096. */
  3097. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Creates a new quaternion from a rotation matrix
  3100. * @param matrix defines the source matrix
  3101. * @returns a new quaternion created from the given rotation matrix values
  3102. */
  3103. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3104. /**
  3105. * Updates the given quaternion with the given rotation matrix values
  3106. * @param matrix defines the source matrix
  3107. * @param result defines the target quaternion
  3108. */
  3109. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3110. /**
  3111. * Returns the dot product (float) between the quaternions "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @returns the dot product
  3115. */
  3116. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3117. /**
  3118. * Checks if the two quaternions are close to each other
  3119. * @param quat0 defines the first quaternion to check
  3120. * @param quat1 defines the second quaternion to check
  3121. * @returns true if the two quaternions are close to each other
  3122. */
  3123. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3124. /**
  3125. * Creates an empty quaternion
  3126. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3127. */
  3128. static Zero(): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @returns a new quaternion as the inverted current quaternion
  3133. */
  3134. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3135. /**
  3136. * Inverse a given quaternion
  3137. * @param q defines the source quaternion
  3138. * @param result the quaternion the result will be stored in
  3139. * @returns the result quaternion
  3140. */
  3141. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3142. /**
  3143. * Creates an identity quaternion
  3144. * @returns the identity quaternion
  3145. */
  3146. static Identity(): Quaternion;
  3147. /**
  3148. * Gets a boolean indicating if the given quaternion is identity
  3149. * @param quaternion defines the quaternion to check
  3150. * @returns true if the quaternion is identity
  3151. */
  3152. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3153. /**
  3154. * Creates a quaternion from a rotation around an axis
  3155. * @param axis defines the axis to use
  3156. * @param angle defines the angle to use
  3157. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3158. */
  3159. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3160. /**
  3161. * Creates a rotation around an axis and stores it into the given quaternion
  3162. * @param axis defines the axis to use
  3163. * @param angle defines the angle to use
  3164. * @param result defines the target quaternion
  3165. * @returns the target quaternion
  3166. */
  3167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3168. /**
  3169. * Creates a new quaternion from data stored into an array
  3170. * @param array defines the data source
  3171. * @param offset defines the offset in the source array where the data starts
  3172. * @returns a new quaternion
  3173. */
  3174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3175. /**
  3176. * Create a quaternion from Euler rotation angles
  3177. * @param x Pitch
  3178. * @param y Yaw
  3179. * @param z Roll
  3180. * @returns the new Quaternion
  3181. */
  3182. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3183. /**
  3184. * Updates a quaternion from Euler rotation angles
  3185. * @param x Pitch
  3186. * @param y Yaw
  3187. * @param z Roll
  3188. * @param result the quaternion to store the result
  3189. * @returns the updated quaternion
  3190. */
  3191. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @returns the new Quaternion
  3196. */
  3197. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3198. /**
  3199. * Updates a quaternion from Euler rotation vector
  3200. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3201. * @param result the quaternion to store the result
  3202. * @returns the updated quaternion
  3203. */
  3204. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3205. /**
  3206. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3207. * @param yaw defines the rotation around Y axis
  3208. * @param pitch defines the rotation around X axis
  3209. * @param roll defines the rotation around Z axis
  3210. * @returns the new quaternion
  3211. */
  3212. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3213. /**
  3214. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3215. * @param yaw defines the rotation around Y axis
  3216. * @param pitch defines the rotation around X axis
  3217. * @param roll defines the rotation around Z axis
  3218. * @param result defines the target quaternion
  3219. */
  3220. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3221. /**
  3222. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3223. * @param alpha defines the rotation around first axis
  3224. * @param beta defines the rotation around second axis
  3225. * @param gamma defines the rotation around third axis
  3226. * @returns the new quaternion
  3227. */
  3228. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3229. /**
  3230. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3231. * @param alpha defines the rotation around first axis
  3232. * @param beta defines the rotation around second axis
  3233. * @param gamma defines the rotation around third axis
  3234. * @param result defines the target quaternion
  3235. */
  3236. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3237. /**
  3238. * 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)
  3239. * @param axis1 defines the first axis
  3240. * @param axis2 defines the second axis
  3241. * @param axis3 defines the third axis
  3242. * @returns the new quaternion
  3243. */
  3244. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3245. /**
  3246. * 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
  3247. * @param axis1 defines the first axis
  3248. * @param axis2 defines the second axis
  3249. * @param axis3 defines the third axis
  3250. * @param ref defines the target quaternion
  3251. */
  3252. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3253. /**
  3254. * Interpolates between two quaternions
  3255. * @param left defines first quaternion
  3256. * @param right defines second quaternion
  3257. * @param amount defines the gradient to use
  3258. * @returns the new interpolated quaternion
  3259. */
  3260. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3261. /**
  3262. * Interpolates between two quaternions and stores it into a target quaternion
  3263. * @param left defines first quaternion
  3264. * @param right defines second quaternion
  3265. * @param amount defines the gradient to use
  3266. * @param result defines the target quaternion
  3267. */
  3268. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3269. /**
  3270. * Interpolate between two quaternions using Hermite interpolation
  3271. * @param value1 defines first quaternion
  3272. * @param tangent1 defines the incoming tangent
  3273. * @param value2 defines second quaternion
  3274. * @param tangent2 defines the outgoing tangent
  3275. * @param amount defines the target quaternion
  3276. * @returns the new interpolated quaternion
  3277. */
  3278. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3279. }
  3280. /**
  3281. * Class used to store matrix data (4x4)
  3282. */
  3283. export class Matrix {
  3284. private static _updateFlagSeed;
  3285. private static _identityReadOnly;
  3286. private _isIdentity;
  3287. private _isIdentityDirty;
  3288. private _isIdentity3x2;
  3289. private _isIdentity3x2Dirty;
  3290. /**
  3291. * Gets the update flag of the matrix which is an unique number for the matrix.
  3292. * It will be incremented every time the matrix data change.
  3293. * You can use it to speed the comparison between two versions of the same matrix.
  3294. */
  3295. updateFlag: number;
  3296. private readonly _m;
  3297. /**
  3298. * Gets the internal data of the matrix
  3299. */
  3300. readonly m: DeepImmutable<Float32Array>;
  3301. /** @hidden */
  3302. _markAsUpdated(): void;
  3303. /** @hidden */
  3304. private _updateIdentityStatus;
  3305. /**
  3306. * Creates an empty matrix (filled with zeros)
  3307. */
  3308. constructor();
  3309. /**
  3310. * Check if the current matrix is identity
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentity(): boolean;
  3314. /**
  3315. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentityAs3x2(): boolean;
  3319. /**
  3320. * Gets the determinant of the matrix
  3321. * @returns the matrix determinant
  3322. */
  3323. determinant(): number;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array
  3327. */
  3328. toArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array.
  3332. */
  3333. asArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Inverts the current matrix in place
  3336. * @returns the current inverted matrix
  3337. */
  3338. invert(): Matrix;
  3339. /**
  3340. * Sets all the matrix elements to zero
  3341. * @returns the current matrix
  3342. */
  3343. reset(): Matrix;
  3344. /**
  3345. * Adds the current matrix with a second one
  3346. * @param other defines the matrix to add
  3347. * @returns a new matrix as the addition of the current matrix and the given one
  3348. */
  3349. add(other: DeepImmutable<Matrix>): Matrix;
  3350. /**
  3351. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3352. * @param other defines the matrix to add
  3353. * @param result defines the target matrix
  3354. * @returns the current matrix
  3355. */
  3356. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3357. /**
  3358. * Adds in place the given matrix to the current matrix
  3359. * @param other defines the second operand
  3360. * @returns the current updated matrix
  3361. */
  3362. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3363. /**
  3364. * Sets the given matrix to the current inverted Matrix
  3365. * @param other defines the target matrix
  3366. * @returns the unmodified current matrix
  3367. */
  3368. invertToRef(other: Matrix): Matrix;
  3369. /**
  3370. * add a value at the specified position in the current Matrix
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. addAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * mutiply the specified position in the current Matrix by a value
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. multiplyAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * Inserts the translation vector (using 3 floats) in the current matrix
  3385. * @param x defines the 1st component of the translation
  3386. * @param y defines the 2nd component of the translation
  3387. * @param z defines the 3rd component of the translation
  3388. * @returns the current updated matrix
  3389. */
  3390. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3391. /**
  3392. * Adds the translation vector (using 3 floats) in the current matrix
  3393. * @param x defines the 1st component of the translation
  3394. * @param y defines the 2nd component of the translation
  3395. * @param z defines the 3rd component of the translation
  3396. * @returns the current updated matrix
  3397. */
  3398. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3399. /**
  3400. * Inserts the translation vector in the current matrix
  3401. * @param vector3 defines the translation to insert
  3402. * @returns the current updated matrix
  3403. */
  3404. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3405. /**
  3406. * Gets the translation value of the current matrix
  3407. * @returns a new Vector3 as the extracted translation from the matrix
  3408. */
  3409. getTranslation(): Vector3;
  3410. /**
  3411. * Fill a Vector3 with the extracted translation from the matrix
  3412. * @param result defines the Vector3 where to store the translation
  3413. * @returns the current matrix
  3414. */
  3415. getTranslationToRef(result: Vector3): Matrix;
  3416. /**
  3417. * Remove rotation and scaling part from the matrix
  3418. * @returns the updated matrix
  3419. */
  3420. removeRotationAndScaling(): Matrix;
  3421. /**
  3422. * Multiply two matrices
  3423. * @param other defines the second operand
  3424. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3425. */
  3426. multiply(other: DeepImmutable<Matrix>): Matrix;
  3427. /**
  3428. * Copy the current matrix from the given one
  3429. * @param other defines the source matrix
  3430. * @returns the current updated matrix
  3431. */
  3432. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3433. /**
  3434. * Populates the given array from the starting index with the current matrix values
  3435. * @param array defines the target array
  3436. * @param offset defines the offset in the target array where to start storing values
  3437. * @returns the current matrix
  3438. */
  3439. copyToArray(array: Float32Array, offset?: number): Matrix;
  3440. /**
  3441. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the matrix where to store the multiplication
  3444. * @returns the current matrix
  3445. */
  3446. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3447. /**
  3448. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the array where to store the multiplication
  3451. * @param offset defines the offset in the target array where to start storing values
  3452. * @returns the current matrix
  3453. */
  3454. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3455. /**
  3456. * Check equality between this matrix and a second one
  3457. * @param value defines the second matrix to compare
  3458. * @returns true is the current matrix and the given one values are strictly equal
  3459. */
  3460. equals(value: DeepImmutable<Matrix>): boolean;
  3461. /**
  3462. * Clone the current matrix
  3463. * @returns a new matrix from the current matrix
  3464. */
  3465. clone(): Matrix;
  3466. /**
  3467. * Returns the name of the current matrix class
  3468. * @returns the string "Matrix"
  3469. */
  3470. getClassName(): string;
  3471. /**
  3472. * Gets the hash code of the current matrix
  3473. * @returns the hash code
  3474. */
  3475. getHashCode(): number;
  3476. /**
  3477. * Decomposes the current Matrix into a translation, rotation and scaling components
  3478. * @param scale defines the scale vector3 given as a reference to update
  3479. * @param rotation defines the rotation quaternion given as a reference to update
  3480. * @param translation defines the translation vector3 given as a reference to update
  3481. * @returns true if operation was successful
  3482. */
  3483. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3484. /**
  3485. * Gets specific row of the matrix
  3486. * @param index defines the number of the row to get
  3487. * @returns the index-th row of the current matrix as a new Vector4
  3488. */
  3489. getRow(index: number): Nullable<Vector4>;
  3490. /**
  3491. * Sets the index-th row of the current matrix to the vector4 values
  3492. * @param index defines the number of the row to set
  3493. * @param row defines the target vector4
  3494. * @returns the updated current matrix
  3495. */
  3496. setRow(index: number, row: Vector4): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix
  3499. * @returns the new transposed matrix
  3500. */
  3501. transpose(): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix and store it in a given matrix
  3504. * @param result defines the target matrix
  3505. * @returns the current matrix
  3506. */
  3507. transposeToRef(result: Matrix): Matrix;
  3508. /**
  3509. * Sets the index-th row of the current matrix with the given 4 x float values
  3510. * @param index defines the row index
  3511. * @param x defines the x component to set
  3512. * @param y defines the y component to set
  3513. * @param z defines the z component to set
  3514. * @param w defines the w component to set
  3515. * @returns the updated current matrix
  3516. */
  3517. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3518. /**
  3519. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3520. * @param scale defines the scale factor
  3521. * @returns a new matrix
  3522. */
  3523. scale(scale: number): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor to a given result matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor and add the result to a given matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3540. * @param ref matrix to store the result
  3541. */
  3542. toNormalMatrix(ref: Matrix): void;
  3543. /**
  3544. * Gets only rotation part of the current matrix
  3545. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3546. */
  3547. getRotationMatrix(): Matrix;
  3548. /**
  3549. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3550. * @param result defines the target matrix to store data to
  3551. * @returns the current matrix
  3552. */
  3553. getRotationMatrixToRef(result: Matrix): Matrix;
  3554. /**
  3555. * Toggles model matrix from being right handed to left handed in place and vice versa
  3556. */
  3557. toggleModelMatrixHandInPlace(): void;
  3558. /**
  3559. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3560. */
  3561. toggleProjectionMatrixHandInPlace(): void;
  3562. /**
  3563. * Creates a matrix from an array
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @returns a new Matrix set from the starting index of the given array
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3569. /**
  3570. * Copy the content of an array into a given matrix
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @param result defines the target matrix
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3576. /**
  3577. * Stores an array into a matrix after having multiplied each component by a given factor
  3578. * @param array defines the source array
  3579. * @param offset defines the offset in the source array
  3580. * @param scale defines the scaling factor
  3581. * @param result defines the target matrix
  3582. */
  3583. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3584. /**
  3585. * Gets an identity matrix that must not be updated
  3586. */
  3587. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3588. /**
  3589. * Stores a list of values (16) inside a given matrix
  3590. * @param initialM11 defines 1st value of 1st row
  3591. * @param initialM12 defines 2nd value of 1st row
  3592. * @param initialM13 defines 3rd value of 1st row
  3593. * @param initialM14 defines 4th value of 1st row
  3594. * @param initialM21 defines 1st value of 2nd row
  3595. * @param initialM22 defines 2nd value of 2nd row
  3596. * @param initialM23 defines 3rd value of 2nd row
  3597. * @param initialM24 defines 4th value of 2nd row
  3598. * @param initialM31 defines 1st value of 3rd row
  3599. * @param initialM32 defines 2nd value of 3rd row
  3600. * @param initialM33 defines 3rd value of 3rd row
  3601. * @param initialM34 defines 4th value of 3rd row
  3602. * @param initialM41 defines 1st value of 4th row
  3603. * @param initialM42 defines 2nd value of 4th row
  3604. * @param initialM43 defines 3rd value of 4th row
  3605. * @param initialM44 defines 4th value of 4th row
  3606. * @param result defines the target matrix
  3607. */
  3608. 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;
  3609. /**
  3610. * Creates new matrix from a list of values (16)
  3611. * @param initialM11 defines 1st value of 1st row
  3612. * @param initialM12 defines 2nd value of 1st row
  3613. * @param initialM13 defines 3rd value of 1st row
  3614. * @param initialM14 defines 4th value of 1st row
  3615. * @param initialM21 defines 1st value of 2nd row
  3616. * @param initialM22 defines 2nd value of 2nd row
  3617. * @param initialM23 defines 3rd value of 2nd row
  3618. * @param initialM24 defines 4th value of 2nd row
  3619. * @param initialM31 defines 1st value of 3rd row
  3620. * @param initialM32 defines 2nd value of 3rd row
  3621. * @param initialM33 defines 3rd value of 3rd row
  3622. * @param initialM34 defines 4th value of 3rd row
  3623. * @param initialM41 defines 1st value of 4th row
  3624. * @param initialM42 defines 2nd value of 4th row
  3625. * @param initialM43 defines 3rd value of 4th row
  3626. * @param initialM44 defines 4th value of 4th row
  3627. * @returns the new matrix
  3628. */
  3629. 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;
  3630. /**
  3631. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3632. * @param scale defines the scale vector3
  3633. * @param rotation defines the rotation quaternion
  3634. * @param translation defines the translation vector3
  3635. * @returns a new matrix
  3636. */
  3637. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3638. /**
  3639. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3640. * @param scale defines the scale vector3
  3641. * @param rotation defines the rotation quaternion
  3642. * @param translation defines the translation vector3
  3643. * @param result defines the target matrix
  3644. */
  3645. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3646. /**
  3647. * Creates a new identity matrix
  3648. * @returns a new identity matrix
  3649. */
  3650. static Identity(): Matrix;
  3651. /**
  3652. * Creates a new identity matrix and stores the result in a given matrix
  3653. * @param result defines the target matrix
  3654. */
  3655. static IdentityToRef(result: Matrix): void;
  3656. /**
  3657. * Creates a new zero matrix
  3658. * @returns a new zero matrix
  3659. */
  3660. static Zero(): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis
  3663. * @param angle defines the angle (in radians) to use
  3664. * @return the new matrix
  3665. */
  3666. static RotationX(angle: number): Matrix;
  3667. /**
  3668. * Creates a new matrix as the invert of a given matrix
  3669. * @param source defines the source matrix
  3670. * @returns the new matrix
  3671. */
  3672. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationXToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Y axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationY(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationYToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the Z axis
  3693. * @param angle defines the angle (in radians) to use
  3694. * @return the new matrix
  3695. */
  3696. static RotationZ(angle: number): Matrix;
  3697. /**
  3698. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3699. * @param angle defines the angle (in radians) to use
  3700. * @param result defines the target matrix
  3701. */
  3702. static RotationZToRef(angle: number, result: Matrix): void;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @return the new matrix
  3708. */
  3709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @param result defines the target matrix
  3715. */
  3716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3717. /**
  3718. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3719. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3720. * @param from defines the vector to align
  3721. * @param to defines the vector to align to
  3722. * @param result defines the target matrix
  3723. */
  3724. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3725. /**
  3726. * Creates a rotation matrix
  3727. * @param yaw defines the yaw angle in radians (Y axis)
  3728. * @param pitch defines the pitch angle in radians (X axis)
  3729. * @param roll defines the roll angle in radians (X axis)
  3730. * @returns the new rotation matrix
  3731. */
  3732. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3733. /**
  3734. * Creates a rotation matrix and stores it in a given matrix
  3735. * @param yaw defines the yaw angle in radians (Y axis)
  3736. * @param pitch defines the pitch angle in radians (X axis)
  3737. * @param roll defines the roll angle in radians (X axis)
  3738. * @param result defines the target matrix
  3739. */
  3740. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3741. /**
  3742. * Creates a scaling matrix
  3743. * @param x defines the scale factor on X axis
  3744. * @param y defines the scale factor on Y axis
  3745. * @param z defines the scale factor on Z axis
  3746. * @returns the new matrix
  3747. */
  3748. static Scaling(x: number, y: number, z: number): Matrix;
  3749. /**
  3750. * Creates a scaling matrix and stores it in a given matrix
  3751. * @param x defines the scale factor on X axis
  3752. * @param y defines the scale factor on Y axis
  3753. * @param z defines the scale factor on Z axis
  3754. * @param result defines the target matrix
  3755. */
  3756. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3757. /**
  3758. * Creates a translation matrix
  3759. * @param x defines the translation on X axis
  3760. * @param y defines the translation on Y axis
  3761. * @param z defines the translationon Z axis
  3762. * @returns the new matrix
  3763. */
  3764. static Translation(x: number, y: number, z: number): Matrix;
  3765. /**
  3766. * Creates a translation matrix and stores it in a given matrix
  3767. * @param x defines the translation on X axis
  3768. * @param y defines the translation on Y axis
  3769. * @param z defines the translationon Z axis
  3770. * @param result defines the target matrix
  3771. */
  3772. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3773. /**
  3774. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3775. * @param startValue defines the start value
  3776. * @param endValue defines the end value
  3777. * @param gradient defines the gradient factor
  3778. * @returns the new matrix
  3779. */
  3780. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3781. /**
  3782. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3783. * @param startValue defines the start value
  3784. * @param endValue defines the end value
  3785. * @param gradient defines the gradient factor
  3786. * @param result defines the Matrix object where to store data
  3787. */
  3788. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3789. /**
  3790. * Builds a new matrix whose values are computed by:
  3791. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3792. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3793. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3794. * @param startValue defines the first matrix
  3795. * @param endValue defines the second matrix
  3796. * @param gradient defines the gradient between the two matrices
  3797. * @returns the new matrix
  3798. */
  3799. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3800. /**
  3801. * Update a matrix to values which are computed by:
  3802. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3803. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3804. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3805. * @param startValue defines the first matrix
  3806. * @param endValue defines the second matrix
  3807. * @param gradient defines the gradient between the two matrices
  3808. * @param result defines the target matrix
  3809. */
  3810. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3811. /**
  3812. * 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"
  3813. * This function works in left handed mode
  3814. * @param eye defines the final position of the entity
  3815. * @param target defines where the entity should look at
  3816. * @param up defines the up vector for the entity
  3817. * @returns the new matrix
  3818. */
  3819. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3820. /**
  3821. * 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".
  3822. * This function works in left handed mode
  3823. * @param eye defines the final position of the entity
  3824. * @param target defines where the entity should look at
  3825. * @param up defines the up vector for the entity
  3826. * @param result defines the target matrix
  3827. */
  3828. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3829. /**
  3830. * 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"
  3831. * This function works in right handed mode
  3832. * @param eye defines the final position of the entity
  3833. * @param target defines where the entity should look at
  3834. * @param up defines the up vector for the entity
  3835. * @returns the new matrix
  3836. */
  3837. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3838. /**
  3839. * 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".
  3840. * This function works in right handed mode
  3841. * @param eye defines the final position of the entity
  3842. * @param target defines where the entity should look at
  3843. * @param up defines the up vector for the entity
  3844. * @param result defines the target matrix
  3845. */
  3846. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3847. /**
  3848. * Create a left-handed orthographic projection matrix
  3849. * @param width defines the viewport width
  3850. * @param height defines the viewport height
  3851. * @param znear defines the near clip plane
  3852. * @param zfar defines the far clip plane
  3853. * @returns a new matrix as a left-handed orthographic projection matrix
  3854. */
  3855. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3856. /**
  3857. * Store a left-handed orthographic projection to a given matrix
  3858. * @param width defines the viewport width
  3859. * @param height defines the viewport height
  3860. * @param znear defines the near clip plane
  3861. * @param zfar defines the far clip plane
  3862. * @param result defines the target matrix
  3863. */
  3864. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3865. /**
  3866. * Create a left-handed orthographic projection matrix
  3867. * @param left defines the viewport left coordinate
  3868. * @param right defines the viewport right coordinate
  3869. * @param bottom defines the viewport bottom coordinate
  3870. * @param top defines the viewport top coordinate
  3871. * @param znear defines the near clip plane
  3872. * @param zfar defines the far clip plane
  3873. * @returns a new matrix as a left-handed orthographic projection matrix
  3874. */
  3875. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3876. /**
  3877. * Stores a left-handed orthographic projection into a given matrix
  3878. * @param left defines the viewport left coordinate
  3879. * @param right defines the viewport right coordinate
  3880. * @param bottom defines the viewport bottom coordinate
  3881. * @param top defines the viewport top coordinate
  3882. * @param znear defines the near clip plane
  3883. * @param zfar defines the far clip plane
  3884. * @param result defines the target matrix
  3885. */
  3886. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3887. /**
  3888. * Creates a right-handed orthographic projection matrix
  3889. * @param left defines the viewport left coordinate
  3890. * @param right defines the viewport right coordinate
  3891. * @param bottom defines the viewport bottom coordinate
  3892. * @param top defines the viewport top coordinate
  3893. * @param znear defines the near clip plane
  3894. * @param zfar defines the far clip plane
  3895. * @returns a new matrix as a right-handed orthographic projection matrix
  3896. */
  3897. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3898. /**
  3899. * Stores a right-handed orthographic projection into a given matrix
  3900. * @param left defines the viewport left coordinate
  3901. * @param right defines the viewport right coordinate
  3902. * @param bottom defines the viewport bottom coordinate
  3903. * @param top defines the viewport top coordinate
  3904. * @param znear defines the near clip plane
  3905. * @param zfar defines the far clip plane
  3906. * @param result defines the target matrix
  3907. */
  3908. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3909. /**
  3910. * Creates a left-handed perspective projection matrix
  3911. * @param width defines the viewport width
  3912. * @param height defines the viewport height
  3913. * @param znear defines the near clip plane
  3914. * @param zfar defines the far clip plane
  3915. * @returns a new matrix as a left-handed perspective projection matrix
  3916. */
  3917. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3918. /**
  3919. * Creates a left-handed perspective projection matrix
  3920. * @param fov defines the horizontal field of view
  3921. * @param aspect defines the aspect ratio
  3922. * @param znear defines the near clip plane
  3923. * @param zfar defines the far clip plane
  3924. * @returns a new matrix as a left-handed perspective projection matrix
  3925. */
  3926. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3927. /**
  3928. * Stores a left-handed perspective projection into a given matrix
  3929. * @param fov defines the horizontal field of view
  3930. * @param aspect defines the aspect ratio
  3931. * @param znear defines the near clip plane
  3932. * @param zfar defines the far clip plane
  3933. * @param result defines the target matrix
  3934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3935. */
  3936. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3937. /**
  3938. * Creates a right-handed perspective projection matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @returns a new matrix as a right-handed perspective projection matrix
  3944. */
  3945. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3946. /**
  3947. * Stores a right-handed perspective projection into a given matrix
  3948. * @param fov defines the horizontal field of view
  3949. * @param aspect defines the aspect ratio
  3950. * @param znear defines the near clip plane
  3951. * @param zfar defines the far clip plane
  3952. * @param result defines the target matrix
  3953. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3954. */
  3955. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3956. /**
  3957. * Stores a perspective projection for WebVR info a given matrix
  3958. * @param fov defines the field of view
  3959. * @param znear defines the near clip plane
  3960. * @param zfar defines the far clip plane
  3961. * @param result defines the target matrix
  3962. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3963. */
  3964. static PerspectiveFovWebVRToRef(fov: {
  3965. upDegrees: number;
  3966. downDegrees: number;
  3967. leftDegrees: number;
  3968. rightDegrees: number;
  3969. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3970. /**
  3971. * Computes a complete transformation matrix
  3972. * @param viewport defines the viewport to use
  3973. * @param world defines the world matrix
  3974. * @param view defines the view matrix
  3975. * @param projection defines the projection matrix
  3976. * @param zmin defines the near clip plane
  3977. * @param zmax defines the far clip plane
  3978. * @returns the transformation matrix
  3979. */
  3980. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3981. /**
  3982. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3983. * @param matrix defines the matrix to use
  3984. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3985. */
  3986. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3987. /**
  3988. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3989. * @param matrix defines the matrix to use
  3990. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3991. */
  3992. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3993. /**
  3994. * Compute the transpose of a given matrix
  3995. * @param matrix defines the matrix to transpose
  3996. * @returns the new matrix
  3997. */
  3998. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3999. /**
  4000. * Compute the transpose of a matrix and store it in a target matrix
  4001. * @param matrix defines the matrix to transpose
  4002. * @param result defines the target matrix
  4003. */
  4004. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4005. /**
  4006. * Computes a reflection matrix from a plane
  4007. * @param plane defines the reflection plane
  4008. * @returns a new matrix
  4009. */
  4010. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4011. /**
  4012. * Computes a reflection matrix from a plane
  4013. * @param plane defines the reflection plane
  4014. * @param result defines the target matrix
  4015. */
  4016. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4017. /**
  4018. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4019. * @param xaxis defines the value of the 1st axis
  4020. * @param yaxis defines the value of the 2nd axis
  4021. * @param zaxis defines the value of the 3rd axis
  4022. * @param result defines the target matrix
  4023. */
  4024. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4025. /**
  4026. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4027. * @param quat defines the quaternion to use
  4028. * @param result defines the target matrix
  4029. */
  4030. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4031. }
  4032. /**
  4033. * @hidden
  4034. */
  4035. export class TmpVectors {
  4036. static Vector2: Vector2[];
  4037. static Vector3: Vector3[];
  4038. static Vector4: Vector4[];
  4039. static Quaternion: Quaternion[];
  4040. static Matrix: Matrix[];
  4041. }
  4042. }
  4043. declare module BABYLON {
  4044. /** Defines the cross module used constants to avoid circular dependncies */
  4045. export class Constants {
  4046. /** Defines that alpha blending is disabled */
  4047. static readonly ALPHA_DISABLE: number;
  4048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4049. static readonly ALPHA_ADD: number;
  4050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4051. static readonly ALPHA_COMBINE: number;
  4052. /** Defines that alpha blending to DEST - SRC * DEST */
  4053. static readonly ALPHA_SUBTRACT: number;
  4054. /** Defines that alpha blending to SRC * DEST */
  4055. static readonly ALPHA_MULTIPLY: number;
  4056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4057. static readonly ALPHA_MAXIMIZED: number;
  4058. /** Defines that alpha blending to SRC + DEST */
  4059. static readonly ALPHA_ONEONE: number;
  4060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_PREMULTIPLIED: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4068. static readonly ALPHA_INTERPOLATE: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_SCREENMODE: number;
  4074. /** Defines that the ressource is not delayed*/
  4075. static readonly DELAYLOADSTATE_NONE: number;
  4076. /** Defines that the ressource was successfully delay loaded */
  4077. static readonly DELAYLOADSTATE_LOADED: number;
  4078. /** Defines that the ressource is currently delay loading */
  4079. static readonly DELAYLOADSTATE_LOADING: number;
  4080. /** Defines that the ressource is delayed and has not started loading */
  4081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4083. static readonly NEVER: number;
  4084. /** 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 */
  4085. static readonly ALWAYS: number;
  4086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4087. static readonly LESS: number;
  4088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4089. static readonly EQUAL: number;
  4090. /** 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 */
  4091. static readonly LEQUAL: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4093. static readonly GREATER: number;
  4094. /** 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 */
  4095. static readonly GEQUAL: number;
  4096. /** 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 */
  4097. static readonly NOTEQUAL: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be kept */
  4099. static readonly KEEP: number;
  4100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4101. static readonly REPLACE: number;
  4102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4103. static readonly INCR: number;
  4104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4105. static readonly DECR: number;
  4106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4107. static readonly INVERT: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4109. static readonly INCR_WRAP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4111. static readonly DECR_WRAP: number;
  4112. /** Texture is not repeating outside of 0..1 UVs */
  4113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4114. /** Texture is repeating outside of 0..1 UVs */
  4115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4116. /** Texture is repeating and mirrored */
  4117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4118. /** ALPHA */
  4119. static readonly TEXTUREFORMAT_ALPHA: number;
  4120. /** LUMINANCE */
  4121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4122. /** LUMINANCE_ALPHA */
  4123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4124. /** RGB */
  4125. static readonly TEXTUREFORMAT_RGB: number;
  4126. /** RGBA */
  4127. static readonly TEXTUREFORMAT_RGBA: number;
  4128. /** RED */
  4129. static readonly TEXTUREFORMAT_RED: number;
  4130. /** RED (2nd reference) */
  4131. static readonly TEXTUREFORMAT_R: number;
  4132. /** RG */
  4133. static readonly TEXTUREFORMAT_RG: number;
  4134. /** RED_INTEGER */
  4135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4136. /** RED_INTEGER (2nd reference) */
  4137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4138. /** RG_INTEGER */
  4139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4140. /** RGB_INTEGER */
  4141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4142. /** RGBA_INTEGER */
  4143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4144. /** UNSIGNED_BYTE */
  4145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4146. /** UNSIGNED_BYTE (2nd reference) */
  4147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4148. /** FLOAT */
  4149. static readonly TEXTURETYPE_FLOAT: number;
  4150. /** HALF_FLOAT */
  4151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4152. /** BYTE */
  4153. static readonly TEXTURETYPE_BYTE: number;
  4154. /** SHORT */
  4155. static readonly TEXTURETYPE_SHORT: number;
  4156. /** UNSIGNED_SHORT */
  4157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4158. /** INT */
  4159. static readonly TEXTURETYPE_INT: number;
  4160. /** UNSIGNED_INT */
  4161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4162. /** UNSIGNED_SHORT_4_4_4_4 */
  4163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4164. /** UNSIGNED_SHORT_5_5_5_1 */
  4165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4166. /** UNSIGNED_SHORT_5_6_5 */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4168. /** UNSIGNED_INT_2_10_10_10_REV */
  4169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4170. /** UNSIGNED_INT_24_8 */
  4171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4172. /** UNSIGNED_INT_10F_11F_11F_REV */
  4173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4174. /** UNSIGNED_INT_5_9_9_9_REV */
  4175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4178. /** nearest is mag = nearest and min = nearest and mip = linear */
  4179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4182. /** Trilinear is mag = linear and min = linear and mip = linear */
  4183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4184. /** nearest is mag = nearest and min = nearest and mip = linear */
  4185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4188. /** Trilinear is mag = linear and min = linear and mip = linear */
  4189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4190. /** mag = nearest and min = nearest and mip = nearest */
  4191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4192. /** mag = nearest and min = linear and mip = nearest */
  4193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4194. /** mag = nearest and min = linear and mip = linear */
  4195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4196. /** mag = nearest and min = linear and mip = none */
  4197. static readonly TEXTURE_NEAREST_LINEAR: number;
  4198. /** mag = nearest and min = nearest and mip = none */
  4199. static readonly TEXTURE_NEAREST_NEAREST: number;
  4200. /** mag = linear and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4202. /** mag = linear and min = nearest and mip = linear */
  4203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4204. /** mag = linear and min = linear and mip = none */
  4205. static readonly TEXTURE_LINEAR_LINEAR: number;
  4206. /** mag = linear and min = nearest and mip = none */
  4207. static readonly TEXTURE_LINEAR_NEAREST: number;
  4208. /** Explicit coordinates mode */
  4209. static readonly TEXTURE_EXPLICIT_MODE: number;
  4210. /** Spherical coordinates mode */
  4211. static readonly TEXTURE_SPHERICAL_MODE: number;
  4212. /** Planar coordinates mode */
  4213. static readonly TEXTURE_PLANAR_MODE: number;
  4214. /** Cubic coordinates mode */
  4215. static readonly TEXTURE_CUBIC_MODE: number;
  4216. /** Projection coordinates mode */
  4217. static readonly TEXTURE_PROJECTION_MODE: number;
  4218. /** Skybox coordinates mode */
  4219. static readonly TEXTURE_SKYBOX_MODE: number;
  4220. /** Inverse Cubic coordinates mode */
  4221. static readonly TEXTURE_INVCUBIC_MODE: number;
  4222. /** Equirectangular coordinates mode */
  4223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4224. /** Equirectangular Fixed coordinates mode */
  4225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4226. /** Equirectangular Fixed Mirrored coordinates mode */
  4227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4229. static readonly SCALEMODE_FLOOR: number;
  4230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4231. static readonly SCALEMODE_NEAREST: number;
  4232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4233. static readonly SCALEMODE_CEILING: number;
  4234. /**
  4235. * The dirty texture flag value
  4236. */
  4237. static readonly MATERIAL_TextureDirtyFlag: number;
  4238. /**
  4239. * The dirty light flag value
  4240. */
  4241. static readonly MATERIAL_LightDirtyFlag: number;
  4242. /**
  4243. * The dirty fresnel flag value
  4244. */
  4245. static readonly MATERIAL_FresnelDirtyFlag: number;
  4246. /**
  4247. * The dirty attribute flag value
  4248. */
  4249. static readonly MATERIAL_AttributesDirtyFlag: number;
  4250. /**
  4251. * The dirty misc flag value
  4252. */
  4253. static readonly MATERIAL_MiscDirtyFlag: number;
  4254. /**
  4255. * The all dirty flag value
  4256. */
  4257. static readonly MATERIAL_AllDirtyFlag: number;
  4258. /**
  4259. * Returns the triangle fill mode
  4260. */
  4261. static readonly MATERIAL_TriangleFillMode: number;
  4262. /**
  4263. * Returns the wireframe mode
  4264. */
  4265. static readonly MATERIAL_WireFrameFillMode: number;
  4266. /**
  4267. * Returns the point fill mode
  4268. */
  4269. static readonly MATERIAL_PointFillMode: number;
  4270. /**
  4271. * Returns the point list draw mode
  4272. */
  4273. static readonly MATERIAL_PointListDrawMode: number;
  4274. /**
  4275. * Returns the line list draw mode
  4276. */
  4277. static readonly MATERIAL_LineListDrawMode: number;
  4278. /**
  4279. * Returns the line loop draw mode
  4280. */
  4281. static readonly MATERIAL_LineLoopDrawMode: number;
  4282. /**
  4283. * Returns the line strip draw mode
  4284. */
  4285. static readonly MATERIAL_LineStripDrawMode: number;
  4286. /**
  4287. * Returns the triangle strip draw mode
  4288. */
  4289. static readonly MATERIAL_TriangleStripDrawMode: number;
  4290. /**
  4291. * Returns the triangle fan draw mode
  4292. */
  4293. static readonly MATERIAL_TriangleFanDrawMode: number;
  4294. /**
  4295. * Stores the clock-wise side orientation
  4296. */
  4297. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4298. /**
  4299. * Stores the counter clock-wise side orientation
  4300. */
  4301. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4302. /**
  4303. * Nothing
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_NothingTrigger: number;
  4307. /**
  4308. * On pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnPickTrigger: number;
  4312. /**
  4313. * On left pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnLeftPickTrigger: number;
  4317. /**
  4318. * On right pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnRightPickTrigger: number;
  4322. /**
  4323. * On center pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnCenterPickTrigger: number;
  4327. /**
  4328. * On pick down
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnPickDownTrigger: number;
  4332. /**
  4333. * On double pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnDoublePickTrigger: number;
  4337. /**
  4338. * On pick up
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickUpTrigger: number;
  4342. /**
  4343. * On pick out.
  4344. * This trigger will only be raised if you also declared a OnPickDown
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnPickOutTrigger: number;
  4348. /**
  4349. * On long press
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnLongPressTrigger: number;
  4353. /**
  4354. * On pointer over
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOverTrigger: number;
  4358. /**
  4359. * On pointer out
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOutTrigger: number;
  4363. /**
  4364. * On every frame
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnEveryFrameTrigger: number;
  4368. /**
  4369. * On intersection enter
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4373. /**
  4374. * On intersection exit
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionExitTrigger: number;
  4378. /**
  4379. * On key down
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyDownTrigger: number;
  4383. /**
  4384. * On key up
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyUpTrigger: number;
  4388. /**
  4389. * Billboard mode will only apply to Y axis
  4390. */
  4391. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4392. /**
  4393. * Billboard mode will apply to all axes
  4394. */
  4395. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4396. /**
  4397. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4398. */
  4399. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4400. /**
  4401. * Gets or sets base Assets URL
  4402. */
  4403. static PARTICLES_BaseAssetsUrl: string;
  4404. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4405. * Test order :
  4406. * Is the bounding sphere outside the frustum ?
  4407. * If not, are the bounding box vertices outside the frustum ?
  4408. * It not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4411. /** Culling strategy : Bounding Sphere Only.
  4412. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4413. * It's also less accurate than the standard because some not visible objects can still be selected.
  4414. * Test : is the bounding sphere outside the frustum ?
  4415. * If not, then the cullable object is in the frustum.
  4416. */
  4417. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4418. /** Culling strategy : Optimistic Inclusion.
  4419. * This in an inclusion test first, then the standard exclusion test.
  4420. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4421. * 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.
  4422. * Anyway, it's as accurate as the standard strategy.
  4423. * Test :
  4424. * Is the cullable object bounding sphere center in the frustum ?
  4425. * If not, apply the default culling strategy.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4428. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4429. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4430. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4438. /**
  4439. * No logging while loading
  4440. */
  4441. static readonly SCENELOADER_NO_LOGGING: number;
  4442. /**
  4443. * Minimal logging while loading
  4444. */
  4445. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4446. /**
  4447. * Summary logging while loading
  4448. */
  4449. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4450. /**
  4451. * Detailled logging while loading
  4452. */
  4453. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4454. }
  4455. }
  4456. declare module BABYLON {
  4457. /**
  4458. * Class used to store and describe the pipeline context associated with an effect
  4459. */
  4460. export interface IPipelineContext {
  4461. /**
  4462. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4463. */
  4464. isAsync: boolean;
  4465. /**
  4466. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4467. */
  4468. isReady: boolean;
  4469. /** @hidden */
  4470. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface IShaderProcessor {
  4476. attributeProcessor?: (attribute: string) => string;
  4477. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4478. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4479. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4480. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4481. lineProcessor?: (line: string, isFragment: boolean) => string;
  4482. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4483. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4484. }
  4485. }
  4486. declare module BABYLON {
  4487. /** @hidden */
  4488. export interface ProcessingOptions {
  4489. defines: string[];
  4490. indexParameters: any;
  4491. isFragment: boolean;
  4492. shouldUseHighPrecisionShader: boolean;
  4493. supportsUniformBuffers: boolean;
  4494. shadersRepository: string;
  4495. includesShadersStore: {
  4496. [key: string]: string;
  4497. };
  4498. processor?: IShaderProcessor;
  4499. version: string;
  4500. platformName: string;
  4501. lookForClosingBracketForUniformBuffer?: boolean;
  4502. }
  4503. }
  4504. declare module BABYLON {
  4505. /**
  4506. * Helper to manipulate strings
  4507. */
  4508. export class StringTools {
  4509. /**
  4510. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4511. * @param str Source string
  4512. * @param suffix Suffix to search for in the source string
  4513. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4514. */
  4515. static EndsWith(str: string, suffix: string): boolean;
  4516. /**
  4517. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4518. * @param str Source string
  4519. * @param suffix Suffix to search for in the source string
  4520. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4521. */
  4522. static StartsWith(str: string, suffix: string): boolean;
  4523. }
  4524. }
  4525. declare module BABYLON {
  4526. /** @hidden */
  4527. export class ShaderCodeNode {
  4528. line: string;
  4529. children: ShaderCodeNode[];
  4530. additionalDefineKey?: string;
  4531. additionalDefineValue?: string;
  4532. isValid(preprocessors: {
  4533. [key: string]: string;
  4534. }): boolean;
  4535. process(preprocessors: {
  4536. [key: string]: string;
  4537. }, options: ProcessingOptions): string;
  4538. }
  4539. }
  4540. declare module BABYLON {
  4541. /** @hidden */
  4542. export class ShaderCodeCursor {
  4543. private _lines;
  4544. lineIndex: number;
  4545. readonly currentLine: string;
  4546. readonly canRead: boolean;
  4547. lines: string[];
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /** @hidden */
  4552. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4553. process(preprocessors: {
  4554. [key: string]: string;
  4555. }, options: ProcessingOptions): string;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. /** @hidden */
  4560. export class ShaderDefineExpression {
  4561. isTrue(preprocessors: {
  4562. [key: string]: string;
  4563. }): boolean;
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /** @hidden */
  4568. export class ShaderCodeTestNode extends ShaderCodeNode {
  4569. testExpression: ShaderDefineExpression;
  4570. isValid(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module BABYLON {
  4576. /** @hidden */
  4577. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4578. define: string;
  4579. not: boolean;
  4580. constructor(define: string, not?: boolean);
  4581. isTrue(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /** @hidden */
  4588. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4589. leftOperand: ShaderDefineExpression;
  4590. rightOperand: ShaderDefineExpression;
  4591. isTrue(preprocessors: {
  4592. [key: string]: string;
  4593. }): boolean;
  4594. }
  4595. }
  4596. declare module BABYLON {
  4597. /** @hidden */
  4598. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4599. leftOperand: ShaderDefineExpression;
  4600. rightOperand: ShaderDefineExpression;
  4601. isTrue(preprocessors: {
  4602. [key: string]: string;
  4603. }): boolean;
  4604. }
  4605. }
  4606. declare module BABYLON {
  4607. /** @hidden */
  4608. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4609. define: string;
  4610. operand: string;
  4611. testValue: string;
  4612. constructor(define: string, operand: string, testValue: string);
  4613. isTrue(preprocessors: {
  4614. [key: string]: string;
  4615. }): boolean;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * @ignore
  4621. * Application error to support additional information when loading a file
  4622. */
  4623. export class LoadFileError extends Error {
  4624. /** defines the optional web request */
  4625. request?: WebRequest | undefined;
  4626. private static _setPrototypeOf;
  4627. /**
  4628. * Creates a new LoadFileError
  4629. * @param message defines the message of the error
  4630. * @param request defines the optional web request
  4631. */
  4632. constructor(message: string,
  4633. /** defines the optional web request */
  4634. request?: WebRequest | undefined);
  4635. }
  4636. }
  4637. declare module BABYLON {
  4638. /**
  4639. * Class used to enable access to offline support
  4640. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4641. */
  4642. export interface IOfflineProvider {
  4643. /**
  4644. * Gets a boolean indicating if scene must be saved in the database
  4645. */
  4646. enableSceneOffline: boolean;
  4647. /**
  4648. * Gets a boolean indicating if textures must be saved in the database
  4649. */
  4650. enableTexturesOffline: boolean;
  4651. /**
  4652. * Open the offline support and make it available
  4653. * @param successCallback defines the callback to call on success
  4654. * @param errorCallback defines the callback to call on error
  4655. */
  4656. open(successCallback: () => void, errorCallback: () => void): void;
  4657. /**
  4658. * Loads an image from the offline support
  4659. * @param url defines the url to load from
  4660. * @param image defines the target DOM image
  4661. */
  4662. loadImage(url: string, image: HTMLImageElement): void;
  4663. /**
  4664. * Loads a file from offline support
  4665. * @param url defines the URL to load from
  4666. * @param sceneLoaded defines a callback to call on success
  4667. * @param progressCallBack defines a callback to call when progress changed
  4668. * @param errorCallback defines a callback to call on error
  4669. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4670. */
  4671. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4672. }
  4673. }
  4674. declare module BABYLON {
  4675. /**
  4676. * Class used to help managing file picking and drag'n'drop
  4677. * File Storage
  4678. */
  4679. export class FilesInputStore {
  4680. /**
  4681. * List of files ready to be loaded
  4682. */
  4683. static FilesToLoad: {
  4684. [key: string]: File;
  4685. };
  4686. }
  4687. }
  4688. declare module BABYLON {
  4689. /**
  4690. * Class used to define a retry strategy when error happens while loading assets
  4691. */
  4692. export class RetryStrategy {
  4693. /**
  4694. * Function used to defines an exponential back off strategy
  4695. * @param maxRetries defines the maximum number of retries (3 by default)
  4696. * @param baseInterval defines the interval between retries
  4697. * @returns the strategy function to use
  4698. */
  4699. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4700. }
  4701. }
  4702. declare module BABYLON {
  4703. /**
  4704. * @hidden
  4705. */
  4706. export class FileTools {
  4707. /**
  4708. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4709. */
  4710. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4711. /**
  4712. * Gets or sets the base URL to use to load assets
  4713. */
  4714. static BaseUrl: string;
  4715. /**
  4716. * Default behaviour for cors in the application.
  4717. * It can be a string if the expected behavior is identical in the entire app.
  4718. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4719. */
  4720. static CorsBehavior: string | ((url: string | string[]) => string);
  4721. /**
  4722. * Gets or sets a function used to pre-process url before using them to load assets
  4723. */
  4724. static PreprocessUrl: (url: string) => string;
  4725. /**
  4726. * Removes unwanted characters from an url
  4727. * @param url defines the url to clean
  4728. * @returns the cleaned url
  4729. */
  4730. private static _CleanUrl;
  4731. /**
  4732. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4733. * @param url define the url we are trying
  4734. * @param element define the dom element where to configure the cors policy
  4735. */
  4736. static SetCorsBehavior(url: string | string[], element: {
  4737. crossOrigin: string | null;
  4738. }): void;
  4739. /**
  4740. * Loads an image as an HTMLImageElement.
  4741. * @param input url string, ArrayBuffer, or Blob to load
  4742. * @param onLoad callback called when the image successfully loads
  4743. * @param onError callback called when the image fails to load
  4744. * @param offlineProvider offline provider for caching
  4745. * @returns the HTMLImageElement of the loaded image
  4746. */
  4747. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4748. /**
  4749. * Loads a file
  4750. * @param fileToLoad defines the file to load
  4751. * @param callback defines the callback to call when data is loaded
  4752. * @param progressCallBack defines the callback to call during loading process
  4753. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4754. * @returns a file request object
  4755. */
  4756. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4757. /**
  4758. * Loads a file
  4759. * @param url url string, ArrayBuffer, or Blob to load
  4760. * @param onSuccess callback called when the file successfully loads
  4761. * @param onProgress callback called while file is loading (if the server supports this mode)
  4762. * @param offlineProvider defines the offline provider for caching
  4763. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4764. * @param onError callback called when the file fails to load
  4765. * @returns a file request object
  4766. */
  4767. 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;
  4768. /**
  4769. * Checks if the loaded document was accessed via `file:`-Protocol.
  4770. * @returns boolean
  4771. */
  4772. static IsFileURL(): boolean;
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /** @hidden */
  4777. export class ShaderProcessor {
  4778. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4779. private static _ProcessPrecision;
  4780. private static _ExtractOperation;
  4781. private static _BuildSubExpression;
  4782. private static _BuildExpression;
  4783. private static _MoveCursorWithinIf;
  4784. private static _MoveCursor;
  4785. private static _EvaluatePreProcessors;
  4786. private static _PreparePreProcessors;
  4787. private static _ProcessShaderConversion;
  4788. private static _ProcessIncludes;
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Class used to hold a RBG color
  4794. */
  4795. export class Color3 {
  4796. /**
  4797. * Defines the red component (between 0 and 1, default is 0)
  4798. */
  4799. r: number;
  4800. /**
  4801. * Defines the green component (between 0 and 1, default is 0)
  4802. */
  4803. g: number;
  4804. /**
  4805. * Defines the blue component (between 0 and 1, default is 0)
  4806. */
  4807. b: number;
  4808. /**
  4809. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4810. * @param r defines the red component (between 0 and 1, default is 0)
  4811. * @param g defines the green component (between 0 and 1, default is 0)
  4812. * @param b defines the blue component (between 0 and 1, default is 0)
  4813. */
  4814. constructor(
  4815. /**
  4816. * Defines the red component (between 0 and 1, default is 0)
  4817. */
  4818. r?: number,
  4819. /**
  4820. * Defines the green component (between 0 and 1, default is 0)
  4821. */
  4822. g?: number,
  4823. /**
  4824. * Defines the blue component (between 0 and 1, default is 0)
  4825. */
  4826. b?: number);
  4827. /**
  4828. * Creates a string with the Color3 current values
  4829. * @returns the string representation of the Color3 object
  4830. */
  4831. toString(): string;
  4832. /**
  4833. * Returns the string "Color3"
  4834. * @returns "Color3"
  4835. */
  4836. getClassName(): string;
  4837. /**
  4838. * Compute the Color3 hash code
  4839. * @returns an unique number that can be used to hash Color3 objects
  4840. */
  4841. getHashCode(): number;
  4842. /**
  4843. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4844. * @param array defines the array where to store the r,g,b components
  4845. * @param index defines an optional index in the target array to define where to start storing values
  4846. * @returns the current Color3 object
  4847. */
  4848. toArray(array: FloatArray, index?: number): Color3;
  4849. /**
  4850. * Returns a new Color4 object from the current Color3 and the given alpha
  4851. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4852. * @returns a new Color4 object
  4853. */
  4854. toColor4(alpha?: number): Color4;
  4855. /**
  4856. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4857. * @returns the new array
  4858. */
  4859. asArray(): number[];
  4860. /**
  4861. * Returns the luminance value
  4862. * @returns a float value
  4863. */
  4864. toLuminance(): number;
  4865. /**
  4866. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4867. * @param otherColor defines the second operand
  4868. * @returns the new Color3 object
  4869. */
  4870. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4871. /**
  4872. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4873. * @param otherColor defines the second operand
  4874. * @param result defines the Color3 object where to store the result
  4875. * @returns the current Color3
  4876. */
  4877. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4878. /**
  4879. * Determines equality between Color3 objects
  4880. * @param otherColor defines the second operand
  4881. * @returns true if the rgb values are equal to the given ones
  4882. */
  4883. equals(otherColor: DeepImmutable<Color3>): boolean;
  4884. /**
  4885. * Determines equality between the current Color3 object and a set of r,b,g values
  4886. * @param r defines the red component to check
  4887. * @param g defines the green component to check
  4888. * @param b defines the blue component to check
  4889. * @returns true if the rgb values are equal to the given ones
  4890. */
  4891. equalsFloats(r: number, g: number, b: number): boolean;
  4892. /**
  4893. * Multiplies in place each rgb value by scale
  4894. * @param scale defines the scaling factor
  4895. * @returns the updated Color3
  4896. */
  4897. scale(scale: number): Color3;
  4898. /**
  4899. * Multiplies the rgb values by scale and stores the result into "result"
  4900. * @param scale defines the scaling factor
  4901. * @param result defines the Color3 object where to store the result
  4902. * @returns the unmodified current Color3
  4903. */
  4904. scaleToRef(scale: number, result: Color3): Color3;
  4905. /**
  4906. * Scale the current Color3 values by a factor and add the result to a given Color3
  4907. * @param scale defines the scale factor
  4908. * @param result defines color to store the result into
  4909. * @returns the unmodified current Color3
  4910. */
  4911. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4912. /**
  4913. * Clamps the rgb values by the min and max values and stores the result into "result"
  4914. * @param min defines minimum clamping value (default is 0)
  4915. * @param max defines maximum clamping value (default is 1)
  4916. * @param result defines color to store the result into
  4917. * @returns the original Color3
  4918. */
  4919. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4920. /**
  4921. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. add(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4935. * @param otherColor defines the second operand
  4936. * @returns the new Color3
  4937. */
  4938. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4939. /**
  4940. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4941. * @param otherColor defines the second operand
  4942. * @param result defines Color3 object to store the result into
  4943. * @returns the unmodified current Color3
  4944. */
  4945. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4946. /**
  4947. * Copy the current object
  4948. * @returns a new Color3 copied the current one
  4949. */
  4950. clone(): Color3;
  4951. /**
  4952. * Copies the rgb values from the source in the current Color3
  4953. * @param source defines the source Color3 object
  4954. * @returns the updated Color3 object
  4955. */
  4956. copyFrom(source: DeepImmutable<Color3>): Color3;
  4957. /**
  4958. * Updates the Color3 rgb values from the given floats
  4959. * @param r defines the red component to read from
  4960. * @param g defines the green component to read from
  4961. * @param b defines the blue component to read from
  4962. * @returns the current Color3 object
  4963. */
  4964. copyFromFloats(r: number, g: number, b: number): Color3;
  4965. /**
  4966. * Updates the Color3 rgb values from the given floats
  4967. * @param r defines the red component to read from
  4968. * @param g defines the green component to read from
  4969. * @param b defines the blue component to read from
  4970. * @returns the current Color3 object
  4971. */
  4972. set(r: number, g: number, b: number): Color3;
  4973. /**
  4974. * Compute the Color3 hexadecimal code as a string
  4975. * @returns a string containing the hexadecimal representation of the Color3 object
  4976. */
  4977. toHexString(): string;
  4978. /**
  4979. * Computes a new Color3 converted from the current one to linear space
  4980. * @returns a new Color3 object
  4981. */
  4982. toLinearSpace(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @returns a new color3 representing the HSV values
  4986. */
  4987. toHSV(): Color3;
  4988. /**
  4989. * Converts current color in rgb space to HSV values
  4990. * @param result defines the Color3 where to store the HSV values
  4991. */
  4992. toHSVToRef(result: Color3): void;
  4993. /**
  4994. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4995. * @param convertedColor defines the Color3 object where to store the linear space version
  4996. * @returns the unmodified Color3
  4997. */
  4998. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4999. /**
  5000. * Computes a new Color3 converted from the current one to gamma space
  5001. * @returns a new Color3 object
  5002. */
  5003. toGammaSpace(): Color3;
  5004. /**
  5005. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5006. * @param convertedColor defines the Color3 object where to store the gamma space version
  5007. * @returns the unmodified Color3
  5008. */
  5009. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5010. private static _BlackReadOnly;
  5011. /**
  5012. * Convert Hue, saturation and value to a Color3 (RGB)
  5013. * @param hue defines the hue
  5014. * @param saturation defines the saturation
  5015. * @param value defines the value
  5016. * @param result defines the Color3 where to store the RGB values
  5017. */
  5018. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5019. /**
  5020. * Creates a new Color3 from the string containing valid hexadecimal values
  5021. * @param hex defines a string containing valid hexadecimal values
  5022. * @returns a new Color3 object
  5023. */
  5024. static FromHexString(hex: string): Color3;
  5025. /**
  5026. * Creates a new Color3 from the starting index of the given array
  5027. * @param array defines the source array
  5028. * @param offset defines an offset in the source array
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5032. /**
  5033. * Creates a new Color3 from integer values (< 256)
  5034. * @param r defines the red component to read from (value between 0 and 255)
  5035. * @param g defines the green component to read from (value between 0 and 255)
  5036. * @param b defines the blue component to read from (value between 0 and 255)
  5037. * @returns a new Color3 object
  5038. */
  5039. static FromInts(r: number, g: number, b: number): Color3;
  5040. /**
  5041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5042. * @param start defines the start Color3 value
  5043. * @param end defines the end Color3 value
  5044. * @param amount defines the gradient value between start and end
  5045. * @returns a new Color3 object
  5046. */
  5047. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5048. /**
  5049. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5050. * @param left defines the start value
  5051. * @param right defines the end value
  5052. * @param amount defines the gradient factor
  5053. * @param result defines the Color3 object where to store the result
  5054. */
  5055. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5056. /**
  5057. * Returns a Color3 value containing a red color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Red(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a green color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Green(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a blue color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Blue(): Color3;
  5071. /**
  5072. * Returns a Color3 value containing a black color
  5073. * @returns a new Color3 object
  5074. */
  5075. static Black(): Color3;
  5076. /**
  5077. * Gets a Color3 value containing a black color that must not be updated
  5078. */
  5079. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5080. /**
  5081. * Returns a Color3 value containing a white color
  5082. * @returns a new Color3 object
  5083. */
  5084. static White(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a purple color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Purple(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a magenta color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Magenta(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a yellow color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Yellow(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a gray color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Gray(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a teal color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Teal(): Color3;
  5110. /**
  5111. * Returns a Color3 value containing a random color
  5112. * @returns a new Color3 object
  5113. */
  5114. static Random(): Color3;
  5115. }
  5116. /**
  5117. * Class used to hold a RBGA color
  5118. */
  5119. export class Color4 {
  5120. /**
  5121. * Defines the red component (between 0 and 1, default is 0)
  5122. */
  5123. r: number;
  5124. /**
  5125. * Defines the green component (between 0 and 1, default is 0)
  5126. */
  5127. g: number;
  5128. /**
  5129. * Defines the blue component (between 0 and 1, default is 0)
  5130. */
  5131. b: number;
  5132. /**
  5133. * Defines the alpha component (between 0 and 1, default is 1)
  5134. */
  5135. a: number;
  5136. /**
  5137. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5138. * @param r defines the red component (between 0 and 1, default is 0)
  5139. * @param g defines the green component (between 0 and 1, default is 0)
  5140. * @param b defines the blue component (between 0 and 1, default is 0)
  5141. * @param a defines the alpha component (between 0 and 1, default is 1)
  5142. */
  5143. constructor(
  5144. /**
  5145. * Defines the red component (between 0 and 1, default is 0)
  5146. */
  5147. r?: number,
  5148. /**
  5149. * Defines the green component (between 0 and 1, default is 0)
  5150. */
  5151. g?: number,
  5152. /**
  5153. * Defines the blue component (between 0 and 1, default is 0)
  5154. */
  5155. b?: number,
  5156. /**
  5157. * Defines the alpha component (between 0 and 1, default is 1)
  5158. */
  5159. a?: number);
  5160. /**
  5161. * Adds in place the given Color4 values to the current Color4 object
  5162. * @param right defines the second operand
  5163. * @returns the current updated Color4 object
  5164. */
  5165. addInPlace(right: DeepImmutable<Color4>): Color4;
  5166. /**
  5167. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Stores from the starting index in the given array the Color4 successive values
  5173. * @param array defines the array where to store the r,g,b components
  5174. * @param index defines an optional index in the target array to define where to start storing values
  5175. * @returns the current Color4 object
  5176. */
  5177. toArray(array: number[], index?: number): Color4;
  5178. /**
  5179. * Determines equality between Color4 objects
  5180. * @param otherColor defines the second operand
  5181. * @returns true if the rgba values are equal to the given ones
  5182. */
  5183. equals(otherColor: DeepImmutable<Color4>): boolean;
  5184. /**
  5185. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5186. * @param right defines the second operand
  5187. * @returns a new Color4 object
  5188. */
  5189. add(right: DeepImmutable<Color4>): Color4;
  5190. /**
  5191. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5192. * @param right defines the second operand
  5193. * @returns a new Color4 object
  5194. */
  5195. subtract(right: DeepImmutable<Color4>): Color4;
  5196. /**
  5197. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5198. * @param right defines the second operand
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current Color4 object
  5201. */
  5202. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5203. /**
  5204. * Creates a new Color4 with the current Color4 values multiplied by scale
  5205. * @param scale defines the scaling factor to apply
  5206. * @returns a new Color4 object
  5207. */
  5208. scale(scale: number): Color4;
  5209. /**
  5210. * Multiplies the current Color4 values by scale and stores the result in "result"
  5211. * @param scale defines the scaling factor to apply
  5212. * @param result defines the Color4 object where to store the result
  5213. * @returns the current unmodified Color4
  5214. */
  5215. scaleToRef(scale: number, result: Color4): Color4;
  5216. /**
  5217. * Scale the current Color4 values by a factor and add the result to a given Color4
  5218. * @param scale defines the scale factor
  5219. * @param result defines the Color4 object where to store the result
  5220. * @returns the unmodified current Color4
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into.
  5228. * @returns the cuurent Color4
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5231. /**
  5232. * Multipy an Color4 value by another and return a new Color4 object
  5233. * @param color defines the Color4 value to multiply by
  5234. * @returns a new Color4 object
  5235. */
  5236. multiply(color: Color4): Color4;
  5237. /**
  5238. * Multipy a Color4 value by another and push the result in a reference value
  5239. * @param color defines the Color4 value to multiply by
  5240. * @param result defines the Color4 to fill the result in
  5241. * @returns the result Color4
  5242. */
  5243. multiplyToRef(color: Color4, result: Color4): Color4;
  5244. /**
  5245. * Creates a string with the Color4 current values
  5246. * @returns the string representation of the Color4 object
  5247. */
  5248. toString(): string;
  5249. /**
  5250. * Returns the string "Color4"
  5251. * @returns "Color4"
  5252. */
  5253. getClassName(): string;
  5254. /**
  5255. * Compute the Color4 hash code
  5256. * @returns an unique number that can be used to hash Color4 objects
  5257. */
  5258. getHashCode(): number;
  5259. /**
  5260. * Creates a new Color4 copied from the current one
  5261. * @returns a new Color4 object
  5262. */
  5263. clone(): Color4;
  5264. /**
  5265. * Copies the given Color4 values into the current one
  5266. * @param source defines the source Color4 object
  5267. * @returns the current updated Color4 object
  5268. */
  5269. copyFrom(source: Color4): Color4;
  5270. /**
  5271. * Copies the given float values into the current one
  5272. * @param r defines the red component to read from
  5273. * @param g defines the green component to read from
  5274. * @param b defines the blue component to read from
  5275. * @param a defines the alpha component to read from
  5276. * @returns the current updated Color4 object
  5277. */
  5278. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5279. /**
  5280. * Copies the given float values into the current one
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @param a defines the alpha component to read from
  5285. * @returns the current updated Color4 object
  5286. */
  5287. set(r: number, g: number, b: number, a: number): Color4;
  5288. /**
  5289. * Compute the Color4 hexadecimal code as a string
  5290. * @returns a string containing the hexadecimal representation of the Color4 object
  5291. */
  5292. toHexString(): string;
  5293. /**
  5294. * Computes a new Color4 converted from the current one to linear space
  5295. * @returns a new Color4 object
  5296. */
  5297. toLinearSpace(): Color4;
  5298. /**
  5299. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5300. * @param convertedColor defines the Color4 object where to store the linear space version
  5301. * @returns the unmodified Color4
  5302. */
  5303. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5304. /**
  5305. * Computes a new Color4 converted from the current one to gamma space
  5306. * @returns a new Color4 object
  5307. */
  5308. toGammaSpace(): Color4;
  5309. /**
  5310. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5311. * @param convertedColor defines the Color4 object where to store the gamma space version
  5312. * @returns the unmodified Color4
  5313. */
  5314. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5315. /**
  5316. * Creates a new Color4 from the string containing valid hexadecimal values
  5317. * @param hex defines a string containing valid hexadecimal values
  5318. * @returns a new Color4 object
  5319. */
  5320. static FromHexString(hex: string): Color4;
  5321. /**
  5322. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5323. * @param left defines the start value
  5324. * @param right defines the end value
  5325. * @param amount defines the gradient factor
  5326. * @returns a new Color4 object
  5327. */
  5328. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5329. /**
  5330. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5331. * @param left defines the start value
  5332. * @param right defines the end value
  5333. * @param amount defines the gradient factor
  5334. * @param result defines the Color4 object where to store data
  5335. */
  5336. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5337. /**
  5338. * Creates a new Color4 from a Color3 and an alpha value
  5339. * @param color3 defines the source Color3 to read from
  5340. * @param alpha defines the alpha component (1.0 by default)
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5344. /**
  5345. * Creates a new Color4 from the starting index element of the given array
  5346. * @param array defines the source array to read from
  5347. * @param offset defines the offset in the source array
  5348. * @returns a new Color4 object
  5349. */
  5350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5351. /**
  5352. * Creates a new Color3 from integer values (< 256)
  5353. * @param r defines the red component to read from (value between 0 and 255)
  5354. * @param g defines the green component to read from (value between 0 and 255)
  5355. * @param b defines the blue component to read from (value between 0 and 255)
  5356. * @param a defines the alpha component to read from (value between 0 and 255)
  5357. * @returns a new Color3 object
  5358. */
  5359. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5360. /**
  5361. * Check the content of a given array and convert it to an array containing RGBA data
  5362. * If the original array was already containing count * 4 values then it is returned directly
  5363. * @param colors defines the array to check
  5364. * @param count defines the number of RGBA data to expect
  5365. * @returns an array containing count * 4 values (RGBA)
  5366. */
  5367. static CheckColors4(colors: number[], count: number): number[];
  5368. }
  5369. /**
  5370. * @hidden
  5371. */
  5372. export class TmpColors {
  5373. static Color3: Color3[];
  5374. static Color4: Color4[];
  5375. }
  5376. }
  5377. declare module BABYLON {
  5378. /**
  5379. * Class representing spherical harmonics coefficients to the 3rd degree
  5380. */
  5381. export class SphericalHarmonics {
  5382. /**
  5383. * Defines whether or not the harmonics have been prescaled for rendering.
  5384. */
  5385. preScaled: boolean;
  5386. /**
  5387. * The l0,0 coefficients of the spherical harmonics
  5388. */
  5389. l00: Vector3;
  5390. /**
  5391. * The l1,-1 coefficients of the spherical harmonics
  5392. */
  5393. l1_1: Vector3;
  5394. /**
  5395. * The l1,0 coefficients of the spherical harmonics
  5396. */
  5397. l10: Vector3;
  5398. /**
  5399. * The l1,1 coefficients of the spherical harmonics
  5400. */
  5401. l11: Vector3;
  5402. /**
  5403. * The l2,-2 coefficients of the spherical harmonics
  5404. */
  5405. l2_2: Vector3;
  5406. /**
  5407. * The l2,-1 coefficients of the spherical harmonics
  5408. */
  5409. l2_1: Vector3;
  5410. /**
  5411. * The l2,0 coefficients of the spherical harmonics
  5412. */
  5413. l20: Vector3;
  5414. /**
  5415. * The l2,1 coefficients of the spherical harmonics
  5416. */
  5417. l21: Vector3;
  5418. /**
  5419. * The l2,2 coefficients of the spherical harmonics
  5420. */
  5421. l22: Vector3;
  5422. /**
  5423. * Adds a light to the spherical harmonics
  5424. * @param direction the direction of the light
  5425. * @param color the color of the light
  5426. * @param deltaSolidAngle the delta solid angle of the light
  5427. */
  5428. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5429. /**
  5430. * Scales the spherical harmonics by the given amount
  5431. * @param scale the amount to scale
  5432. */
  5433. scaleInPlace(scale: number): void;
  5434. /**
  5435. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5436. *
  5437. * ```
  5438. * E_lm = A_l * L_lm
  5439. * ```
  5440. *
  5441. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5442. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5443. * the scaling factors are given in equation 9.
  5444. */
  5445. convertIncidentRadianceToIrradiance(): void;
  5446. /**
  5447. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5448. *
  5449. * ```
  5450. * L = (1/pi) * E * rho
  5451. * ```
  5452. *
  5453. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5454. */
  5455. convertIrradianceToLambertianRadiance(): void;
  5456. /**
  5457. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5458. * required operations at run time.
  5459. *
  5460. * This is simply done by scaling back the SH with Ylm constants parameter.
  5461. * The trigonometric part being applied by the shader at run time.
  5462. */
  5463. preScaleForRendering(): void;
  5464. /**
  5465. * Constructs a spherical harmonics from an array.
  5466. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5467. * @returns the spherical harmonics
  5468. */
  5469. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5470. /**
  5471. * Gets the spherical harmonics from polynomial
  5472. * @param polynomial the spherical polynomial
  5473. * @returns the spherical harmonics
  5474. */
  5475. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5476. }
  5477. /**
  5478. * Class representing spherical polynomial coefficients to the 3rd degree
  5479. */
  5480. export class SphericalPolynomial {
  5481. private _harmonics;
  5482. /**
  5483. * The spherical harmonics used to create the polynomials.
  5484. */
  5485. readonly preScaledHarmonics: SphericalHarmonics;
  5486. /**
  5487. * The x coefficients of the spherical polynomial
  5488. */
  5489. x: Vector3;
  5490. /**
  5491. * The y coefficients of the spherical polynomial
  5492. */
  5493. y: Vector3;
  5494. /**
  5495. * The z coefficients of the spherical polynomial
  5496. */
  5497. z: Vector3;
  5498. /**
  5499. * The xx coefficients of the spherical polynomial
  5500. */
  5501. xx: Vector3;
  5502. /**
  5503. * The yy coefficients of the spherical polynomial
  5504. */
  5505. yy: Vector3;
  5506. /**
  5507. * The zz coefficients of the spherical polynomial
  5508. */
  5509. zz: Vector3;
  5510. /**
  5511. * The xy coefficients of the spherical polynomial
  5512. */
  5513. xy: Vector3;
  5514. /**
  5515. * The yz coefficients of the spherical polynomial
  5516. */
  5517. yz: Vector3;
  5518. /**
  5519. * The zx coefficients of the spherical polynomial
  5520. */
  5521. zx: Vector3;
  5522. /**
  5523. * Adds an ambient color to the spherical polynomial
  5524. * @param color the color to add
  5525. */
  5526. addAmbient(color: Color3): void;
  5527. /**
  5528. * Scales the spherical polynomial by the given amount
  5529. * @param scale the amount to scale
  5530. */
  5531. scaleInPlace(scale: number): void;
  5532. /**
  5533. * Gets the spherical polynomial from harmonics
  5534. * @param harmonics the spherical harmonics
  5535. * @returns the spherical polynomial
  5536. */
  5537. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5538. /**
  5539. * Constructs a spherical polynomial from an array.
  5540. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5541. * @returns the spherical polynomial
  5542. */
  5543. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5544. }
  5545. }
  5546. declare module BABYLON {
  5547. /**
  5548. * Define options used to create a render target texture
  5549. */
  5550. export class RenderTargetCreationOptions {
  5551. /**
  5552. * Specifies is mipmaps must be generated
  5553. */
  5554. generateMipMaps?: boolean;
  5555. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5556. generateDepthBuffer?: boolean;
  5557. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5558. generateStencilBuffer?: boolean;
  5559. /** Defines texture type (int by default) */
  5560. type?: number;
  5561. /** Defines sampling mode (trilinear by default) */
  5562. samplingMode?: number;
  5563. /** Defines format (RGBA by default) */
  5564. format?: number;
  5565. }
  5566. }
  5567. declare module BABYLON {
  5568. /**
  5569. * @hidden
  5570. **/
  5571. export class _AlphaState {
  5572. private _isAlphaBlendDirty;
  5573. private _isBlendFunctionParametersDirty;
  5574. private _isBlendEquationParametersDirty;
  5575. private _isBlendConstantsDirty;
  5576. private _alphaBlend;
  5577. private _blendFunctionParameters;
  5578. private _blendEquationParameters;
  5579. private _blendConstants;
  5580. /**
  5581. * Initializes the state.
  5582. */
  5583. constructor();
  5584. readonly isDirty: boolean;
  5585. alphaBlend: boolean;
  5586. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5587. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5588. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5589. reset(): void;
  5590. apply(gl: WebGLRenderingContext): void;
  5591. }
  5592. }
  5593. declare module BABYLON {
  5594. /**
  5595. * @hidden
  5596. **/
  5597. export class _DepthCullingState {
  5598. private _isDepthTestDirty;
  5599. private _isDepthMaskDirty;
  5600. private _isDepthFuncDirty;
  5601. private _isCullFaceDirty;
  5602. private _isCullDirty;
  5603. private _isZOffsetDirty;
  5604. private _isFrontFaceDirty;
  5605. private _depthTest;
  5606. private _depthMask;
  5607. private _depthFunc;
  5608. private _cull;
  5609. private _cullFace;
  5610. private _zOffset;
  5611. private _frontFace;
  5612. /**
  5613. * Initializes the state.
  5614. */
  5615. constructor();
  5616. readonly isDirty: boolean;
  5617. zOffset: number;
  5618. cullFace: Nullable<number>;
  5619. cull: Nullable<boolean>;
  5620. depthFunc: Nullable<number>;
  5621. depthMask: boolean;
  5622. depthTest: boolean;
  5623. frontFace: Nullable<number>;
  5624. reset(): void;
  5625. apply(gl: WebGLRenderingContext): void;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * @hidden
  5631. **/
  5632. export class _StencilState {
  5633. /** 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 */
  5634. static readonly ALWAYS: number;
  5635. /** Passed to stencilOperation to specify that stencil value must be kept */
  5636. static readonly KEEP: number;
  5637. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5638. static readonly REPLACE: number;
  5639. private _isStencilTestDirty;
  5640. private _isStencilMaskDirty;
  5641. private _isStencilFuncDirty;
  5642. private _isStencilOpDirty;
  5643. private _stencilTest;
  5644. private _stencilMask;
  5645. private _stencilFunc;
  5646. private _stencilFuncRef;
  5647. private _stencilFuncMask;
  5648. private _stencilOpStencilFail;
  5649. private _stencilOpDepthFail;
  5650. private _stencilOpStencilDepthPass;
  5651. readonly isDirty: boolean;
  5652. stencilFunc: number;
  5653. stencilFuncRef: number;
  5654. stencilFuncMask: number;
  5655. stencilOpStencilFail: number;
  5656. stencilOpDepthFail: number;
  5657. stencilOpStencilDepthPass: number;
  5658. stencilMask: number;
  5659. stencilTest: boolean;
  5660. constructor();
  5661. reset(): void;
  5662. apply(gl: WebGLRenderingContext): void;
  5663. }
  5664. }
  5665. declare module BABYLON {
  5666. /**
  5667. * @hidden
  5668. **/
  5669. export class _TimeToken {
  5670. _startTimeQuery: Nullable<WebGLQuery>;
  5671. _endTimeQuery: Nullable<WebGLQuery>;
  5672. _timeElapsedQuery: Nullable<WebGLQuery>;
  5673. _timeElapsedQueryEnded: boolean;
  5674. }
  5675. }
  5676. declare module BABYLON {
  5677. /**
  5678. * Class used to evalaute queries containing `and` and `or` operators
  5679. */
  5680. export class AndOrNotEvaluator {
  5681. /**
  5682. * Evaluate a query
  5683. * @param query defines the query to evaluate
  5684. * @param evaluateCallback defines the callback used to filter result
  5685. * @returns true if the query matches
  5686. */
  5687. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5688. private static _HandleParenthesisContent;
  5689. private static _SimplifyNegation;
  5690. }
  5691. }
  5692. declare module BABYLON {
  5693. /**
  5694. * Class used to store custom tags
  5695. */
  5696. export class Tags {
  5697. /**
  5698. * Adds support for tags on the given object
  5699. * @param obj defines the object to use
  5700. */
  5701. static EnableFor(obj: any): void;
  5702. /**
  5703. * Removes tags support
  5704. * @param obj defines the object to use
  5705. */
  5706. static DisableFor(obj: any): void;
  5707. /**
  5708. * Gets a boolean indicating if the given object has tags
  5709. * @param obj defines the object to use
  5710. * @returns a boolean
  5711. */
  5712. static HasTags(obj: any): boolean;
  5713. /**
  5714. * Gets the tags available on a given object
  5715. * @param obj defines the object to use
  5716. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5717. * @returns the tags
  5718. */
  5719. static GetTags(obj: any, asString?: boolean): any;
  5720. /**
  5721. * Adds tags to an object
  5722. * @param obj defines the object to use
  5723. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5724. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5725. */
  5726. static AddTagsTo(obj: any, tagsString: string): void;
  5727. /**
  5728. * @hidden
  5729. */
  5730. static _AddTagTo(obj: any, tag: string): void;
  5731. /**
  5732. * Removes specific tags from a specific object
  5733. * @param obj defines the object to use
  5734. * @param tagsString defines the tags to remove
  5735. */
  5736. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5737. /**
  5738. * @hidden
  5739. */
  5740. static _RemoveTagFrom(obj: any, tag: string): void;
  5741. /**
  5742. * Defines if tags hosted on an object match a given query
  5743. * @param obj defines the object to use
  5744. * @param tagsQuery defines the tag query
  5745. * @returns a boolean
  5746. */
  5747. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5748. }
  5749. }
  5750. declare module BABYLON {
  5751. /**
  5752. * Defines potential orientation for back face culling
  5753. */
  5754. export enum Orientation {
  5755. /**
  5756. * Clockwise
  5757. */
  5758. CW = 0,
  5759. /** Counter clockwise */
  5760. CCW = 1
  5761. }
  5762. /** Class used to represent a Bezier curve */
  5763. export class BezierCurve {
  5764. /**
  5765. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5766. * @param t defines the time
  5767. * @param x1 defines the left coordinate on X axis
  5768. * @param y1 defines the left coordinate on Y axis
  5769. * @param x2 defines the right coordinate on X axis
  5770. * @param y2 defines the right coordinate on Y axis
  5771. * @returns the interpolated value
  5772. */
  5773. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5774. }
  5775. /**
  5776. * Defines angle representation
  5777. */
  5778. export class Angle {
  5779. private _radians;
  5780. /**
  5781. * Creates an Angle object of "radians" radians (float).
  5782. * @param radians the angle in radians
  5783. */
  5784. constructor(radians: number);
  5785. /**
  5786. * Get value in degrees
  5787. * @returns the Angle value in degrees (float)
  5788. */
  5789. degrees(): number;
  5790. /**
  5791. * Get value in radians
  5792. * @returns the Angle value in radians (float)
  5793. */
  5794. radians(): number;
  5795. /**
  5796. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5797. * @param a defines first vector
  5798. * @param b defines second vector
  5799. * @returns a new Angle
  5800. */
  5801. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5802. /**
  5803. * Gets a new Angle object from the given float in radians
  5804. * @param radians defines the angle value in radians
  5805. * @returns a new Angle
  5806. */
  5807. static FromRadians(radians: number): Angle;
  5808. /**
  5809. * Gets a new Angle object from the given float in degrees
  5810. * @param degrees defines the angle value in degrees
  5811. * @returns a new Angle
  5812. */
  5813. static FromDegrees(degrees: number): Angle;
  5814. }
  5815. /**
  5816. * This represents an arc in a 2d space.
  5817. */
  5818. export class Arc2 {
  5819. /** Defines the start point of the arc */
  5820. startPoint: Vector2;
  5821. /** Defines the mid point of the arc */
  5822. midPoint: Vector2;
  5823. /** Defines the end point of the arc */
  5824. endPoint: Vector2;
  5825. /**
  5826. * Defines the center point of the arc.
  5827. */
  5828. centerPoint: Vector2;
  5829. /**
  5830. * Defines the radius of the arc.
  5831. */
  5832. radius: number;
  5833. /**
  5834. * Defines the angle of the arc (from mid point to end point).
  5835. */
  5836. angle: Angle;
  5837. /**
  5838. * Defines the start angle of the arc (from start point to middle point).
  5839. */
  5840. startAngle: Angle;
  5841. /**
  5842. * Defines the orientation of the arc (clock wise/counter clock wise).
  5843. */
  5844. orientation: Orientation;
  5845. /**
  5846. * Creates an Arc object from the three given points : start, middle and end.
  5847. * @param startPoint Defines the start point of the arc
  5848. * @param midPoint Defines the midlle point of the arc
  5849. * @param endPoint Defines the end point of the arc
  5850. */
  5851. constructor(
  5852. /** Defines the start point of the arc */
  5853. startPoint: Vector2,
  5854. /** Defines the mid point of the arc */
  5855. midPoint: Vector2,
  5856. /** Defines the end point of the arc */
  5857. endPoint: Vector2);
  5858. }
  5859. /**
  5860. * Represents a 2D path made up of multiple 2D points
  5861. */
  5862. export class Path2 {
  5863. private _points;
  5864. private _length;
  5865. /**
  5866. * If the path start and end point are the same
  5867. */
  5868. closed: boolean;
  5869. /**
  5870. * Creates a Path2 object from the starting 2D coordinates x and y.
  5871. * @param x the starting points x value
  5872. * @param y the starting points y value
  5873. */
  5874. constructor(x: number, y: number);
  5875. /**
  5876. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5877. * @param x the added points x value
  5878. * @param y the added points y value
  5879. * @returns the updated Path2.
  5880. */
  5881. addLineTo(x: number, y: number): Path2;
  5882. /**
  5883. * 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.
  5884. * @param midX middle point x value
  5885. * @param midY middle point y value
  5886. * @param endX end point x value
  5887. * @param endY end point y value
  5888. * @param numberOfSegments (default: 36)
  5889. * @returns the updated Path2.
  5890. */
  5891. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5892. /**
  5893. * Closes the Path2.
  5894. * @returns the Path2.
  5895. */
  5896. close(): Path2;
  5897. /**
  5898. * Gets the sum of the distance between each sequential point in the path
  5899. * @returns the Path2 total length (float).
  5900. */
  5901. length(): number;
  5902. /**
  5903. * Gets the points which construct the path
  5904. * @returns the Path2 internal array of points.
  5905. */
  5906. getPoints(): Vector2[];
  5907. /**
  5908. * Retreives the point at the distance aways from the starting point
  5909. * @param normalizedLengthPosition the length along the path to retreive the point from
  5910. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5911. */
  5912. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5913. /**
  5914. * Creates a new path starting from an x and y position
  5915. * @param x starting x value
  5916. * @param y starting y value
  5917. * @returns a new Path2 starting at the coordinates (x, y).
  5918. */
  5919. static StartingAt(x: number, y: number): Path2;
  5920. }
  5921. /**
  5922. * Represents a 3D path made up of multiple 3D points
  5923. */
  5924. export class Path3D {
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[];
  5929. private _curve;
  5930. private _distances;
  5931. private _tangents;
  5932. private _normals;
  5933. private _binormals;
  5934. private _raw;
  5935. /**
  5936. * new Path3D(path, normal, raw)
  5937. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5938. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5939. * @param path an array of Vector3, the curve axis of the Path3D
  5940. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5941. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5942. */
  5943. constructor(
  5944. /**
  5945. * an array of Vector3, the curve axis of the Path3D
  5946. */
  5947. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5948. /**
  5949. * Returns the Path3D array of successive Vector3 designing its curve.
  5950. * @returns the Path3D array of successive Vector3 designing its curve.
  5951. */
  5952. getCurve(): Vector3[];
  5953. /**
  5954. * Returns an array populated with tangent vectors on each Path3D curve point.
  5955. * @returns an array populated with tangent vectors on each Path3D curve point.
  5956. */
  5957. getTangents(): Vector3[];
  5958. /**
  5959. * Returns an array populated with normal vectors on each Path3D curve point.
  5960. * @returns an array populated with normal vectors on each Path3D curve point.
  5961. */
  5962. getNormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with binormal vectors on each Path3D curve point.
  5965. * @returns an array populated with binormal vectors on each Path3D curve point.
  5966. */
  5967. getBinormals(): Vector3[];
  5968. /**
  5969. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5970. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5971. */
  5972. getDistances(): number[];
  5973. /**
  5974. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5975. * @param path path which all values are copied into the curves points
  5976. * @param firstNormal which should be projected onto the curve
  5977. * @returns the same object updated.
  5978. */
  5979. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5980. private _compute;
  5981. private _getFirstNonNullVector;
  5982. private _getLastNonNullVector;
  5983. private _normalVector;
  5984. }
  5985. /**
  5986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5987. * A Curve3 is designed from a series of successive Vector3.
  5988. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5989. */
  5990. export class Curve3 {
  5991. private _points;
  5992. private _length;
  5993. /**
  5994. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5995. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5996. * @param v1 (Vector3) the control point
  5997. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5998. * @param nbPoints (integer) the wanted number of points in the curve
  5999. * @returns the created Curve3
  6000. */
  6001. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6002. /**
  6003. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6004. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6005. * @param v1 (Vector3) the first control point
  6006. * @param v2 (Vector3) the second control point
  6007. * @param v3 (Vector3) the end point of the Cubic Bezier
  6008. * @param nbPoints (integer) the wanted number of points in the curve
  6009. * @returns the created Curve3
  6010. */
  6011. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6012. /**
  6013. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6014. * @param p1 (Vector3) the origin point of the Hermite Spline
  6015. * @param t1 (Vector3) the tangent vector at the origin point
  6016. * @param p2 (Vector3) the end point of the Hermite Spline
  6017. * @param t2 (Vector3) the tangent vector at the end point
  6018. * @param nbPoints (integer) the wanted number of points in the curve
  6019. * @returns the created Curve3
  6020. */
  6021. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6022. /**
  6023. * Returns a Curve3 object along a CatmullRom Spline curve :
  6024. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6025. * @param nbPoints (integer) the wanted number of points between each curve control points
  6026. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6027. * @returns the created Curve3
  6028. */
  6029. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6030. /**
  6031. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6032. * A Curve3 is designed from a series of successive Vector3.
  6033. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6034. * @param points points which make up the curve
  6035. */
  6036. constructor(points: Vector3[]);
  6037. /**
  6038. * @returns the Curve3 stored array of successive Vector3
  6039. */
  6040. getPoints(): Vector3[];
  6041. /**
  6042. * @returns the computed length (float) of the curve.
  6043. */
  6044. length(): number;
  6045. /**
  6046. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6047. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6048. * curveA and curveB keep unchanged.
  6049. * @param curve the curve to continue from this curve
  6050. * @returns the newly constructed curve
  6051. */
  6052. continue(curve: DeepImmutable<Curve3>): Curve3;
  6053. private _computeLength;
  6054. }
  6055. }
  6056. declare module BABYLON {
  6057. /**
  6058. * This represents the main contract an easing function should follow.
  6059. * Easing functions are used throughout the animation system.
  6060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6061. */
  6062. export interface IEasingFunction {
  6063. /**
  6064. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6065. * of the easing function.
  6066. * The link below provides some of the most common examples of easing functions.
  6067. * @see https://easings.net/
  6068. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6069. * @returns the corresponding value on the curve defined by the easing function
  6070. */
  6071. ease(gradient: number): number;
  6072. }
  6073. /**
  6074. * Base class used for every default easing function.
  6075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6076. */
  6077. export class EasingFunction implements IEasingFunction {
  6078. /**
  6079. * Interpolation follows the mathematical formula associated with the easing function.
  6080. */
  6081. static readonly EASINGMODE_EASEIN: number;
  6082. /**
  6083. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6084. */
  6085. static readonly EASINGMODE_EASEOUT: number;
  6086. /**
  6087. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6088. */
  6089. static readonly EASINGMODE_EASEINOUT: number;
  6090. private _easingMode;
  6091. /**
  6092. * Sets the easing mode of the current function.
  6093. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6094. */
  6095. setEasingMode(easingMode: number): void;
  6096. /**
  6097. * Gets the current easing mode.
  6098. * @returns the easing mode
  6099. */
  6100. getEasingMode(): number;
  6101. /**
  6102. * @hidden
  6103. */
  6104. easeInCore(gradient: number): number;
  6105. /**
  6106. * Given an input gradient between 0 and 1, this returns the corresponding value
  6107. * of the easing function.
  6108. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6109. * @returns the corresponding value on the curve defined by the easing function
  6110. */
  6111. ease(gradient: number): number;
  6112. }
  6113. /**
  6114. * Easing function with a circle shape (see link below).
  6115. * @see https://easings.net/#easeInCirc
  6116. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6117. */
  6118. export class CircleEase extends EasingFunction implements IEasingFunction {
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a ease back shape (see link below).
  6124. * @see https://easings.net/#easeInBack
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BackEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the amplitude of the function */
  6129. amplitude: number;
  6130. /**
  6131. * Instantiates a back ease easing
  6132. * @see https://easings.net/#easeInBack
  6133. * @param amplitude Defines the amplitude of the function
  6134. */
  6135. constructor(
  6136. /** Defines the amplitude of the function */
  6137. amplitude?: number);
  6138. /** @hidden */
  6139. easeInCore(gradient: number): number;
  6140. }
  6141. /**
  6142. * Easing function with a bouncing shape (see link below).
  6143. * @see https://easings.net/#easeInBounce
  6144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6145. */
  6146. export class BounceEase extends EasingFunction implements IEasingFunction {
  6147. /** Defines the number of bounces */
  6148. bounces: number;
  6149. /** Defines the amplitude of the bounce */
  6150. bounciness: number;
  6151. /**
  6152. * Instantiates a bounce easing
  6153. * @see https://easings.net/#easeInBounce
  6154. * @param bounces Defines the number of bounces
  6155. * @param bounciness Defines the amplitude of the bounce
  6156. */
  6157. constructor(
  6158. /** Defines the number of bounces */
  6159. bounces?: number,
  6160. /** Defines the amplitude of the bounce */
  6161. bounciness?: number);
  6162. /** @hidden */
  6163. easeInCore(gradient: number): number;
  6164. }
  6165. /**
  6166. * Easing function with a power of 3 shape (see link below).
  6167. * @see https://easings.net/#easeInCubic
  6168. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6169. */
  6170. export class CubicEase extends EasingFunction implements IEasingFunction {
  6171. /** @hidden */
  6172. easeInCore(gradient: number): number;
  6173. }
  6174. /**
  6175. * Easing function with an elastic shape (see link below).
  6176. * @see https://easings.net/#easeInElastic
  6177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6178. */
  6179. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6180. /** Defines the number of oscillations*/
  6181. oscillations: number;
  6182. /** Defines the amplitude of the oscillations*/
  6183. springiness: number;
  6184. /**
  6185. * Instantiates an elastic easing function
  6186. * @see https://easings.net/#easeInElastic
  6187. * @param oscillations Defines the number of oscillations
  6188. * @param springiness Defines the amplitude of the oscillations
  6189. */
  6190. constructor(
  6191. /** Defines the number of oscillations*/
  6192. oscillations?: number,
  6193. /** Defines the amplitude of the oscillations*/
  6194. springiness?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with an exponential shape (see link below).
  6200. * @see https://easings.net/#easeInExpo
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the exponent of the function */
  6205. exponent: number;
  6206. /**
  6207. * Instantiates an exponential easing function
  6208. * @see https://easings.net/#easeInExpo
  6209. * @param exponent Defines the exponent of the function
  6210. */
  6211. constructor(
  6212. /** Defines the exponent of the function */
  6213. exponent?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class PowerEase extends EasingFunction implements IEasingFunction {
  6223. /** Defines the power of the function */
  6224. power: number;
  6225. /**
  6226. * Instantiates an power base easing function
  6227. * @see https://easings.net/#easeInQuad
  6228. * @param power Defines the power of the function
  6229. */
  6230. constructor(
  6231. /** Defines the power of the function */
  6232. power?: number);
  6233. /** @hidden */
  6234. easeInCore(gradient: number): number;
  6235. }
  6236. /**
  6237. * Easing function with a power of 2 shape (see link below).
  6238. * @see https://easings.net/#easeInQuad
  6239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6240. */
  6241. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6242. /** @hidden */
  6243. easeInCore(gradient: number): number;
  6244. }
  6245. /**
  6246. * Easing function with a power of 4 shape (see link below).
  6247. * @see https://easings.net/#easeInQuart
  6248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6249. */
  6250. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6251. /** @hidden */
  6252. easeInCore(gradient: number): number;
  6253. }
  6254. /**
  6255. * Easing function with a power of 5 shape (see link below).
  6256. * @see https://easings.net/#easeInQuint
  6257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6258. */
  6259. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a sin shape (see link below).
  6265. * @see https://easings.net/#easeInSine
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class SineEase extends EasingFunction implements IEasingFunction {
  6269. /** @hidden */
  6270. easeInCore(gradient: number): number;
  6271. }
  6272. /**
  6273. * Easing function with a bezier shape (see link below).
  6274. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6276. */
  6277. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6278. /** Defines the x component of the start tangent in the bezier curve */
  6279. x1: number;
  6280. /** Defines the y component of the start tangent in the bezier curve */
  6281. y1: number;
  6282. /** Defines the x component of the end tangent in the bezier curve */
  6283. x2: number;
  6284. /** Defines the y component of the end tangent in the bezier curve */
  6285. y2: number;
  6286. /**
  6287. * Instantiates a bezier function
  6288. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6289. * @param x1 Defines the x component of the start tangent in the bezier curve
  6290. * @param y1 Defines the y component of the start tangent in the bezier curve
  6291. * @param x2 Defines the x component of the end tangent in the bezier curve
  6292. * @param y2 Defines the y component of the end tangent in the bezier curve
  6293. */
  6294. constructor(
  6295. /** Defines the x component of the start tangent in the bezier curve */
  6296. x1?: number,
  6297. /** Defines the y component of the start tangent in the bezier curve */
  6298. y1?: number,
  6299. /** Defines the x component of the end tangent in the bezier curve */
  6300. x2?: number,
  6301. /** Defines the y component of the end tangent in the bezier curve */
  6302. y2?: number);
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. }
  6307. declare module BABYLON {
  6308. /**
  6309. * Defines an interface which represents an animation key frame
  6310. */
  6311. export interface IAnimationKey {
  6312. /**
  6313. * Frame of the key frame
  6314. */
  6315. frame: number;
  6316. /**
  6317. * Value at the specifies key frame
  6318. */
  6319. value: any;
  6320. /**
  6321. * The input tangent for the cubic hermite spline
  6322. */
  6323. inTangent?: any;
  6324. /**
  6325. * The output tangent for the cubic hermite spline
  6326. */
  6327. outTangent?: any;
  6328. /**
  6329. * The animation interpolation type
  6330. */
  6331. interpolation?: AnimationKeyInterpolation;
  6332. }
  6333. /**
  6334. * Enum for the animation key frame interpolation type
  6335. */
  6336. export enum AnimationKeyInterpolation {
  6337. /**
  6338. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6339. */
  6340. STEP = 1
  6341. }
  6342. }
  6343. declare module BABYLON {
  6344. /**
  6345. * Represents the range of an animation
  6346. */
  6347. export class AnimationRange {
  6348. /**The name of the animation range**/
  6349. name: string;
  6350. /**The starting frame of the animation */
  6351. from: number;
  6352. /**The ending frame of the animation*/
  6353. to: number;
  6354. /**
  6355. * Initializes the range of an animation
  6356. * @param name The name of the animation range
  6357. * @param from The starting frame of the animation
  6358. * @param to The ending frame of the animation
  6359. */
  6360. constructor(
  6361. /**The name of the animation range**/
  6362. name: string,
  6363. /**The starting frame of the animation */
  6364. from: number,
  6365. /**The ending frame of the animation*/
  6366. to: number);
  6367. /**
  6368. * Makes a copy of the animation range
  6369. * @returns A copy of the animation range
  6370. */
  6371. clone(): AnimationRange;
  6372. }
  6373. }
  6374. declare module BABYLON {
  6375. /**
  6376. * Composed of a frame, and an action function
  6377. */
  6378. export class AnimationEvent {
  6379. /** The frame for which the event is triggered **/
  6380. frame: number;
  6381. /** The event to perform when triggered **/
  6382. action: (currentFrame: number) => void;
  6383. /** Specifies if the event should be triggered only once**/
  6384. onlyOnce?: boolean | undefined;
  6385. /**
  6386. * Specifies if the animation event is done
  6387. */
  6388. isDone: boolean;
  6389. /**
  6390. * Initializes the animation event
  6391. * @param frame The frame for which the event is triggered
  6392. * @param action The event to perform when triggered
  6393. * @param onlyOnce Specifies if the event should be triggered only once
  6394. */
  6395. constructor(
  6396. /** The frame for which the event is triggered **/
  6397. frame: number,
  6398. /** The event to perform when triggered **/
  6399. action: (currentFrame: number) => void,
  6400. /** Specifies if the event should be triggered only once**/
  6401. onlyOnce?: boolean | undefined);
  6402. /** @hidden */
  6403. _clone(): AnimationEvent;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Interface used to define a behavior
  6409. */
  6410. export interface Behavior<T> {
  6411. /** gets or sets behavior's name */
  6412. name: string;
  6413. /**
  6414. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6415. */
  6416. init(): void;
  6417. /**
  6418. * Called when the behavior is attached to a target
  6419. * @param target defines the target where the behavior is attached to
  6420. */
  6421. attach(target: T): void;
  6422. /**
  6423. * Called when the behavior is detached from its target
  6424. */
  6425. detach(): void;
  6426. }
  6427. /**
  6428. * Interface implemented by classes supporting behaviors
  6429. */
  6430. export interface IBehaviorAware<T> {
  6431. /**
  6432. * Attach a behavior
  6433. * @param behavior defines the behavior to attach
  6434. * @returns the current host
  6435. */
  6436. addBehavior(behavior: Behavior<T>): T;
  6437. /**
  6438. * Remove a behavior from the current object
  6439. * @param behavior defines the behavior to detach
  6440. * @returns the current host
  6441. */
  6442. removeBehavior(behavior: Behavior<T>): T;
  6443. /**
  6444. * Gets a behavior using its name to search
  6445. * @param name defines the name to search
  6446. * @returns the behavior or null if not found
  6447. */
  6448. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Defines an array and its length.
  6454. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6455. */
  6456. export interface ISmartArrayLike<T> {
  6457. /**
  6458. * The data of the array.
  6459. */
  6460. data: Array<T>;
  6461. /**
  6462. * The active length of the array.
  6463. */
  6464. length: number;
  6465. }
  6466. /**
  6467. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6468. */
  6469. export class SmartArray<T> implements ISmartArrayLike<T> {
  6470. /**
  6471. * The full set of data from the array.
  6472. */
  6473. data: Array<T>;
  6474. /**
  6475. * The active length of the array.
  6476. */
  6477. length: number;
  6478. protected _id: number;
  6479. /**
  6480. * Instantiates a Smart Array.
  6481. * @param capacity defines the default capacity of the array.
  6482. */
  6483. constructor(capacity: number);
  6484. /**
  6485. * Pushes a value at the end of the active data.
  6486. * @param value defines the object to push in the array.
  6487. */
  6488. push(value: T): void;
  6489. /**
  6490. * Iterates over the active data and apply the lambda to them.
  6491. * @param func defines the action to apply on each value.
  6492. */
  6493. forEach(func: (content: T) => void): void;
  6494. /**
  6495. * Sorts the full sets of data.
  6496. * @param compareFn defines the comparison function to apply.
  6497. */
  6498. sort(compareFn: (a: T, b: T) => number): void;
  6499. /**
  6500. * Resets the active data to an empty array.
  6501. */
  6502. reset(): void;
  6503. /**
  6504. * Releases all the data from the array as well as the array.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Concats the active data with a given array.
  6509. * @param array defines the data to concatenate with.
  6510. */
  6511. concat(array: any): void;
  6512. /**
  6513. * Returns the position of a value in the active data.
  6514. * @param value defines the value to find the index for
  6515. * @returns the index if found in the active data otherwise -1
  6516. */
  6517. indexOf(value: T): number;
  6518. /**
  6519. * Returns whether an element is part of the active data.
  6520. * @param value defines the value to look for
  6521. * @returns true if found in the active data otherwise false
  6522. */
  6523. contains(value: T): boolean;
  6524. private static _GlobalId;
  6525. }
  6526. /**
  6527. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6528. * The data in this array can only be present once
  6529. */
  6530. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6531. private _duplicateId;
  6532. /**
  6533. * Pushes a value at the end of the active data.
  6534. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6535. * @param value defines the object to push in the array.
  6536. */
  6537. push(value: T): void;
  6538. /**
  6539. * Pushes a value at the end of the active data.
  6540. * If the data is already present, it won t be added again
  6541. * @param value defines the object to push in the array.
  6542. * @returns true if added false if it was already present
  6543. */
  6544. pushNoDuplicate(value: T): boolean;
  6545. /**
  6546. * Resets the active data to an empty array.
  6547. */
  6548. reset(): void;
  6549. /**
  6550. * Concats the active data with a given array.
  6551. * This ensures no dupplicate will be present in the result.
  6552. * @param array defines the data to concatenate with.
  6553. */
  6554. concatWithNoDuplicate(array: any): void;
  6555. }
  6556. }
  6557. declare module BABYLON {
  6558. /**
  6559. * @ignore
  6560. * This is a list of all the different input types that are available in the application.
  6561. * Fo instance: ArcRotateCameraGamepadInput...
  6562. */
  6563. export var CameraInputTypes: {};
  6564. /**
  6565. * This is the contract to implement in order to create a new input class.
  6566. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6567. */
  6568. export interface ICameraInput<TCamera extends Camera> {
  6569. /**
  6570. * Defines the camera the input is attached to.
  6571. */
  6572. camera: Nullable<TCamera>;
  6573. /**
  6574. * Gets the class name of the current intput.
  6575. * @returns the class name
  6576. */
  6577. getClassName(): string;
  6578. /**
  6579. * Get the friendly name associated with the input class.
  6580. * @returns the input friendly name
  6581. */
  6582. getSimpleName(): string;
  6583. /**
  6584. * Attach the input controls to a specific dom element to get the input from.
  6585. * @param element Defines the element the controls should be listened from
  6586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6587. */
  6588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6589. /**
  6590. * Detach the current controls from the specified dom element.
  6591. * @param element Defines the element to stop listening the inputs from
  6592. */
  6593. detachControl(element: Nullable<HTMLElement>): void;
  6594. /**
  6595. * Update the current camera state depending on the inputs that have been used this frame.
  6596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6597. */
  6598. checkInputs?: () => void;
  6599. }
  6600. /**
  6601. * Represents a map of input types to input instance or input index to input instance.
  6602. */
  6603. export interface CameraInputsMap<TCamera extends Camera> {
  6604. /**
  6605. * Accessor to the input by input type.
  6606. */
  6607. [name: string]: ICameraInput<TCamera>;
  6608. /**
  6609. * Accessor to the input by input index.
  6610. */
  6611. [idx: number]: ICameraInput<TCamera>;
  6612. }
  6613. /**
  6614. * This represents the input manager used within a camera.
  6615. * It helps dealing with all the different kind of input attached to a camera.
  6616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6617. */
  6618. export class CameraInputsManager<TCamera extends Camera> {
  6619. /**
  6620. * Defines the list of inputs attahed to the camera.
  6621. */
  6622. attached: CameraInputsMap<TCamera>;
  6623. /**
  6624. * Defines the dom element the camera is collecting inputs from.
  6625. * This is null if the controls have not been attached.
  6626. */
  6627. attachedElement: Nullable<HTMLElement>;
  6628. /**
  6629. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6630. */
  6631. noPreventDefault: boolean;
  6632. /**
  6633. * Defined the camera the input manager belongs to.
  6634. */
  6635. camera: TCamera;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs: () => void;
  6641. /**
  6642. * Instantiate a new Camera Input Manager.
  6643. * @param camera Defines the camera the input manager blongs to
  6644. */
  6645. constructor(camera: TCamera);
  6646. /**
  6647. * Add an input method to a camera
  6648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6649. * @param input camera input method
  6650. */
  6651. add(input: ICameraInput<TCamera>): void;
  6652. /**
  6653. * Remove a specific input method from a camera
  6654. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6655. * @param inputToRemove camera input method
  6656. */
  6657. remove(inputToRemove: ICameraInput<TCamera>): void;
  6658. /**
  6659. * Remove a specific input type from a camera
  6660. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6661. * @param inputType the type of the input to remove
  6662. */
  6663. removeByType(inputType: string): void;
  6664. private _addCheckInputs;
  6665. /**
  6666. * Attach the input controls to the currently attached dom element to listen the events from.
  6667. * @param input Defines the input to attach
  6668. */
  6669. attachInput(input: ICameraInput<TCamera>): void;
  6670. /**
  6671. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6672. * @param element Defines the dom element to collect the events from
  6673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6674. */
  6675. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6676. /**
  6677. * Detach the current manager inputs controls from a specific dom element.
  6678. * @param element Defines the dom element to collect the events from
  6679. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6680. */
  6681. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6682. /**
  6683. * Rebuild the dynamic inputCheck function from the current list of
  6684. * defined inputs in the manager.
  6685. */
  6686. rebuildInputCheck(): void;
  6687. /**
  6688. * Remove all attached input methods from a camera
  6689. */
  6690. clear(): void;
  6691. /**
  6692. * Serialize the current input manager attached to a camera.
  6693. * This ensures than once parsed,
  6694. * the input associated to the camera will be identical to the current ones
  6695. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6696. */
  6697. serialize(serializedCamera: any): void;
  6698. /**
  6699. * Parses an input manager serialized JSON to restore the previous list of inputs
  6700. * and states associated to a camera.
  6701. * @param parsedCamera Defines the JSON to parse
  6702. */
  6703. parse(parsedCamera: any): void;
  6704. }
  6705. }
  6706. declare module BABYLON {
  6707. /**
  6708. * @hidden
  6709. */
  6710. export class IntersectionInfo {
  6711. bu: Nullable<number>;
  6712. bv: Nullable<number>;
  6713. distance: number;
  6714. faceId: number;
  6715. subMeshId: number;
  6716. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6717. }
  6718. }
  6719. declare module BABYLON {
  6720. /**
  6721. * Represens a plane by the equation ax + by + cz + d = 0
  6722. */
  6723. export class Plane {
  6724. private static _TmpMatrix;
  6725. /**
  6726. * Normal of the plane (a,b,c)
  6727. */
  6728. normal: Vector3;
  6729. /**
  6730. * d component of the plane
  6731. */
  6732. d: number;
  6733. /**
  6734. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6735. * @param a a component of the plane
  6736. * @param b b component of the plane
  6737. * @param c c component of the plane
  6738. * @param d d component of the plane
  6739. */
  6740. constructor(a: number, b: number, c: number, d: number);
  6741. /**
  6742. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6743. */
  6744. asArray(): number[];
  6745. /**
  6746. * @returns a new plane copied from the current Plane.
  6747. */
  6748. clone(): Plane;
  6749. /**
  6750. * @returns the string "Plane".
  6751. */
  6752. getClassName(): string;
  6753. /**
  6754. * @returns the Plane hash code.
  6755. */
  6756. getHashCode(): number;
  6757. /**
  6758. * Normalize the current Plane in place.
  6759. * @returns the updated Plane.
  6760. */
  6761. normalize(): Plane;
  6762. /**
  6763. * Applies a transformation the plane and returns the result
  6764. * @param transformation the transformation matrix to be applied to the plane
  6765. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6766. */
  6767. transform(transformation: DeepImmutable<Matrix>): Plane;
  6768. /**
  6769. * Calcualtte the dot product between the point and the plane normal
  6770. * @param point point to calculate the dot product with
  6771. * @returns the dot product (float) of the point coordinates and the plane normal.
  6772. */
  6773. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6774. /**
  6775. * Updates the current Plane from the plane defined by the three given points.
  6776. * @param point1 one of the points used to contruct the plane
  6777. * @param point2 one of the points used to contruct the plane
  6778. * @param point3 one of the points used to contruct the plane
  6779. * @returns the updated Plane.
  6780. */
  6781. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6782. /**
  6783. * Checks if the plane is facing a given direction
  6784. * @param direction the direction to check if the plane is facing
  6785. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6786. * @returns True is the vector "direction" is the same side than the plane normal.
  6787. */
  6788. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6789. /**
  6790. * Calculates the distance to a point
  6791. * @param point point to calculate distance to
  6792. * @returns the signed distance (float) from the given point to the Plane.
  6793. */
  6794. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6795. /**
  6796. * Creates a plane from an array
  6797. * @param array the array to create a plane from
  6798. * @returns a new Plane from the given array.
  6799. */
  6800. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6801. /**
  6802. * Creates a plane from three points
  6803. * @param point1 point used to create the plane
  6804. * @param point2 point used to create the plane
  6805. * @param point3 point used to create the plane
  6806. * @returns a new Plane defined by the three given points.
  6807. */
  6808. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6809. /**
  6810. * Creates a plane from an origin point and a normal
  6811. * @param origin origin of the plane to be constructed
  6812. * @param normal normal of the plane to be constructed
  6813. * @returns a new Plane the normal vector to this plane at the given origin point.
  6814. * Note : the vector "normal" is updated because normalized.
  6815. */
  6816. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6817. /**
  6818. * Calculates the distance from a plane and a point
  6819. * @param origin origin of the plane to be constructed
  6820. * @param normal normal of the plane to be constructed
  6821. * @param point point to calculate distance to
  6822. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6823. */
  6824. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6825. }
  6826. }
  6827. declare module BABYLON {
  6828. /**
  6829. * Class used to store bounding sphere information
  6830. */
  6831. export class BoundingSphere {
  6832. /**
  6833. * Gets the center of the bounding sphere in local space
  6834. */
  6835. readonly center: Vector3;
  6836. /**
  6837. * Radius of the bounding sphere in local space
  6838. */
  6839. radius: number;
  6840. /**
  6841. * Gets the center of the bounding sphere in world space
  6842. */
  6843. readonly centerWorld: Vector3;
  6844. /**
  6845. * Radius of the bounding sphere in world space
  6846. */
  6847. radiusWorld: number;
  6848. /**
  6849. * Gets the minimum vector in local space
  6850. */
  6851. readonly minimum: Vector3;
  6852. /**
  6853. * Gets the maximum vector in local space
  6854. */
  6855. readonly maximum: Vector3;
  6856. private _worldMatrix;
  6857. private static readonly TmpVector3;
  6858. /**
  6859. * Creates a new bounding sphere
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding sphere by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingSphere;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding sphere is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding sphere center is in between the frustum planes.
  6893. * Used for optimistic fast inclusion.
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if the sphere center is in between the frustum planes
  6896. */
  6897. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if a point is inside the bounding sphere
  6900. * @param point defines the point to test
  6901. * @returns true if the point is inside the bounding sphere
  6902. */
  6903. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6904. /**
  6905. * Checks if two sphere intersct
  6906. * @param sphere0 sphere 0
  6907. * @param sphere1 sphere 1
  6908. * @returns true if the speres intersect
  6909. */
  6910. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6911. }
  6912. }
  6913. declare module BABYLON {
  6914. /**
  6915. * Class used to store bounding box information
  6916. */
  6917. export class BoundingBox implements ICullable {
  6918. /**
  6919. * Gets the 8 vectors representing the bounding box in local space
  6920. */
  6921. readonly vectors: Vector3[];
  6922. /**
  6923. * Gets the center of the bounding box in local space
  6924. */
  6925. readonly center: Vector3;
  6926. /**
  6927. * Gets the center of the bounding box in world space
  6928. */
  6929. readonly centerWorld: Vector3;
  6930. /**
  6931. * Gets the extend size in local space
  6932. */
  6933. readonly extendSize: Vector3;
  6934. /**
  6935. * Gets the extend size in world space
  6936. */
  6937. readonly extendSizeWorld: Vector3;
  6938. /**
  6939. * Gets the OBB (object bounding box) directions
  6940. */
  6941. readonly directions: Vector3[];
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in world space
  6944. */
  6945. readonly vectorsWorld: Vector3[];
  6946. /**
  6947. * Gets the minimum vector in world space
  6948. */
  6949. readonly minimumWorld: Vector3;
  6950. /**
  6951. * Gets the maximum vector in world space
  6952. */
  6953. readonly maximumWorld: Vector3;
  6954. /**
  6955. * Gets the minimum vector in local space
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * Gets the maximum vector in local space
  6960. */
  6961. readonly maximum: Vector3;
  6962. private _worldMatrix;
  6963. private static readonly TmpVector3;
  6964. /**
  6965. * @hidden
  6966. */
  6967. _tag: number;
  6968. /**
  6969. * Creates a new bounding box
  6970. * @param min defines the minimum vector (in local space)
  6971. * @param max defines the maximum vector (in local space)
  6972. * @param worldMatrix defines the new world matrix
  6973. */
  6974. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6975. /**
  6976. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6977. * @param min defines the new minimum vector (in local space)
  6978. * @param max defines the new maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Scale the current bounding box by applying a scale factor
  6984. * @param factor defines the scale factor to apply
  6985. * @returns the current bounding box
  6986. */
  6987. scale(factor: number): BoundingBox;
  6988. /**
  6989. * Gets the world matrix of the bounding box
  6990. * @returns a matrix
  6991. */
  6992. getWorldMatrix(): DeepImmutable<Matrix>;
  6993. /** @hidden */
  6994. _update(world: DeepImmutable<Matrix>): void;
  6995. /**
  6996. * Tests if the bounding box is intersecting the frustum planes
  6997. * @param frustumPlanes defines the frustum planes to test
  6998. * @returns true if there is an intersection
  6999. */
  7000. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7001. /**
  7002. * Tests if the bounding box is entirely inside the frustum planes
  7003. * @param frustumPlanes defines the frustum planes to test
  7004. * @returns true if there is an inclusion
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7007. /**
  7008. * Tests if a point is inside the bounding box
  7009. * @param point defines the point to test
  7010. * @returns true if the point is inside the bounding box
  7011. */
  7012. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if the bounding box intersects with a bounding sphere
  7015. * @param sphere defines the sphere to test
  7016. * @returns true if there is an intersection
  7017. */
  7018. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7019. /**
  7020. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7021. * @param min defines the min vector to use
  7022. * @param max defines the max vector to use
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7026. /**
  7027. * Tests if two bounding boxes are intersections
  7028. * @param box0 defines the first box to test
  7029. * @param box1 defines the second box to test
  7030. * @returns true if there is an intersection
  7031. */
  7032. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7033. /**
  7034. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7035. * @param minPoint defines the minimum vector of the bounding box
  7036. * @param maxPoint defines the maximum vector of the bounding box
  7037. * @param sphereCenter defines the sphere center
  7038. * @param sphereRadius defines the sphere radius
  7039. * @returns true if there is an intersection
  7040. */
  7041. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7042. /**
  7043. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7044. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @return true if there is an inclusion
  7047. */
  7048. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an intersection
  7054. */
  7055. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. }
  7057. }
  7058. declare module BABYLON {
  7059. /** @hidden */
  7060. export class Collider {
  7061. /** Define if a collision was found */
  7062. collisionFound: boolean;
  7063. /**
  7064. * Define last intersection point in local space
  7065. */
  7066. intersectionPoint: Vector3;
  7067. /**
  7068. * Define last collided mesh
  7069. */
  7070. collidedMesh: Nullable<AbstractMesh>;
  7071. private _collisionPoint;
  7072. private _planeIntersectionPoint;
  7073. private _tempVector;
  7074. private _tempVector2;
  7075. private _tempVector3;
  7076. private _tempVector4;
  7077. private _edge;
  7078. private _baseToVertex;
  7079. private _destinationPoint;
  7080. private _slidePlaneNormal;
  7081. private _displacementVector;
  7082. /** @hidden */
  7083. _radius: Vector3;
  7084. /** @hidden */
  7085. _retry: number;
  7086. private _velocity;
  7087. private _basePoint;
  7088. private _epsilon;
  7089. /** @hidden */
  7090. _velocityWorldLength: number;
  7091. /** @hidden */
  7092. _basePointWorld: Vector3;
  7093. private _velocityWorld;
  7094. private _normalizedVelocity;
  7095. /** @hidden */
  7096. _initialVelocity: Vector3;
  7097. /** @hidden */
  7098. _initialPosition: Vector3;
  7099. private _nearestDistance;
  7100. private _collisionMask;
  7101. collisionMask: number;
  7102. /**
  7103. * Gets the plane normal used to compute the sliding response (in local space)
  7104. */
  7105. readonly slidePlaneNormal: Vector3;
  7106. /** @hidden */
  7107. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7108. /** @hidden */
  7109. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7110. /** @hidden */
  7111. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7112. /** @hidden */
  7113. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7114. /** @hidden */
  7115. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7116. /** @hidden */
  7117. _getResponse(pos: Vector3, vel: Vector3): void;
  7118. }
  7119. }
  7120. declare module BABYLON {
  7121. /**
  7122. * Interface for cullable objects
  7123. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7124. */
  7125. export interface ICullable {
  7126. /**
  7127. * Checks if the object or part of the object is in the frustum
  7128. * @param frustumPlanes Camera near/planes
  7129. * @returns true if the object is in frustum otherwise false
  7130. */
  7131. isInFrustum(frustumPlanes: Plane[]): boolean;
  7132. /**
  7133. * Checks if a cullable object (mesh...) is in the camera frustum
  7134. * Unlike isInFrustum this cheks the full bounding box
  7135. * @param frustumPlanes Camera near/planes
  7136. * @returns true if the object is in frustum otherwise false
  7137. */
  7138. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7139. }
  7140. /**
  7141. * Info for a bounding data of a mesh
  7142. */
  7143. export class BoundingInfo implements ICullable {
  7144. /**
  7145. * Bounding box for the mesh
  7146. */
  7147. readonly boundingBox: BoundingBox;
  7148. /**
  7149. * Bounding sphere for the mesh
  7150. */
  7151. readonly boundingSphere: BoundingSphere;
  7152. private _isLocked;
  7153. private static readonly TmpVector3;
  7154. /**
  7155. * Constructs bounding info
  7156. * @param minimum min vector of the bounding box/sphere
  7157. * @param maximum max vector of the bounding box/sphere
  7158. * @param worldMatrix defines the new world matrix
  7159. */
  7160. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7161. /**
  7162. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7163. * @param min defines the new minimum vector (in local space)
  7164. * @param max defines the new maximum vector (in local space)
  7165. * @param worldMatrix defines the new world matrix
  7166. */
  7167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7168. /**
  7169. * min vector of the bounding box/sphere
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * max vector of the bounding box/sphere
  7174. */
  7175. readonly maximum: Vector3;
  7176. /**
  7177. * If the info is locked and won't be updated to avoid perf overhead
  7178. */
  7179. isLocked: boolean;
  7180. /**
  7181. * Updates the bounding sphere and box
  7182. * @param world world matrix to be used to update
  7183. */
  7184. update(world: DeepImmutable<Matrix>): void;
  7185. /**
  7186. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7187. * @param center New center of the bounding info
  7188. * @param extend New extend of the bounding info
  7189. * @returns the current bounding info
  7190. */
  7191. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7192. /**
  7193. * Scale the current bounding info by applying a scale factor
  7194. * @param factor defines the scale factor to apply
  7195. * @returns the current bounding info
  7196. */
  7197. scale(factor: number): BoundingInfo;
  7198. /**
  7199. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7200. * @param frustumPlanes defines the frustum to test
  7201. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7202. * @returns true if the bounding info is in the frustum planes
  7203. */
  7204. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7205. /**
  7206. * Gets the world distance between the min and max points of the bounding box
  7207. */
  7208. readonly diagonalLength: number;
  7209. /**
  7210. * Checks if a cullable object (mesh...) is in the camera frustum
  7211. * Unlike isInFrustum this cheks the full bounding box
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7216. /** @hidden */
  7217. _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Extracts minimum and maximum values from a list of indexed positions
  7238. * @param positions defines the positions to use
  7239. * @param indices defines the indices to the positions
  7240. * @param indexStart defines the start index
  7241. * @param indexCount defines the end index
  7242. * @param bias defines bias value to add to the result
  7243. * @return minimum and maximum values
  7244. */
  7245. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7246. minimum: Vector3;
  7247. maximum: Vector3;
  7248. };
  7249. /**
  7250. * Extracts minimum and maximum values from a list of positions
  7251. * @param positions defines the positions to use
  7252. * @param start defines the start index in the positions array
  7253. * @param count defines the number of positions to handle
  7254. * @param bias defines bias value to add to the result
  7255. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7256. * @return minimum and maximum values
  7257. */
  7258. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7259. minimum: Vector3;
  7260. maximum: Vector3;
  7261. };
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * Enum that determines the text-wrapping mode to use.
  7266. */
  7267. export enum InspectableType {
  7268. /**
  7269. * Checkbox for booleans
  7270. */
  7271. Checkbox = 0,
  7272. /**
  7273. * Sliders for numbers
  7274. */
  7275. Slider = 1,
  7276. /**
  7277. * Vector3
  7278. */
  7279. Vector3 = 2,
  7280. /**
  7281. * Quaternions
  7282. */
  7283. Quaternion = 3,
  7284. /**
  7285. * Color3
  7286. */
  7287. Color3 = 4,
  7288. /**
  7289. * String
  7290. */
  7291. String = 5
  7292. }
  7293. /**
  7294. * Interface used to define custom inspectable properties.
  7295. * This interface is used by the inspector to display custom property grids
  7296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7297. */
  7298. export interface IInspectable {
  7299. /**
  7300. * Gets the label to display
  7301. */
  7302. label: string;
  7303. /**
  7304. * Gets the name of the property to edit
  7305. */
  7306. propertyName: string;
  7307. /**
  7308. * Gets the type of the editor to use
  7309. */
  7310. type: InspectableType;
  7311. /**
  7312. * Gets the minimum value of the property when using in "slider" mode
  7313. */
  7314. min?: number;
  7315. /**
  7316. * Gets the maximum value of the property when using in "slider" mode
  7317. */
  7318. max?: number;
  7319. /**
  7320. * Gets the setp to use when using in "slider" mode
  7321. */
  7322. step?: number;
  7323. }
  7324. }
  7325. declare module BABYLON {
  7326. /**
  7327. * Class used to provide helper for timing
  7328. */
  7329. export class TimingTools {
  7330. /**
  7331. * Polyfill for setImmediate
  7332. * @param action defines the action to execute after the current execution block
  7333. */
  7334. static SetImmediate(action: () => void): void;
  7335. }
  7336. }
  7337. declare module BABYLON {
  7338. /**
  7339. * Class used to enable instatition of objects by class name
  7340. */
  7341. export class InstantiationTools {
  7342. /**
  7343. * Use this object to register external classes like custom textures or material
  7344. * to allow the laoders to instantiate them
  7345. */
  7346. static RegisteredExternalClasses: {
  7347. [key: string]: Object;
  7348. };
  7349. /**
  7350. * Tries to instantiate a new object from a given class name
  7351. * @param className defines the class name to instantiate
  7352. * @returns the new object or null if the system was not able to do the instantiation
  7353. */
  7354. static Instantiate(className: string): any;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * This represents the required contract to create a new type of texture loader.
  7360. */
  7361. export interface IInternalTextureLoader {
  7362. /**
  7363. * Defines wether the loader supports cascade loading the different faces.
  7364. */
  7365. supportCascades: boolean;
  7366. /**
  7367. * This returns if the loader support the current file information.
  7368. * @param extension defines the file extension of the file being loaded
  7369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7370. * @param fallback defines the fallback internal texture if any
  7371. * @param isBase64 defines whether the texture is encoded as a base64
  7372. * @param isBuffer defines whether the texture data are stored as a buffer
  7373. * @returns true if the loader can load the specified file
  7374. */
  7375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7376. /**
  7377. * Transform the url before loading if required.
  7378. * @param rootUrl the url of the texture
  7379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7380. * @returns the transformed texture
  7381. */
  7382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7383. /**
  7384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7385. * @param rootUrl the url of the texture
  7386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7387. * @returns the fallback texture
  7388. */
  7389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7390. /**
  7391. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7392. * @param data contains the texture data
  7393. * @param texture defines the BabylonJS internal texture
  7394. * @param createPolynomials will be true if polynomials have been requested
  7395. * @param onLoad defines the callback to trigger once the texture is ready
  7396. * @param onError defines the callback to trigger in case of error
  7397. */
  7398. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7399. /**
  7400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7401. * @param data contains the texture data
  7402. * @param texture defines the BabylonJS internal texture
  7403. * @param callback defines the method to call once ready to upload
  7404. */
  7405. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7406. }
  7407. }
  7408. declare module BABYLON {
  7409. interface Engine {
  7410. /**
  7411. * Creates a depth stencil cube texture.
  7412. * This is only available in WebGL 2.
  7413. * @param size The size of face edge in the cube texture.
  7414. * @param options The options defining the cube texture.
  7415. * @returns The cube texture
  7416. */
  7417. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7418. /**
  7419. * Creates a cube texture
  7420. * @param rootUrl defines the url where the files to load is located
  7421. * @param scene defines the current scene
  7422. * @param files defines the list of files to load (1 per face)
  7423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7424. * @param onLoad defines an optional callback raised when the texture is loaded
  7425. * @param onError defines an optional callback raised if there is an issue to load the texture
  7426. * @param format defines the format of the data
  7427. * @param forcedExtension defines the extension to use to pick the right loader
  7428. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7431. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7432. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7433. * @returns the cube texture as an InternalTexture
  7434. */
  7435. 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;
  7436. /**
  7437. * Creates a cube texture
  7438. * @param rootUrl defines the url where the files to load is located
  7439. * @param scene defines the current scene
  7440. * @param files defines the list of files to load (1 per face)
  7441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7442. * @param onLoad defines an optional callback raised when the texture is loaded
  7443. * @param onError defines an optional callback raised if there is an issue to load the texture
  7444. * @param format defines the format of the data
  7445. * @param forcedExtension defines the extension to use to pick the right loader
  7446. * @returns the cube texture as an InternalTexture
  7447. */
  7448. 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;
  7449. /**
  7450. * Creates a cube texture
  7451. * @param rootUrl defines the url where the files to load is located
  7452. * @param scene defines the current scene
  7453. * @param files defines the list of files to load (1 per face)
  7454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7455. * @param onLoad defines an optional callback raised when the texture is loaded
  7456. * @param onError defines an optional callback raised if there is an issue to load the texture
  7457. * @param format defines the format of the data
  7458. * @param forcedExtension defines the extension to use to pick the right loader
  7459. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7462. * @returns the cube texture as an InternalTexture
  7463. */
  7464. 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;
  7465. /** @hidden */
  7466. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7467. /** @hidden */
  7468. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7469. /** @hidden */
  7470. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7471. /** @hidden */
  7472. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class for creating a cube texture
  7478. */
  7479. export class CubeTexture extends BaseTexture {
  7480. private _delayedOnLoad;
  7481. /**
  7482. * The url of the texture
  7483. */
  7484. url: string;
  7485. /**
  7486. * Gets or sets the center of the bounding box associated with the cube texture.
  7487. * It must define where the camera used to render the texture was set
  7488. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7489. */
  7490. boundingBoxPosition: Vector3;
  7491. private _boundingBoxSize;
  7492. /**
  7493. * Gets or sets the size of the bounding box associated with the cube texture
  7494. * When defined, the cubemap will switch to local mode
  7495. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7496. * @example https://www.babylonjs-playground.com/#RNASML
  7497. */
  7498. /**
  7499. * Returns the bounding box size
  7500. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7501. */
  7502. boundingBoxSize: Vector3;
  7503. protected _rotationY: number;
  7504. /**
  7505. * Sets texture matrix rotation angle around Y axis in radians.
  7506. */
  7507. /**
  7508. * Gets texture matrix rotation angle around Y axis radians.
  7509. */
  7510. rotationY: number;
  7511. /**
  7512. * Are mip maps generated for this texture or not.
  7513. */
  7514. readonly noMipmap: boolean;
  7515. private _noMipmap;
  7516. private _files;
  7517. private _extensions;
  7518. private _textureMatrix;
  7519. private _format;
  7520. private _createPolynomials;
  7521. /** @hidden */
  7522. _prefiltered: boolean;
  7523. /**
  7524. * Creates a cube texture from an array of image urls
  7525. * @param files defines an array of image urls
  7526. * @param scene defines the hosting scene
  7527. * @param noMipmap specifies if mip maps are not used
  7528. * @returns a cube texture
  7529. */
  7530. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7531. /**
  7532. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7533. * @param url defines the url of the prefiltered texture
  7534. * @param scene defines the scene the texture is attached to
  7535. * @param forcedExtension defines the extension of the file if different from the url
  7536. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7537. * @return the prefiltered texture
  7538. */
  7539. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7540. /**
  7541. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7542. * as prefiltered data.
  7543. * @param rootUrl defines the url of the texture or the root name of the six images
  7544. * @param scene defines the scene the texture is attached to
  7545. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7546. * @param noMipmap defines if mipmaps should be created or not
  7547. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7548. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7549. * @param onError defines a callback triggered in case of error during load
  7550. * @param format defines the internal format to use for the texture once loaded
  7551. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7552. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7553. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7556. * @return the cube texture
  7557. */
  7558. 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);
  7559. /**
  7560. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7561. */
  7562. readonly isPrefiltered: boolean;
  7563. /**
  7564. * Get the current class name of the texture useful for serialization or dynamic coding.
  7565. * @returns "CubeTexture"
  7566. */
  7567. getClassName(): string;
  7568. /**
  7569. * Update the url (and optional buffer) of this texture if url was null during construction.
  7570. * @param url the url of the texture
  7571. * @param forcedExtension defines the extension to use
  7572. * @param onLoad callback called when the texture is loaded (defaults to null)
  7573. */
  7574. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7575. /**
  7576. * Delays loading of the cube texture
  7577. * @param forcedExtension defines the extension to use
  7578. */
  7579. delayLoad(forcedExtension?: string): void;
  7580. /**
  7581. * Returns the reflection texture matrix
  7582. * @returns the reflection texture matrix
  7583. */
  7584. getReflectionTextureMatrix(): Matrix;
  7585. /**
  7586. * Sets the reflection texture matrix
  7587. * @param value Reflection texture matrix
  7588. */
  7589. setReflectionTextureMatrix(value: Matrix): void;
  7590. /**
  7591. * Parses text to create a cube texture
  7592. * @param parsedTexture define the serialized text to read from
  7593. * @param scene defines the hosting scene
  7594. * @param rootUrl defines the root url of the cube texture
  7595. * @returns a cube texture
  7596. */
  7597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7598. /**
  7599. * Makes a clone, or deep copy, of the cube texture
  7600. * @returns a new cube texture
  7601. */
  7602. clone(): CubeTexture;
  7603. }
  7604. }
  7605. declare module BABYLON {
  7606. /**
  7607. * Manages the defines for the Material
  7608. */
  7609. export class MaterialDefines {
  7610. /** @hidden */
  7611. protected _keys: string[];
  7612. private _isDirty;
  7613. /** @hidden */
  7614. _renderId: number;
  7615. /** @hidden */
  7616. _areLightsDirty: boolean;
  7617. /** @hidden */
  7618. _areLightsDisposed: boolean;
  7619. /** @hidden */
  7620. _areAttributesDirty: boolean;
  7621. /** @hidden */
  7622. _areTexturesDirty: boolean;
  7623. /** @hidden */
  7624. _areFresnelDirty: boolean;
  7625. /** @hidden */
  7626. _areMiscDirty: boolean;
  7627. /** @hidden */
  7628. _areImageProcessingDirty: boolean;
  7629. /** @hidden */
  7630. _normals: boolean;
  7631. /** @hidden */
  7632. _uvs: boolean;
  7633. /** @hidden */
  7634. _needNormals: boolean;
  7635. /** @hidden */
  7636. _needUVs: boolean;
  7637. [id: string]: any;
  7638. /**
  7639. * Specifies if the material needs to be re-calculated
  7640. */
  7641. readonly isDirty: boolean;
  7642. /**
  7643. * Marks the material to indicate that it has been re-calculated
  7644. */
  7645. markAsProcessed(): void;
  7646. /**
  7647. * Marks the material to indicate that it needs to be re-calculated
  7648. */
  7649. markAsUnprocessed(): void;
  7650. /**
  7651. * Marks the material to indicate all of its defines need to be re-calculated
  7652. */
  7653. markAllAsDirty(): void;
  7654. /**
  7655. * Marks the material to indicate that image processing needs to be re-calculated
  7656. */
  7657. markAsImageProcessingDirty(): void;
  7658. /**
  7659. * Marks the material to indicate the lights need to be re-calculated
  7660. * @param disposed Defines whether the light is dirty due to dispose or not
  7661. */
  7662. markAsLightDirty(disposed?: boolean): void;
  7663. /**
  7664. * Marks the attribute state as changed
  7665. */
  7666. markAsAttributesDirty(): void;
  7667. /**
  7668. * Marks the texture state as changed
  7669. */
  7670. markAsTexturesDirty(): void;
  7671. /**
  7672. * Marks the fresnel state as changed
  7673. */
  7674. markAsFresnelDirty(): void;
  7675. /**
  7676. * Marks the misc state as changed
  7677. */
  7678. markAsMiscDirty(): void;
  7679. /**
  7680. * Rebuilds the material defines
  7681. */
  7682. rebuild(): void;
  7683. /**
  7684. * Specifies if two material defines are equal
  7685. * @param other - A material define instance to compare to
  7686. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7687. */
  7688. isEqual(other: MaterialDefines): boolean;
  7689. /**
  7690. * Clones this instance's defines to another instance
  7691. * @param other - material defines to clone values to
  7692. */
  7693. cloneTo(other: MaterialDefines): void;
  7694. /**
  7695. * Resets the material define values
  7696. */
  7697. reset(): void;
  7698. /**
  7699. * Converts the material define values to a string
  7700. * @returns - String of material define information
  7701. */
  7702. toString(): string;
  7703. }
  7704. }
  7705. declare module BABYLON {
  7706. /**
  7707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7709. * 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;
  7710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7711. */
  7712. export class ColorCurves {
  7713. private _dirty;
  7714. private _tempColor;
  7715. private _globalCurve;
  7716. private _highlightsCurve;
  7717. private _midtonesCurve;
  7718. private _shadowsCurve;
  7719. private _positiveCurve;
  7720. private _negativeCurve;
  7721. private _globalHue;
  7722. private _globalDensity;
  7723. private _globalSaturation;
  7724. private _globalExposure;
  7725. /**
  7726. * Gets the global Hue value.
  7727. * 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).
  7728. */
  7729. /**
  7730. * Sets the global Hue value.
  7731. * 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).
  7732. */
  7733. globalHue: number;
  7734. /**
  7735. * Gets the global Density value.
  7736. * 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.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. /**
  7740. * Sets the global Density value.
  7741. * 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.
  7742. * Values less than zero provide a filter of opposite hue.
  7743. */
  7744. globalDensity: number;
  7745. /**
  7746. * Gets the global Saturation value.
  7747. * 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.
  7748. */
  7749. /**
  7750. * Sets the global Saturation value.
  7751. * 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.
  7752. */
  7753. globalSaturation: number;
  7754. /**
  7755. * Gets the global Exposure value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets the global Exposure value.
  7760. * 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.
  7761. */
  7762. globalExposure: number;
  7763. private _highlightsHue;
  7764. private _highlightsDensity;
  7765. private _highlightsSaturation;
  7766. private _highlightsExposure;
  7767. /**
  7768. * Gets the highlights Hue value.
  7769. * 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).
  7770. */
  7771. /**
  7772. * Sets the highlights Hue value.
  7773. * 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).
  7774. */
  7775. highlightsHue: number;
  7776. /**
  7777. * Gets the highlights Density value.
  7778. * 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.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. /**
  7782. * Sets the highlights Density value.
  7783. * 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.
  7784. * Values less than zero provide a filter of opposite hue.
  7785. */
  7786. highlightsDensity: number;
  7787. /**
  7788. * Gets the highlights Saturation value.
  7789. * 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.
  7790. */
  7791. /**
  7792. * Sets the highlights Saturation value.
  7793. * 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.
  7794. */
  7795. highlightsSaturation: number;
  7796. /**
  7797. * Gets the highlights Exposure value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets the highlights Exposure value.
  7802. * 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.
  7803. */
  7804. highlightsExposure: number;
  7805. private _midtonesHue;
  7806. private _midtonesDensity;
  7807. private _midtonesSaturation;
  7808. private _midtonesExposure;
  7809. /**
  7810. * Gets the midtones Hue value.
  7811. * 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).
  7812. */
  7813. /**
  7814. * Sets the midtones Hue value.
  7815. * 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).
  7816. */
  7817. midtonesHue: number;
  7818. /**
  7819. * Gets the midtones Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. /**
  7824. * Sets the midtones Density value.
  7825. * 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.
  7826. * Values less than zero provide a filter of opposite hue.
  7827. */
  7828. midtonesDensity: number;
  7829. /**
  7830. * Gets the midtones Saturation value.
  7831. * 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.
  7832. */
  7833. /**
  7834. * Sets the midtones Saturation value.
  7835. * 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.
  7836. */
  7837. midtonesSaturation: number;
  7838. /**
  7839. * Gets the midtones Exposure value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets the midtones Exposure value.
  7844. * 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.
  7845. */
  7846. midtonesExposure: number;
  7847. private _shadowsHue;
  7848. private _shadowsDensity;
  7849. private _shadowsSaturation;
  7850. private _shadowsExposure;
  7851. /**
  7852. * Gets the shadows Hue value.
  7853. * 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).
  7854. */
  7855. /**
  7856. * Sets the shadows Hue value.
  7857. * 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).
  7858. */
  7859. shadowsHue: number;
  7860. /**
  7861. * Gets the shadows Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. /**
  7866. * Sets the shadows Density value.
  7867. * 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.
  7868. * Values less than zero provide a filter of opposite hue.
  7869. */
  7870. shadowsDensity: number;
  7871. /**
  7872. * Gets the shadows Saturation value.
  7873. * 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.
  7874. */
  7875. /**
  7876. * Sets the shadows Saturation value.
  7877. * 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.
  7878. */
  7879. shadowsSaturation: number;
  7880. /**
  7881. * Gets the shadows Exposure value.
  7882. * 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.
  7883. */
  7884. /**
  7885. * Sets the shadows Exposure value.
  7886. * 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.
  7887. */
  7888. shadowsExposure: number;
  7889. /**
  7890. * Returns the class name
  7891. * @returns The class name
  7892. */
  7893. getClassName(): string;
  7894. /**
  7895. * Binds the color curves to the shader.
  7896. * @param colorCurves The color curve to bind
  7897. * @param effect The effect to bind to
  7898. * @param positiveUniform The positive uniform shader parameter
  7899. * @param neutralUniform The neutral uniform shader parameter
  7900. * @param negativeUniform The negative uniform shader parameter
  7901. */
  7902. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7903. /**
  7904. * Prepare the list of uniforms associated with the ColorCurves effects.
  7905. * @param uniformsList The list of uniforms used in the effect
  7906. */
  7907. static PrepareUniforms(uniformsList: string[]): void;
  7908. /**
  7909. * Returns color grading data based on a hue, density, saturation and exposure value.
  7910. * @param filterHue The hue of the color filter.
  7911. * @param filterDensity The density of the color filter.
  7912. * @param saturation The saturation.
  7913. * @param exposure The exposure.
  7914. * @param result The result data container.
  7915. */
  7916. private getColorGradingDataToRef;
  7917. /**
  7918. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7919. * @param value The input slider value in range [-100,100].
  7920. * @returns Adjusted value.
  7921. */
  7922. private static applyColorGradingSliderNonlinear;
  7923. /**
  7924. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7925. * @param hue The hue (H) input.
  7926. * @param saturation The saturation (S) input.
  7927. * @param brightness The brightness (B) input.
  7928. * @result An RGBA color represented as Vector4.
  7929. */
  7930. private static fromHSBToRef;
  7931. /**
  7932. * Returns a value clamped between min and max
  7933. * @param value The value to clamp
  7934. * @param min The minimum of value
  7935. * @param max The maximum of value
  7936. * @returns The clamped value.
  7937. */
  7938. private static clamp;
  7939. /**
  7940. * Clones the current color curve instance.
  7941. * @return The cloned curves
  7942. */
  7943. clone(): ColorCurves;
  7944. /**
  7945. * Serializes the current color curve instance to a json representation.
  7946. * @return a JSON representation
  7947. */
  7948. serialize(): any;
  7949. /**
  7950. * Parses the color curve from a json representation.
  7951. * @param source the JSON source to parse
  7952. * @return The parsed curves
  7953. */
  7954. static Parse(source: any): ColorCurves;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Interface to follow in your material defines to integrate easily the
  7960. * Image proccessing functions.
  7961. * @hidden
  7962. */
  7963. export interface IImageProcessingConfigurationDefines {
  7964. IMAGEPROCESSING: boolean;
  7965. VIGNETTE: boolean;
  7966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7967. VIGNETTEBLENDMODEOPAQUE: boolean;
  7968. TONEMAPPING: boolean;
  7969. TONEMAPPING_ACES: boolean;
  7970. CONTRAST: boolean;
  7971. EXPOSURE: boolean;
  7972. COLORCURVES: boolean;
  7973. COLORGRADING: boolean;
  7974. COLORGRADING3D: boolean;
  7975. SAMPLER3DGREENDEPTH: boolean;
  7976. SAMPLER3DBGRMAP: boolean;
  7977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7978. }
  7979. /**
  7980. * @hidden
  7981. */
  7982. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7983. IMAGEPROCESSING: boolean;
  7984. VIGNETTE: boolean;
  7985. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7986. VIGNETTEBLENDMODEOPAQUE: boolean;
  7987. TONEMAPPING: boolean;
  7988. TONEMAPPING_ACES: boolean;
  7989. CONTRAST: boolean;
  7990. COLORCURVES: boolean;
  7991. COLORGRADING: boolean;
  7992. COLORGRADING3D: boolean;
  7993. SAMPLER3DGREENDEPTH: boolean;
  7994. SAMPLER3DBGRMAP: boolean;
  7995. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7996. EXPOSURE: boolean;
  7997. constructor();
  7998. }
  7999. /**
  8000. * This groups together the common properties used for image processing either in direct forward pass
  8001. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8002. * or not.
  8003. */
  8004. export class ImageProcessingConfiguration {
  8005. /**
  8006. * Default tone mapping applied in BabylonJS.
  8007. */
  8008. static readonly TONEMAPPING_STANDARD: number;
  8009. /**
  8010. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8011. * to other engines rendering to increase portability.
  8012. */
  8013. static readonly TONEMAPPING_ACES: number;
  8014. /**
  8015. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8016. */
  8017. colorCurves: Nullable<ColorCurves>;
  8018. private _colorCurvesEnabled;
  8019. /**
  8020. * Gets wether the color curves effect is enabled.
  8021. */
  8022. /**
  8023. * Sets wether the color curves effect is enabled.
  8024. */
  8025. colorCurvesEnabled: boolean;
  8026. private _colorGradingTexture;
  8027. /**
  8028. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8029. */
  8030. /**
  8031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8032. */
  8033. colorGradingTexture: Nullable<BaseTexture>;
  8034. private _colorGradingEnabled;
  8035. /**
  8036. * Gets wether the color grading effect is enabled.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is enabled.
  8040. */
  8041. colorGradingEnabled: boolean;
  8042. private _colorGradingWithGreenDepth;
  8043. /**
  8044. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8045. */
  8046. /**
  8047. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8048. */
  8049. colorGradingWithGreenDepth: boolean;
  8050. private _colorGradingBGR;
  8051. /**
  8052. * Gets wether the color grading texture contains BGR values.
  8053. */
  8054. /**
  8055. * Sets wether the color grading texture contains BGR values.
  8056. */
  8057. colorGradingBGR: boolean;
  8058. /** @hidden */
  8059. _exposure: number;
  8060. /**
  8061. * Gets the Exposure used in the effect.
  8062. */
  8063. /**
  8064. * Sets the Exposure used in the effect.
  8065. */
  8066. exposure: number;
  8067. private _toneMappingEnabled;
  8068. /**
  8069. * Gets wether the tone mapping effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the tone mapping effect is enabled.
  8073. */
  8074. toneMappingEnabled: boolean;
  8075. private _toneMappingType;
  8076. /**
  8077. * Gets the type of tone mapping effect.
  8078. */
  8079. /**
  8080. * Sets the type of tone mapping effect used in BabylonJS.
  8081. */
  8082. toneMappingType: number;
  8083. protected _contrast: number;
  8084. /**
  8085. * Gets the contrast used in the effect.
  8086. */
  8087. /**
  8088. * Sets the contrast used in the effect.
  8089. */
  8090. contrast: number;
  8091. /**
  8092. * Vignette stretch size.
  8093. */
  8094. vignetteStretch: number;
  8095. /**
  8096. * Vignette centre X Offset.
  8097. */
  8098. vignetteCentreX: number;
  8099. /**
  8100. * Vignette centre Y Offset.
  8101. */
  8102. vignetteCentreY: number;
  8103. /**
  8104. * Vignette weight or intensity of the vignette effect.
  8105. */
  8106. vignetteWeight: number;
  8107. /**
  8108. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8109. * if vignetteEnabled is set to true.
  8110. */
  8111. vignetteColor: Color4;
  8112. /**
  8113. * Camera field of view used by the Vignette effect.
  8114. */
  8115. vignetteCameraFov: number;
  8116. private _vignetteBlendMode;
  8117. /**
  8118. * Gets the vignette blend mode allowing different kind of effect.
  8119. */
  8120. /**
  8121. * Sets the vignette blend mode allowing different kind of effect.
  8122. */
  8123. vignetteBlendMode: number;
  8124. private _vignetteEnabled;
  8125. /**
  8126. * Gets wether the vignette effect is enabled.
  8127. */
  8128. /**
  8129. * Sets wether the vignette effect is enabled.
  8130. */
  8131. vignetteEnabled: boolean;
  8132. private _applyByPostProcess;
  8133. /**
  8134. * Gets wether the image processing is applied through a post process or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is applied through a post process or not.
  8138. */
  8139. applyByPostProcess: boolean;
  8140. private _isEnabled;
  8141. /**
  8142. * Gets wether the image processing is enabled or not.
  8143. */
  8144. /**
  8145. * Sets wether the image processing is enabled or not.
  8146. */
  8147. isEnabled: boolean;
  8148. /**
  8149. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8150. */
  8151. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8152. /**
  8153. * Method called each time the image processing information changes requires to recompile the effect.
  8154. */
  8155. protected _updateParameters(): void;
  8156. /**
  8157. * Gets the current class name.
  8158. * @return "ImageProcessingConfiguration"
  8159. */
  8160. getClassName(): string;
  8161. /**
  8162. * Prepare the list of uniforms associated with the Image Processing effects.
  8163. * @param uniforms The list of uniforms used in the effect
  8164. * @param defines the list of defines currently in use
  8165. */
  8166. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8167. /**
  8168. * Prepare the list of samplers associated with the Image Processing effects.
  8169. * @param samplersList The list of uniforms used in the effect
  8170. * @param defines the list of defines currently in use
  8171. */
  8172. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8173. /**
  8174. * Prepare the list of defines associated to the shader.
  8175. * @param defines the list of defines to complete
  8176. * @param forPostProcess Define if we are currently in post process mode or not
  8177. */
  8178. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8179. /**
  8180. * Returns true if all the image processing information are ready.
  8181. * @returns True if ready, otherwise, false
  8182. */
  8183. isReady(): boolean;
  8184. /**
  8185. * Binds the image processing to the shader.
  8186. * @param effect The effect to bind to
  8187. * @param aspectRatio Define the current aspect ratio of the effect
  8188. */
  8189. bind(effect: Effect, aspectRatio?: number): void;
  8190. /**
  8191. * Clones the current image processing instance.
  8192. * @return The cloned image processing
  8193. */
  8194. clone(): ImageProcessingConfiguration;
  8195. /**
  8196. * Serializes the current image processing instance to a json representation.
  8197. * @return a JSON representation
  8198. */
  8199. serialize(): any;
  8200. /**
  8201. * Parses the image processing from a json representation.
  8202. * @param source the JSON source to parse
  8203. * @return The parsed image processing
  8204. */
  8205. static Parse(source: any): ImageProcessingConfiguration;
  8206. private static _VIGNETTEMODE_MULTIPLY;
  8207. private static _VIGNETTEMODE_OPAQUE;
  8208. /**
  8209. * Used to apply the vignette as a mix with the pixel color.
  8210. */
  8211. static readonly VIGNETTEMODE_MULTIPLY: number;
  8212. /**
  8213. * Used to apply the vignette as a replacement of the pixel color.
  8214. */
  8215. static readonly VIGNETTEMODE_OPAQUE: number;
  8216. }
  8217. }
  8218. declare module BABYLON {
  8219. /** @hidden */
  8220. export var postprocessVertexShader: {
  8221. name: string;
  8222. shader: string;
  8223. };
  8224. }
  8225. declare module BABYLON {
  8226. /** Defines supported spaces */
  8227. export enum Space {
  8228. /** Local (object) space */
  8229. LOCAL = 0,
  8230. /** World space */
  8231. WORLD = 1,
  8232. /** Bone space */
  8233. BONE = 2
  8234. }
  8235. /** Defines the 3 main axes */
  8236. export class Axis {
  8237. /** X axis */
  8238. static X: Vector3;
  8239. /** Y axis */
  8240. static Y: Vector3;
  8241. /** Z axis */
  8242. static Z: Vector3;
  8243. }
  8244. }
  8245. declare module BABYLON {
  8246. /**
  8247. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8248. * This is the base of the follow, arc rotate cameras and Free camera
  8249. * @see http://doc.babylonjs.com/features/cameras
  8250. */
  8251. export class TargetCamera extends Camera {
  8252. private static _RigCamTransformMatrix;
  8253. private static _TargetTransformMatrix;
  8254. private static _TargetFocalPoint;
  8255. /**
  8256. * Define the current direction the camera is moving to
  8257. */
  8258. cameraDirection: Vector3;
  8259. /**
  8260. * Define the current rotation the camera is rotating to
  8261. */
  8262. cameraRotation: Vector2;
  8263. /**
  8264. * When set, the up vector of the camera will be updated by the rotation of the camera
  8265. */
  8266. updateUpVectorFromRotation: boolean;
  8267. private _tmpQuaternion;
  8268. /**
  8269. * Define the current rotation of the camera
  8270. */
  8271. rotation: Vector3;
  8272. /**
  8273. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8274. */
  8275. rotationQuaternion: Quaternion;
  8276. /**
  8277. * Define the current speed of the camera
  8278. */
  8279. speed: number;
  8280. /**
  8281. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8282. * around all axis.
  8283. */
  8284. noRotationConstraint: boolean;
  8285. /**
  8286. * Define the current target of the camera as an object or a position.
  8287. */
  8288. lockedTarget: any;
  8289. /** @hidden */
  8290. _currentTarget: Vector3;
  8291. /** @hidden */
  8292. _initialFocalDistance: number;
  8293. /** @hidden */
  8294. _viewMatrix: Matrix;
  8295. /** @hidden */
  8296. _camMatrix: Matrix;
  8297. /** @hidden */
  8298. _cameraTransformMatrix: Matrix;
  8299. /** @hidden */
  8300. _cameraRotationMatrix: Matrix;
  8301. /** @hidden */
  8302. _referencePoint: Vector3;
  8303. /** @hidden */
  8304. _transformedReferencePoint: Vector3;
  8305. protected _globalCurrentTarget: Vector3;
  8306. protected _globalCurrentUpVector: Vector3;
  8307. /** @hidden */
  8308. _reset: () => void;
  8309. private _defaultUp;
  8310. /**
  8311. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8312. * This is the base of the follow, arc rotate cameras and Free camera
  8313. * @see http://doc.babylonjs.com/features/cameras
  8314. * @param name Defines the name of the camera in the scene
  8315. * @param position Defines the start position of the camera in the scene
  8316. * @param scene Defines the scene the camera belongs to
  8317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8318. */
  8319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8320. /**
  8321. * Gets the position in front of the camera at a given distance.
  8322. * @param distance The distance from the camera we want the position to be
  8323. * @returns the position
  8324. */
  8325. getFrontPosition(distance: number): Vector3;
  8326. /** @hidden */
  8327. _getLockedTargetPosition(): Nullable<Vector3>;
  8328. private _storedPosition;
  8329. private _storedRotation;
  8330. private _storedRotationQuaternion;
  8331. /**
  8332. * Store current camera state of the camera (fov, position, rotation, etc..)
  8333. * @returns the camera
  8334. */
  8335. storeState(): Camera;
  8336. /**
  8337. * Restored camera state. You must call storeState() first
  8338. * @returns whether it was successful or not
  8339. * @hidden
  8340. */
  8341. _restoreStateValues(): boolean;
  8342. /** @hidden */
  8343. _initCache(): void;
  8344. /** @hidden */
  8345. _updateCache(ignoreParentClass?: boolean): void;
  8346. /** @hidden */
  8347. _isSynchronizedViewMatrix(): boolean;
  8348. /** @hidden */
  8349. _computeLocalCameraSpeed(): number;
  8350. /**
  8351. * Defines the target the camera should look at.
  8352. * @param target Defines the new target as a Vector or a mesh
  8353. */
  8354. setTarget(target: Vector3): void;
  8355. /**
  8356. * Return the current target position of the camera. This value is expressed in local space.
  8357. * @returns the target position
  8358. */
  8359. getTarget(): Vector3;
  8360. /** @hidden */
  8361. _decideIfNeedsToMove(): boolean;
  8362. /** @hidden */
  8363. _updatePosition(): void;
  8364. /** @hidden */
  8365. _checkInputs(): void;
  8366. protected _updateCameraRotationMatrix(): void;
  8367. /**
  8368. * 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)
  8369. * @returns the current camera
  8370. */
  8371. private _rotateUpVectorWithCameraRotationMatrix;
  8372. private _cachedRotationZ;
  8373. private _cachedQuaternionRotationZ;
  8374. /** @hidden */
  8375. _getViewMatrix(): Matrix;
  8376. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8377. /**
  8378. * @hidden
  8379. */
  8380. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8381. /**
  8382. * @hidden
  8383. */
  8384. _updateRigCameras(): void;
  8385. private _getRigCamPositionAndTarget;
  8386. /**
  8387. * Gets the current object class name.
  8388. * @return the class name
  8389. */
  8390. getClassName(): string;
  8391. }
  8392. }
  8393. declare module BABYLON {
  8394. /**
  8395. * Gather the list of keyboard event types as constants.
  8396. */
  8397. export class KeyboardEventTypes {
  8398. /**
  8399. * The keydown event is fired when a key becomes active (pressed).
  8400. */
  8401. static readonly KEYDOWN: number;
  8402. /**
  8403. * The keyup event is fired when a key has been released.
  8404. */
  8405. static readonly KEYUP: number;
  8406. }
  8407. /**
  8408. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8409. */
  8410. export class KeyboardInfo {
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number;
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent;
  8419. /**
  8420. * Instantiates a new keyboard info.
  8421. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8422. * @param type Defines the type of event (KeyboardEventTypes)
  8423. * @param event Defines the related dom event
  8424. */
  8425. constructor(
  8426. /**
  8427. * Defines the type of event (KeyboardEventTypes)
  8428. */
  8429. type: number,
  8430. /**
  8431. * Defines the related dom event
  8432. */
  8433. event: KeyboardEvent);
  8434. }
  8435. /**
  8436. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8437. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8438. */
  8439. export class KeyboardInfoPre extends KeyboardInfo {
  8440. /**
  8441. * Defines the type of event (KeyboardEventTypes)
  8442. */
  8443. type: number;
  8444. /**
  8445. * Defines the related dom event
  8446. */
  8447. event: KeyboardEvent;
  8448. /**
  8449. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8450. */
  8451. skipOnPointerObservable: boolean;
  8452. /**
  8453. * Instantiates a new keyboard pre info.
  8454. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8455. * @param type Defines the type of event (KeyboardEventTypes)
  8456. * @param event Defines the related dom event
  8457. */
  8458. constructor(
  8459. /**
  8460. * Defines the type of event (KeyboardEventTypes)
  8461. */
  8462. type: number,
  8463. /**
  8464. * Defines the related dom event
  8465. */
  8466. event: KeyboardEvent);
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /**
  8471. * Manage the keyboard inputs to control the movement of a free camera.
  8472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8473. */
  8474. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8475. /**
  8476. * Defines the camera the input is attached to.
  8477. */
  8478. camera: FreeCamera;
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8481. */
  8482. keysUp: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8485. */
  8486. keysDown: number[];
  8487. /**
  8488. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8489. */
  8490. keysLeft: number[];
  8491. /**
  8492. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8493. */
  8494. keysRight: number[];
  8495. private _keys;
  8496. private _onCanvasBlurObserver;
  8497. private _onKeyboardObserver;
  8498. private _engine;
  8499. private _scene;
  8500. /**
  8501. * Attach the input controls to a specific dom element to get the input from.
  8502. * @param element Defines the element the controls should be listened from
  8503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8504. */
  8505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8506. /**
  8507. * Detach the current controls from the specified dom element.
  8508. * @param element Defines the element to stop listening the inputs from
  8509. */
  8510. detachControl(element: Nullable<HTMLElement>): void;
  8511. /**
  8512. * Update the current camera state depending on the inputs that have been used this frame.
  8513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8514. */
  8515. checkInputs(): void;
  8516. /**
  8517. * Gets the class name of the current intput.
  8518. * @returns the class name
  8519. */
  8520. getClassName(): string;
  8521. /** @hidden */
  8522. _onLostFocus(): void;
  8523. /**
  8524. * Get the friendly name associated with the input class.
  8525. * @returns the input friendly name
  8526. */
  8527. getSimpleName(): string;
  8528. }
  8529. }
  8530. declare module BABYLON {
  8531. /**
  8532. * Interface describing all the common properties and methods a shadow light needs to implement.
  8533. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8534. * as well as binding the different shadow properties to the effects.
  8535. */
  8536. export interface IShadowLight extends Light {
  8537. /**
  8538. * The light id in the scene (used in scene.findLighById for instance)
  8539. */
  8540. id: string;
  8541. /**
  8542. * The position the shdow will be casted from.
  8543. */
  8544. position: Vector3;
  8545. /**
  8546. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8547. */
  8548. direction: Vector3;
  8549. /**
  8550. * The transformed position. Position of the light in world space taking parenting in account.
  8551. */
  8552. transformedPosition: Vector3;
  8553. /**
  8554. * The transformed direction. Direction of the light in world space taking parenting in account.
  8555. */
  8556. transformedDirection: Vector3;
  8557. /**
  8558. * The friendly name of the light in the scene.
  8559. */
  8560. name: string;
  8561. /**
  8562. * Defines the shadow projection clipping minimum z value.
  8563. */
  8564. shadowMinZ: number;
  8565. /**
  8566. * Defines the shadow projection clipping maximum z value.
  8567. */
  8568. shadowMaxZ: number;
  8569. /**
  8570. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8571. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8572. */
  8573. computeTransformedInformation(): boolean;
  8574. /**
  8575. * Gets the scene the light belongs to.
  8576. * @returns The scene
  8577. */
  8578. getScene(): Scene;
  8579. /**
  8580. * Callback defining a custom Projection Matrix Builder.
  8581. * This can be used to override the default projection matrix computation.
  8582. */
  8583. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8584. /**
  8585. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8586. * @param matrix The materix to updated with the projection information
  8587. * @param viewMatrix The transform matrix of the light
  8588. * @param renderList The list of mesh to render in the map
  8589. * @returns The current light
  8590. */
  8591. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8592. /**
  8593. * Gets the current depth scale used in ESM.
  8594. * @returns The scale
  8595. */
  8596. getDepthScale(): number;
  8597. /**
  8598. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8599. * @returns true if a cube texture needs to be use
  8600. */
  8601. needCube(): boolean;
  8602. /**
  8603. * Detects if the projection matrix requires to be recomputed this frame.
  8604. * @returns true if it requires to be recomputed otherwise, false.
  8605. */
  8606. needProjectionMatrixCompute(): boolean;
  8607. /**
  8608. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8609. */
  8610. forceProjectionMatrixCompute(): void;
  8611. /**
  8612. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8613. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8614. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8615. */
  8616. getShadowDirection(faceIndex?: number): Vector3;
  8617. /**
  8618. * Gets the minZ used for shadow according to both the scene and the light.
  8619. * @param activeCamera The camera we are returning the min for
  8620. * @returns the depth min z
  8621. */
  8622. getDepthMinZ(activeCamera: Camera): number;
  8623. /**
  8624. * Gets the maxZ used for shadow according to both the scene and the light.
  8625. * @param activeCamera The camera we are returning the max for
  8626. * @returns the depth max z
  8627. */
  8628. getDepthMaxZ(activeCamera: Camera): number;
  8629. }
  8630. /**
  8631. * Base implementation IShadowLight
  8632. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8633. */
  8634. export abstract class ShadowLight extends Light implements IShadowLight {
  8635. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8636. protected _position: Vector3;
  8637. protected _setPosition(value: Vector3): void;
  8638. /**
  8639. * Sets the position the shadow will be casted from. Also use as the light position for both
  8640. * point and spot lights.
  8641. */
  8642. /**
  8643. * Sets the position the shadow will be casted from. Also use as the light position for both
  8644. * point and spot lights.
  8645. */
  8646. position: Vector3;
  8647. protected _direction: Vector3;
  8648. protected _setDirection(value: Vector3): void;
  8649. /**
  8650. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8651. * Also use as the light direction on spot and directional lights.
  8652. */
  8653. /**
  8654. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8655. * Also use as the light direction on spot and directional lights.
  8656. */
  8657. direction: Vector3;
  8658. private _shadowMinZ;
  8659. /**
  8660. * Gets the shadow projection clipping minimum z value.
  8661. */
  8662. /**
  8663. * Sets the shadow projection clipping minimum z value.
  8664. */
  8665. shadowMinZ: number;
  8666. private _shadowMaxZ;
  8667. /**
  8668. * Sets the shadow projection clipping maximum z value.
  8669. */
  8670. /**
  8671. * Gets the shadow projection clipping maximum z value.
  8672. */
  8673. shadowMaxZ: number;
  8674. /**
  8675. * Callback defining a custom Projection Matrix Builder.
  8676. * This can be used to override the default projection matrix computation.
  8677. */
  8678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8679. /**
  8680. * The transformed position. Position of the light in world space taking parenting in account.
  8681. */
  8682. transformedPosition: Vector3;
  8683. /**
  8684. * The transformed direction. Direction of the light in world space taking parenting in account.
  8685. */
  8686. transformedDirection: Vector3;
  8687. private _needProjectionMatrixCompute;
  8688. /**
  8689. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8690. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8691. */
  8692. computeTransformedInformation(): boolean;
  8693. /**
  8694. * Return the depth scale used for the shadow map.
  8695. * @returns the depth scale.
  8696. */
  8697. getDepthScale(): number;
  8698. /**
  8699. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8700. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8701. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8702. */
  8703. getShadowDirection(faceIndex?: number): Vector3;
  8704. /**
  8705. * Returns the ShadowLight absolute position in the World.
  8706. * @returns the position vector in world space
  8707. */
  8708. getAbsolutePosition(): Vector3;
  8709. /**
  8710. * Sets the ShadowLight direction toward the passed target.
  8711. * @param target The point to target in local space
  8712. * @returns the updated ShadowLight direction
  8713. */
  8714. setDirectionToTarget(target: Vector3): Vector3;
  8715. /**
  8716. * Returns the light rotation in euler definition.
  8717. * @returns the x y z rotation in local space.
  8718. */
  8719. getRotation(): Vector3;
  8720. /**
  8721. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8722. * @returns true if a cube texture needs to be use
  8723. */
  8724. needCube(): boolean;
  8725. /**
  8726. * Detects if the projection matrix requires to be recomputed this frame.
  8727. * @returns true if it requires to be recomputed otherwise, false.
  8728. */
  8729. needProjectionMatrixCompute(): boolean;
  8730. /**
  8731. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8732. */
  8733. forceProjectionMatrixCompute(): void;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _isSynchronized(): boolean;
  8738. /**
  8739. * Computes the world matrix of the node
  8740. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8741. * @returns the world matrix
  8742. */
  8743. computeWorldMatrix(force?: boolean): Matrix;
  8744. /**
  8745. * Gets the minZ used for shadow according to both the scene and the light.
  8746. * @param activeCamera The camera we are returning the min for
  8747. * @returns the depth min z
  8748. */
  8749. getDepthMinZ(activeCamera: Camera): number;
  8750. /**
  8751. * Gets the maxZ used for shadow according to both the scene and the light.
  8752. * @param activeCamera The camera we are returning the max for
  8753. * @returns the depth max z
  8754. */
  8755. getDepthMaxZ(activeCamera: Camera): number;
  8756. /**
  8757. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8758. * @param matrix The materix to updated with the projection information
  8759. * @param viewMatrix The transform matrix of the light
  8760. * @param renderList The list of mesh to render in the map
  8761. * @returns The current light
  8762. */
  8763. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8764. }
  8765. }
  8766. declare module BABYLON {
  8767. /**
  8768. * "Static Class" containing the most commonly used helper while dealing with material for
  8769. * rendering purpose.
  8770. *
  8771. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8772. *
  8773. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8774. */
  8775. export class MaterialHelper {
  8776. /**
  8777. * Bind the current view position to an effect.
  8778. * @param effect The effect to be bound
  8779. * @param scene The scene the eyes position is used from
  8780. */
  8781. static BindEyePosition(effect: Effect, scene: Scene): void;
  8782. /**
  8783. * Helps preparing the defines values about the UVs in used in the effect.
  8784. * UVs are shared as much as we can accross channels in the shaders.
  8785. * @param texture The texture we are preparing the UVs for
  8786. * @param defines The defines to update
  8787. * @param key The channel key "diffuse", "specular"... used in the shader
  8788. */
  8789. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8790. /**
  8791. * Binds a texture matrix value to its corrsponding uniform
  8792. * @param texture The texture to bind the matrix for
  8793. * @param uniformBuffer The uniform buffer receivin the data
  8794. * @param key The channel key "diffuse", "specular"... used in the shader
  8795. */
  8796. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8797. /**
  8798. * Gets the current status of the fog (should it be enabled?)
  8799. * @param mesh defines the mesh to evaluate for fog support
  8800. * @param scene defines the hosting scene
  8801. * @returns true if fog must be enabled
  8802. */
  8803. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8804. /**
  8805. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8806. * @param mesh defines the current mesh
  8807. * @param scene defines the current scene
  8808. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8809. * @param pointsCloud defines if point cloud rendering has to be turned on
  8810. * @param fogEnabled defines if fog has to be turned on
  8811. * @param alphaTest defines if alpha testing has to be turned on
  8812. * @param defines defines the current list of defines
  8813. */
  8814. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8815. /**
  8816. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8817. * @param scene defines the current scene
  8818. * @param engine defines the current engine
  8819. * @param defines specifies the list of active defines
  8820. * @param useInstances defines if instances have to be turned on
  8821. * @param useClipPlane defines if clip plane have to be turned on
  8822. */
  8823. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8824. /**
  8825. * Prepares the defines for bones
  8826. * @param mesh The mesh containing the geometry data we will draw
  8827. * @param defines The defines to update
  8828. */
  8829. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8830. /**
  8831. * Prepares the defines for morph targets
  8832. * @param mesh The mesh containing the geometry data we will draw
  8833. * @param defines The defines to update
  8834. */
  8835. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8836. /**
  8837. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8838. * @param mesh The mesh containing the geometry data we will draw
  8839. * @param defines The defines to update
  8840. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8841. * @param useBones Precise whether bones should be used or not (override mesh info)
  8842. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8843. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8844. * @returns false if defines are considered not dirty and have not been checked
  8845. */
  8846. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8847. /**
  8848. * Prepares the defines related to multiview
  8849. * @param scene The scene we are intending to draw
  8850. * @param defines The defines to update
  8851. */
  8852. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8853. /**
  8854. * Prepares the defines related to the light information passed in parameter
  8855. * @param scene The scene we are intending to draw
  8856. * @param mesh The mesh the effect is compiling for
  8857. * @param light The light the effect is compiling for
  8858. * @param lightIndex The index of the light
  8859. * @param defines The defines to update
  8860. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8861. * @param state Defines the current state regarding what is needed (normals, etc...)
  8862. */
  8863. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8864. needNormals: boolean;
  8865. needRebuild: boolean;
  8866. shadowEnabled: boolean;
  8867. specularEnabled: boolean;
  8868. lightmapMode: boolean;
  8869. }): void;
  8870. /**
  8871. * Prepares the defines related to the light information passed in parameter
  8872. * @param scene The scene we are intending to draw
  8873. * @param mesh The mesh the effect is compiling for
  8874. * @param defines The defines to update
  8875. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8876. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8877. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8878. * @returns true if normals will be required for the rest of the effect
  8879. */
  8880. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8881. /**
  8882. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8883. * @param lightIndex defines the light index
  8884. * @param uniformsList The uniform list
  8885. * @param samplersList The sampler list
  8886. * @param projectedLightTexture defines if projected texture must be used
  8887. * @param uniformBuffersList defines an optional list of uniform buffers
  8888. */
  8889. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8890. /**
  8891. * Prepares the uniforms and samplers list to be used in the effect
  8892. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8893. * @param samplersList The sampler list
  8894. * @param defines The defines helping in the list generation
  8895. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8896. */
  8897. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8898. /**
  8899. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8900. * @param defines The defines to update while falling back
  8901. * @param fallbacks The authorized effect fallbacks
  8902. * @param maxSimultaneousLights The maximum number of lights allowed
  8903. * @param rank the current rank of the Effect
  8904. * @returns The newly affected rank
  8905. */
  8906. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8907. private static _TmpMorphInfluencers;
  8908. /**
  8909. * Prepares the list of attributes required for morph targets according to the effect defines.
  8910. * @param attribs The current list of supported attribs
  8911. * @param mesh The mesh to prepare the morph targets attributes for
  8912. * @param influencers The number of influencers
  8913. */
  8914. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8915. /**
  8916. * Prepares the list of attributes required for morph targets according to the effect defines.
  8917. * @param attribs The current list of supported attribs
  8918. * @param mesh The mesh to prepare the morph targets attributes for
  8919. * @param defines The current Defines of the effect
  8920. */
  8921. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8922. /**
  8923. * Prepares the list of attributes required for bones according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param mesh The mesh to prepare the bones attributes for
  8926. * @param defines The current Defines of the effect
  8927. * @param fallbacks The current efffect fallback strategy
  8928. */
  8929. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8930. /**
  8931. * Check and prepare the list of attributes required for instances according to the effect defines.
  8932. * @param attribs The current list of supported attribs
  8933. * @param defines The current MaterialDefines of the effect
  8934. */
  8935. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8936. /**
  8937. * Add the list of attributes required for instances to the attribs array.
  8938. * @param attribs The current list of supported attribs
  8939. */
  8940. static PushAttributesForInstances(attribs: string[]): void;
  8941. /**
  8942. * Binds the light shadow information to the effect for the given mesh.
  8943. * @param light The light containing the generator
  8944. * @param scene The scene the lights belongs to
  8945. * @param mesh The mesh we are binding the information to render
  8946. * @param lightIndex The light index in the effect used to render the mesh
  8947. * @param effect The effect we are binding the data to
  8948. */
  8949. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8950. /**
  8951. * Binds the light information to the effect.
  8952. * @param light The light containing the generator
  8953. * @param effect The effect we are binding the data to
  8954. * @param lightIndex The light index in the effect used to render
  8955. */
  8956. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8957. /**
  8958. * Binds the lights information from the scene to the effect for the given mesh.
  8959. * @param light Light to bind
  8960. * @param lightIndex Light index
  8961. * @param scene The scene where the light belongs to
  8962. * @param mesh The mesh we are binding the information to render
  8963. * @param effect The effect we are binding the data to
  8964. * @param useSpecular Defines if specular is supported
  8965. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8966. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8967. */
  8968. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8969. /**
  8970. * Binds the lights information from the scene to the effect for the given mesh.
  8971. * @param scene The scene the lights belongs to
  8972. * @param mesh The mesh we are binding the information to render
  8973. * @param effect The effect we are binding the data to
  8974. * @param defines The generated defines for the effect
  8975. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8977. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8978. */
  8979. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8980. private static _tempFogColor;
  8981. /**
  8982. * Binds the fog information from the scene to the effect for the given mesh.
  8983. * @param scene The scene the lights belongs to
  8984. * @param mesh The mesh we are binding the information to render
  8985. * @param effect The effect we are binding the data to
  8986. * @param linearSpace Defines if the fog effect is applied in linear space
  8987. */
  8988. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8989. /**
  8990. * Binds the bones information from the mesh to the effect.
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param effect The effect we are binding the data to
  8993. */
  8994. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8995. /**
  8996. * Binds the morph targets information from the mesh to the effect.
  8997. * @param abstractMesh The mesh we are binding the information to render
  8998. * @param effect The effect we are binding the data to
  8999. */
  9000. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9001. /**
  9002. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9003. * @param defines The generated defines used in the effect
  9004. * @param effect The effect we are binding the data to
  9005. * @param scene The scene we are willing to render with logarithmic scale for
  9006. */
  9007. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9008. /**
  9009. * Binds the clip plane information from the scene to the effect.
  9010. * @param scene The scene the clip plane information are extracted from
  9011. * @param effect The effect we are binding the data to
  9012. */
  9013. static BindClipPlane(effect: Effect, scene: Scene): void;
  9014. }
  9015. }
  9016. declare module BABYLON {
  9017. /** @hidden */
  9018. export var packingFunctions: {
  9019. name: string;
  9020. shader: string;
  9021. };
  9022. }
  9023. declare module BABYLON {
  9024. /** @hidden */
  9025. export var shadowMapPixelShader: {
  9026. name: string;
  9027. shader: string;
  9028. };
  9029. }
  9030. declare module BABYLON {
  9031. /** @hidden */
  9032. export var bonesDeclaration: {
  9033. name: string;
  9034. shader: string;
  9035. };
  9036. }
  9037. declare module BABYLON {
  9038. /** @hidden */
  9039. export var morphTargetsVertexGlobalDeclaration: {
  9040. name: string;
  9041. shader: string;
  9042. };
  9043. }
  9044. declare module BABYLON {
  9045. /** @hidden */
  9046. export var morphTargetsVertexDeclaration: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module BABYLON {
  9052. /** @hidden */
  9053. export var instancesDeclaration: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module BABYLON {
  9059. /** @hidden */
  9060. export var helperFunctions: {
  9061. name: string;
  9062. shader: string;
  9063. };
  9064. }
  9065. declare module BABYLON {
  9066. /** @hidden */
  9067. export var morphTargetsVertex: {
  9068. name: string;
  9069. shader: string;
  9070. };
  9071. }
  9072. declare module BABYLON {
  9073. /** @hidden */
  9074. export var instancesVertex: {
  9075. name: string;
  9076. shader: string;
  9077. };
  9078. }
  9079. declare module BABYLON {
  9080. /** @hidden */
  9081. export var bonesVertex: {
  9082. name: string;
  9083. shader: string;
  9084. };
  9085. }
  9086. declare module BABYLON {
  9087. /** @hidden */
  9088. export var shadowMapVertexShader: {
  9089. name: string;
  9090. shader: string;
  9091. };
  9092. }
  9093. declare module BABYLON {
  9094. /** @hidden */
  9095. export var depthBoxBlurPixelShader: {
  9096. name: string;
  9097. shader: string;
  9098. };
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9103. */
  9104. export interface ICustomShaderOptions {
  9105. /**
  9106. * Gets or sets the custom shader name to use
  9107. */
  9108. shaderName: string;
  9109. /**
  9110. * The list of attribute names used in the shader
  9111. */
  9112. attributes?: string[];
  9113. /**
  9114. * The list of unifrom names used in the shader
  9115. */
  9116. uniforms?: string[];
  9117. /**
  9118. * The list of sampler names used in the shader
  9119. */
  9120. samplers?: string[];
  9121. /**
  9122. * The list of defines used in the shader
  9123. */
  9124. defines?: string[];
  9125. }
  9126. /**
  9127. * Interface to implement to create a shadow generator compatible with BJS.
  9128. */
  9129. export interface IShadowGenerator {
  9130. /**
  9131. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9132. * @returns The render target texture if present otherwise, null
  9133. */
  9134. getShadowMap(): Nullable<RenderTargetTexture>;
  9135. /**
  9136. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9137. * @returns The render target texture if the shadow map is present otherwise, null
  9138. */
  9139. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9140. /**
  9141. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9142. * @param subMesh The submesh we want to render in the shadow map
  9143. * @param useInstances Defines wether will draw in the map using instances
  9144. * @returns true if ready otherwise, false
  9145. */
  9146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9147. /**
  9148. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9149. * @param defines Defines of the material we want to update
  9150. * @param lightIndex Index of the light in the enabled light list of the material
  9151. */
  9152. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9153. /**
  9154. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9155. * defined in the generator but impacting the effect).
  9156. * It implies the unifroms available on the materials are the standard BJS ones.
  9157. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9158. * @param effect The effect we are binfing the information for
  9159. */
  9160. bindShadowLight(lightIndex: string, effect: Effect): void;
  9161. /**
  9162. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9163. * (eq to shadow prjection matrix * light transform matrix)
  9164. * @returns The transform matrix used to create the shadow map
  9165. */
  9166. getTransformMatrix(): Matrix;
  9167. /**
  9168. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9169. * Cube and 2D textures for instance.
  9170. */
  9171. recreateShadowMap(): void;
  9172. /**
  9173. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9174. * @param onCompiled Callback triggered at the and of the effects compilation
  9175. * @param options Sets of optional options forcing the compilation with different modes
  9176. */
  9177. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9178. useInstances: boolean;
  9179. }>): void;
  9180. /**
  9181. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9182. * @param options Sets of optional options forcing the compilation with different modes
  9183. * @returns A promise that resolves when the compilation completes
  9184. */
  9185. forceCompilationAsync(options?: Partial<{
  9186. useInstances: boolean;
  9187. }>): Promise<void>;
  9188. /**
  9189. * Serializes the shadow generator setup to a json object.
  9190. * @returns The serialized JSON object
  9191. */
  9192. serialize(): any;
  9193. /**
  9194. * Disposes the Shadow map and related Textures and effects.
  9195. */
  9196. dispose(): void;
  9197. }
  9198. /**
  9199. * Default implementation IShadowGenerator.
  9200. * This is the main object responsible of generating shadows in the framework.
  9201. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9202. */
  9203. export class ShadowGenerator implements IShadowGenerator {
  9204. /**
  9205. * Shadow generator mode None: no filtering applied.
  9206. */
  9207. static readonly FILTER_NONE: number;
  9208. /**
  9209. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9215. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9216. */
  9217. static readonly FILTER_POISSONSAMPLING: number;
  9218. /**
  9219. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9220. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9221. */
  9222. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9223. /**
  9224. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9225. * edge artifacts on steep falloff.
  9226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9227. */
  9228. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9229. /**
  9230. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9231. * edge artifacts on steep falloff.
  9232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9233. */
  9234. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9235. /**
  9236. * Shadow generator mode PCF: Percentage Closer Filtering
  9237. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9238. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9239. */
  9240. static readonly FILTER_PCF: number;
  9241. /**
  9242. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9243. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9244. * Contact Hardening
  9245. */
  9246. static readonly FILTER_PCSS: number;
  9247. /**
  9248. * Reserved for PCF and PCSS
  9249. * Highest Quality.
  9250. *
  9251. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9252. *
  9253. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9254. */
  9255. static readonly QUALITY_HIGH: number;
  9256. /**
  9257. * Reserved for PCF and PCSS
  9258. * Good tradeoff for quality/perf cross devices
  9259. *
  9260. * Execute PCF on a 3*3 kernel.
  9261. *
  9262. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9263. */
  9264. static readonly QUALITY_MEDIUM: number;
  9265. /**
  9266. * Reserved for PCF and PCSS
  9267. * The lowest quality but the fastest.
  9268. *
  9269. * Execute PCF on a 1*1 kernel.
  9270. *
  9271. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9272. */
  9273. static readonly QUALITY_LOW: number;
  9274. /** Gets or sets the custom shader name to use */
  9275. customShaderOptions: ICustomShaderOptions;
  9276. /**
  9277. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9278. */
  9279. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9280. /**
  9281. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9282. */
  9283. onAfterShadowMapRenderObservable: Observable<Effect>;
  9284. /**
  9285. * Observable triggered before a mesh is rendered in the shadow map.
  9286. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9287. */
  9288. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9289. /**
  9290. * Observable triggered after a mesh is rendered in the shadow map.
  9291. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9292. */
  9293. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9294. private _bias;
  9295. /**
  9296. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9297. */
  9298. /**
  9299. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9300. */
  9301. bias: number;
  9302. private _normalBias;
  9303. /**
  9304. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9305. */
  9306. /**
  9307. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9308. */
  9309. normalBias: number;
  9310. private _blurBoxOffset;
  9311. /**
  9312. * Gets the blur box offset: offset applied during the blur pass.
  9313. * Only useful if useKernelBlur = false
  9314. */
  9315. /**
  9316. * Sets the blur box offset: offset applied during the blur pass.
  9317. * Only useful if useKernelBlur = false
  9318. */
  9319. blurBoxOffset: number;
  9320. private _blurScale;
  9321. /**
  9322. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9323. * 2 means half of the size.
  9324. */
  9325. /**
  9326. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9327. * 2 means half of the size.
  9328. */
  9329. blurScale: number;
  9330. private _blurKernel;
  9331. /**
  9332. * Gets the blur kernel: kernel size of the blur pass.
  9333. * Only useful if useKernelBlur = true
  9334. */
  9335. /**
  9336. * Sets the blur kernel: kernel size of the blur pass.
  9337. * Only useful if useKernelBlur = true
  9338. */
  9339. blurKernel: number;
  9340. private _useKernelBlur;
  9341. /**
  9342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9344. */
  9345. /**
  9346. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9347. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9348. */
  9349. useKernelBlur: boolean;
  9350. private _depthScale;
  9351. /**
  9352. * Gets the depth scale used in ESM mode.
  9353. */
  9354. /**
  9355. * Sets the depth scale used in ESM mode.
  9356. * This can override the scale stored on the light.
  9357. */
  9358. depthScale: number;
  9359. private _filter;
  9360. /**
  9361. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9362. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9363. */
  9364. /**
  9365. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9366. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9367. */
  9368. filter: number;
  9369. /**
  9370. * Gets if the current filter is set to Poisson Sampling.
  9371. */
  9372. /**
  9373. * Sets the current filter to Poisson Sampling.
  9374. */
  9375. usePoissonSampling: boolean;
  9376. /**
  9377. * Gets if the current filter is set to ESM.
  9378. */
  9379. /**
  9380. * Sets the current filter is to ESM.
  9381. */
  9382. useExponentialShadowMap: boolean;
  9383. /**
  9384. * Gets if the current filter is set to filtered ESM.
  9385. */
  9386. /**
  9387. * Gets if the current filter is set to filtered ESM.
  9388. */
  9389. useBlurExponentialShadowMap: boolean;
  9390. /**
  9391. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9392. * exponential to prevent steep falloff artifacts).
  9393. */
  9394. /**
  9395. * Sets the current filter to "close ESM" (using the inverse of the
  9396. * exponential to prevent steep falloff artifacts).
  9397. */
  9398. useCloseExponentialShadowMap: boolean;
  9399. /**
  9400. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9401. * exponential to prevent steep falloff artifacts).
  9402. */
  9403. /**
  9404. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9405. * exponential to prevent steep falloff artifacts).
  9406. */
  9407. useBlurCloseExponentialShadowMap: boolean;
  9408. /**
  9409. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9410. */
  9411. /**
  9412. * Sets the current filter to "PCF" (percentage closer filtering).
  9413. */
  9414. usePercentageCloserFiltering: boolean;
  9415. private _filteringQuality;
  9416. /**
  9417. * Gets the PCF or PCSS Quality.
  9418. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9419. */
  9420. /**
  9421. * Sets the PCF or PCSS Quality.
  9422. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9423. */
  9424. filteringQuality: number;
  9425. /**
  9426. * Gets if the current filter is set to "PCSS" (contact hardening).
  9427. */
  9428. /**
  9429. * Sets the current filter to "PCSS" (contact hardening).
  9430. */
  9431. useContactHardeningShadow: boolean;
  9432. private _contactHardeningLightSizeUVRatio;
  9433. /**
  9434. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9435. * Using a ratio helps keeping shape stability independently of the map size.
  9436. *
  9437. * It does not account for the light projection as it was having too much
  9438. * instability during the light setup or during light position changes.
  9439. *
  9440. * Only valid if useContactHardeningShadow is true.
  9441. */
  9442. /**
  9443. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9444. * Using a ratio helps keeping shape stability independently of the map size.
  9445. *
  9446. * It does not account for the light projection as it was having too much
  9447. * instability during the light setup or during light position changes.
  9448. *
  9449. * Only valid if useContactHardeningShadow is true.
  9450. */
  9451. contactHardeningLightSizeUVRatio: number;
  9452. private _darkness;
  9453. /** Gets or sets the actual darkness of a shadow */
  9454. darkness: number;
  9455. /**
  9456. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9457. * 0 means strongest and 1 would means no shadow.
  9458. * @returns the darkness.
  9459. */
  9460. getDarkness(): number;
  9461. /**
  9462. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9463. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9464. * @returns the shadow generator allowing fluent coding.
  9465. */
  9466. setDarkness(darkness: number): ShadowGenerator;
  9467. private _transparencyShadow;
  9468. /** Gets or sets the ability to have transparent shadow */
  9469. transparencyShadow: boolean;
  9470. /**
  9471. * Sets the ability to have transparent shadow (boolean).
  9472. * @param transparent True if transparent else False
  9473. * @returns the shadow generator allowing fluent coding
  9474. */
  9475. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9476. private _shadowMap;
  9477. private _shadowMap2;
  9478. /**
  9479. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9480. * @returns The render target texture if present otherwise, null
  9481. */
  9482. getShadowMap(): Nullable<RenderTargetTexture>;
  9483. /**
  9484. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9485. * @returns The render target texture if the shadow map is present otherwise, null
  9486. */
  9487. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9488. /**
  9489. * Gets the class name of that object
  9490. * @returns "ShadowGenerator"
  9491. */
  9492. getClassName(): string;
  9493. /**
  9494. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9495. * @param mesh Mesh to add
  9496. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9497. * @returns the Shadow Generator itself
  9498. */
  9499. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9500. /**
  9501. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9502. * @param mesh Mesh to remove
  9503. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9504. * @returns the Shadow Generator itself
  9505. */
  9506. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9507. /**
  9508. * Controls the extent to which the shadows fade out at the edge of the frustum
  9509. * Used only by directionals and spots
  9510. */
  9511. frustumEdgeFalloff: number;
  9512. private _light;
  9513. /**
  9514. * Returns the associated light object.
  9515. * @returns the light generating the shadow
  9516. */
  9517. getLight(): IShadowLight;
  9518. /**
  9519. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9520. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9521. * It might on the other hand introduce peter panning.
  9522. */
  9523. forceBackFacesOnly: boolean;
  9524. private _scene;
  9525. private _lightDirection;
  9526. private _effect;
  9527. private _viewMatrix;
  9528. private _projectionMatrix;
  9529. private _transformMatrix;
  9530. private _cachedPosition;
  9531. private _cachedDirection;
  9532. private _cachedDefines;
  9533. private _currentRenderID;
  9534. private _boxBlurPostprocess;
  9535. private _kernelBlurXPostprocess;
  9536. private _kernelBlurYPostprocess;
  9537. private _blurPostProcesses;
  9538. private _mapSize;
  9539. private _currentFaceIndex;
  9540. private _currentFaceIndexCache;
  9541. private _textureType;
  9542. private _defaultTextureMatrix;
  9543. /** @hidden */
  9544. static _SceneComponentInitialization: (scene: Scene) => void;
  9545. /**
  9546. * Creates a ShadowGenerator object.
  9547. * A ShadowGenerator is the required tool to use the shadows.
  9548. * Each light casting shadows needs to use its own ShadowGenerator.
  9549. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9550. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9551. * @param light The light object generating the shadows.
  9552. * @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.
  9553. */
  9554. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9555. private _initializeGenerator;
  9556. private _initializeShadowMap;
  9557. private _initializeBlurRTTAndPostProcesses;
  9558. private _renderForShadowMap;
  9559. private _renderSubMeshForShadowMap;
  9560. private _applyFilterValues;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param onCompiled Callback triggered at the and of the effects compilation
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. */
  9566. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): void;
  9569. /**
  9570. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9571. * @param options Sets of optional options forcing the compilation with different modes
  9572. * @returns A promise that resolves when the compilation completes
  9573. */
  9574. forceCompilationAsync(options?: Partial<{
  9575. useInstances: boolean;
  9576. }>): Promise<void>;
  9577. /**
  9578. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9579. * @param subMesh The submesh we want to render in the shadow map
  9580. * @param useInstances Defines wether will draw in the map using instances
  9581. * @returns true if ready otherwise, false
  9582. */
  9583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9584. /**
  9585. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9586. * @param defines Defines of the material we want to update
  9587. * @param lightIndex Index of the light in the enabled light list of the material
  9588. */
  9589. prepareDefines(defines: any, lightIndex: number): void;
  9590. /**
  9591. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9592. * defined in the generator but impacting the effect).
  9593. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9594. * @param effect The effect we are binfing the information for
  9595. */
  9596. bindShadowLight(lightIndex: string, effect: Effect): void;
  9597. /**
  9598. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9599. * (eq to shadow prjection matrix * light transform matrix)
  9600. * @returns The transform matrix used to create the shadow map
  9601. */
  9602. getTransformMatrix(): Matrix;
  9603. /**
  9604. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9605. * Cube and 2D textures for instance.
  9606. */
  9607. recreateShadowMap(): void;
  9608. private _disposeBlurPostProcesses;
  9609. private _disposeRTTandPostProcesses;
  9610. /**
  9611. * Disposes the ShadowGenerator.
  9612. * Returns nothing.
  9613. */
  9614. dispose(): void;
  9615. /**
  9616. * Serializes the shadow generator setup to a json object.
  9617. * @returns The serialized JSON object
  9618. */
  9619. serialize(): any;
  9620. /**
  9621. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9622. * @param parsedShadowGenerator The JSON object to parse
  9623. * @param scene The scene to create the shadow map for
  9624. * @returns The parsed shadow generator
  9625. */
  9626. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9627. }
  9628. }
  9629. declare module BABYLON {
  9630. /**
  9631. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9632. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9633. * 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.
  9634. */
  9635. export abstract class Light extends Node {
  9636. /**
  9637. * Falloff Default: light is falling off following the material specification:
  9638. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9639. */
  9640. static readonly FALLOFF_DEFAULT: number;
  9641. /**
  9642. * Falloff Physical: light is falling off following the inverse squared distance law.
  9643. */
  9644. static readonly FALLOFF_PHYSICAL: number;
  9645. /**
  9646. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9647. * to enhance interoperability with other engines.
  9648. */
  9649. static readonly FALLOFF_GLTF: number;
  9650. /**
  9651. * Falloff Standard: light is falling off like in the standard material
  9652. * to enhance interoperability with other materials.
  9653. */
  9654. static readonly FALLOFF_STANDARD: number;
  9655. /**
  9656. * If every light affecting the material is in this lightmapMode,
  9657. * material.lightmapTexture adds or multiplies
  9658. * (depends on material.useLightmapAsShadowmap)
  9659. * after every other light calculations.
  9660. */
  9661. static readonly LIGHTMAP_DEFAULT: number;
  9662. /**
  9663. * material.lightmapTexture as only diffuse lighting from this light
  9664. * adds only specular lighting from this light
  9665. * adds dynamic shadows
  9666. */
  9667. static readonly LIGHTMAP_SPECULAR: number;
  9668. /**
  9669. * material.lightmapTexture as only lighting
  9670. * no light calculation from this light
  9671. * only adds dynamic shadows from this light
  9672. */
  9673. static readonly LIGHTMAP_SHADOWSONLY: number;
  9674. /**
  9675. * Each light type uses the default quantity according to its type:
  9676. * point/spot lights use luminous intensity
  9677. * directional lights use illuminance
  9678. */
  9679. static readonly INTENSITYMODE_AUTOMATIC: number;
  9680. /**
  9681. * lumen (lm)
  9682. */
  9683. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9684. /**
  9685. * candela (lm/sr)
  9686. */
  9687. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9688. /**
  9689. * lux (lm/m^2)
  9690. */
  9691. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9692. /**
  9693. * nit (cd/m^2)
  9694. */
  9695. static readonly INTENSITYMODE_LUMINANCE: number;
  9696. /**
  9697. * Light type const id of the point light.
  9698. */
  9699. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9700. /**
  9701. * Light type const id of the directional light.
  9702. */
  9703. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9704. /**
  9705. * Light type const id of the spot light.
  9706. */
  9707. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9708. /**
  9709. * Light type const id of the hemispheric light.
  9710. */
  9711. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9712. /**
  9713. * Diffuse gives the basic color to an object.
  9714. */
  9715. diffuse: Color3;
  9716. /**
  9717. * Specular produces a highlight color on an object.
  9718. * Note: This is note affecting PBR materials.
  9719. */
  9720. specular: Color3;
  9721. /**
  9722. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9723. * falling off base on range or angle.
  9724. * This can be set to any values in Light.FALLOFF_x.
  9725. *
  9726. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9727. * other types of materials.
  9728. */
  9729. falloffType: number;
  9730. /**
  9731. * Strength of the light.
  9732. * Note: By default it is define in the framework own unit.
  9733. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9734. */
  9735. intensity: number;
  9736. private _range;
  9737. protected _inverseSquaredRange: number;
  9738. /**
  9739. * Defines how far from the source the light is impacting in scene units.
  9740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9741. */
  9742. /**
  9743. * Defines how far from the source the light is impacting in scene units.
  9744. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9745. */
  9746. range: number;
  9747. /**
  9748. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9749. * of light.
  9750. */
  9751. private _photometricScale;
  9752. private _intensityMode;
  9753. /**
  9754. * Gets the photometric scale used to interpret the intensity.
  9755. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9756. */
  9757. /**
  9758. * Sets the photometric scale used to interpret the intensity.
  9759. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9760. */
  9761. intensityMode: number;
  9762. private _radius;
  9763. /**
  9764. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9765. */
  9766. /**
  9767. * sets the light radius used by PBR Materials to simulate soft area lights.
  9768. */
  9769. radius: number;
  9770. private _renderPriority;
  9771. /**
  9772. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9773. * exceeding the number allowed of the materials.
  9774. */
  9775. renderPriority: number;
  9776. private _shadowEnabled;
  9777. /**
  9778. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9779. * the current shadow generator.
  9780. */
  9781. /**
  9782. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9783. * the current shadow generator.
  9784. */
  9785. shadowEnabled: boolean;
  9786. private _includedOnlyMeshes;
  9787. /**
  9788. * Gets the only meshes impacted by this light.
  9789. */
  9790. /**
  9791. * Sets the only meshes impacted by this light.
  9792. */
  9793. includedOnlyMeshes: AbstractMesh[];
  9794. private _excludedMeshes;
  9795. /**
  9796. * Gets the meshes not impacted by this light.
  9797. */
  9798. /**
  9799. * Sets the meshes not impacted by this light.
  9800. */
  9801. excludedMeshes: AbstractMesh[];
  9802. private _excludeWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are not impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are not impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. excludeWithLayerMask: number;
  9812. private _includeOnlyWithLayerMask;
  9813. /**
  9814. * Gets the layer id use to find what meshes are impacted by the light.
  9815. * Inactive if 0
  9816. */
  9817. /**
  9818. * Sets the layer id use to find what meshes are impacted by the light.
  9819. * Inactive if 0
  9820. */
  9821. includeOnlyWithLayerMask: number;
  9822. private _lightmapMode;
  9823. /**
  9824. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9825. */
  9826. /**
  9827. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9828. */
  9829. lightmapMode: number;
  9830. /**
  9831. * Shadow generator associted to the light.
  9832. * @hidden Internal use only.
  9833. */
  9834. _shadowGenerator: Nullable<IShadowGenerator>;
  9835. /**
  9836. * @hidden Internal use only.
  9837. */
  9838. _excludedMeshesIds: string[];
  9839. /**
  9840. * @hidden Internal use only.
  9841. */
  9842. _includedOnlyMeshesIds: string[];
  9843. /**
  9844. * The current light unifom buffer.
  9845. * @hidden Internal use only.
  9846. */
  9847. _uniformBuffer: UniformBuffer;
  9848. /**
  9849. * Creates a Light object in the scene.
  9850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9851. * @param name The firendly name of the light
  9852. * @param scene The scene the light belongs too
  9853. */
  9854. constructor(name: string, scene: Scene);
  9855. protected abstract _buildUniformLayout(): void;
  9856. /**
  9857. * Sets the passed Effect "effect" with the Light information.
  9858. * @param effect The effect to update
  9859. * @param lightIndex The index of the light in the effect to update
  9860. * @returns The light
  9861. */
  9862. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9863. /**
  9864. * Sets the passed Effect "effect" with the Light information.
  9865. * @param effect The effect to update
  9866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9867. * @returns The light
  9868. */
  9869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9870. /**
  9871. * Returns the string "Light".
  9872. * @returns the class name
  9873. */
  9874. getClassName(): string;
  9875. /** @hidden */
  9876. readonly _isLight: boolean;
  9877. /**
  9878. * Converts the light information to a readable string for debug purpose.
  9879. * @param fullDetails Supports for multiple levels of logging within scene loading
  9880. * @returns the human readable light info
  9881. */
  9882. toString(fullDetails?: boolean): string;
  9883. /** @hidden */
  9884. protected _syncParentEnabledState(): void;
  9885. /**
  9886. * Set the enabled state of this node.
  9887. * @param value - the new enabled state
  9888. */
  9889. setEnabled(value: boolean): void;
  9890. /**
  9891. * Returns the Light associated shadow generator if any.
  9892. * @return the associated shadow generator.
  9893. */
  9894. getShadowGenerator(): Nullable<IShadowGenerator>;
  9895. /**
  9896. * Returns a Vector3, the absolute light position in the World.
  9897. * @returns the world space position of the light
  9898. */
  9899. getAbsolutePosition(): Vector3;
  9900. /**
  9901. * Specifies if the light will affect the passed mesh.
  9902. * @param mesh The mesh to test against the light
  9903. * @return true the mesh is affected otherwise, false.
  9904. */
  9905. canAffectMesh(mesh: AbstractMesh): boolean;
  9906. /**
  9907. * Sort function to order lights for rendering.
  9908. * @param a First Light object to compare to second.
  9909. * @param b Second Light object to compare first.
  9910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9911. */
  9912. static CompareLightsPriority(a: Light, b: Light): number;
  9913. /**
  9914. * Releases resources associated with this node.
  9915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9917. */
  9918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9919. /**
  9920. * Returns the light type ID (integer).
  9921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9922. */
  9923. getTypeID(): number;
  9924. /**
  9925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9926. * @returns the scaled intensity in intensity mode unit
  9927. */
  9928. getScaledIntensity(): number;
  9929. /**
  9930. * Returns a new Light object, named "name", from the current one.
  9931. * @param name The name of the cloned light
  9932. * @returns the new created light
  9933. */
  9934. clone(name: string): Nullable<Light>;
  9935. /**
  9936. * Serializes the current light into a Serialization object.
  9937. * @returns the serialized object.
  9938. */
  9939. serialize(): any;
  9940. /**
  9941. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9942. * This new light is named "name" and added to the passed scene.
  9943. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9944. * @param name The friendly name of the light
  9945. * @param scene The scene the new light will belong to
  9946. * @returns the constructor function
  9947. */
  9948. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9949. /**
  9950. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9951. * @param parsedLight The JSON representation of the light
  9952. * @param scene The scene to create the parsed light in
  9953. * @returns the created light after parsing
  9954. */
  9955. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9956. private _hookArrayForExcluded;
  9957. private _hookArrayForIncludedOnly;
  9958. private _resyncMeshes;
  9959. /**
  9960. * Forces the meshes to update their light related information in their rendering used effects
  9961. * @hidden Internal Use Only
  9962. */
  9963. _markMeshesAsLightDirty(): void;
  9964. /**
  9965. * Recomputes the cached photometric scale if needed.
  9966. */
  9967. private _computePhotometricScale;
  9968. /**
  9969. * Returns the Photometric Scale according to the light type and intensity mode.
  9970. */
  9971. private _getPhotometricScale;
  9972. /**
  9973. * Reorder the light in the scene according to their defined priority.
  9974. * @hidden Internal Use Only
  9975. */
  9976. _reorderLightsInScene(): void;
  9977. /**
  9978. * Prepares the list of defines specific to the light type.
  9979. * @param defines the list of defines
  9980. * @param lightIndex defines the index of the light for the effect
  9981. */
  9982. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9983. }
  9984. }
  9985. declare module BABYLON {
  9986. /**
  9987. * Interface used to define Action
  9988. */
  9989. export interface IAction {
  9990. /**
  9991. * Trigger for the action
  9992. */
  9993. trigger: number;
  9994. /** Options of the trigger */
  9995. triggerOptions: any;
  9996. /**
  9997. * Gets the trigger parameters
  9998. * @returns the trigger parameters
  9999. */
  10000. getTriggerParameter(): any;
  10001. /**
  10002. * Internal only - executes current action event
  10003. * @hidden
  10004. */
  10005. _executeCurrent(evt?: ActionEvent): void;
  10006. /**
  10007. * Serialize placeholder for child classes
  10008. * @param parent of child
  10009. * @returns the serialized object
  10010. */
  10011. serialize(parent: any): any;
  10012. /**
  10013. * Internal only
  10014. * @hidden
  10015. */
  10016. _prepare(): void;
  10017. /**
  10018. * Internal only - manager for action
  10019. * @hidden
  10020. */
  10021. _actionManager: AbstractActionManager;
  10022. /**
  10023. * Adds action to chain of actions, may be a DoNothingAction
  10024. * @param action defines the next action to execute
  10025. * @returns The action passed in
  10026. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10027. */
  10028. then(action: IAction): IAction;
  10029. }
  10030. /**
  10031. * The action to be carried out following a trigger
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10033. */
  10034. export class Action implements IAction {
  10035. /** the trigger, with or without parameters, for the action */
  10036. triggerOptions: any;
  10037. /**
  10038. * Trigger for the action
  10039. */
  10040. trigger: number;
  10041. /**
  10042. * Internal only - manager for action
  10043. * @hidden
  10044. */
  10045. _actionManager: ActionManager;
  10046. private _nextActiveAction;
  10047. private _child;
  10048. private _condition?;
  10049. private _triggerParameter;
  10050. /**
  10051. * An event triggered prior to action being executed.
  10052. */
  10053. onBeforeExecuteObservable: Observable<Action>;
  10054. /**
  10055. * Creates a new Action
  10056. * @param triggerOptions the trigger, with or without parameters, for the action
  10057. * @param condition an optional determinant of action
  10058. */
  10059. constructor(
  10060. /** the trigger, with or without parameters, for the action */
  10061. triggerOptions: any, condition?: Condition);
  10062. /**
  10063. * Internal only
  10064. * @hidden
  10065. */
  10066. _prepare(): void;
  10067. /**
  10068. * Gets the trigger parameters
  10069. * @returns the trigger parameters
  10070. */
  10071. getTriggerParameter(): any;
  10072. /**
  10073. * Internal only - executes current action event
  10074. * @hidden
  10075. */
  10076. _executeCurrent(evt?: ActionEvent): void;
  10077. /**
  10078. * Execute placeholder for child classes
  10079. * @param evt optional action event
  10080. */
  10081. execute(evt?: ActionEvent): void;
  10082. /**
  10083. * Skips to next active action
  10084. */
  10085. skipToNextActiveAction(): void;
  10086. /**
  10087. * Adds action to chain of actions, may be a DoNothingAction
  10088. * @param action defines the next action to execute
  10089. * @returns The action passed in
  10090. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10091. */
  10092. then(action: Action): Action;
  10093. /**
  10094. * Internal only
  10095. * @hidden
  10096. */
  10097. _getProperty(propertyPath: string): string;
  10098. /**
  10099. * Internal only
  10100. * @hidden
  10101. */
  10102. _getEffectiveTarget(target: any, propertyPath: string): any;
  10103. /**
  10104. * Serialize placeholder for child classes
  10105. * @param parent of child
  10106. * @returns the serialized object
  10107. */
  10108. serialize(parent: any): any;
  10109. /**
  10110. * Internal only called by serialize
  10111. * @hidden
  10112. */
  10113. protected _serialize(serializedAction: any, parent?: any): any;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. static _SerializeValueAsString: (value: any) => string;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. static _GetTargetProperty: (target: Node | Scene) => {
  10124. name: string;
  10125. targetType: string;
  10126. value: string;
  10127. };
  10128. }
  10129. }
  10130. declare module BABYLON {
  10131. /**
  10132. * A Condition applied to an Action
  10133. */
  10134. export class Condition {
  10135. /**
  10136. * Internal only - manager for action
  10137. * @hidden
  10138. */
  10139. _actionManager: ActionManager;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _evaluationId: number;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. _currentResult: boolean;
  10150. /**
  10151. * Creates a new Condition
  10152. * @param actionManager the manager of the action the condition is applied to
  10153. */
  10154. constructor(actionManager: ActionManager);
  10155. /**
  10156. * Check if the current condition is valid
  10157. * @returns a boolean
  10158. */
  10159. isValid(): boolean;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _getProperty(propertyPath: string): string;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _getEffectiveTarget(target: any, propertyPath: string): any;
  10170. /**
  10171. * Serialize placeholder for child classes
  10172. * @returns the serialized object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Internal only
  10177. * @hidden
  10178. */
  10179. protected _serialize(serializedCondition: any): any;
  10180. }
  10181. /**
  10182. * Defines specific conditional operators as extensions of Condition
  10183. */
  10184. export class ValueCondition extends Condition {
  10185. /** path to specify the property of the target the conditional operator uses */
  10186. propertyPath: string;
  10187. /** the value compared by the conditional operator against the current value of the property */
  10188. value: any;
  10189. /** the conditional operator, default ValueCondition.IsEqual */
  10190. operator: number;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsEqual;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsDifferent;
  10201. /**
  10202. * Internal only
  10203. * @hidden
  10204. */
  10205. private static _IsGreater;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. private static _IsLesser;
  10211. /**
  10212. * returns the number for IsEqual
  10213. */
  10214. static readonly IsEqual: number;
  10215. /**
  10216. * Returns the number for IsDifferent
  10217. */
  10218. static readonly IsDifferent: number;
  10219. /**
  10220. * Returns the number for IsGreater
  10221. */
  10222. static readonly IsGreater: number;
  10223. /**
  10224. * Returns the number for IsLesser
  10225. */
  10226. static readonly IsLesser: number;
  10227. /**
  10228. * Internal only The action manager for the condition
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. private _target;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. private _effectiveTarget;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. private _property;
  10247. /**
  10248. * Creates a new ValueCondition
  10249. * @param actionManager manager for the action the condition applies to
  10250. * @param target for the action
  10251. * @param propertyPath path to specify the property of the target the conditional operator uses
  10252. * @param value the value compared by the conditional operator against the current value of the property
  10253. * @param operator the conditional operator, default ValueCondition.IsEqual
  10254. */
  10255. constructor(actionManager: ActionManager, target: any,
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string,
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any,
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator?: number);
  10262. /**
  10263. * Compares the given value with the property value for the specified conditional operator
  10264. * @returns the result of the comparison
  10265. */
  10266. isValid(): boolean;
  10267. /**
  10268. * Serialize the ValueCondition into a JSON compatible object
  10269. * @returns serialization object
  10270. */
  10271. serialize(): any;
  10272. /**
  10273. * Gets the name of the conditional operator for the ValueCondition
  10274. * @param operator the conditional operator
  10275. * @returns the name
  10276. */
  10277. static GetOperatorName(operator: number): string;
  10278. }
  10279. /**
  10280. * Defines a predicate condition as an extension of Condition
  10281. */
  10282. export class PredicateCondition extends Condition {
  10283. /** defines the predicate function used to validate the condition */
  10284. predicate: () => boolean;
  10285. /**
  10286. * Internal only - manager for action
  10287. * @hidden
  10288. */
  10289. _actionManager: ActionManager;
  10290. /**
  10291. * Creates a new PredicateCondition
  10292. * @param actionManager manager for the action the condition applies to
  10293. * @param predicate defines the predicate function used to validate the condition
  10294. */
  10295. constructor(actionManager: ActionManager,
  10296. /** defines the predicate function used to validate the condition */
  10297. predicate: () => boolean);
  10298. /**
  10299. * @returns the validity of the predicate condition
  10300. */
  10301. isValid(): boolean;
  10302. }
  10303. /**
  10304. * Defines a state condition as an extension of Condition
  10305. */
  10306. export class StateCondition extends Condition {
  10307. /** Value to compare with target state */
  10308. value: string;
  10309. /**
  10310. * Internal only - manager for action
  10311. * @hidden
  10312. */
  10313. _actionManager: ActionManager;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. private _target;
  10319. /**
  10320. * Creates a new StateCondition
  10321. * @param actionManager manager for the action the condition applies to
  10322. * @param target of the condition
  10323. * @param value to compare with target state
  10324. */
  10325. constructor(actionManager: ActionManager, target: any,
  10326. /** Value to compare with target state */
  10327. value: string);
  10328. /**
  10329. * Gets a boolean indicating if the current condition is met
  10330. * @returns the validity of the state
  10331. */
  10332. isValid(): boolean;
  10333. /**
  10334. * Serialize the StateCondition into a JSON compatible object
  10335. * @returns serialization object
  10336. */
  10337. serialize(): any;
  10338. }
  10339. }
  10340. declare module BABYLON {
  10341. /**
  10342. * This defines an action responsible to toggle a boolean once triggered.
  10343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10344. */
  10345. export class SwitchBooleanAction extends Action {
  10346. /**
  10347. * The path to the boolean property in the target object
  10348. */
  10349. propertyPath: string;
  10350. private _target;
  10351. private _effectiveTarget;
  10352. private _property;
  10353. /**
  10354. * Instantiate the action
  10355. * @param triggerOptions defines the trigger options
  10356. * @param target defines the object containing the boolean
  10357. * @param propertyPath defines the path to the boolean property in the target object
  10358. * @param condition defines the trigger related conditions
  10359. */
  10360. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10361. /** @hidden */
  10362. _prepare(): void;
  10363. /**
  10364. * Execute the action toggle the boolean value.
  10365. */
  10366. execute(): void;
  10367. /**
  10368. * Serializes the actions and its related information.
  10369. * @param parent defines the object to serialize in
  10370. * @returns the serialized object
  10371. */
  10372. serialize(parent: any): any;
  10373. }
  10374. /**
  10375. * This defines an action responsible to set a the state field of the target
  10376. * to a desired value once triggered.
  10377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10378. */
  10379. export class SetStateAction extends Action {
  10380. /**
  10381. * The value to store in the state field.
  10382. */
  10383. value: string;
  10384. private _target;
  10385. /**
  10386. * Instantiate the action
  10387. * @param triggerOptions defines the trigger options
  10388. * @param target defines the object containing the state property
  10389. * @param value defines the value to store in the state field
  10390. * @param condition defines the trigger related conditions
  10391. */
  10392. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10393. /**
  10394. * Execute the action and store the value on the target state property.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to set a property of the target
  10406. * to a desired value once triggered.
  10407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10408. */
  10409. export class SetValueAction extends Action {
  10410. /**
  10411. * The path of the property to set in the target.
  10412. */
  10413. propertyPath: string;
  10414. /**
  10415. * The value to set in the property
  10416. */
  10417. value: any;
  10418. private _target;
  10419. private _effectiveTarget;
  10420. private _property;
  10421. /**
  10422. * Instantiate the action
  10423. * @param triggerOptions defines the trigger options
  10424. * @param target defines the object containing the property
  10425. * @param propertyPath defines the path of the property to set in the target
  10426. * @param value defines the value to set in the property
  10427. * @param condition defines the trigger related conditions
  10428. */
  10429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10430. /** @hidden */
  10431. _prepare(): void;
  10432. /**
  10433. * Execute the action and set the targetted property to the desired value.
  10434. */
  10435. execute(): void;
  10436. /**
  10437. * Serializes the actions and its related information.
  10438. * @param parent defines the object to serialize in
  10439. * @returns the serialized object
  10440. */
  10441. serialize(parent: any): any;
  10442. }
  10443. /**
  10444. * This defines an action responsible to increment the target value
  10445. * to a desired value once triggered.
  10446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10447. */
  10448. export class IncrementValueAction extends Action {
  10449. /**
  10450. * The path of the property to increment in the target.
  10451. */
  10452. propertyPath: string;
  10453. /**
  10454. * The value we should increment the property by.
  10455. */
  10456. value: any;
  10457. private _target;
  10458. private _effectiveTarget;
  10459. private _property;
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param target defines the object containing the property
  10464. * @param propertyPath defines the path of the property to increment in the target
  10465. * @param value defines the value value we should increment the property by
  10466. * @param condition defines the trigger related conditions
  10467. */
  10468. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10469. /** @hidden */
  10470. _prepare(): void;
  10471. /**
  10472. * Execute the action and increment the target of the value amount.
  10473. */
  10474. execute(): void;
  10475. /**
  10476. * Serializes the actions and its related information.
  10477. * @param parent defines the object to serialize in
  10478. * @returns the serialized object
  10479. */
  10480. serialize(parent: any): any;
  10481. }
  10482. /**
  10483. * This defines an action responsible to start an animation once triggered.
  10484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10485. */
  10486. export class PlayAnimationAction extends Action {
  10487. /**
  10488. * Where the animation should start (animation frame)
  10489. */
  10490. from: number;
  10491. /**
  10492. * Where the animation should stop (animation frame)
  10493. */
  10494. to: number;
  10495. /**
  10496. * Define if the animation should loop or stop after the first play.
  10497. */
  10498. loop?: boolean;
  10499. private _target;
  10500. /**
  10501. * Instantiate the action
  10502. * @param triggerOptions defines the trigger options
  10503. * @param target defines the target animation or animation name
  10504. * @param from defines from where the animation should start (animation frame)
  10505. * @param end defines where the animation should stop (animation frame)
  10506. * @param loop defines if the animation should loop or stop after the first play
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action and play the animation.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to stop an animation once triggered.
  10525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10526. */
  10527. export class StopAnimationAction extends Action {
  10528. private _target;
  10529. /**
  10530. * Instantiate the action
  10531. * @param triggerOptions defines the trigger options
  10532. * @param target defines the target animation or animation name
  10533. * @param condition defines the trigger related conditions
  10534. */
  10535. constructor(triggerOptions: any, target: any, condition?: Condition);
  10536. /** @hidden */
  10537. _prepare(): void;
  10538. /**
  10539. * Execute the action and stop the animation.
  10540. */
  10541. execute(): void;
  10542. /**
  10543. * Serializes the actions and its related information.
  10544. * @param parent defines the object to serialize in
  10545. * @returns the serialized object
  10546. */
  10547. serialize(parent: any): any;
  10548. }
  10549. /**
  10550. * This defines an action responsible that does nothing once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class DoNothingAction extends Action {
  10554. /**
  10555. * Instantiate the action
  10556. * @param triggerOptions defines the trigger options
  10557. * @param condition defines the trigger related conditions
  10558. */
  10559. constructor(triggerOptions?: any, condition?: Condition);
  10560. /**
  10561. * Execute the action and do nothing.
  10562. */
  10563. execute(): void;
  10564. /**
  10565. * Serializes the actions and its related information.
  10566. * @param parent defines the object to serialize in
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. }
  10571. /**
  10572. * This defines an action responsible to trigger several actions once triggered.
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10574. */
  10575. export class CombineAction extends Action {
  10576. /**
  10577. * The list of aggregated animations to run.
  10578. */
  10579. children: Action[];
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param children defines the list of aggregated animations to run
  10584. * @param condition defines the trigger related conditions
  10585. */
  10586. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10587. /** @hidden */
  10588. _prepare(): void;
  10589. /**
  10590. * Execute the action and executes all the aggregated actions.
  10591. */
  10592. execute(evt: ActionEvent): void;
  10593. /**
  10594. * Serializes the actions and its related information.
  10595. * @param parent defines the object to serialize in
  10596. * @returns the serialized object
  10597. */
  10598. serialize(parent: any): any;
  10599. }
  10600. /**
  10601. * This defines an action responsible to run code (external event) once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class ExecuteCodeAction extends Action {
  10605. /**
  10606. * The callback function to run.
  10607. */
  10608. func: (evt: ActionEvent) => void;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param func defines the callback function to run
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10616. /**
  10617. * Execute the action and run the attached code.
  10618. */
  10619. execute(evt: ActionEvent): void;
  10620. }
  10621. /**
  10622. * This defines an action responsible to set the parent property of the target once triggered.
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10624. */
  10625. export class SetParentAction extends Action {
  10626. private _parent;
  10627. private _target;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param target defines the target containing the parent property
  10632. * @param parent defines from where the animation should start (animation frame)
  10633. * @param condition defines the trigger related conditions
  10634. */
  10635. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10636. /** @hidden */
  10637. _prepare(): void;
  10638. /**
  10639. * Execute the action and set the parent property.
  10640. */
  10641. execute(): void;
  10642. /**
  10643. * Serializes the actions and its related information.
  10644. * @param parent defines the object to serialize in
  10645. * @returns the serialized object
  10646. */
  10647. serialize(parent: any): any;
  10648. }
  10649. }
  10650. declare module BABYLON {
  10651. /**
  10652. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10653. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10655. */
  10656. export class ActionManager extends AbstractActionManager {
  10657. /**
  10658. * Nothing
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly NothingTrigger: number;
  10662. /**
  10663. * On pick
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnPickTrigger: number;
  10667. /**
  10668. * On left pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnLeftPickTrigger: number;
  10672. /**
  10673. * On right pick
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnRightPickTrigger: number;
  10677. /**
  10678. * On center pick
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnCenterPickTrigger: number;
  10682. /**
  10683. * On pick down
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnPickDownTrigger: number;
  10687. /**
  10688. * On double pick
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnDoublePickTrigger: number;
  10692. /**
  10693. * On pick up
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnPickUpTrigger: number;
  10697. /**
  10698. * On pick out.
  10699. * This trigger will only be raised if you also declared a OnPickDown
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnPickOutTrigger: number;
  10703. /**
  10704. * On long press
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnLongPressTrigger: number;
  10708. /**
  10709. * On pointer over
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnPointerOverTrigger: number;
  10713. /**
  10714. * On pointer out
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPointerOutTrigger: number;
  10718. /**
  10719. * On every frame
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnEveryFrameTrigger: number;
  10723. /**
  10724. * On intersection enter
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnIntersectionEnterTrigger: number;
  10728. /**
  10729. * On intersection exit
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnIntersectionExitTrigger: number;
  10733. /**
  10734. * On key down
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnKeyDownTrigger: number;
  10738. /**
  10739. * On key up
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnKeyUpTrigger: number;
  10743. private _scene;
  10744. /**
  10745. * Creates a new action manager
  10746. * @param scene defines the hosting scene
  10747. */
  10748. constructor(scene: Scene);
  10749. /**
  10750. * Releases all associated resources
  10751. */
  10752. dispose(): void;
  10753. /**
  10754. * Gets hosting scene
  10755. * @returns the hosting scene
  10756. */
  10757. getScene(): Scene;
  10758. /**
  10759. * Does this action manager handles actions of any of the given triggers
  10760. * @param triggers defines the triggers to be tested
  10761. * @return a boolean indicating whether one (or more) of the triggers is handled
  10762. */
  10763. hasSpecificTriggers(triggers: number[]): boolean;
  10764. /**
  10765. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10766. * speed.
  10767. * @param triggerA defines the trigger to be tested
  10768. * @param triggerB defines the trigger to be tested
  10769. * @return a boolean indicating whether one (or more) of the triggers is handled
  10770. */
  10771. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10772. /**
  10773. * Does this action manager handles actions of a given trigger
  10774. * @param trigger defines the trigger to be tested
  10775. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10776. * @return whether the trigger is handled
  10777. */
  10778. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10779. /**
  10780. * Does this action manager has pointer triggers
  10781. */
  10782. readonly hasPointerTriggers: boolean;
  10783. /**
  10784. * Does this action manager has pick triggers
  10785. */
  10786. readonly hasPickTriggers: boolean;
  10787. /**
  10788. * Registers an action to this action manager
  10789. * @param action defines the action to be registered
  10790. * @return the action amended (prepared) after registration
  10791. */
  10792. registerAction(action: IAction): Nullable<IAction>;
  10793. /**
  10794. * Unregisters an action to this action manager
  10795. * @param action defines the action to be unregistered
  10796. * @return a boolean indicating whether the action has been unregistered
  10797. */
  10798. unregisterAction(action: IAction): Boolean;
  10799. /**
  10800. * Process a specific trigger
  10801. * @param trigger defines the trigger to process
  10802. * @param evt defines the event details to be processed
  10803. */
  10804. processTrigger(trigger: number, evt?: IActionEvent): void;
  10805. /** @hidden */
  10806. _getEffectiveTarget(target: any, propertyPath: string): any;
  10807. /** @hidden */
  10808. _getProperty(propertyPath: string): string;
  10809. /**
  10810. * Serialize this manager to a JSON object
  10811. * @param name defines the property name to store this manager
  10812. * @returns a JSON representation of this manager
  10813. */
  10814. serialize(name: string): any;
  10815. /**
  10816. * Creates a new ActionManager from a JSON data
  10817. * @param parsedActions defines the JSON data to read from
  10818. * @param object defines the hosting mesh
  10819. * @param scene defines the hosting scene
  10820. */
  10821. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10822. /**
  10823. * Get a trigger name by index
  10824. * @param trigger defines the trigger index
  10825. * @returns a trigger name
  10826. */
  10827. static GetTriggerName(trigger: number): string;
  10828. }
  10829. }
  10830. declare module BABYLON {
  10831. /**
  10832. * Class representing a ray with position and direction
  10833. */
  10834. export class Ray {
  10835. /** origin point */
  10836. origin: Vector3;
  10837. /** direction */
  10838. direction: Vector3;
  10839. /** length of the ray */
  10840. length: number;
  10841. private static readonly TmpVector3;
  10842. private _tmpRay;
  10843. /**
  10844. * Creates a new ray
  10845. * @param origin origin point
  10846. * @param direction direction
  10847. * @param length length of the ray
  10848. */
  10849. constructor(
  10850. /** origin point */
  10851. origin: Vector3,
  10852. /** direction */
  10853. direction: Vector3,
  10854. /** length of the ray */
  10855. length?: number);
  10856. /**
  10857. * Checks if the ray intersects a box
  10858. * @param minimum bound of the box
  10859. * @param maximum bound of the box
  10860. * @param intersectionTreshold extra extend to be added to the box in all direction
  10861. * @returns if the box was hit
  10862. */
  10863. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10864. /**
  10865. * Checks if the ray intersects a box
  10866. * @param box the bounding box to check
  10867. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10868. * @returns if the box was hit
  10869. */
  10870. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10871. /**
  10872. * If the ray hits a sphere
  10873. * @param sphere the bounding sphere to check
  10874. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10875. * @returns true if it hits the sphere
  10876. */
  10877. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10878. /**
  10879. * If the ray hits a triange
  10880. * @param vertex0 triangle vertex
  10881. * @param vertex1 triangle vertex
  10882. * @param vertex2 triangle vertex
  10883. * @returns intersection information if hit
  10884. */
  10885. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10886. /**
  10887. * Checks if ray intersects a plane
  10888. * @param plane the plane to check
  10889. * @returns the distance away it was hit
  10890. */
  10891. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10892. /**
  10893. * Calculate the intercept of a ray on a given axis
  10894. * @param axis to check 'x' | 'y' | 'z'
  10895. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10896. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10897. */
  10898. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10899. /**
  10900. * Checks if ray intersects a mesh
  10901. * @param mesh the mesh to check
  10902. * @param fastCheck if only the bounding box should checked
  10903. * @returns picking info of the intersecton
  10904. */
  10905. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10906. /**
  10907. * Checks if ray intersects a mesh
  10908. * @param meshes the meshes to check
  10909. * @param fastCheck if only the bounding box should checked
  10910. * @param results array to store result in
  10911. * @returns Array of picking infos
  10912. */
  10913. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10914. private _comparePickingInfo;
  10915. private static smallnum;
  10916. private static rayl;
  10917. /**
  10918. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10919. * @param sega the first point of the segment to test the intersection against
  10920. * @param segb the second point of the segment to test the intersection against
  10921. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10922. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10923. */
  10924. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10925. /**
  10926. * Update the ray from viewport position
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns this ray updated
  10935. */
  10936. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * Creates a ray with origin and direction of 0,0,0
  10939. * @returns the new ray
  10940. */
  10941. static Zero(): Ray;
  10942. /**
  10943. * Creates a new ray from screen space and viewport
  10944. * @param x position
  10945. * @param y y position
  10946. * @param viewportWidth viewport width
  10947. * @param viewportHeight viewport height
  10948. * @param world world matrix
  10949. * @param view view matrix
  10950. * @param projection projection matrix
  10951. * @returns new ray
  10952. */
  10953. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10954. /**
  10955. * 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
  10956. * transformed to the given world matrix.
  10957. * @param origin The origin point
  10958. * @param end The end point
  10959. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10960. * @returns the new ray
  10961. */
  10962. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10963. /**
  10964. * Transforms a ray by a matrix
  10965. * @param ray ray to transform
  10966. * @param matrix matrix to apply
  10967. * @returns the resulting new ray
  10968. */
  10969. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10970. /**
  10971. * Transforms a ray by a matrix
  10972. * @param ray ray to transform
  10973. * @param matrix matrix to apply
  10974. * @param result ray to store result in
  10975. */
  10976. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10977. /**
  10978. * Unproject a ray from screen space to object space
  10979. * @param sourceX defines the screen space x coordinate to use
  10980. * @param sourceY defines the screen space y coordinate to use
  10981. * @param viewportWidth defines the current width of the viewport
  10982. * @param viewportHeight defines the current height of the viewport
  10983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10984. * @param view defines the view matrix to use
  10985. * @param projection defines the projection matrix to use
  10986. */
  10987. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10988. }
  10989. /**
  10990. * Type used to define predicate used to select faces when a mesh intersection is detected
  10991. */
  10992. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10993. interface Scene {
  10994. /** @hidden */
  10995. _tempPickingRay: Nullable<Ray>;
  10996. /** @hidden */
  10997. _cachedRayForTransform: Ray;
  10998. /** @hidden */
  10999. _pickWithRayInverseMatrix: Matrix;
  11000. /** @hidden */
  11001. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11002. /** @hidden */
  11003. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11004. }
  11005. }
  11006. declare module BABYLON {
  11007. /**
  11008. * Groups all the scene component constants in one place to ease maintenance.
  11009. * @hidden
  11010. */
  11011. export class SceneComponentConstants {
  11012. static readonly NAME_EFFECTLAYER: string;
  11013. static readonly NAME_LAYER: string;
  11014. static readonly NAME_LENSFLARESYSTEM: string;
  11015. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11016. static readonly NAME_PARTICLESYSTEM: string;
  11017. static readonly NAME_GAMEPAD: string;
  11018. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11019. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11020. static readonly NAME_DEPTHRENDERER: string;
  11021. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11022. static readonly NAME_SPRITE: string;
  11023. static readonly NAME_OUTLINERENDERER: string;
  11024. static readonly NAME_PROCEDURALTEXTURE: string;
  11025. static readonly NAME_SHADOWGENERATOR: string;
  11026. static readonly NAME_OCTREE: string;
  11027. static readonly NAME_PHYSICSENGINE: string;
  11028. static readonly NAME_AUDIO: string;
  11029. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11030. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11033. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11038. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11040. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11041. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11042. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11043. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11044. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11045. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11046. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11049. static readonly STEP_AFTERRENDER_AUDIO: number;
  11050. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11051. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11052. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11054. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11055. static readonly STEP_POINTERMOVE_SPRITE: number;
  11056. static readonly STEP_POINTERDOWN_SPRITE: number;
  11057. static readonly STEP_POINTERUP_SPRITE: number;
  11058. }
  11059. /**
  11060. * This represents a scene component.
  11061. *
  11062. * This is used to decouple the dependency the scene is having on the different workloads like
  11063. * layers, post processes...
  11064. */
  11065. export interface ISceneComponent {
  11066. /**
  11067. * The name of the component. Each component must have a unique name.
  11068. */
  11069. name: string;
  11070. /**
  11071. * The scene the component belongs to.
  11072. */
  11073. scene: Scene;
  11074. /**
  11075. * Register the component to one instance of a scene.
  11076. */
  11077. register(): void;
  11078. /**
  11079. * Rebuilds the elements related to this component in case of
  11080. * context lost for instance.
  11081. */
  11082. rebuild(): void;
  11083. /**
  11084. * Disposes the component and the associated ressources.
  11085. */
  11086. dispose(): void;
  11087. }
  11088. /**
  11089. * This represents a SERIALIZABLE scene component.
  11090. *
  11091. * This extends Scene Component to add Serialization methods on top.
  11092. */
  11093. export interface ISceneSerializableComponent extends ISceneComponent {
  11094. /**
  11095. * Adds all the elements from the container to the scene
  11096. * @param container the container holding the elements
  11097. */
  11098. addFromContainer(container: AbstractScene): void;
  11099. /**
  11100. * Removes all the elements in the container from the scene
  11101. * @param container contains the elements to remove
  11102. * @param dispose if the removed element should be disposed (default: false)
  11103. */
  11104. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11105. /**
  11106. * Serializes the component data to the specified json object
  11107. * @param serializationObject The object to serialize to
  11108. */
  11109. serialize(serializationObject: any): void;
  11110. }
  11111. /**
  11112. * Strong typing of a Mesh related stage step action
  11113. */
  11114. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11115. /**
  11116. * Strong typing of a Evaluate Sub Mesh related stage step action
  11117. */
  11118. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11119. /**
  11120. * Strong typing of a Active Mesh related stage step action
  11121. */
  11122. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11123. /**
  11124. * Strong typing of a Camera related stage step action
  11125. */
  11126. export type CameraStageAction = (camera: Camera) => void;
  11127. /**
  11128. * Strong typing of a Camera Frame buffer related stage step action
  11129. */
  11130. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11131. /**
  11132. * Strong typing of a Render Target related stage step action
  11133. */
  11134. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11135. /**
  11136. * Strong typing of a RenderingGroup related stage step action
  11137. */
  11138. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11139. /**
  11140. * Strong typing of a Mesh Render related stage step action
  11141. */
  11142. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11143. /**
  11144. * Strong typing of a simple stage step action
  11145. */
  11146. export type SimpleStageAction = () => void;
  11147. /**
  11148. * Strong typing of a render target action.
  11149. */
  11150. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11151. /**
  11152. * Strong typing of a pointer move action.
  11153. */
  11154. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11155. /**
  11156. * Strong typing of a pointer up/down action.
  11157. */
  11158. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11159. /**
  11160. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11161. * @hidden
  11162. */
  11163. export class Stage<T extends Function> extends Array<{
  11164. index: number;
  11165. component: ISceneComponent;
  11166. action: T;
  11167. }> {
  11168. /**
  11169. * Hide ctor from the rest of the world.
  11170. * @param items The items to add.
  11171. */
  11172. private constructor();
  11173. /**
  11174. * Creates a new Stage.
  11175. * @returns A new instance of a Stage
  11176. */
  11177. static Create<T extends Function>(): Stage<T>;
  11178. /**
  11179. * Registers a step in an ordered way in the targeted stage.
  11180. * @param index Defines the position to register the step in
  11181. * @param component Defines the component attached to the step
  11182. * @param action Defines the action to launch during the step
  11183. */
  11184. registerStep(index: number, component: ISceneComponent, action: T): void;
  11185. /**
  11186. * Clears all the steps from the stage.
  11187. */
  11188. clear(): void;
  11189. }
  11190. }
  11191. declare module BABYLON {
  11192. interface Scene {
  11193. /** @hidden */
  11194. _pointerOverSprite: Nullable<Sprite>;
  11195. /** @hidden */
  11196. _pickedDownSprite: Nullable<Sprite>;
  11197. /** @hidden */
  11198. _tempSpritePickingRay: Nullable<Ray>;
  11199. /**
  11200. * All of the sprite managers added to this scene
  11201. * @see http://doc.babylonjs.com/babylon101/sprites
  11202. */
  11203. spriteManagers: Array<ISpriteManager>;
  11204. /**
  11205. * An event triggered when sprites rendering is about to start
  11206. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11207. */
  11208. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11209. /**
  11210. * An event triggered when sprites rendering is done
  11211. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11212. */
  11213. onAfterSpritesRenderingObservable: Observable<Scene>;
  11214. /** @hidden */
  11215. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /** Launch a ray to try to pick a sprite in the scene
  11217. * @param x position on screen
  11218. * @param y position on screen
  11219. * @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
  11220. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11221. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11222. * @returns a PickingInfo
  11223. */
  11224. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11225. /** Use the given ray to pick a sprite in the scene
  11226. * @param ray The ray (in world space) to use to pick meshes
  11227. * @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
  11228. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11229. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11230. * @returns a PickingInfo
  11231. */
  11232. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11233. /** @hidden */
  11234. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11235. /** Launch a ray to try to pick sprites in the scene
  11236. * @param x position on screen
  11237. * @param y position on screen
  11238. * @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
  11239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11240. * @returns a PickingInfo array
  11241. */
  11242. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11243. /** Use the given ray to pick sprites in the scene
  11244. * @param ray The ray (in world space) to use to pick meshes
  11245. * @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
  11246. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11247. * @returns a PickingInfo array
  11248. */
  11249. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11250. /**
  11251. * Force the sprite under the pointer
  11252. * @param sprite defines the sprite to use
  11253. */
  11254. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11255. /**
  11256. * Gets the sprite under the pointer
  11257. * @returns a Sprite or null if no sprite is under the pointer
  11258. */
  11259. getPointerOverSprite(): Nullable<Sprite>;
  11260. }
  11261. /**
  11262. * Defines the sprite scene component responsible to manage sprites
  11263. * in a given scene.
  11264. */
  11265. export class SpriteSceneComponent implements ISceneComponent {
  11266. /**
  11267. * The component name helpfull to identify the component in the list of scene components.
  11268. */
  11269. readonly name: string;
  11270. /**
  11271. * The scene the component belongs to.
  11272. */
  11273. scene: Scene;
  11274. /** @hidden */
  11275. private _spritePredicate;
  11276. /**
  11277. * Creates a new instance of the component for the given scene
  11278. * @param scene Defines the scene to register the component in
  11279. */
  11280. constructor(scene: Scene);
  11281. /**
  11282. * Registers the component in a given scene
  11283. */
  11284. register(): void;
  11285. /**
  11286. * Rebuilds the elements related to this component in case of
  11287. * context lost for instance.
  11288. */
  11289. rebuild(): void;
  11290. /**
  11291. * Disposes the component and the associated ressources.
  11292. */
  11293. dispose(): void;
  11294. private _pickSpriteButKeepRay;
  11295. private _pointerMove;
  11296. private _pointerDown;
  11297. private _pointerUp;
  11298. }
  11299. }
  11300. declare module BABYLON {
  11301. /** @hidden */
  11302. export var fogFragmentDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module BABYLON {
  11308. /** @hidden */
  11309. export var fogFragment: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module BABYLON {
  11315. /** @hidden */
  11316. export var spritesPixelShader: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module BABYLON {
  11322. /** @hidden */
  11323. export var fogVertexDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module BABYLON {
  11329. /** @hidden */
  11330. export var spritesVertexShader: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module BABYLON {
  11336. /**
  11337. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11338. */
  11339. export interface ISpriteManager extends IDisposable {
  11340. /**
  11341. * Restricts the camera to viewing objects with the same layerMask.
  11342. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11343. */
  11344. layerMask: number;
  11345. /**
  11346. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11347. */
  11348. isPickable: boolean;
  11349. /**
  11350. * Specifies the rendering group id for this mesh (0 by default)
  11351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11352. */
  11353. renderingGroupId: number;
  11354. /**
  11355. * Defines the list of sprites managed by the manager.
  11356. */
  11357. sprites: Array<Sprite>;
  11358. /**
  11359. * Tests the intersection of a sprite with a specific ray.
  11360. * @param ray The ray we are sending to test the collision
  11361. * @param camera The camera space we are sending rays in
  11362. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11363. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11364. * @returns picking info or null.
  11365. */
  11366. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11367. /**
  11368. * Intersects the sprites with a ray
  11369. * @param ray defines the ray to intersect with
  11370. * @param camera defines the current active camera
  11371. * @param predicate defines a predicate used to select candidate sprites
  11372. * @returns null if no hit or a PickingInfo array
  11373. */
  11374. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11375. /**
  11376. * Renders the list of sprites on screen.
  11377. */
  11378. render(): void;
  11379. }
  11380. /**
  11381. * Class used to manage multiple sprites on the same spritesheet
  11382. * @see http://doc.babylonjs.com/babylon101/sprites
  11383. */
  11384. export class SpriteManager implements ISpriteManager {
  11385. /** defines the manager's name */
  11386. name: string;
  11387. /** Gets the list of sprites */
  11388. sprites: Sprite[];
  11389. /** Gets or sets the rendering group id (0 by default) */
  11390. renderingGroupId: number;
  11391. /** Gets or sets camera layer mask */
  11392. layerMask: number;
  11393. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11394. fogEnabled: boolean;
  11395. /** Gets or sets a boolean indicating if the sprites are pickable */
  11396. isPickable: boolean;
  11397. /** Defines the default width of a cell in the spritesheet */
  11398. cellWidth: number;
  11399. /** Defines the default height of a cell in the spritesheet */
  11400. cellHeight: number;
  11401. /** Associative array from JSON sprite data file */
  11402. private _cellData;
  11403. /** Array of sprite names from JSON sprite data file */
  11404. private _spriteMap;
  11405. /** True when packed cell data from JSON file is ready*/
  11406. private _packedAndReady;
  11407. /**
  11408. * An event triggered when the manager is disposed.
  11409. */
  11410. onDisposeObservable: Observable<SpriteManager>;
  11411. private _onDisposeObserver;
  11412. /**
  11413. * Callback called when the manager is disposed
  11414. */
  11415. onDispose: () => void;
  11416. private _capacity;
  11417. private _fromPacked;
  11418. private _spriteTexture;
  11419. private _epsilon;
  11420. private _scene;
  11421. private _vertexData;
  11422. private _buffer;
  11423. private _vertexBuffers;
  11424. private _indexBuffer;
  11425. private _effectBase;
  11426. private _effectFog;
  11427. /**
  11428. * Gets or sets the spritesheet texture
  11429. */
  11430. texture: Texture;
  11431. /**
  11432. * Creates a new sprite manager
  11433. * @param name defines the manager's name
  11434. * @param imgUrl defines the sprite sheet url
  11435. * @param capacity defines the maximum allowed number of sprites
  11436. * @param cellSize defines the size of a sprite cell
  11437. * @param scene defines the hosting scene
  11438. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11439. * @param samplingMode defines the smapling mode to use with spritesheet
  11440. * @param fromPacked set to false; do not alter
  11441. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11442. */
  11443. constructor(
  11444. /** defines the manager's name */
  11445. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11446. private _makePacked;
  11447. private _appendSpriteVertex;
  11448. /**
  11449. * Intersects the sprites with a ray
  11450. * @param ray defines the ray to intersect with
  11451. * @param camera defines the current active camera
  11452. * @param predicate defines a predicate used to select candidate sprites
  11453. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11454. * @returns null if no hit or a PickingInfo
  11455. */
  11456. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11457. /**
  11458. * Intersects the sprites with a ray
  11459. * @param ray defines the ray to intersect with
  11460. * @param camera defines the current active camera
  11461. * @param predicate defines a predicate used to select candidate sprites
  11462. * @returns null if no hit or a PickingInfo array
  11463. */
  11464. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11465. /**
  11466. * Render all child sprites
  11467. */
  11468. render(): void;
  11469. /**
  11470. * Release associated resources
  11471. */
  11472. dispose(): void;
  11473. }
  11474. }
  11475. declare module BABYLON {
  11476. /**
  11477. * Class used to represent a sprite
  11478. * @see http://doc.babylonjs.com/babylon101/sprites
  11479. */
  11480. export class Sprite {
  11481. /** defines the name */
  11482. name: string;
  11483. /** Gets or sets the current world position */
  11484. position: Vector3;
  11485. /** Gets or sets the main color */
  11486. color: Color4;
  11487. /** Gets or sets the width */
  11488. width: number;
  11489. /** Gets or sets the height */
  11490. height: number;
  11491. /** Gets or sets rotation angle */
  11492. angle: number;
  11493. /** Gets or sets the cell index in the sprite sheet */
  11494. cellIndex: number;
  11495. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11496. cellRef: string;
  11497. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11498. invertU: number;
  11499. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11500. invertV: number;
  11501. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11502. disposeWhenFinishedAnimating: boolean;
  11503. /** Gets the list of attached animations */
  11504. animations: Animation[];
  11505. /** Gets or sets a boolean indicating if the sprite can be picked */
  11506. isPickable: boolean;
  11507. /**
  11508. * Gets or sets the associated action manager
  11509. */
  11510. actionManager: Nullable<ActionManager>;
  11511. private _animationStarted;
  11512. private _loopAnimation;
  11513. private _fromIndex;
  11514. private _toIndex;
  11515. private _delay;
  11516. private _direction;
  11517. private _manager;
  11518. private _time;
  11519. private _onAnimationEnd;
  11520. /**
  11521. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11522. */
  11523. isVisible: boolean;
  11524. /**
  11525. * Gets or sets the sprite size
  11526. */
  11527. size: number;
  11528. /**
  11529. * Creates a new Sprite
  11530. * @param name defines the name
  11531. * @param manager defines the manager
  11532. */
  11533. constructor(
  11534. /** defines the name */
  11535. name: string, manager: ISpriteManager);
  11536. /**
  11537. * Starts an animation
  11538. * @param from defines the initial key
  11539. * @param to defines the end key
  11540. * @param loop defines if the animation must loop
  11541. * @param delay defines the start delay (in ms)
  11542. * @param onAnimationEnd defines a callback to call when animation ends
  11543. */
  11544. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11545. /** Stops current animation (if any) */
  11546. stopAnimation(): void;
  11547. /** @hidden */
  11548. _animate(deltaTime: number): void;
  11549. /** Release associated resources */
  11550. dispose(): void;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Information about the result of picking within a scene
  11556. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11557. */
  11558. export class PickingInfo {
  11559. /** @hidden */
  11560. _pickingUnavailable: boolean;
  11561. /**
  11562. * If the pick collided with an object
  11563. */
  11564. hit: boolean;
  11565. /**
  11566. * Distance away where the pick collided
  11567. */
  11568. distance: number;
  11569. /**
  11570. * The location of pick collision
  11571. */
  11572. pickedPoint: Nullable<Vector3>;
  11573. /**
  11574. * The mesh corresponding the the pick collision
  11575. */
  11576. pickedMesh: Nullable<AbstractMesh>;
  11577. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11578. bu: number;
  11579. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11580. bv: number;
  11581. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11582. faceId: number;
  11583. /** Id of the the submesh that was picked */
  11584. subMeshId: number;
  11585. /** If a sprite was picked, this will be the sprite the pick collided with */
  11586. pickedSprite: Nullable<Sprite>;
  11587. /**
  11588. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11589. */
  11590. originMesh: Nullable<AbstractMesh>;
  11591. /**
  11592. * The ray that was used to perform the picking.
  11593. */
  11594. ray: Nullable<Ray>;
  11595. /**
  11596. * Gets the normal correspodning to the face the pick collided with
  11597. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11598. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11599. * @returns The normal correspodning to the face the pick collided with
  11600. */
  11601. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11602. /**
  11603. * Gets the texture coordinates of where the pick occured
  11604. * @returns the vector containing the coordnates of the texture
  11605. */
  11606. getTextureCoordinates(): Nullable<Vector2>;
  11607. }
  11608. }
  11609. declare module BABYLON {
  11610. /**
  11611. * Gather the list of pointer event types as constants.
  11612. */
  11613. export class PointerEventTypes {
  11614. /**
  11615. * 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.
  11616. */
  11617. static readonly POINTERDOWN: number;
  11618. /**
  11619. * The pointerup event is fired when a pointer is no longer active.
  11620. */
  11621. static readonly POINTERUP: number;
  11622. /**
  11623. * The pointermove event is fired when a pointer changes coordinates.
  11624. */
  11625. static readonly POINTERMOVE: number;
  11626. /**
  11627. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11628. */
  11629. static readonly POINTERWHEEL: number;
  11630. /**
  11631. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11632. */
  11633. static readonly POINTERPICK: number;
  11634. /**
  11635. * The pointertap event is fired when a the object has been touched and released without drag.
  11636. */
  11637. static readonly POINTERTAP: number;
  11638. /**
  11639. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11640. */
  11641. static readonly POINTERDOUBLETAP: number;
  11642. }
  11643. /**
  11644. * Base class of pointer info types.
  11645. */
  11646. export class PointerInfoBase {
  11647. /**
  11648. * Defines the type of event (PointerEventTypes)
  11649. */
  11650. type: number;
  11651. /**
  11652. * Defines the related dom event
  11653. */
  11654. event: PointerEvent | MouseWheelEvent;
  11655. /**
  11656. * Instantiates the base class of pointers info.
  11657. * @param type Defines the type of event (PointerEventTypes)
  11658. * @param event Defines the related dom event
  11659. */
  11660. constructor(
  11661. /**
  11662. * Defines the type of event (PointerEventTypes)
  11663. */
  11664. type: number,
  11665. /**
  11666. * Defines the related dom event
  11667. */
  11668. event: PointerEvent | MouseWheelEvent);
  11669. }
  11670. /**
  11671. * This class is used to store pointer related info for the onPrePointerObservable event.
  11672. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11673. */
  11674. export class PointerInfoPre extends PointerInfoBase {
  11675. /**
  11676. * Ray from a pointer if availible (eg. 6dof controller)
  11677. */
  11678. ray: Nullable<Ray>;
  11679. /**
  11680. * Defines the local position of the pointer on the canvas.
  11681. */
  11682. localPosition: Vector2;
  11683. /**
  11684. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11685. */
  11686. skipOnPointerObservable: boolean;
  11687. /**
  11688. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11689. * @param type Defines the type of event (PointerEventTypes)
  11690. * @param event Defines the related dom event
  11691. * @param localX Defines the local x coordinates of the pointer when the event occured
  11692. * @param localY Defines the local y coordinates of the pointer when the event occured
  11693. */
  11694. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11695. }
  11696. /**
  11697. * This type contains all the data related to a pointer event in Babylon.js.
  11698. * 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.
  11699. */
  11700. export class PointerInfo extends PointerInfoBase {
  11701. /**
  11702. * Defines the picking info associated to the info (if any)\
  11703. */
  11704. pickInfo: Nullable<PickingInfo>;
  11705. /**
  11706. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11707. * @param type Defines the type of event (PointerEventTypes)
  11708. * @param event Defines the related dom event
  11709. * @param pickInfo Defines the picking info associated to the info (if any)\
  11710. */
  11711. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11712. /**
  11713. * Defines the picking info associated to the info (if any)\
  11714. */
  11715. pickInfo: Nullable<PickingInfo>);
  11716. }
  11717. /**
  11718. * Data relating to a touch event on the screen.
  11719. */
  11720. export interface PointerTouch {
  11721. /**
  11722. * X coordinate of touch.
  11723. */
  11724. x: number;
  11725. /**
  11726. * Y coordinate of touch.
  11727. */
  11728. y: number;
  11729. /**
  11730. * Id of touch. Unique for each finger.
  11731. */
  11732. pointerId: number;
  11733. /**
  11734. * Event type passed from DOM.
  11735. */
  11736. type: any;
  11737. }
  11738. }
  11739. declare module BABYLON {
  11740. /**
  11741. * Manage the mouse inputs to control the movement of a free camera.
  11742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11743. */
  11744. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11745. /**
  11746. * Define if touch is enabled in the mouse input
  11747. */
  11748. touchEnabled: boolean;
  11749. /**
  11750. * Defines the camera the input is attached to.
  11751. */
  11752. camera: FreeCamera;
  11753. /**
  11754. * Defines the buttons associated with the input to handle camera move.
  11755. */
  11756. buttons: number[];
  11757. /**
  11758. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11759. */
  11760. angularSensibility: number;
  11761. private _pointerInput;
  11762. private _onMouseMove;
  11763. private _observer;
  11764. private previousPosition;
  11765. /**
  11766. * Observable for when a pointer move event occurs containing the move offset
  11767. */
  11768. onPointerMovedObservable: Observable<{
  11769. offsetX: number;
  11770. offsetY: number;
  11771. }>;
  11772. /**
  11773. * @hidden
  11774. * If the camera should be rotated automatically based on pointer movement
  11775. */
  11776. _allowCameraRotation: boolean;
  11777. /**
  11778. * Manage the mouse inputs to control the movement of a free camera.
  11779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11780. * @param touchEnabled Defines if touch is enabled or not
  11781. */
  11782. constructor(
  11783. /**
  11784. * Define if touch is enabled in the mouse input
  11785. */
  11786. touchEnabled?: boolean);
  11787. /**
  11788. * Attach the input controls to a specific dom element to get the input from.
  11789. * @param element Defines the element the controls should be listened from
  11790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11791. */
  11792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11793. /**
  11794. * Called on JS contextmenu event.
  11795. * Override this method to provide functionality.
  11796. */
  11797. protected onContextMenu(evt: PointerEvent): void;
  11798. /**
  11799. * Detach the current controls from the specified dom element.
  11800. * @param element Defines the element to stop listening the inputs from
  11801. */
  11802. detachControl(element: Nullable<HTMLElement>): void;
  11803. /**
  11804. * Gets the class name of the current intput.
  11805. * @returns the class name
  11806. */
  11807. getClassName(): string;
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. getSimpleName(): string;
  11813. }
  11814. }
  11815. declare module BABYLON {
  11816. /**
  11817. * Manage the touch inputs to control the movement of a free camera.
  11818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11819. */
  11820. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11821. /**
  11822. * Defines the camera the input is attached to.
  11823. */
  11824. camera: FreeCamera;
  11825. /**
  11826. * Defines the touch sensibility for rotation.
  11827. * The higher the faster.
  11828. */
  11829. touchAngularSensibility: number;
  11830. /**
  11831. * Defines the touch sensibility for move.
  11832. * The higher the faster.
  11833. */
  11834. touchMoveSensibility: number;
  11835. private _offsetX;
  11836. private _offsetY;
  11837. private _pointerPressed;
  11838. private _pointerInput;
  11839. private _observer;
  11840. private _onLostFocus;
  11841. /**
  11842. * Attach the input controls to a specific dom element to get the input from.
  11843. * @param element Defines the element the controls should be listened from
  11844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11845. */
  11846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11847. /**
  11848. * Detach the current controls from the specified dom element.
  11849. * @param element Defines the element to stop listening the inputs from
  11850. */
  11851. detachControl(element: Nullable<HTMLElement>): void;
  11852. /**
  11853. * Update the current camera state depending on the inputs that have been used this frame.
  11854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11855. */
  11856. checkInputs(): void;
  11857. /**
  11858. * Gets the class name of the current intput.
  11859. * @returns the class name
  11860. */
  11861. getClassName(): string;
  11862. /**
  11863. * Get the friendly name associated with the input class.
  11864. * @returns the input friendly name
  11865. */
  11866. getSimpleName(): string;
  11867. }
  11868. }
  11869. declare module BABYLON {
  11870. /**
  11871. * Default Inputs manager for the FreeCamera.
  11872. * It groups all the default supported inputs for ease of use.
  11873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11874. */
  11875. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11876. /**
  11877. * @hidden
  11878. */
  11879. _mouseInput: Nullable<FreeCameraMouseInput>;
  11880. /**
  11881. * Instantiates a new FreeCameraInputsManager.
  11882. * @param camera Defines the camera the inputs belong to
  11883. */
  11884. constructor(camera: FreeCamera);
  11885. /**
  11886. * Add keyboard input support to the input manager.
  11887. * @returns the current input manager
  11888. */
  11889. addKeyboard(): FreeCameraInputsManager;
  11890. /**
  11891. * Add mouse input support to the input manager.
  11892. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11893. * @returns the current input manager
  11894. */
  11895. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11896. /**
  11897. * Removes the mouse input support from the manager
  11898. * @returns the current input manager
  11899. */
  11900. removeMouse(): FreeCameraInputsManager;
  11901. /**
  11902. * Add touch input support to the input manager.
  11903. * @returns the current input manager
  11904. */
  11905. addTouch(): FreeCameraInputsManager;
  11906. /**
  11907. * Remove all attached input methods from a camera
  11908. */
  11909. clear(): void;
  11910. }
  11911. }
  11912. declare module BABYLON {
  11913. /**
  11914. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11915. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11917. */
  11918. export class FreeCamera extends TargetCamera {
  11919. /**
  11920. * Define the collision ellipsoid of the camera.
  11921. * This is helpful to simulate a camera body like the player body around the camera
  11922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11923. */
  11924. ellipsoid: Vector3;
  11925. /**
  11926. * Define an offset for the position of the ellipsoid around the camera.
  11927. * This can be helpful to determine the center of the body near the gravity center of the body
  11928. * instead of its head.
  11929. */
  11930. ellipsoidOffset: Vector3;
  11931. /**
  11932. * Enable or disable collisions of the camera with the rest of the scene objects.
  11933. */
  11934. checkCollisions: boolean;
  11935. /**
  11936. * Enable or disable gravity on the camera.
  11937. */
  11938. applyGravity: boolean;
  11939. /**
  11940. * Define the input manager associated to the camera.
  11941. */
  11942. inputs: FreeCameraInputsManager;
  11943. /**
  11944. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11945. * Higher values reduce sensitivity.
  11946. */
  11947. /**
  11948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11949. * Higher values reduce sensitivity.
  11950. */
  11951. angularSensibility: number;
  11952. /**
  11953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11954. */
  11955. keysUp: number[];
  11956. /**
  11957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11958. */
  11959. keysDown: number[];
  11960. /**
  11961. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11962. */
  11963. keysLeft: number[];
  11964. /**
  11965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11966. */
  11967. keysRight: number[];
  11968. /**
  11969. * Event raised when the camera collide with a mesh in the scene.
  11970. */
  11971. onCollide: (collidedMesh: AbstractMesh) => void;
  11972. private _collider;
  11973. private _needMoveForGravity;
  11974. private _oldPosition;
  11975. private _diffPosition;
  11976. private _newPosition;
  11977. /** @hidden */
  11978. _localDirection: Vector3;
  11979. /** @hidden */
  11980. _transformedDirection: Vector3;
  11981. /**
  11982. * Instantiates a Free Camera.
  11983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11984. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11985. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11986. * @param name Define the name of the camera in the scene
  11987. * @param position Define the start position of the camera in the scene
  11988. * @param scene Define the scene the camera belongs to
  11989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11990. */
  11991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11992. /**
  11993. * Attached controls to the current camera.
  11994. * @param element Defines the element the controls should be listened from
  11995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11996. */
  11997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11998. /**
  11999. * Detach the current controls from the camera.
  12000. * The camera will stop reacting to inputs.
  12001. * @param element Defines the element to stop listening the inputs from
  12002. */
  12003. detachControl(element: HTMLElement): void;
  12004. private _collisionMask;
  12005. /**
  12006. * Define a collision mask to limit the list of object the camera can collide with
  12007. */
  12008. collisionMask: number;
  12009. /** @hidden */
  12010. _collideWithWorld(displacement: Vector3): void;
  12011. private _onCollisionPositionChange;
  12012. /** @hidden */
  12013. _checkInputs(): void;
  12014. /** @hidden */
  12015. _decideIfNeedsToMove(): boolean;
  12016. /** @hidden */
  12017. _updatePosition(): void;
  12018. /**
  12019. * Destroy the camera and release the current resources hold by it.
  12020. */
  12021. dispose(): void;
  12022. /**
  12023. * Gets the current object class name.
  12024. * @return the class name
  12025. */
  12026. getClassName(): string;
  12027. }
  12028. }
  12029. declare module BABYLON {
  12030. /**
  12031. * Represents a gamepad control stick position
  12032. */
  12033. export class StickValues {
  12034. /**
  12035. * The x component of the control stick
  12036. */
  12037. x: number;
  12038. /**
  12039. * The y component of the control stick
  12040. */
  12041. y: number;
  12042. /**
  12043. * Initializes the gamepad x and y control stick values
  12044. * @param x The x component of the gamepad control stick value
  12045. * @param y The y component of the gamepad control stick value
  12046. */
  12047. constructor(
  12048. /**
  12049. * The x component of the control stick
  12050. */
  12051. x: number,
  12052. /**
  12053. * The y component of the control stick
  12054. */
  12055. y: number);
  12056. }
  12057. /**
  12058. * An interface which manages callbacks for gamepad button changes
  12059. */
  12060. export interface GamepadButtonChanges {
  12061. /**
  12062. * Called when a gamepad has been changed
  12063. */
  12064. changed: boolean;
  12065. /**
  12066. * Called when a gamepad press event has been triggered
  12067. */
  12068. pressChanged: boolean;
  12069. /**
  12070. * Called when a touch event has been triggered
  12071. */
  12072. touchChanged: boolean;
  12073. /**
  12074. * Called when a value has changed
  12075. */
  12076. valueChanged: boolean;
  12077. }
  12078. /**
  12079. * Represents a gamepad
  12080. */
  12081. export class Gamepad {
  12082. /**
  12083. * The id of the gamepad
  12084. */
  12085. id: string;
  12086. /**
  12087. * The index of the gamepad
  12088. */
  12089. index: number;
  12090. /**
  12091. * The browser gamepad
  12092. */
  12093. browserGamepad: any;
  12094. /**
  12095. * Specifies what type of gamepad this represents
  12096. */
  12097. type: number;
  12098. private _leftStick;
  12099. private _rightStick;
  12100. /** @hidden */
  12101. _isConnected: boolean;
  12102. private _leftStickAxisX;
  12103. private _leftStickAxisY;
  12104. private _rightStickAxisX;
  12105. private _rightStickAxisY;
  12106. /**
  12107. * Triggered when the left control stick has been changed
  12108. */
  12109. private _onleftstickchanged;
  12110. /**
  12111. * Triggered when the right control stick has been changed
  12112. */
  12113. private _onrightstickchanged;
  12114. /**
  12115. * Represents a gamepad controller
  12116. */
  12117. static GAMEPAD: number;
  12118. /**
  12119. * Represents a generic controller
  12120. */
  12121. static GENERIC: number;
  12122. /**
  12123. * Represents an XBox controller
  12124. */
  12125. static XBOX: number;
  12126. /**
  12127. * Represents a pose-enabled controller
  12128. */
  12129. static POSE_ENABLED: number;
  12130. /**
  12131. * Represents an Dual Shock controller
  12132. */
  12133. static DUALSHOCK: number;
  12134. /**
  12135. * Specifies whether the left control stick should be Y-inverted
  12136. */
  12137. protected _invertLeftStickY: boolean;
  12138. /**
  12139. * Specifies if the gamepad has been connected
  12140. */
  12141. readonly isConnected: boolean;
  12142. /**
  12143. * Initializes the gamepad
  12144. * @param id The id of the gamepad
  12145. * @param index The index of the gamepad
  12146. * @param browserGamepad The browser gamepad
  12147. * @param leftStickX The x component of the left joystick
  12148. * @param leftStickY The y component of the left joystick
  12149. * @param rightStickX The x component of the right joystick
  12150. * @param rightStickY The y component of the right joystick
  12151. */
  12152. constructor(
  12153. /**
  12154. * The id of the gamepad
  12155. */
  12156. id: string,
  12157. /**
  12158. * The index of the gamepad
  12159. */
  12160. index: number,
  12161. /**
  12162. * The browser gamepad
  12163. */
  12164. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12165. /**
  12166. * Callback triggered when the left joystick has changed
  12167. * @param callback
  12168. */
  12169. onleftstickchanged(callback: (values: StickValues) => void): void;
  12170. /**
  12171. * Callback triggered when the right joystick has changed
  12172. * @param callback
  12173. */
  12174. onrightstickchanged(callback: (values: StickValues) => void): void;
  12175. /**
  12176. * Gets the left joystick
  12177. */
  12178. /**
  12179. * Sets the left joystick values
  12180. */
  12181. leftStick: StickValues;
  12182. /**
  12183. * Gets the right joystick
  12184. */
  12185. /**
  12186. * Sets the right joystick value
  12187. */
  12188. rightStick: StickValues;
  12189. /**
  12190. * Updates the gamepad joystick positions
  12191. */
  12192. update(): void;
  12193. /**
  12194. * Disposes the gamepad
  12195. */
  12196. dispose(): void;
  12197. }
  12198. /**
  12199. * Represents a generic gamepad
  12200. */
  12201. export class GenericPad extends Gamepad {
  12202. private _buttons;
  12203. private _onbuttondown;
  12204. private _onbuttonup;
  12205. /**
  12206. * Observable triggered when a button has been pressed
  12207. */
  12208. onButtonDownObservable: Observable<number>;
  12209. /**
  12210. * Observable triggered when a button has been released
  12211. */
  12212. onButtonUpObservable: Observable<number>;
  12213. /**
  12214. * Callback triggered when a button has been pressed
  12215. * @param callback Called when a button has been pressed
  12216. */
  12217. onbuttondown(callback: (buttonPressed: number) => void): void;
  12218. /**
  12219. * Callback triggered when a button has been released
  12220. * @param callback Called when a button has been released
  12221. */
  12222. onbuttonup(callback: (buttonReleased: number) => void): void;
  12223. /**
  12224. * Initializes the generic gamepad
  12225. * @param id The id of the generic gamepad
  12226. * @param index The index of the generic gamepad
  12227. * @param browserGamepad The browser gamepad
  12228. */
  12229. constructor(id: string, index: number, browserGamepad: any);
  12230. private _setButtonValue;
  12231. /**
  12232. * Updates the generic gamepad
  12233. */
  12234. update(): void;
  12235. /**
  12236. * Disposes the generic gamepad
  12237. */
  12238. dispose(): void;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. interface Engine {
  12243. /**
  12244. * Creates a raw texture
  12245. * @param data defines the data to store in the texture
  12246. * @param width defines the width of the texture
  12247. * @param height defines the height of the texture
  12248. * @param format defines the format of the data
  12249. * @param generateMipMaps defines if the engine should generate the mip levels
  12250. * @param invertY defines if data must be stored with Y axis inverted
  12251. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12252. * @param compression defines the compression used (null by default)
  12253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12254. * @returns the raw texture inside an InternalTexture
  12255. */
  12256. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12257. /**
  12258. * Update a raw texture
  12259. * @param texture defines the texture to update
  12260. * @param data defines the data to store in the texture
  12261. * @param format defines the format of the data
  12262. * @param invertY defines if data must be stored with Y axis inverted
  12263. */
  12264. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12265. /**
  12266. * Update a raw texture
  12267. * @param texture defines the texture to update
  12268. * @param data defines the data to store in the texture
  12269. * @param format defines the format of the data
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param compression defines the compression used (null by default)
  12272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12273. */
  12274. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12275. /**
  12276. * Creates a new raw cube texture
  12277. * @param data defines the array of data to use to create each face
  12278. * @param size defines the size of the textures
  12279. * @param format defines the format of the data
  12280. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12281. * @param generateMipMaps defines if the engine should generate the mip levels
  12282. * @param invertY defines if data must be stored with Y axis inverted
  12283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12284. * @param compression defines the compression used (null by default)
  12285. * @returns the cube texture as an InternalTexture
  12286. */
  12287. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12288. /**
  12289. * Update a raw cube texture
  12290. * @param texture defines the texture to udpdate
  12291. * @param data defines the data to store
  12292. * @param format defines the data format
  12293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12294. * @param invertY defines if data must be stored with Y axis inverted
  12295. */
  12296. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12297. /**
  12298. * Update a raw cube texture
  12299. * @param texture defines the texture to udpdate
  12300. * @param data defines the data to store
  12301. * @param format defines the data format
  12302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @param compression defines the compression used (null by default)
  12305. */
  12306. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12307. /**
  12308. * Update a raw cube texture
  12309. * @param texture defines the texture to udpdate
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12313. * @param invertY defines if data must be stored with Y axis inverted
  12314. * @param compression defines the compression used (null by default)
  12315. * @param level defines which level of the texture to update
  12316. */
  12317. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12318. /**
  12319. * Creates a new raw cube texture from a specified url
  12320. * @param url defines the url where the data is located
  12321. * @param scene defines the current scene
  12322. * @param size defines the size of the textures
  12323. * @param format defines the format of the data
  12324. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12325. * @param noMipmap defines if the engine should avoid generating the mip levels
  12326. * @param callback defines a callback used to extract texture data from loaded data
  12327. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12328. * @param onLoad defines a callback called when texture is loaded
  12329. * @param onError defines a callback called if there is an error
  12330. * @returns the cube texture as an InternalTexture
  12331. */
  12332. 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;
  12333. /**
  12334. * Creates a new raw cube texture from a specified url
  12335. * @param url defines the url where the data is located
  12336. * @param scene defines the current scene
  12337. * @param size defines the size of the textures
  12338. * @param format defines the format of the data
  12339. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12340. * @param noMipmap defines if the engine should avoid generating the mip levels
  12341. * @param callback defines a callback used to extract texture data from loaded data
  12342. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12343. * @param onLoad defines a callback called when texture is loaded
  12344. * @param onError defines a callback called if there is an error
  12345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12346. * @param invertY defines if data must be stored with Y axis inverted
  12347. * @returns the cube texture as an InternalTexture
  12348. */
  12349. 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;
  12350. /**
  12351. * Creates a new raw 3D texture
  12352. * @param data defines the data used to create the texture
  12353. * @param width defines the width of the texture
  12354. * @param height defines the height of the texture
  12355. * @param depth defines the depth of the texture
  12356. * @param format defines the format of the texture
  12357. * @param generateMipMaps defines if the engine must generate mip levels
  12358. * @param invertY defines if data must be stored with Y axis inverted
  12359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12360. * @param compression defines the compressed used (can be null)
  12361. * @param textureType defines the compressed used (can be null)
  12362. * @returns a new raw 3D texture (stored in an InternalTexture)
  12363. */
  12364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12365. /**
  12366. * Update a raw 3D texture
  12367. * @param texture defines the texture to update
  12368. * @param data defines the data to store
  12369. * @param format defines the data format
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. */
  12372. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12373. /**
  12374. * Update a raw 3D texture
  12375. * @param texture defines the texture to update
  12376. * @param data defines the data to store
  12377. * @param format defines the data format
  12378. * @param invertY defines if data must be stored with Y axis inverted
  12379. * @param compression defines the used compression (can be null)
  12380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12381. */
  12382. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12383. }
  12384. }
  12385. declare module BABYLON {
  12386. /**
  12387. * Raw texture can help creating a texture directly from an array of data.
  12388. * This can be super useful if you either get the data from an uncompressed source or
  12389. * if you wish to create your texture pixel by pixel.
  12390. */
  12391. export class RawTexture extends Texture {
  12392. /**
  12393. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12394. */
  12395. format: number;
  12396. private _engine;
  12397. /**
  12398. * Instantiates a new RawTexture.
  12399. * Raw texture can help creating a texture directly from an array of data.
  12400. * This can be super useful if you either get the data from an uncompressed source or
  12401. * if you wish to create your texture pixel by pixel.
  12402. * @param data define the array of data to use to create the texture
  12403. * @param width define the width of the texture
  12404. * @param height define the height of the texture
  12405. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12406. * @param scene define the scene the texture belongs to
  12407. * @param generateMipMaps define whether mip maps should be generated or not
  12408. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12409. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12410. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12411. */
  12412. constructor(data: ArrayBufferView, width: number, height: number,
  12413. /**
  12414. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12415. */
  12416. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12417. /**
  12418. * Updates the texture underlying data.
  12419. * @param data Define the new data of the texture
  12420. */
  12421. update(data: ArrayBufferView): void;
  12422. /**
  12423. * Creates a luminance texture from some data.
  12424. * @param data Define the texture data
  12425. * @param width Define the width of the texture
  12426. * @param height Define the height of the texture
  12427. * @param scene Define the scene the texture belongs to
  12428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12431. * @returns the luminance texture
  12432. */
  12433. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12434. /**
  12435. * Creates a luminance alpha texture from some data.
  12436. * @param data Define the texture data
  12437. * @param width Define the width of the texture
  12438. * @param height Define the height of the texture
  12439. * @param scene Define the scene the texture belongs to
  12440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12443. * @returns the luminance alpha texture
  12444. */
  12445. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12446. /**
  12447. * Creates an alpha texture from some data.
  12448. * @param data Define the texture data
  12449. * @param width Define the width of the texture
  12450. * @param height Define the height of the texture
  12451. * @param scene Define the scene the texture belongs to
  12452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12455. * @returns the alpha texture
  12456. */
  12457. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12458. /**
  12459. * Creates a RGB texture from some data.
  12460. * @param data Define the texture data
  12461. * @param width Define the width of the texture
  12462. * @param height Define the height of the texture
  12463. * @param scene Define the scene the texture belongs to
  12464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12468. * @returns the RGB alpha texture
  12469. */
  12470. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12471. /**
  12472. * Creates a RGBA texture from some data.
  12473. * @param data Define the texture data
  12474. * @param width Define the width of the texture
  12475. * @param height Define the height of the texture
  12476. * @param scene Define the scene the texture belongs to
  12477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12481. * @returns the RGBA texture
  12482. */
  12483. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12484. /**
  12485. * Creates a R texture from some data.
  12486. * @param data Define the texture data
  12487. * @param width Define the width of the texture
  12488. * @param height Define the height of the texture
  12489. * @param scene Define the scene the texture belongs to
  12490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12494. * @returns the R texture
  12495. */
  12496. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Interface for the size containing width and height
  12502. */
  12503. export interface ISize {
  12504. /**
  12505. * Width
  12506. */
  12507. width: number;
  12508. /**
  12509. * Heighht
  12510. */
  12511. height: number;
  12512. }
  12513. /**
  12514. * Size containing widht and height
  12515. */
  12516. export class Size implements ISize {
  12517. /**
  12518. * Width
  12519. */
  12520. width: number;
  12521. /**
  12522. * Height
  12523. */
  12524. height: number;
  12525. /**
  12526. * Creates a Size object from the given width and height (floats).
  12527. * @param width width of the new size
  12528. * @param height height of the new size
  12529. */
  12530. constructor(width: number, height: number);
  12531. /**
  12532. * Returns a string with the Size width and height
  12533. * @returns a string with the Size width and height
  12534. */
  12535. toString(): string;
  12536. /**
  12537. * "Size"
  12538. * @returns the string "Size"
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Returns the Size hash code.
  12543. * @returns a hash code for a unique width and height
  12544. */
  12545. getHashCode(): number;
  12546. /**
  12547. * Updates the current size from the given one.
  12548. * @param src the given size
  12549. */
  12550. copyFrom(src: Size): void;
  12551. /**
  12552. * Updates in place the current Size from the given floats.
  12553. * @param width width of the new size
  12554. * @param height height of the new size
  12555. * @returns the updated Size.
  12556. */
  12557. copyFromFloats(width: number, height: number): Size;
  12558. /**
  12559. * Updates in place the current Size from the given floats.
  12560. * @param width width to set
  12561. * @param height height to set
  12562. * @returns the updated Size.
  12563. */
  12564. set(width: number, height: number): Size;
  12565. /**
  12566. * Multiplies the width and height by numbers
  12567. * @param w factor to multiple the width by
  12568. * @param h factor to multiple the height by
  12569. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12570. */
  12571. multiplyByFloats(w: number, h: number): Size;
  12572. /**
  12573. * Clones the size
  12574. * @returns a new Size copied from the given one.
  12575. */
  12576. clone(): Size;
  12577. /**
  12578. * True if the current Size and the given one width and height are strictly equal.
  12579. * @param other the other size to compare against
  12580. * @returns True if the current Size and the given one width and height are strictly equal.
  12581. */
  12582. equals(other: Size): boolean;
  12583. /**
  12584. * The surface of the Size : width * height (float).
  12585. */
  12586. readonly surface: number;
  12587. /**
  12588. * Create a new size of zero
  12589. * @returns a new Size set to (0.0, 0.0)
  12590. */
  12591. static Zero(): Size;
  12592. /**
  12593. * Sums the width and height of two sizes
  12594. * @param otherSize size to add to this size
  12595. * @returns a new Size set as the addition result of the current Size and the given one.
  12596. */
  12597. add(otherSize: Size): Size;
  12598. /**
  12599. * Subtracts the width and height of two
  12600. * @param otherSize size to subtract to this size
  12601. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12602. */
  12603. subtract(otherSize: Size): Size;
  12604. /**
  12605. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12606. * @param start starting size to lerp between
  12607. * @param end end size to lerp between
  12608. * @param amount amount to lerp between the start and end values
  12609. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12610. */
  12611. static Lerp(start: Size, end: Size, amount: number): Size;
  12612. }
  12613. }
  12614. declare module BABYLON {
  12615. /**
  12616. * Defines a runtime animation
  12617. */
  12618. export class RuntimeAnimation {
  12619. private _events;
  12620. /**
  12621. * The current frame of the runtime animation
  12622. */
  12623. private _currentFrame;
  12624. /**
  12625. * The animation used by the runtime animation
  12626. */
  12627. private _animation;
  12628. /**
  12629. * The target of the runtime animation
  12630. */
  12631. private _target;
  12632. /**
  12633. * The initiating animatable
  12634. */
  12635. private _host;
  12636. /**
  12637. * The original value of the runtime animation
  12638. */
  12639. private _originalValue;
  12640. /**
  12641. * The original blend value of the runtime animation
  12642. */
  12643. private _originalBlendValue;
  12644. /**
  12645. * The offsets cache of the runtime animation
  12646. */
  12647. private _offsetsCache;
  12648. /**
  12649. * The high limits cache of the runtime animation
  12650. */
  12651. private _highLimitsCache;
  12652. /**
  12653. * Specifies if the runtime animation has been stopped
  12654. */
  12655. private _stopped;
  12656. /**
  12657. * The blending factor of the runtime animation
  12658. */
  12659. private _blendingFactor;
  12660. /**
  12661. * The BabylonJS scene
  12662. */
  12663. private _scene;
  12664. /**
  12665. * The current value of the runtime animation
  12666. */
  12667. private _currentValue;
  12668. /** @hidden */
  12669. _animationState: _IAnimationState;
  12670. /**
  12671. * The active target of the runtime animation
  12672. */
  12673. private _activeTargets;
  12674. private _currentActiveTarget;
  12675. private _directTarget;
  12676. /**
  12677. * The target path of the runtime animation
  12678. */
  12679. private _targetPath;
  12680. /**
  12681. * The weight of the runtime animation
  12682. */
  12683. private _weight;
  12684. /**
  12685. * The ratio offset of the runtime animation
  12686. */
  12687. private _ratioOffset;
  12688. /**
  12689. * The previous delay of the runtime animation
  12690. */
  12691. private _previousDelay;
  12692. /**
  12693. * The previous ratio of the runtime animation
  12694. */
  12695. private _previousRatio;
  12696. private _enableBlending;
  12697. private _keys;
  12698. private _minFrame;
  12699. private _maxFrame;
  12700. private _minValue;
  12701. private _maxValue;
  12702. private _targetIsArray;
  12703. /**
  12704. * Gets the current frame of the runtime animation
  12705. */
  12706. readonly currentFrame: number;
  12707. /**
  12708. * Gets the weight of the runtime animation
  12709. */
  12710. readonly weight: number;
  12711. /**
  12712. * Gets the current value of the runtime animation
  12713. */
  12714. readonly currentValue: any;
  12715. /**
  12716. * Gets the target path of the runtime animation
  12717. */
  12718. readonly targetPath: string;
  12719. /**
  12720. * Gets the actual target of the runtime animation
  12721. */
  12722. readonly target: any;
  12723. /** @hidden */
  12724. _onLoop: () => void;
  12725. /**
  12726. * Create a new RuntimeAnimation object
  12727. * @param target defines the target of the animation
  12728. * @param animation defines the source animation object
  12729. * @param scene defines the hosting scene
  12730. * @param host defines the initiating Animatable
  12731. */
  12732. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12733. private _preparePath;
  12734. /**
  12735. * Gets the animation from the runtime animation
  12736. */
  12737. readonly animation: Animation;
  12738. /**
  12739. * Resets the runtime animation to the beginning
  12740. * @param restoreOriginal defines whether to restore the target property to the original value
  12741. */
  12742. reset(restoreOriginal?: boolean): void;
  12743. /**
  12744. * Specifies if the runtime animation is stopped
  12745. * @returns Boolean specifying if the runtime animation is stopped
  12746. */
  12747. isStopped(): boolean;
  12748. /**
  12749. * Disposes of the runtime animation
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Apply the interpolated value to the target
  12754. * @param currentValue defines the value computed by the animation
  12755. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12756. */
  12757. setValue(currentValue: any, weight: number): void;
  12758. private _getOriginalValues;
  12759. private _setValue;
  12760. /**
  12761. * Gets the loop pmode of the runtime animation
  12762. * @returns Loop Mode
  12763. */
  12764. private _getCorrectLoopMode;
  12765. /**
  12766. * Move the current animation to a given frame
  12767. * @param frame defines the frame to move to
  12768. */
  12769. goToFrame(frame: number): void;
  12770. /**
  12771. * @hidden Internal use only
  12772. */
  12773. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12774. /**
  12775. * Execute the current animation
  12776. * @param delay defines the delay to add to the current frame
  12777. * @param from defines the lower bound of the animation range
  12778. * @param to defines the upper bound of the animation range
  12779. * @param loop defines if the current animation must loop
  12780. * @param speedRatio defines the current speed ratio
  12781. * @param weight defines the weight of the animation (default is -1 so no weight)
  12782. * @param onLoop optional callback called when animation loops
  12783. * @returns a boolean indicating if the animation is running
  12784. */
  12785. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12786. }
  12787. }
  12788. declare module BABYLON {
  12789. /**
  12790. * Class used to store an actual running animation
  12791. */
  12792. export class Animatable {
  12793. /** defines the target object */
  12794. target: any;
  12795. /** defines the starting frame number (default is 0) */
  12796. fromFrame: number;
  12797. /** defines the ending frame number (default is 100) */
  12798. toFrame: number;
  12799. /** defines if the animation must loop (default is false) */
  12800. loopAnimation: boolean;
  12801. /** defines a callback to call when animation ends if it is not looping */
  12802. onAnimationEnd?: (() => void) | null | undefined;
  12803. /** defines a callback to call when animation loops */
  12804. onAnimationLoop?: (() => void) | null | undefined;
  12805. private _localDelayOffset;
  12806. private _pausedDelay;
  12807. private _runtimeAnimations;
  12808. private _paused;
  12809. private _scene;
  12810. private _speedRatio;
  12811. private _weight;
  12812. private _syncRoot;
  12813. /**
  12814. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12815. * This will only apply for non looping animation (default is true)
  12816. */
  12817. disposeOnEnd: boolean;
  12818. /**
  12819. * Gets a boolean indicating if the animation has started
  12820. */
  12821. animationStarted: boolean;
  12822. /**
  12823. * Observer raised when the animation ends
  12824. */
  12825. onAnimationEndObservable: Observable<Animatable>;
  12826. /**
  12827. * Observer raised when the animation loops
  12828. */
  12829. onAnimationLoopObservable: Observable<Animatable>;
  12830. /**
  12831. * Gets the root Animatable used to synchronize and normalize animations
  12832. */
  12833. readonly syncRoot: Nullable<Animatable>;
  12834. /**
  12835. * Gets the current frame of the first RuntimeAnimation
  12836. * Used to synchronize Animatables
  12837. */
  12838. readonly masterFrame: number;
  12839. /**
  12840. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12841. */
  12842. weight: number;
  12843. /**
  12844. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12845. */
  12846. speedRatio: number;
  12847. /**
  12848. * Creates a new Animatable
  12849. * @param scene defines the hosting scene
  12850. * @param target defines the target object
  12851. * @param fromFrame defines the starting frame number (default is 0)
  12852. * @param toFrame defines the ending frame number (default is 100)
  12853. * @param loopAnimation defines if the animation must loop (default is false)
  12854. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12855. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12856. * @param animations defines a group of animation to add to the new Animatable
  12857. * @param onAnimationLoop defines a callback to call when animation loops
  12858. */
  12859. constructor(scene: Scene,
  12860. /** defines the target object */
  12861. target: any,
  12862. /** defines the starting frame number (default is 0) */
  12863. fromFrame?: number,
  12864. /** defines the ending frame number (default is 100) */
  12865. toFrame?: number,
  12866. /** defines if the animation must loop (default is false) */
  12867. loopAnimation?: boolean, speedRatio?: number,
  12868. /** defines a callback to call when animation ends if it is not looping */
  12869. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12870. /** defines a callback to call when animation loops */
  12871. onAnimationLoop?: (() => void) | null | undefined);
  12872. /**
  12873. * Synchronize and normalize current Animatable with a source Animatable
  12874. * This is useful when using animation weights and when animations are not of the same length
  12875. * @param root defines the root Animatable to synchronize with
  12876. * @returns the current Animatable
  12877. */
  12878. syncWith(root: Animatable): Animatable;
  12879. /**
  12880. * Gets the list of runtime animations
  12881. * @returns an array of RuntimeAnimation
  12882. */
  12883. getAnimations(): RuntimeAnimation[];
  12884. /**
  12885. * Adds more animations to the current animatable
  12886. * @param target defines the target of the animations
  12887. * @param animations defines the new animations to add
  12888. */
  12889. appendAnimations(target: any, animations: Animation[]): void;
  12890. /**
  12891. * Gets the source animation for a specific property
  12892. * @param property defines the propertyu to look for
  12893. * @returns null or the source animation for the given property
  12894. */
  12895. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12896. /**
  12897. * Gets the runtime animation for a specific property
  12898. * @param property defines the propertyu to look for
  12899. * @returns null or the runtime animation for the given property
  12900. */
  12901. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12902. /**
  12903. * Resets the animatable to its original state
  12904. */
  12905. reset(): void;
  12906. /**
  12907. * Allows the animatable to blend with current running animations
  12908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12909. * @param blendingSpeed defines the blending speed to use
  12910. */
  12911. enableBlending(blendingSpeed: number): void;
  12912. /**
  12913. * Disable animation blending
  12914. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12915. */
  12916. disableBlending(): void;
  12917. /**
  12918. * Jump directly to a given frame
  12919. * @param frame defines the frame to jump to
  12920. */
  12921. goToFrame(frame: number): void;
  12922. /**
  12923. * Pause the animation
  12924. */
  12925. pause(): void;
  12926. /**
  12927. * Restart the animation
  12928. */
  12929. restart(): void;
  12930. private _raiseOnAnimationEnd;
  12931. /**
  12932. * Stop and delete the current animation
  12933. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12934. * @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)
  12935. */
  12936. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12937. /**
  12938. * Wait asynchronously for the animation to end
  12939. * @returns a promise which will be fullfilled when the animation ends
  12940. */
  12941. waitAsync(): Promise<Animatable>;
  12942. /** @hidden */
  12943. _animate(delay: number): boolean;
  12944. }
  12945. interface Scene {
  12946. /** @hidden */
  12947. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12948. /** @hidden */
  12949. _processLateAnimationBindingsForMatrices(holder: {
  12950. totalWeight: number;
  12951. animations: RuntimeAnimation[];
  12952. originalValue: Matrix;
  12953. }): any;
  12954. /** @hidden */
  12955. _processLateAnimationBindingsForQuaternions(holder: {
  12956. totalWeight: number;
  12957. animations: RuntimeAnimation[];
  12958. originalValue: Quaternion;
  12959. }, refQuaternion: Quaternion): Quaternion;
  12960. /** @hidden */
  12961. _processLateAnimationBindings(): void;
  12962. /**
  12963. * Will start the animation sequence of a given target
  12964. * @param target defines the target
  12965. * @param from defines from which frame should animation start
  12966. * @param to defines until which frame should animation run.
  12967. * @param weight defines the weight to apply to the animation (1.0 by default)
  12968. * @param loop defines if the animation loops
  12969. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12970. * @param onAnimationEnd defines the function to be executed when the animation ends
  12971. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12972. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12973. * @param onAnimationLoop defines the callback to call when an animation loops
  12974. * @returns the animatable object created for this animation
  12975. */
  12976. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12977. /**
  12978. * Will start the animation sequence of a given target
  12979. * @param target defines the target
  12980. * @param from defines from which frame should animation start
  12981. * @param to defines until which frame should animation run.
  12982. * @param loop defines if the animation loops
  12983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12984. * @param onAnimationEnd defines the function to be executed when the animation ends
  12985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12986. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12987. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12988. * @param onAnimationLoop defines the callback to call when an animation loops
  12989. * @returns the animatable object created for this animation
  12990. */
  12991. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12992. /**
  12993. * Will start the animation sequence of a given target and its hierarchy
  12994. * @param target defines the target
  12995. * @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.
  12996. * @param from defines from which frame should animation start
  12997. * @param to defines until which frame should animation run.
  12998. * @param loop defines if the animation loops
  12999. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13000. * @param onAnimationEnd defines the function to be executed when the animation ends
  13001. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13002. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13003. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13004. * @param onAnimationLoop defines the callback to call when an animation loops
  13005. * @returns the list of created animatables
  13006. */
  13007. 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[];
  13008. /**
  13009. * Begin a new animation on a given node
  13010. * @param target defines the target where the animation will take place
  13011. * @param animations defines the list of animations to start
  13012. * @param from defines the initial value
  13013. * @param to defines the final value
  13014. * @param loop defines if you want animation to loop (off by default)
  13015. * @param speedRatio defines the speed ratio to apply to all animations
  13016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13017. * @param onAnimationLoop defines the callback to call when an animation loops
  13018. * @returns the list of created animatables
  13019. */
  13020. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13021. /**
  13022. * Begin a new animation on a given node and its hierarchy
  13023. * @param target defines the root node where the animation will take place
  13024. * @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.
  13025. * @param animations defines the list of animations to start
  13026. * @param from defines the initial value
  13027. * @param to defines the final value
  13028. * @param loop defines if you want animation to loop (off by default)
  13029. * @param speedRatio defines the speed ratio to apply to all animations
  13030. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13031. * @param onAnimationLoop defines the callback to call when an animation loops
  13032. * @returns the list of animatables created for all nodes
  13033. */
  13034. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13035. /**
  13036. * Gets the animatable associated with a specific target
  13037. * @param target defines the target of the animatable
  13038. * @returns the required animatable if found
  13039. */
  13040. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13041. /**
  13042. * Gets all animatables associated with a given target
  13043. * @param target defines the target to look animatables for
  13044. * @returns an array of Animatables
  13045. */
  13046. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13047. /**
  13048. * Stops and removes all animations that have been applied to the scene
  13049. */
  13050. stopAllAnimations(): void;
  13051. }
  13052. interface Bone {
  13053. /**
  13054. * Copy an animation range from another bone
  13055. * @param source defines the source bone
  13056. * @param rangeName defines the range name to copy
  13057. * @param frameOffset defines the frame offset
  13058. * @param rescaleAsRequired defines if rescaling must be applied if required
  13059. * @param skelDimensionsRatio defines the scaling ratio
  13060. * @returns true if operation was successful
  13061. */
  13062. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Class used to override all child animations of a given target
  13068. */
  13069. export class AnimationPropertiesOverride {
  13070. /**
  13071. * Gets or sets a value indicating if animation blending must be used
  13072. */
  13073. enableBlending: boolean;
  13074. /**
  13075. * Gets or sets the blending speed to use when enableBlending is true
  13076. */
  13077. blendingSpeed: number;
  13078. /**
  13079. * Gets or sets the default loop mode to use
  13080. */
  13081. loopMode: number;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * Class used to handle skinning animations
  13087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13088. */
  13089. export class Skeleton implements IAnimatable {
  13090. /** defines the skeleton name */
  13091. name: string;
  13092. /** defines the skeleton Id */
  13093. id: string;
  13094. /**
  13095. * Defines the list of child bones
  13096. */
  13097. bones: Bone[];
  13098. /**
  13099. * Defines an estimate of the dimension of the skeleton at rest
  13100. */
  13101. dimensionsAtRest: Vector3;
  13102. /**
  13103. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13104. */
  13105. needInitialSkinMatrix: boolean;
  13106. /**
  13107. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13108. */
  13109. overrideMesh: Nullable<AbstractMesh>;
  13110. /**
  13111. * Gets the list of animations attached to this skeleton
  13112. */
  13113. animations: Array<Animation>;
  13114. private _scene;
  13115. private _isDirty;
  13116. private _transformMatrices;
  13117. private _transformMatrixTexture;
  13118. private _meshesWithPoseMatrix;
  13119. private _animatables;
  13120. private _identity;
  13121. private _synchronizedWithMesh;
  13122. private _ranges;
  13123. private _lastAbsoluteTransformsUpdateId;
  13124. private _canUseTextureForBones;
  13125. private _uniqueId;
  13126. /** @hidden */
  13127. _numBonesWithLinkedTransformNode: number;
  13128. /** @hidden */
  13129. _hasWaitingData: Nullable<boolean>;
  13130. /**
  13131. * Specifies if the skeleton should be serialized
  13132. */
  13133. doNotSerialize: boolean;
  13134. private _useTextureToStoreBoneMatrices;
  13135. /**
  13136. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13137. * Please note that this option is not available if the hardware does not support it
  13138. */
  13139. useTextureToStoreBoneMatrices: boolean;
  13140. private _animationPropertiesOverride;
  13141. /**
  13142. * Gets or sets the animation properties override
  13143. */
  13144. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13145. /**
  13146. * List of inspectable custom properties (used by the Inspector)
  13147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13148. */
  13149. inspectableCustomProperties: IInspectable[];
  13150. /**
  13151. * An observable triggered before computing the skeleton's matrices
  13152. */
  13153. onBeforeComputeObservable: Observable<Skeleton>;
  13154. /**
  13155. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13156. */
  13157. readonly isUsingTextureForMatrices: boolean;
  13158. /**
  13159. * Gets the unique ID of this skeleton
  13160. */
  13161. readonly uniqueId: number;
  13162. /**
  13163. * Creates a new skeleton
  13164. * @param name defines the skeleton name
  13165. * @param id defines the skeleton Id
  13166. * @param scene defines the hosting scene
  13167. */
  13168. constructor(
  13169. /** defines the skeleton name */
  13170. name: string,
  13171. /** defines the skeleton Id */
  13172. id: string, scene: Scene);
  13173. /**
  13174. * Gets the current object class name.
  13175. * @return the class name
  13176. */
  13177. getClassName(): string;
  13178. /**
  13179. * Returns an array containing the root bones
  13180. * @returns an array containing the root bones
  13181. */
  13182. getChildren(): Array<Bone>;
  13183. /**
  13184. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13185. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13186. * @returns a Float32Array containing matrices data
  13187. */
  13188. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13189. /**
  13190. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13191. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13192. * @returns a raw texture containing the data
  13193. */
  13194. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13195. /**
  13196. * Gets the current hosting scene
  13197. * @returns a scene object
  13198. */
  13199. getScene(): Scene;
  13200. /**
  13201. * Gets a string representing the current skeleton data
  13202. * @param fullDetails defines a boolean indicating if we want a verbose version
  13203. * @returns a string representing the current skeleton data
  13204. */
  13205. toString(fullDetails?: boolean): string;
  13206. /**
  13207. * Get bone's index searching by name
  13208. * @param name defines bone's name to search for
  13209. * @return the indice of the bone. Returns -1 if not found
  13210. */
  13211. getBoneIndexByName(name: string): number;
  13212. /**
  13213. * Creater a new animation range
  13214. * @param name defines the name of the range
  13215. * @param from defines the start key
  13216. * @param to defines the end key
  13217. */
  13218. createAnimationRange(name: string, from: number, to: number): void;
  13219. /**
  13220. * Delete a specific animation range
  13221. * @param name defines the name of the range
  13222. * @param deleteFrames defines if frames must be removed as well
  13223. */
  13224. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13225. /**
  13226. * Gets a specific animation range
  13227. * @param name defines the name of the range to look for
  13228. * @returns the requested animation range or null if not found
  13229. */
  13230. getAnimationRange(name: string): Nullable<AnimationRange>;
  13231. /**
  13232. * Gets the list of all animation ranges defined on this skeleton
  13233. * @returns an array
  13234. */
  13235. getAnimationRanges(): Nullable<AnimationRange>[];
  13236. /**
  13237. * Copy animation range from a source skeleton.
  13238. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13239. * @param source defines the source skeleton
  13240. * @param name defines the name of the range to copy
  13241. * @param rescaleAsRequired defines if rescaling must be applied if required
  13242. * @returns true if operation was successful
  13243. */
  13244. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13245. /**
  13246. * Forces the skeleton to go to rest pose
  13247. */
  13248. returnToRest(): void;
  13249. private _getHighestAnimationFrame;
  13250. /**
  13251. * Begin a specific animation range
  13252. * @param name defines the name of the range to start
  13253. * @param loop defines if looping must be turned on (false by default)
  13254. * @param speedRatio defines the speed ratio to apply (1 by default)
  13255. * @param onAnimationEnd defines a callback which will be called when animation will end
  13256. * @returns a new animatable
  13257. */
  13258. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13259. /** @hidden */
  13260. _markAsDirty(): void;
  13261. /** @hidden */
  13262. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13263. /** @hidden */
  13264. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13265. private _computeTransformMatrices;
  13266. /**
  13267. * Build all resources required to render a skeleton
  13268. */
  13269. prepare(): void;
  13270. /**
  13271. * Gets the list of animatables currently running for this skeleton
  13272. * @returns an array of animatables
  13273. */
  13274. getAnimatables(): IAnimatable[];
  13275. /**
  13276. * Clone the current skeleton
  13277. * @param name defines the name of the new skeleton
  13278. * @param id defines the id of the new skeleton
  13279. * @returns the new skeleton
  13280. */
  13281. clone(name: string, id: string): Skeleton;
  13282. /**
  13283. * Enable animation blending for this skeleton
  13284. * @param blendingSpeed defines the blending speed to apply
  13285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13286. */
  13287. enableBlending(blendingSpeed?: number): void;
  13288. /**
  13289. * Releases all resources associated with the current skeleton
  13290. */
  13291. dispose(): void;
  13292. /**
  13293. * Serialize the skeleton in a JSON object
  13294. * @returns a JSON object
  13295. */
  13296. serialize(): any;
  13297. /**
  13298. * Creates a new skeleton from serialized data
  13299. * @param parsedSkeleton defines the serialized data
  13300. * @param scene defines the hosting scene
  13301. * @returns a new skeleton
  13302. */
  13303. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13304. /**
  13305. * Compute all node absolute transforms
  13306. * @param forceUpdate defines if computation must be done even if cache is up to date
  13307. */
  13308. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13309. /**
  13310. * Gets the root pose matrix
  13311. * @returns a matrix
  13312. */
  13313. getPoseMatrix(): Nullable<Matrix>;
  13314. /**
  13315. * Sorts bones per internal index
  13316. */
  13317. sortBones(): void;
  13318. private _sortBones;
  13319. }
  13320. }
  13321. declare module BABYLON {
  13322. /**
  13323. * Class used to store bone information
  13324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13325. */
  13326. export class Bone extends Node {
  13327. /**
  13328. * defines the bone name
  13329. */
  13330. name: string;
  13331. private static _tmpVecs;
  13332. private static _tmpQuat;
  13333. private static _tmpMats;
  13334. /**
  13335. * Gets the list of child bones
  13336. */
  13337. children: Bone[];
  13338. /** Gets the animations associated with this bone */
  13339. animations: Animation[];
  13340. /**
  13341. * Gets or sets bone length
  13342. */
  13343. length: number;
  13344. /**
  13345. * @hidden Internal only
  13346. * Set this value to map this bone to a different index in the transform matrices
  13347. * Set this value to -1 to exclude the bone from the transform matrices
  13348. */
  13349. _index: Nullable<number>;
  13350. private _skeleton;
  13351. private _localMatrix;
  13352. private _restPose;
  13353. private _baseMatrix;
  13354. private _absoluteTransform;
  13355. private _invertedAbsoluteTransform;
  13356. private _parent;
  13357. private _scalingDeterminant;
  13358. private _worldTransform;
  13359. private _localScaling;
  13360. private _localRotation;
  13361. private _localPosition;
  13362. private _needToDecompose;
  13363. private _needToCompose;
  13364. /** @hidden */
  13365. _linkedTransformNode: Nullable<TransformNode>;
  13366. /** @hidden */
  13367. _waitingTransformNodeId: Nullable<string>;
  13368. /** @hidden */
  13369. /** @hidden */
  13370. _matrix: Matrix;
  13371. /**
  13372. * Create a new bone
  13373. * @param name defines the bone name
  13374. * @param skeleton defines the parent skeleton
  13375. * @param parentBone defines the parent (can be null if the bone is the root)
  13376. * @param localMatrix defines the local matrix
  13377. * @param restPose defines the rest pose matrix
  13378. * @param baseMatrix defines the base matrix
  13379. * @param index defines index of the bone in the hiearchy
  13380. */
  13381. constructor(
  13382. /**
  13383. * defines the bone name
  13384. */
  13385. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13386. /**
  13387. * Gets the current object class name.
  13388. * @return the class name
  13389. */
  13390. getClassName(): string;
  13391. /**
  13392. * Gets the parent skeleton
  13393. * @returns a skeleton
  13394. */
  13395. getSkeleton(): Skeleton;
  13396. /**
  13397. * Gets parent bone
  13398. * @returns a bone or null if the bone is the root of the bone hierarchy
  13399. */
  13400. getParent(): Nullable<Bone>;
  13401. /**
  13402. * Returns an array containing the root bones
  13403. * @returns an array containing the root bones
  13404. */
  13405. getChildren(): Array<Bone>;
  13406. /**
  13407. * Sets the parent bone
  13408. * @param parent defines the parent (can be null if the bone is the root)
  13409. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13410. */
  13411. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13412. /**
  13413. * Gets the local matrix
  13414. * @returns a matrix
  13415. */
  13416. getLocalMatrix(): Matrix;
  13417. /**
  13418. * Gets the base matrix (initial matrix which remains unchanged)
  13419. * @returns a matrix
  13420. */
  13421. getBaseMatrix(): Matrix;
  13422. /**
  13423. * Gets the rest pose matrix
  13424. * @returns a matrix
  13425. */
  13426. getRestPose(): Matrix;
  13427. /**
  13428. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13429. */
  13430. getWorldMatrix(): Matrix;
  13431. /**
  13432. * Sets the local matrix to rest pose matrix
  13433. */
  13434. returnToRest(): void;
  13435. /**
  13436. * Gets the inverse of the absolute transform matrix.
  13437. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13438. * @returns a matrix
  13439. */
  13440. getInvertedAbsoluteTransform(): Matrix;
  13441. /**
  13442. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13443. * @returns a matrix
  13444. */
  13445. getAbsoluteTransform(): Matrix;
  13446. /**
  13447. * Links with the given transform node.
  13448. * The local matrix of this bone is copied from the transform node every frame.
  13449. * @param transformNode defines the transform node to link to
  13450. */
  13451. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13452. /**
  13453. * Gets the node used to drive the bone's transformation
  13454. * @returns a transform node or null
  13455. */
  13456. getTransformNode(): Nullable<TransformNode>;
  13457. /** Gets or sets current position (in local space) */
  13458. position: Vector3;
  13459. /** Gets or sets current rotation (in local space) */
  13460. rotation: Vector3;
  13461. /** Gets or sets current rotation quaternion (in local space) */
  13462. rotationQuaternion: Quaternion;
  13463. /** Gets or sets current scaling (in local space) */
  13464. scaling: Vector3;
  13465. /**
  13466. * Gets the animation properties override
  13467. */
  13468. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13469. private _decompose;
  13470. private _compose;
  13471. /**
  13472. * Update the base and local matrices
  13473. * @param matrix defines the new base or local matrix
  13474. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13475. * @param updateLocalMatrix defines if the local matrix should be updated
  13476. */
  13477. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13478. /** @hidden */
  13479. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13480. /**
  13481. * Flag the bone as dirty (Forcing it to update everything)
  13482. */
  13483. markAsDirty(): void;
  13484. /** @hidden */
  13485. _markAsDirtyAndCompose(): void;
  13486. private _markAsDirtyAndDecompose;
  13487. /**
  13488. * Translate the bone in local or world space
  13489. * @param vec The amount to translate the bone
  13490. * @param space The space that the translation is in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. */
  13493. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13494. /**
  13495. * Set the postion of the bone in local or world space
  13496. * @param position The position to set the bone
  13497. * @param space The space that the position is in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. */
  13500. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13501. /**
  13502. * Set the absolute position of the bone (world space)
  13503. * @param position The position to set the bone
  13504. * @param mesh The mesh that this bone is attached to
  13505. */
  13506. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13507. /**
  13508. * Scale the bone on the x, y and z axes (in local space)
  13509. * @param x The amount to scale the bone on the x axis
  13510. * @param y The amount to scale the bone on the y axis
  13511. * @param z The amount to scale the bone on the z axis
  13512. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13513. */
  13514. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13515. /**
  13516. * Set the bone scaling in local space
  13517. * @param scale defines the scaling vector
  13518. */
  13519. setScale(scale: Vector3): void;
  13520. /**
  13521. * Gets the current scaling in local space
  13522. * @returns the current scaling vector
  13523. */
  13524. getScale(): Vector3;
  13525. /**
  13526. * Gets the current scaling in local space and stores it in a target vector
  13527. * @param result defines the target vector
  13528. */
  13529. getScaleToRef(result: Vector3): void;
  13530. /**
  13531. * Set the yaw, pitch, and roll of the bone in local or world space
  13532. * @param yaw The rotation of the bone on the y axis
  13533. * @param pitch The rotation of the bone on the x axis
  13534. * @param roll The rotation of the bone on the z axis
  13535. * @param space The space that the axes of rotation are in
  13536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13537. */
  13538. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13539. /**
  13540. * Add a rotation to the bone on an axis in local or world space
  13541. * @param axis The axis to rotate the bone on
  13542. * @param amount The amount to rotate the bone
  13543. * @param space The space that the axis is in
  13544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13545. */
  13546. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13547. /**
  13548. * Set the rotation of the bone to a particular axis angle in local or world space
  13549. * @param axis The axis to rotate the bone on
  13550. * @param angle The angle that the bone should be rotated to
  13551. * @param space The space that the axis is in
  13552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13553. */
  13554. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13555. /**
  13556. * Set the euler rotation of the bone in local of world space
  13557. * @param rotation The euler rotation that the bone should be set to
  13558. * @param space The space that the rotation is in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. */
  13561. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13562. /**
  13563. * Set the quaternion rotation of the bone in local of world space
  13564. * @param quat The quaternion rotation that the bone should be set to
  13565. * @param space The space that the rotation is in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. */
  13568. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13569. /**
  13570. * Set the rotation matrix of the bone in local of world space
  13571. * @param rotMat The rotation matrix that the bone should be set to
  13572. * @param space The space that the rotation is in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. */
  13575. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13576. private _rotateWithMatrix;
  13577. private _getNegativeRotationToRef;
  13578. /**
  13579. * Get the position of the bone in local or world space
  13580. * @param space The space that the returned position is in
  13581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13582. * @returns The position of the bone
  13583. */
  13584. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13585. /**
  13586. * Copy the position of the bone to a vector3 in local or world space
  13587. * @param space The space that the returned position is in
  13588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13589. * @param result The vector3 to copy the position to
  13590. */
  13591. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13592. /**
  13593. * Get the absolute position of the bone (world space)
  13594. * @param mesh The mesh that this bone is attached to
  13595. * @returns The absolute position of the bone
  13596. */
  13597. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13598. /**
  13599. * Copy the absolute position of the bone (world space) to the result param
  13600. * @param mesh The mesh that this bone is attached to
  13601. * @param result The vector3 to copy the absolute position to
  13602. */
  13603. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13604. /**
  13605. * Compute the absolute transforms of this bone and its children
  13606. */
  13607. computeAbsoluteTransforms(): void;
  13608. /**
  13609. * Get the world direction from an axis that is in the local space of the bone
  13610. * @param localAxis The local direction that is used to compute the world direction
  13611. * @param mesh The mesh that this bone is attached to
  13612. * @returns The world direction
  13613. */
  13614. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13615. /**
  13616. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13617. * @param localAxis The local direction that is used to compute the world direction
  13618. * @param mesh The mesh that this bone is attached to
  13619. * @param result The vector3 that the world direction will be copied to
  13620. */
  13621. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13622. /**
  13623. * Get the euler rotation of the bone in local or world space
  13624. * @param space The space that the rotation should be in
  13625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13626. * @returns The euler rotation
  13627. */
  13628. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13629. /**
  13630. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13631. * @param space The space that the rotation should be in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. * @param result The vector3 that the rotation should be copied to
  13634. */
  13635. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13636. /**
  13637. * Get the quaternion rotation of the bone in either local or world space
  13638. * @param space The space that the rotation should be in
  13639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13640. * @returns The quaternion rotation
  13641. */
  13642. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13643. /**
  13644. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13645. * @param space The space that the rotation should be in
  13646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13647. * @param result The quaternion that the rotation should be copied to
  13648. */
  13649. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13650. /**
  13651. * Get the rotation matrix of the bone in local or world space
  13652. * @param space The space that the rotation should be in
  13653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13654. * @returns The rotation matrix
  13655. */
  13656. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13657. /**
  13658. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13659. * @param space The space that the rotation should be in
  13660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13661. * @param result The quaternion that the rotation should be copied to
  13662. */
  13663. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13664. /**
  13665. * Get the world position of a point that is in the local space of the bone
  13666. * @param position The local position
  13667. * @param mesh The mesh that this bone is attached to
  13668. * @returns The world position
  13669. */
  13670. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13671. /**
  13672. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13673. * @param position The local position
  13674. * @param mesh The mesh that this bone is attached to
  13675. * @param result The vector3 that the world position should be copied to
  13676. */
  13677. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13678. /**
  13679. * Get the local position of a point that is in world space
  13680. * @param position The world position
  13681. * @param mesh The mesh that this bone is attached to
  13682. * @returns The local position
  13683. */
  13684. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13685. /**
  13686. * Get the local position of a point that is in world space and copy it to the result param
  13687. * @param position The world position
  13688. * @param mesh The mesh that this bone is attached to
  13689. * @param result The vector3 that the local position should be copied to
  13690. */
  13691. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13692. }
  13693. }
  13694. declare module BABYLON {
  13695. /**
  13696. * 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.
  13697. * @see https://doc.babylonjs.com/how_to/transformnode
  13698. */
  13699. export class TransformNode extends Node {
  13700. /**
  13701. * Object will not rotate to face the camera
  13702. */
  13703. static BILLBOARDMODE_NONE: number;
  13704. /**
  13705. * Object will rotate to face the camera but only on the x axis
  13706. */
  13707. static BILLBOARDMODE_X: number;
  13708. /**
  13709. * Object will rotate to face the camera but only on the y axis
  13710. */
  13711. static BILLBOARDMODE_Y: number;
  13712. /**
  13713. * Object will rotate to face the camera but only on the z axis
  13714. */
  13715. static BILLBOARDMODE_Z: number;
  13716. /**
  13717. * Object will rotate to face the camera
  13718. */
  13719. static BILLBOARDMODE_ALL: number;
  13720. /**
  13721. * Object will rotate to face the camera's position instead of orientation
  13722. */
  13723. static BILLBOARDMODE_USE_POSITION: number;
  13724. private _forward;
  13725. private _forwardInverted;
  13726. private _up;
  13727. private _right;
  13728. private _rightInverted;
  13729. private _position;
  13730. private _rotation;
  13731. private _rotationQuaternion;
  13732. protected _scaling: Vector3;
  13733. protected _isDirty: boolean;
  13734. private _transformToBoneReferal;
  13735. private _isAbsoluteSynced;
  13736. private _billboardMode;
  13737. /**
  13738. * Gets or sets the billboard mode. Default is 0.
  13739. *
  13740. * | Value | Type | Description |
  13741. * | --- | --- | --- |
  13742. * | 0 | BILLBOARDMODE_NONE | |
  13743. * | 1 | BILLBOARDMODE_X | |
  13744. * | 2 | BILLBOARDMODE_Y | |
  13745. * | 4 | BILLBOARDMODE_Z | |
  13746. * | 7 | BILLBOARDMODE_ALL | |
  13747. *
  13748. */
  13749. billboardMode: number;
  13750. private _preserveParentRotationForBillboard;
  13751. /**
  13752. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13753. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13754. */
  13755. preserveParentRotationForBillboard: boolean;
  13756. /**
  13757. * 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
  13758. */
  13759. scalingDeterminant: number;
  13760. private _infiniteDistance;
  13761. /**
  13762. * Gets or sets the distance of the object to max, often used by skybox
  13763. */
  13764. infiniteDistance: boolean;
  13765. /**
  13766. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13767. * By default the system will update normals to compensate
  13768. */
  13769. ignoreNonUniformScaling: boolean;
  13770. /**
  13771. * 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
  13772. */
  13773. reIntegrateRotationIntoRotationQuaternion: boolean;
  13774. /** @hidden */
  13775. _poseMatrix: Nullable<Matrix>;
  13776. /** @hidden */
  13777. _localMatrix: Matrix;
  13778. private _usePivotMatrix;
  13779. private _absolutePosition;
  13780. private _absoluteScaling;
  13781. private _absoluteRotationQuaternion;
  13782. private _pivotMatrix;
  13783. private _pivotMatrixInverse;
  13784. protected _postMultiplyPivotMatrix: boolean;
  13785. protected _isWorldMatrixFrozen: boolean;
  13786. /** @hidden */
  13787. _indexInSceneTransformNodesArray: number;
  13788. /**
  13789. * An event triggered after the world matrix is updated
  13790. */
  13791. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13792. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13793. /**
  13794. * Gets a string identifying the name of the class
  13795. * @returns "TransformNode" string
  13796. */
  13797. getClassName(): string;
  13798. /**
  13799. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13800. */
  13801. position: Vector3;
  13802. /**
  13803. * 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)).
  13804. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13805. */
  13806. rotation: Vector3;
  13807. /**
  13808. * 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)).
  13809. */
  13810. scaling: Vector3;
  13811. /**
  13812. * 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).
  13813. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13814. */
  13815. rotationQuaternion: Nullable<Quaternion>;
  13816. /**
  13817. * The forward direction of that transform in world space.
  13818. */
  13819. readonly forward: Vector3;
  13820. /**
  13821. * The up direction of that transform in world space.
  13822. */
  13823. readonly up: Vector3;
  13824. /**
  13825. * The right direction of that transform in world space.
  13826. */
  13827. readonly right: Vector3;
  13828. /**
  13829. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13830. * @param matrix the matrix to copy the pose from
  13831. * @returns this TransformNode.
  13832. */
  13833. updatePoseMatrix(matrix: Matrix): TransformNode;
  13834. /**
  13835. * Returns the mesh Pose matrix.
  13836. * @returns the pose matrix
  13837. */
  13838. getPoseMatrix(): Matrix;
  13839. /** @hidden */
  13840. _isSynchronized(): boolean;
  13841. /** @hidden */
  13842. _initCache(): void;
  13843. /**
  13844. * Flag the transform node as dirty (Forcing it to update everything)
  13845. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13846. * @returns this transform node
  13847. */
  13848. markAsDirty(property: string): TransformNode;
  13849. /**
  13850. * Returns the current mesh absolute position.
  13851. * Returns a Vector3.
  13852. */
  13853. readonly absolutePosition: Vector3;
  13854. /**
  13855. * Returns the current mesh absolute scaling.
  13856. * Returns a Vector3.
  13857. */
  13858. readonly absoluteScaling: Vector3;
  13859. /**
  13860. * Returns the current mesh absolute rotation.
  13861. * Returns a Quaternion.
  13862. */
  13863. readonly absoluteRotationQuaternion: Quaternion;
  13864. /**
  13865. * Sets a new matrix to apply before all other transformation
  13866. * @param matrix defines the transform matrix
  13867. * @returns the current TransformNode
  13868. */
  13869. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13870. /**
  13871. * Sets a new pivot matrix to the current node
  13872. * @param matrix defines the new pivot matrix to use
  13873. * @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
  13874. * @returns the current TransformNode
  13875. */
  13876. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13877. /**
  13878. * Returns the mesh pivot matrix.
  13879. * Default : Identity.
  13880. * @returns the matrix
  13881. */
  13882. getPivotMatrix(): Matrix;
  13883. /**
  13884. * Instantiate (when possible) or clone that node with its hierarchy
  13885. * @param newParent defines the new parent to use for the instance (or clone)
  13886. * @returns an instance (or a clone) of the current node with its hiearchy
  13887. */
  13888. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13889. /**
  13890. * Prevents the World matrix to be computed any longer
  13891. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13892. * @returns the TransformNode.
  13893. */
  13894. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13895. /**
  13896. * Allows back the World matrix computation.
  13897. * @returns the TransformNode.
  13898. */
  13899. unfreezeWorldMatrix(): this;
  13900. /**
  13901. * True if the World matrix has been frozen.
  13902. */
  13903. readonly isWorldMatrixFrozen: boolean;
  13904. /**
  13905. * Retuns the mesh absolute position in the World.
  13906. * @returns a Vector3.
  13907. */
  13908. getAbsolutePosition(): Vector3;
  13909. /**
  13910. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13911. * @param absolutePosition the absolute position to set
  13912. * @returns the TransformNode.
  13913. */
  13914. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13915. /**
  13916. * Sets the mesh position in its local space.
  13917. * @param vector3 the position to set in localspace
  13918. * @returns the TransformNode.
  13919. */
  13920. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13921. /**
  13922. * Returns the mesh position in the local space from the current World matrix values.
  13923. * @returns a new Vector3.
  13924. */
  13925. getPositionExpressedInLocalSpace(): Vector3;
  13926. /**
  13927. * Translates the mesh along the passed Vector3 in its local space.
  13928. * @param vector3 the distance to translate in localspace
  13929. * @returns the TransformNode.
  13930. */
  13931. locallyTranslate(vector3: Vector3): TransformNode;
  13932. private static _lookAtVectorCache;
  13933. /**
  13934. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13935. * @param targetPoint the position (must be in same space as current mesh) to look at
  13936. * @param yawCor optional yaw (y-axis) correction in radians
  13937. * @param pitchCor optional pitch (x-axis) correction in radians
  13938. * @param rollCor optional roll (z-axis) correction in radians
  13939. * @param space the choosen space of the target
  13940. * @returns the TransformNode.
  13941. */
  13942. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13943. /**
  13944. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13945. * This Vector3 is expressed in the World space.
  13946. * @param localAxis axis to rotate
  13947. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13948. */
  13949. getDirection(localAxis: Vector3): Vector3;
  13950. /**
  13951. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13952. * localAxis is expressed in the mesh local space.
  13953. * result is computed in the Wordl space from the mesh World matrix.
  13954. * @param localAxis axis to rotate
  13955. * @param result the resulting transformnode
  13956. * @returns this TransformNode.
  13957. */
  13958. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13959. /**
  13960. * Sets this transform node rotation to the given local axis.
  13961. * @param localAxis the axis in local space
  13962. * @param yawCor optional yaw (y-axis) correction in radians
  13963. * @param pitchCor optional pitch (x-axis) correction in radians
  13964. * @param rollCor optional roll (z-axis) correction in radians
  13965. * @returns this TransformNode
  13966. */
  13967. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13968. /**
  13969. * Sets a new pivot point to the current node
  13970. * @param point defines the new pivot point to use
  13971. * @param space defines if the point is in world or local space (local by default)
  13972. * @returns the current TransformNode
  13973. */
  13974. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13975. /**
  13976. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13977. * @returns the pivot point
  13978. */
  13979. getPivotPoint(): Vector3;
  13980. /**
  13981. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13982. * @param result the vector3 to store the result
  13983. * @returns this TransformNode.
  13984. */
  13985. getPivotPointToRef(result: Vector3): TransformNode;
  13986. /**
  13987. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13988. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13989. */
  13990. getAbsolutePivotPoint(): Vector3;
  13991. /**
  13992. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13993. * @param result vector3 to store the result
  13994. * @returns this TransformNode.
  13995. */
  13996. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13997. /**
  13998. * Defines the passed node as the parent of the current node.
  13999. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14000. * @see https://doc.babylonjs.com/how_to/parenting
  14001. * @param node the node ot set as the parent
  14002. * @returns this TransformNode.
  14003. */
  14004. setParent(node: Nullable<Node>): TransformNode;
  14005. private _nonUniformScaling;
  14006. /**
  14007. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14008. */
  14009. readonly nonUniformScaling: boolean;
  14010. /** @hidden */
  14011. _updateNonUniformScalingState(value: boolean): boolean;
  14012. /**
  14013. * Attach the current TransformNode to another TransformNode associated with a bone
  14014. * @param bone Bone affecting the TransformNode
  14015. * @param affectedTransformNode TransformNode associated with the bone
  14016. * @returns this object
  14017. */
  14018. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14019. /**
  14020. * Detach the transform node if its associated with a bone
  14021. * @returns this object
  14022. */
  14023. detachFromBone(): TransformNode;
  14024. private static _rotationAxisCache;
  14025. /**
  14026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14027. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14028. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14029. * The passed axis is also normalized.
  14030. * @param axis the axis to rotate around
  14031. * @param amount the amount to rotate in radians
  14032. * @param space Space to rotate in (Default: local)
  14033. * @returns the TransformNode.
  14034. */
  14035. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14036. /**
  14037. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14038. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14039. * The passed axis is also normalized. .
  14040. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14041. * @param point the point to rotate around
  14042. * @param axis the axis to rotate around
  14043. * @param amount the amount to rotate in radians
  14044. * @returns the TransformNode
  14045. */
  14046. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14047. /**
  14048. * Translates the mesh along the axis vector for the passed distance in the given space.
  14049. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14050. * @param axis the axis to translate in
  14051. * @param distance the distance to translate
  14052. * @param space Space to rotate in (Default: local)
  14053. * @returns the TransformNode.
  14054. */
  14055. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14056. /**
  14057. * Adds a rotation step to the mesh current rotation.
  14058. * x, y, z are Euler angles expressed in radians.
  14059. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14060. * This means this rotation is made in the mesh local space only.
  14061. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14062. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14063. * ```javascript
  14064. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14065. * ```
  14066. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14067. * 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.
  14068. * @param x Rotation to add
  14069. * @param y Rotation to add
  14070. * @param z Rotation to add
  14071. * @returns the TransformNode.
  14072. */
  14073. addRotation(x: number, y: number, z: number): TransformNode;
  14074. /**
  14075. * @hidden
  14076. */
  14077. protected _getEffectiveParent(): Nullable<Node>;
  14078. /**
  14079. * Computes the world matrix of the node
  14080. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14081. * @returns the world matrix
  14082. */
  14083. computeWorldMatrix(force?: boolean): Matrix;
  14084. protected _afterComputeWorldMatrix(): void;
  14085. /**
  14086. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14087. * @param func callback function to add
  14088. *
  14089. * @returns the TransformNode.
  14090. */
  14091. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14092. /**
  14093. * Removes a registered callback function.
  14094. * @param func callback function to remove
  14095. * @returns the TransformNode.
  14096. */
  14097. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14098. /**
  14099. * Gets the position of the current mesh in camera space
  14100. * @param camera defines the camera to use
  14101. * @returns a position
  14102. */
  14103. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14104. /**
  14105. * Returns the distance from the mesh to the active camera
  14106. * @param camera defines the camera to use
  14107. * @returns the distance
  14108. */
  14109. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14110. /**
  14111. * Clone the current transform node
  14112. * @param name Name of the new clone
  14113. * @param newParent New parent for the clone
  14114. * @param doNotCloneChildren Do not clone children hierarchy
  14115. * @returns the new transform node
  14116. */
  14117. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14118. /**
  14119. * Serializes the objects information.
  14120. * @param currentSerializationObject defines the object to serialize in
  14121. * @returns the serialized object
  14122. */
  14123. serialize(currentSerializationObject?: any): any;
  14124. /**
  14125. * Returns a new TransformNode object parsed from the source provided.
  14126. * @param parsedTransformNode is the source.
  14127. * @param scene the scne the object belongs to
  14128. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14129. * @returns a new TransformNode object parsed from the source provided.
  14130. */
  14131. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14132. /**
  14133. * Get all child-transformNodes of this node
  14134. * @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
  14135. * @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
  14136. * @returns an array of TransformNode
  14137. */
  14138. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14139. /**
  14140. * Releases resources associated with this transform node.
  14141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14143. */
  14144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14145. /**
  14146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14147. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14148. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14149. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14150. * @returns the current mesh
  14151. */
  14152. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14153. private _syncAbsoluteScalingAndRotation;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /**
  14158. * Defines the types of pose enabled controllers that are supported
  14159. */
  14160. export enum PoseEnabledControllerType {
  14161. /**
  14162. * HTC Vive
  14163. */
  14164. VIVE = 0,
  14165. /**
  14166. * Oculus Rift
  14167. */
  14168. OCULUS = 1,
  14169. /**
  14170. * Windows mixed reality
  14171. */
  14172. WINDOWS = 2,
  14173. /**
  14174. * Samsung gear VR
  14175. */
  14176. GEAR_VR = 3,
  14177. /**
  14178. * Google Daydream
  14179. */
  14180. DAYDREAM = 4,
  14181. /**
  14182. * Generic
  14183. */
  14184. GENERIC = 5
  14185. }
  14186. /**
  14187. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14188. */
  14189. export interface MutableGamepadButton {
  14190. /**
  14191. * Value of the button/trigger
  14192. */
  14193. value: number;
  14194. /**
  14195. * If the button/trigger is currently touched
  14196. */
  14197. touched: boolean;
  14198. /**
  14199. * If the button/trigger is currently pressed
  14200. */
  14201. pressed: boolean;
  14202. }
  14203. /**
  14204. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14205. * @hidden
  14206. */
  14207. export interface ExtendedGamepadButton extends GamepadButton {
  14208. /**
  14209. * If the button/trigger is currently pressed
  14210. */
  14211. readonly pressed: boolean;
  14212. /**
  14213. * If the button/trigger is currently touched
  14214. */
  14215. readonly touched: boolean;
  14216. /**
  14217. * Value of the button/trigger
  14218. */
  14219. readonly value: number;
  14220. }
  14221. /** @hidden */
  14222. export interface _GamePadFactory {
  14223. /**
  14224. * Returns wether or not the current gamepad can be created for this type of controller.
  14225. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14226. * @returns true if it can be created, otherwise false
  14227. */
  14228. canCreate(gamepadInfo: any): boolean;
  14229. /**
  14230. * Creates a new instance of the Gamepad.
  14231. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14232. * @returns the new gamepad instance
  14233. */
  14234. create(gamepadInfo: any): Gamepad;
  14235. }
  14236. /**
  14237. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14238. */
  14239. export class PoseEnabledControllerHelper {
  14240. /** @hidden */
  14241. static _ControllerFactories: _GamePadFactory[];
  14242. /** @hidden */
  14243. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14244. /**
  14245. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14246. * @param vrGamepad the gamepad to initialized
  14247. * @returns a vr controller of the type the gamepad identified as
  14248. */
  14249. static InitiateController(vrGamepad: any): Gamepad;
  14250. }
  14251. /**
  14252. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14253. */
  14254. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14255. /**
  14256. * If the controller is used in a webXR session
  14257. */
  14258. isXR: boolean;
  14259. private _deviceRoomPosition;
  14260. private _deviceRoomRotationQuaternion;
  14261. /**
  14262. * The device position in babylon space
  14263. */
  14264. devicePosition: Vector3;
  14265. /**
  14266. * The device rotation in babylon space
  14267. */
  14268. deviceRotationQuaternion: Quaternion;
  14269. /**
  14270. * The scale factor of the device in babylon space
  14271. */
  14272. deviceScaleFactor: number;
  14273. /**
  14274. * (Likely devicePosition should be used instead) The device position in its room space
  14275. */
  14276. position: Vector3;
  14277. /**
  14278. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14279. */
  14280. rotationQuaternion: Quaternion;
  14281. /**
  14282. * The type of controller (Eg. Windows mixed reality)
  14283. */
  14284. controllerType: PoseEnabledControllerType;
  14285. protected _calculatedPosition: Vector3;
  14286. private _calculatedRotation;
  14287. /**
  14288. * The raw pose from the device
  14289. */
  14290. rawPose: DevicePose;
  14291. private _trackPosition;
  14292. private _maxRotationDistFromHeadset;
  14293. private _draggedRoomRotation;
  14294. /**
  14295. * @hidden
  14296. */
  14297. _disableTrackPosition(fixedPosition: Vector3): void;
  14298. /**
  14299. * Internal, the mesh attached to the controller
  14300. * @hidden
  14301. */
  14302. _mesh: Nullable<AbstractMesh>;
  14303. private _poseControlledCamera;
  14304. private _leftHandSystemQuaternion;
  14305. /**
  14306. * Internal, matrix used to convert room space to babylon space
  14307. * @hidden
  14308. */
  14309. _deviceToWorld: Matrix;
  14310. /**
  14311. * Node to be used when casting a ray from the controller
  14312. * @hidden
  14313. */
  14314. _pointingPoseNode: Nullable<TransformNode>;
  14315. /**
  14316. * Name of the child mesh that can be used to cast a ray from the controller
  14317. */
  14318. static readonly POINTING_POSE: string;
  14319. /**
  14320. * Creates a new PoseEnabledController from a gamepad
  14321. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14322. */
  14323. constructor(browserGamepad: any);
  14324. private _workingMatrix;
  14325. /**
  14326. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14327. */
  14328. update(): void;
  14329. /**
  14330. * Updates only the pose device and mesh without doing any button event checking
  14331. */
  14332. protected _updatePoseAndMesh(): void;
  14333. /**
  14334. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14335. * @param poseData raw pose fromthe device
  14336. */
  14337. updateFromDevice(poseData: DevicePose): void;
  14338. /**
  14339. * @hidden
  14340. */
  14341. _meshAttachedObservable: Observable<AbstractMesh>;
  14342. /**
  14343. * Attaches a mesh to the controller
  14344. * @param mesh the mesh to be attached
  14345. */
  14346. attachToMesh(mesh: AbstractMesh): void;
  14347. /**
  14348. * Attaches the controllers mesh to a camera
  14349. * @param camera the camera the mesh should be attached to
  14350. */
  14351. attachToPoseControlledCamera(camera: TargetCamera): void;
  14352. /**
  14353. * Disposes of the controller
  14354. */
  14355. dispose(): void;
  14356. /**
  14357. * The mesh that is attached to the controller
  14358. */
  14359. readonly mesh: Nullable<AbstractMesh>;
  14360. /**
  14361. * Gets the ray of the controller in the direction the controller is pointing
  14362. * @param length the length the resulting ray should be
  14363. * @returns a ray in the direction the controller is pointing
  14364. */
  14365. getForwardRay(length?: number): Ray;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. /**
  14370. * Defines the WebVRController object that represents controllers tracked in 3D space
  14371. */
  14372. export abstract class WebVRController extends PoseEnabledController {
  14373. /**
  14374. * Internal, the default controller model for the controller
  14375. */
  14376. protected _defaultModel: AbstractMesh;
  14377. /**
  14378. * Fired when the trigger state has changed
  14379. */
  14380. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14381. /**
  14382. * Fired when the main button state has changed
  14383. */
  14384. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14385. /**
  14386. * Fired when the secondary button state has changed
  14387. */
  14388. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14389. /**
  14390. * Fired when the pad state has changed
  14391. */
  14392. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14393. /**
  14394. * Fired when controllers stick values have changed
  14395. */
  14396. onPadValuesChangedObservable: Observable<StickValues>;
  14397. /**
  14398. * Array of button availible on the controller
  14399. */
  14400. protected _buttons: Array<MutableGamepadButton>;
  14401. private _onButtonStateChange;
  14402. /**
  14403. * Fired when a controller button's state has changed
  14404. * @param callback the callback containing the button that was modified
  14405. */
  14406. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14407. /**
  14408. * X and Y axis corresponding to the controllers joystick
  14409. */
  14410. pad: StickValues;
  14411. /**
  14412. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14413. */
  14414. hand: string;
  14415. /**
  14416. * The default controller model for the controller
  14417. */
  14418. readonly defaultModel: AbstractMesh;
  14419. /**
  14420. * Creates a new WebVRController from a gamepad
  14421. * @param vrGamepad the gamepad that the WebVRController should be created from
  14422. */
  14423. constructor(vrGamepad: any);
  14424. /**
  14425. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14426. */
  14427. update(): void;
  14428. /**
  14429. * Function to be called when a button is modified
  14430. */
  14431. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14432. /**
  14433. * Loads a mesh and attaches it to the controller
  14434. * @param scene the scene the mesh should be added to
  14435. * @param meshLoaded callback for when the mesh has been loaded
  14436. */
  14437. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14438. private _setButtonValue;
  14439. private _changes;
  14440. private _checkChanges;
  14441. /**
  14442. * Disposes of th webVRCOntroller
  14443. */
  14444. dispose(): void;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. /**
  14449. * The HemisphericLight simulates the ambient environment light,
  14450. * so the passed direction is the light reflection direction, not the incoming direction.
  14451. */
  14452. export class HemisphericLight extends Light {
  14453. /**
  14454. * The groundColor is the light in the opposite direction to the one specified during creation.
  14455. * 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.
  14456. */
  14457. groundColor: Color3;
  14458. /**
  14459. * The light reflection direction, not the incoming direction.
  14460. */
  14461. direction: Vector3;
  14462. /**
  14463. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14464. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14465. * The HemisphericLight can't cast shadows.
  14466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14467. * @param name The friendly name of the light
  14468. * @param direction The direction of the light reflection
  14469. * @param scene The scene the light belongs to
  14470. */
  14471. constructor(name: string, direction: Vector3, scene: Scene);
  14472. protected _buildUniformLayout(): void;
  14473. /**
  14474. * Returns the string "HemisphericLight".
  14475. * @return The class name
  14476. */
  14477. getClassName(): string;
  14478. /**
  14479. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14480. * Returns the updated direction.
  14481. * @param target The target the direction should point to
  14482. * @return The computed direction
  14483. */
  14484. setDirectionToTarget(target: Vector3): Vector3;
  14485. /**
  14486. * Returns the shadow generator associated to the light.
  14487. * @returns Always null for hemispheric lights because it does not support shadows.
  14488. */
  14489. getShadowGenerator(): Nullable<IShadowGenerator>;
  14490. /**
  14491. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14492. * @param effect The effect to update
  14493. * @param lightIndex The index of the light in the effect to update
  14494. * @returns The hemispheric light
  14495. */
  14496. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14497. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14498. /**
  14499. * Computes the world matrix of the node
  14500. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14501. * @param useWasUpdatedFlag defines a reserved property
  14502. * @returns the world matrix
  14503. */
  14504. computeWorldMatrix(): Matrix;
  14505. /**
  14506. * Returns the integer 3.
  14507. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14508. */
  14509. getTypeID(): number;
  14510. /**
  14511. * Prepares the list of defines specific to the light type.
  14512. * @param defines the list of defines
  14513. * @param lightIndex defines the index of the light for the effect
  14514. */
  14515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14516. }
  14517. }
  14518. declare module BABYLON {
  14519. /** @hidden */
  14520. export var vrMultiviewToSingleviewPixelShader: {
  14521. name: string;
  14522. shader: string;
  14523. };
  14524. }
  14525. declare module BABYLON {
  14526. /**
  14527. * Renders to multiple views with a single draw call
  14528. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14529. */
  14530. export class MultiviewRenderTarget extends RenderTargetTexture {
  14531. /**
  14532. * Creates a multiview render target
  14533. * @param scene scene used with the render target
  14534. * @param size the size of the render target (used for each view)
  14535. */
  14536. constructor(scene: Scene, size?: number | {
  14537. width: number;
  14538. height: number;
  14539. } | {
  14540. ratio: number;
  14541. });
  14542. /**
  14543. * @hidden
  14544. * @param faceIndex the face index, if its a cube texture
  14545. */
  14546. _bindFrameBuffer(faceIndex?: number): void;
  14547. /**
  14548. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14549. * @returns the view count
  14550. */
  14551. getViewCount(): number;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Represents a camera frustum
  14557. */
  14558. export class Frustum {
  14559. /**
  14560. * Gets the planes representing the frustum
  14561. * @param transform matrix to be applied to the returned planes
  14562. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14563. */
  14564. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14565. /**
  14566. * Gets the near frustum plane transformed by the transform matrix
  14567. * @param transform transformation matrix to be applied to the resulting frustum plane
  14568. * @param frustumPlane the resuling frustum plane
  14569. */
  14570. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14571. /**
  14572. * Gets the far frustum plane transformed by the transform matrix
  14573. * @param transform transformation matrix to be applied to the resulting frustum plane
  14574. * @param frustumPlane the resuling frustum plane
  14575. */
  14576. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14577. /**
  14578. * Gets the left frustum plane transformed by the transform matrix
  14579. * @param transform transformation matrix to be applied to the resulting frustum plane
  14580. * @param frustumPlane the resuling frustum plane
  14581. */
  14582. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14583. /**
  14584. * Gets the right frustum plane transformed by the transform matrix
  14585. * @param transform transformation matrix to be applied to the resulting frustum plane
  14586. * @param frustumPlane the resuling frustum plane
  14587. */
  14588. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14589. /**
  14590. * Gets the top frustum plane transformed by the transform matrix
  14591. * @param transform transformation matrix to be applied to the resulting frustum plane
  14592. * @param frustumPlane the resuling frustum plane
  14593. */
  14594. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14595. /**
  14596. * Gets the bottom frustum plane transformed by the transform matrix
  14597. * @param transform transformation matrix to be applied to the resulting frustum plane
  14598. * @param frustumPlane the resuling frustum plane
  14599. */
  14600. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14601. /**
  14602. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14603. * @param transform transformation matrix to be applied to the resulting frustum planes
  14604. * @param frustumPlanes the resuling frustum planes
  14605. */
  14606. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14607. }
  14608. }
  14609. declare module BABYLON {
  14610. interface Engine {
  14611. /**
  14612. * Creates a new multiview render target
  14613. * @param width defines the width of the texture
  14614. * @param height defines the height of the texture
  14615. * @returns the created multiview texture
  14616. */
  14617. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14618. /**
  14619. * Binds a multiview framebuffer to be drawn to
  14620. * @param multiviewTexture texture to bind
  14621. */
  14622. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14623. }
  14624. interface Camera {
  14625. /**
  14626. * @hidden
  14627. * 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)
  14628. */
  14629. _useMultiviewToSingleView: boolean;
  14630. /**
  14631. * @hidden
  14632. * 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)
  14633. */
  14634. _multiviewTexture: Nullable<RenderTargetTexture>;
  14635. /**
  14636. * @hidden
  14637. * ensures the multiview texture of the camera exists and has the specified width/height
  14638. * @param width height to set on the multiview texture
  14639. * @param height width to set on the multiview texture
  14640. */
  14641. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14642. }
  14643. interface Scene {
  14644. /** @hidden */
  14645. _transformMatrixR: Matrix;
  14646. /** @hidden */
  14647. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14648. /** @hidden */
  14649. _createMultiviewUbo(): void;
  14650. /** @hidden */
  14651. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14652. /** @hidden */
  14653. _renderMultiviewToSingleView(camera: Camera): void;
  14654. }
  14655. }
  14656. declare module BABYLON {
  14657. /**
  14658. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14659. * This will not be used for webXR as it supports displaying texture arrays directly
  14660. */
  14661. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14662. /**
  14663. * Initializes a VRMultiviewToSingleview
  14664. * @param name name of the post process
  14665. * @param camera camera to be applied to
  14666. * @param scaleFactor scaling factor to the size of the output texture
  14667. */
  14668. constructor(name: string, camera: Camera, scaleFactor: number);
  14669. }
  14670. }
  14671. declare module BABYLON {
  14672. interface Engine {
  14673. /** @hidden */
  14674. _vrDisplay: any;
  14675. /** @hidden */
  14676. _vrSupported: boolean;
  14677. /** @hidden */
  14678. _oldSize: Size;
  14679. /** @hidden */
  14680. _oldHardwareScaleFactor: number;
  14681. /** @hidden */
  14682. _vrExclusivePointerMode: boolean;
  14683. /** @hidden */
  14684. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14685. /** @hidden */
  14686. _onVRDisplayPointerRestricted: () => void;
  14687. /** @hidden */
  14688. _onVRDisplayPointerUnrestricted: () => void;
  14689. /** @hidden */
  14690. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14691. /** @hidden */
  14692. _onVrDisplayDisconnect: Nullable<() => void>;
  14693. /** @hidden */
  14694. _onVrDisplayPresentChange: Nullable<() => void>;
  14695. /**
  14696. * Observable signaled when VR display mode changes
  14697. */
  14698. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14699. /**
  14700. * Observable signaled when VR request present is complete
  14701. */
  14702. onVRRequestPresentComplete: Observable<boolean>;
  14703. /**
  14704. * Observable signaled when VR request present starts
  14705. */
  14706. onVRRequestPresentStart: Observable<Engine>;
  14707. /**
  14708. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14709. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14710. */
  14711. isInVRExclusivePointerMode: boolean;
  14712. /**
  14713. * Gets a boolean indicating if a webVR device was detected
  14714. * @returns true if a webVR device was detected
  14715. */
  14716. isVRDevicePresent(): boolean;
  14717. /**
  14718. * Gets the current webVR device
  14719. * @returns the current webVR device (or null)
  14720. */
  14721. getVRDevice(): any;
  14722. /**
  14723. * Initializes a webVR display and starts listening to display change events
  14724. * The onVRDisplayChangedObservable will be notified upon these changes
  14725. * @returns A promise containing a VRDisplay and if vr is supported
  14726. */
  14727. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14728. /** @hidden */
  14729. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14730. /**
  14731. * Call this function to switch to webVR mode
  14732. * Will do nothing if webVR is not supported or if there is no webVR device
  14733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14734. */
  14735. enableVR(): void;
  14736. /** @hidden */
  14737. _onVRFullScreenTriggered(): void;
  14738. }
  14739. }
  14740. declare module BABYLON {
  14741. /**
  14742. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14743. * IMPORTANT!! The data is right-hand data.
  14744. * @export
  14745. * @interface DevicePose
  14746. */
  14747. export interface DevicePose {
  14748. /**
  14749. * The position of the device, values in array are [x,y,z].
  14750. */
  14751. readonly position: Nullable<Float32Array>;
  14752. /**
  14753. * The linearVelocity of the device, values in array are [x,y,z].
  14754. */
  14755. readonly linearVelocity: Nullable<Float32Array>;
  14756. /**
  14757. * The linearAcceleration of the device, values in array are [x,y,z].
  14758. */
  14759. readonly linearAcceleration: Nullable<Float32Array>;
  14760. /**
  14761. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14762. */
  14763. readonly orientation: Nullable<Float32Array>;
  14764. /**
  14765. * The angularVelocity of the device, values in array are [x,y,z].
  14766. */
  14767. readonly angularVelocity: Nullable<Float32Array>;
  14768. /**
  14769. * The angularAcceleration of the device, values in array are [x,y,z].
  14770. */
  14771. readonly angularAcceleration: Nullable<Float32Array>;
  14772. }
  14773. /**
  14774. * Interface representing a pose controlled object in Babylon.
  14775. * A pose controlled object has both regular pose values as well as pose values
  14776. * from an external device such as a VR head mounted display
  14777. */
  14778. export interface PoseControlled {
  14779. /**
  14780. * The position of the object in babylon space.
  14781. */
  14782. position: Vector3;
  14783. /**
  14784. * The rotation quaternion of the object in babylon space.
  14785. */
  14786. rotationQuaternion: Quaternion;
  14787. /**
  14788. * The position of the device in babylon space.
  14789. */
  14790. devicePosition?: Vector3;
  14791. /**
  14792. * The rotation quaternion of the device in babylon space.
  14793. */
  14794. deviceRotationQuaternion: Quaternion;
  14795. /**
  14796. * The raw pose coming from the device.
  14797. */
  14798. rawPose: Nullable<DevicePose>;
  14799. /**
  14800. * The scale of the device to be used when translating from device space to babylon space.
  14801. */
  14802. deviceScaleFactor: number;
  14803. /**
  14804. * Updates the poseControlled values based on the input device pose.
  14805. * @param poseData the pose data to update the object with
  14806. */
  14807. updateFromDevice(poseData: DevicePose): void;
  14808. }
  14809. /**
  14810. * Set of options to customize the webVRCamera
  14811. */
  14812. export interface WebVROptions {
  14813. /**
  14814. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14815. */
  14816. trackPosition?: boolean;
  14817. /**
  14818. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14819. */
  14820. positionScale?: number;
  14821. /**
  14822. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14823. */
  14824. displayName?: string;
  14825. /**
  14826. * Should the native controller meshes be initialized. (default: true)
  14827. */
  14828. controllerMeshes?: boolean;
  14829. /**
  14830. * Creating a default HemiLight only on controllers. (default: true)
  14831. */
  14832. defaultLightingOnControllers?: boolean;
  14833. /**
  14834. * If you don't want to use the default VR button of the helper. (default: false)
  14835. */
  14836. useCustomVRButton?: boolean;
  14837. /**
  14838. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14839. */
  14840. customVRButton?: HTMLButtonElement;
  14841. /**
  14842. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14843. */
  14844. rayLength?: number;
  14845. /**
  14846. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14847. */
  14848. defaultHeight?: number;
  14849. /**
  14850. * If multiview should be used if availible (default: false)
  14851. */
  14852. useMultiview?: boolean;
  14853. }
  14854. /**
  14855. * This represents a WebVR camera.
  14856. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14857. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14858. */
  14859. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14860. private webVROptions;
  14861. /**
  14862. * @hidden
  14863. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14864. */
  14865. _vrDevice: any;
  14866. /**
  14867. * The rawPose of the vrDevice.
  14868. */
  14869. rawPose: Nullable<DevicePose>;
  14870. private _onVREnabled;
  14871. private _specsVersion;
  14872. private _attached;
  14873. private _frameData;
  14874. protected _descendants: Array<Node>;
  14875. private _deviceRoomPosition;
  14876. /** @hidden */
  14877. _deviceRoomRotationQuaternion: Quaternion;
  14878. private _standingMatrix;
  14879. /**
  14880. * Represents device position in babylon space.
  14881. */
  14882. devicePosition: Vector3;
  14883. /**
  14884. * Represents device rotation in babylon space.
  14885. */
  14886. deviceRotationQuaternion: Quaternion;
  14887. /**
  14888. * The scale of the device to be used when translating from device space to babylon space.
  14889. */
  14890. deviceScaleFactor: number;
  14891. private _deviceToWorld;
  14892. private _worldToDevice;
  14893. /**
  14894. * References to the webVR controllers for the vrDevice.
  14895. */
  14896. controllers: Array<WebVRController>;
  14897. /**
  14898. * Emits an event when a controller is attached.
  14899. */
  14900. onControllersAttachedObservable: Observable<WebVRController[]>;
  14901. /**
  14902. * Emits an event when a controller's mesh has been loaded;
  14903. */
  14904. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14905. /**
  14906. * Emits an event when the HMD's pose has been updated.
  14907. */
  14908. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14909. private _poseSet;
  14910. /**
  14911. * If the rig cameras be used as parent instead of this camera.
  14912. */
  14913. rigParenting: boolean;
  14914. private _lightOnControllers;
  14915. private _defaultHeight?;
  14916. /**
  14917. * Instantiates a WebVRFreeCamera.
  14918. * @param name The name of the WebVRFreeCamera
  14919. * @param position The starting anchor position for the camera
  14920. * @param scene The scene the camera belongs to
  14921. * @param webVROptions a set of customizable options for the webVRCamera
  14922. */
  14923. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14924. /**
  14925. * Gets the device distance from the ground in meters.
  14926. * @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.
  14927. */
  14928. deviceDistanceToRoomGround(): number;
  14929. /**
  14930. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14931. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14932. */
  14933. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14934. /**
  14935. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14936. * @returns A promise with a boolean set to if the standing matrix is supported.
  14937. */
  14938. useStandingMatrixAsync(): Promise<boolean>;
  14939. /**
  14940. * Disposes the camera
  14941. */
  14942. dispose(): void;
  14943. /**
  14944. * Gets a vrController by name.
  14945. * @param name The name of the controller to retreive
  14946. * @returns the controller matching the name specified or null if not found
  14947. */
  14948. getControllerByName(name: string): Nullable<WebVRController>;
  14949. private _leftController;
  14950. /**
  14951. * The controller corresponding to the users left hand.
  14952. */
  14953. readonly leftController: Nullable<WebVRController>;
  14954. private _rightController;
  14955. /**
  14956. * The controller corresponding to the users right hand.
  14957. */
  14958. readonly rightController: Nullable<WebVRController>;
  14959. /**
  14960. * Casts a ray forward from the vrCamera's gaze.
  14961. * @param length Length of the ray (default: 100)
  14962. * @returns the ray corresponding to the gaze
  14963. */
  14964. getForwardRay(length?: number): Ray;
  14965. /**
  14966. * @hidden
  14967. * Updates the camera based on device's frame data
  14968. */
  14969. _checkInputs(): void;
  14970. /**
  14971. * Updates the poseControlled values based on the input device pose.
  14972. * @param poseData Pose coming from the device
  14973. */
  14974. updateFromDevice(poseData: DevicePose): void;
  14975. private _htmlElementAttached;
  14976. private _detachIfAttached;
  14977. /**
  14978. * WebVR's attach control will start broadcasting frames to the device.
  14979. * Note that in certain browsers (chrome for example) this function must be called
  14980. * within a user-interaction callback. Example:
  14981. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14982. *
  14983. * @param element html element to attach the vrDevice to
  14984. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14985. */
  14986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14987. /**
  14988. * Detaches the camera from the html element and disables VR
  14989. *
  14990. * @param element html element to detach from
  14991. */
  14992. detachControl(element: HTMLElement): void;
  14993. /**
  14994. * @returns the name of this class
  14995. */
  14996. getClassName(): string;
  14997. /**
  14998. * Calls resetPose on the vrDisplay
  14999. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15000. */
  15001. resetToCurrentRotation(): void;
  15002. /**
  15003. * @hidden
  15004. * Updates the rig cameras (left and right eye)
  15005. */
  15006. _updateRigCameras(): void;
  15007. private _workingVector;
  15008. private _oneVector;
  15009. private _workingMatrix;
  15010. private updateCacheCalled;
  15011. private _correctPositionIfNotTrackPosition;
  15012. /**
  15013. * @hidden
  15014. * Updates the cached values of the camera
  15015. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15016. */
  15017. _updateCache(ignoreParentClass?: boolean): void;
  15018. /**
  15019. * @hidden
  15020. * Get current device position in babylon world
  15021. */
  15022. _computeDevicePosition(): void;
  15023. /**
  15024. * Updates the current device position and rotation in the babylon world
  15025. */
  15026. update(): void;
  15027. /**
  15028. * @hidden
  15029. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15030. * @returns an identity matrix
  15031. */
  15032. _getViewMatrix(): Matrix;
  15033. private _tmpMatrix;
  15034. /**
  15035. * This function is called by the two RIG cameras.
  15036. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15037. * @hidden
  15038. */
  15039. _getWebVRViewMatrix(): Matrix;
  15040. /** @hidden */
  15041. _getWebVRProjectionMatrix(): Matrix;
  15042. private _onGamepadConnectedObserver;
  15043. private _onGamepadDisconnectedObserver;
  15044. private _updateCacheWhenTrackingDisabledObserver;
  15045. /**
  15046. * Initializes the controllers and their meshes
  15047. */
  15048. initControllers(): void;
  15049. }
  15050. }
  15051. declare module BABYLON {
  15052. /**
  15053. * Size options for a post process
  15054. */
  15055. export type PostProcessOptions = {
  15056. width: number;
  15057. height: number;
  15058. };
  15059. /**
  15060. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15061. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15062. */
  15063. export class PostProcess {
  15064. /** Name of the PostProcess. */
  15065. name: string;
  15066. /**
  15067. * Gets or sets the unique id of the post process
  15068. */
  15069. uniqueId: number;
  15070. /**
  15071. * Width of the texture to apply the post process on
  15072. */
  15073. width: number;
  15074. /**
  15075. * Height of the texture to apply the post process on
  15076. */
  15077. height: number;
  15078. /**
  15079. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15080. * @hidden
  15081. */
  15082. _outputTexture: Nullable<InternalTexture>;
  15083. /**
  15084. * Sampling mode used by the shader
  15085. * See https://doc.babylonjs.com/classes/3.1/texture
  15086. */
  15087. renderTargetSamplingMode: number;
  15088. /**
  15089. * Clear color to use when screen clearing
  15090. */
  15091. clearColor: Color4;
  15092. /**
  15093. * If the buffer needs to be cleared before applying the post process. (default: true)
  15094. * Should be set to false if shader will overwrite all previous pixels.
  15095. */
  15096. autoClear: boolean;
  15097. /**
  15098. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15099. */
  15100. alphaMode: number;
  15101. /**
  15102. * Sets the setAlphaBlendConstants of the babylon engine
  15103. */
  15104. alphaConstants: Color4;
  15105. /**
  15106. * Animations to be used for the post processing
  15107. */
  15108. animations: Animation[];
  15109. /**
  15110. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15111. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15112. */
  15113. enablePixelPerfectMode: boolean;
  15114. /**
  15115. * Force the postprocess to be applied without taking in account viewport
  15116. */
  15117. forceFullscreenViewport: boolean;
  15118. /**
  15119. * List of inspectable custom properties (used by the Inspector)
  15120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15121. */
  15122. inspectableCustomProperties: IInspectable[];
  15123. /**
  15124. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15125. *
  15126. * | Value | Type | Description |
  15127. * | ----- | ----------------------------------- | ----------- |
  15128. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15129. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15130. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15131. *
  15132. */
  15133. scaleMode: number;
  15134. /**
  15135. * Force textures to be a power of two (default: false)
  15136. */
  15137. alwaysForcePOT: boolean;
  15138. private _samples;
  15139. /**
  15140. * Number of sample textures (default: 1)
  15141. */
  15142. samples: number;
  15143. /**
  15144. * Modify the scale of the post process to be the same as the viewport (default: false)
  15145. */
  15146. adaptScaleToCurrentViewport: boolean;
  15147. private _camera;
  15148. private _scene;
  15149. private _engine;
  15150. private _options;
  15151. private _reusable;
  15152. private _textureType;
  15153. /**
  15154. * Smart array of input and output textures for the post process.
  15155. * @hidden
  15156. */
  15157. _textures: SmartArray<InternalTexture>;
  15158. /**
  15159. * The index in _textures that corresponds to the output texture.
  15160. * @hidden
  15161. */
  15162. _currentRenderTextureInd: number;
  15163. private _effect;
  15164. private _samplers;
  15165. private _fragmentUrl;
  15166. private _vertexUrl;
  15167. private _parameters;
  15168. private _scaleRatio;
  15169. protected _indexParameters: any;
  15170. private _shareOutputWithPostProcess;
  15171. private _texelSize;
  15172. private _forcedOutputTexture;
  15173. /**
  15174. * Returns the fragment url or shader name used in the post process.
  15175. * @returns the fragment url or name in the shader store.
  15176. */
  15177. getEffectName(): string;
  15178. /**
  15179. * An event triggered when the postprocess is activated.
  15180. */
  15181. onActivateObservable: Observable<Camera>;
  15182. private _onActivateObserver;
  15183. /**
  15184. * A function that is added to the onActivateObservable
  15185. */
  15186. onActivate: Nullable<(camera: Camera) => void>;
  15187. /**
  15188. * An event triggered when the postprocess changes its size.
  15189. */
  15190. onSizeChangedObservable: Observable<PostProcess>;
  15191. private _onSizeChangedObserver;
  15192. /**
  15193. * A function that is added to the onSizeChangedObservable
  15194. */
  15195. onSizeChanged: (postProcess: PostProcess) => void;
  15196. /**
  15197. * An event triggered when the postprocess applies its effect.
  15198. */
  15199. onApplyObservable: Observable<Effect>;
  15200. private _onApplyObserver;
  15201. /**
  15202. * A function that is added to the onApplyObservable
  15203. */
  15204. onApply: (effect: Effect) => void;
  15205. /**
  15206. * An event triggered before rendering the postprocess
  15207. */
  15208. onBeforeRenderObservable: Observable<Effect>;
  15209. private _onBeforeRenderObserver;
  15210. /**
  15211. * A function that is added to the onBeforeRenderObservable
  15212. */
  15213. onBeforeRender: (effect: Effect) => void;
  15214. /**
  15215. * An event triggered after rendering the postprocess
  15216. */
  15217. onAfterRenderObservable: Observable<Effect>;
  15218. private _onAfterRenderObserver;
  15219. /**
  15220. * A function that is added to the onAfterRenderObservable
  15221. */
  15222. onAfterRender: (efect: Effect) => void;
  15223. /**
  15224. * 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
  15225. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15226. */
  15227. inputTexture: InternalTexture;
  15228. /**
  15229. * Gets the camera which post process is applied to.
  15230. * @returns The camera the post process is applied to.
  15231. */
  15232. getCamera(): Camera;
  15233. /**
  15234. * Gets the texel size of the postprocess.
  15235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15236. */
  15237. readonly texelSize: Vector2;
  15238. /**
  15239. * Creates a new instance PostProcess
  15240. * @param name The name of the PostProcess.
  15241. * @param fragmentUrl The url of the fragment shader to be used.
  15242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15245. * @param camera The camera to apply the render pass to.
  15246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15247. * @param engine The engine which the post process will be applied. (default: current engine)
  15248. * @param reusable If the post process can be reused on the same frame. (default: false)
  15249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15250. * @param textureType Type of textures used when performing the post process. (default: 0)
  15251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15252. * @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
  15253. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15254. */
  15255. constructor(
  15256. /** Name of the PostProcess. */
  15257. 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);
  15258. /**
  15259. * Gets a string idenfifying the name of the class
  15260. * @returns "PostProcess" string
  15261. */
  15262. getClassName(): string;
  15263. /**
  15264. * Gets the engine which this post process belongs to.
  15265. * @returns The engine the post process was enabled with.
  15266. */
  15267. getEngine(): Engine;
  15268. /**
  15269. * The effect that is created when initializing the post process.
  15270. * @returns The created effect corresponding the the postprocess.
  15271. */
  15272. getEffect(): Effect;
  15273. /**
  15274. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15275. * @param postProcess The post process to share the output with.
  15276. * @returns This post process.
  15277. */
  15278. shareOutputWith(postProcess: PostProcess): PostProcess;
  15279. /**
  15280. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15281. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15282. */
  15283. useOwnOutput(): void;
  15284. /**
  15285. * Updates the effect with the current post process compile time values and recompiles the shader.
  15286. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15287. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15288. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15289. * @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
  15290. * @param onCompiled Called when the shader has been compiled.
  15291. * @param onError Called if there is an error when compiling a shader.
  15292. */
  15293. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15294. /**
  15295. * The post process is reusable if it can be used multiple times within one frame.
  15296. * @returns If the post process is reusable
  15297. */
  15298. isReusable(): boolean;
  15299. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15300. markTextureDirty(): void;
  15301. /**
  15302. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15303. * 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.
  15304. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15305. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15306. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15307. * @returns The target texture that was bound to be written to.
  15308. */
  15309. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15310. /**
  15311. * If the post process is supported.
  15312. */
  15313. readonly isSupported: boolean;
  15314. /**
  15315. * The aspect ratio of the output texture.
  15316. */
  15317. readonly aspectRatio: number;
  15318. /**
  15319. * Get a value indicating if the post-process is ready to be used
  15320. * @returns true if the post-process is ready (shader is compiled)
  15321. */
  15322. isReady(): boolean;
  15323. /**
  15324. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15325. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15326. */
  15327. apply(): Nullable<Effect>;
  15328. private _disposeTextures;
  15329. /**
  15330. * Disposes the post process.
  15331. * @param camera The camera to dispose the post process on.
  15332. */
  15333. dispose(camera?: Camera): void;
  15334. }
  15335. }
  15336. declare module BABYLON {
  15337. /** @hidden */
  15338. export var kernelBlurVaryingDeclaration: {
  15339. name: string;
  15340. shader: string;
  15341. };
  15342. }
  15343. declare module BABYLON {
  15344. /** @hidden */
  15345. export var kernelBlurFragment: {
  15346. name: string;
  15347. shader: string;
  15348. };
  15349. }
  15350. declare module BABYLON {
  15351. /** @hidden */
  15352. export var kernelBlurFragment2: {
  15353. name: string;
  15354. shader: string;
  15355. };
  15356. }
  15357. declare module BABYLON {
  15358. /** @hidden */
  15359. export var kernelBlurPixelShader: {
  15360. name: string;
  15361. shader: string;
  15362. };
  15363. }
  15364. declare module BABYLON {
  15365. /** @hidden */
  15366. export var kernelBlurVertex: {
  15367. name: string;
  15368. shader: string;
  15369. };
  15370. }
  15371. declare module BABYLON {
  15372. /** @hidden */
  15373. export var kernelBlurVertexShader: {
  15374. name: string;
  15375. shader: string;
  15376. };
  15377. }
  15378. declare module BABYLON {
  15379. /**
  15380. * The Blur Post Process which blurs an image based on a kernel and direction.
  15381. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15382. */
  15383. export class BlurPostProcess extends PostProcess {
  15384. /** The direction in which to blur the image. */
  15385. direction: Vector2;
  15386. private blockCompilation;
  15387. protected _kernel: number;
  15388. protected _idealKernel: number;
  15389. protected _packedFloat: boolean;
  15390. private _staticDefines;
  15391. /**
  15392. * Sets the length in pixels of the blur sample region
  15393. */
  15394. /**
  15395. * Gets the length in pixels of the blur sample region
  15396. */
  15397. kernel: number;
  15398. /**
  15399. * Sets wether or not the blur needs to unpack/repack floats
  15400. */
  15401. /**
  15402. * Gets wether or not the blur is unpacking/repacking floats
  15403. */
  15404. packedFloat: boolean;
  15405. /**
  15406. * Creates a new instance BlurPostProcess
  15407. * @param name The name of the effect.
  15408. * @param direction The direction in which to blur the image.
  15409. * @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.
  15410. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15411. * @param camera The camera to apply the render pass to.
  15412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15413. * @param engine The engine which the post process will be applied. (default: current engine)
  15414. * @param reusable If the post process can be reused on the same frame. (default: false)
  15415. * @param textureType Type of textures used when performing the post process. (default: 0)
  15416. * @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)
  15417. */
  15418. constructor(name: string,
  15419. /** The direction in which to blur the image. */
  15420. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15421. /**
  15422. * Updates the effect with the current post process compile time values and recompiles the shader.
  15423. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15424. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15425. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15426. * @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
  15427. * @param onCompiled Called when the shader has been compiled.
  15428. * @param onError Called if there is an error when compiling a shader.
  15429. */
  15430. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15431. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15432. /**
  15433. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15434. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15435. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15436. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15437. * The gaps between physical kernels are compensated for in the weighting of the samples
  15438. * @param idealKernel Ideal blur kernel.
  15439. * @return Nearest best kernel.
  15440. */
  15441. protected _nearestBestKernel(idealKernel: number): number;
  15442. /**
  15443. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15444. * @param x The point on the Gaussian distribution to sample.
  15445. * @return the value of the Gaussian function at x.
  15446. */
  15447. protected _gaussianWeight(x: number): number;
  15448. /**
  15449. * Generates a string that can be used as a floating point number in GLSL.
  15450. * @param x Value to print.
  15451. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15452. * @return GLSL float string.
  15453. */
  15454. protected _glslFloat(x: number, decimalFigures?: number): string;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15460. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15461. * You can then easily use it as a reflectionTexture on a flat surface.
  15462. * In case the surface is not a plane, please consider relying on reflection probes.
  15463. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15464. */
  15465. export class MirrorTexture extends RenderTargetTexture {
  15466. private scene;
  15467. /**
  15468. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15469. * 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.
  15470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15471. */
  15472. mirrorPlane: Plane;
  15473. /**
  15474. * Define the blur ratio used to blur the reflection if needed.
  15475. */
  15476. blurRatio: number;
  15477. /**
  15478. * Define the adaptive blur kernel used to blur the reflection if needed.
  15479. * This will autocompute the closest best match for the `blurKernel`
  15480. */
  15481. adaptiveBlurKernel: number;
  15482. /**
  15483. * Define the blur kernel used to blur the reflection if needed.
  15484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15485. */
  15486. blurKernel: number;
  15487. /**
  15488. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15490. */
  15491. blurKernelX: number;
  15492. /**
  15493. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15494. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15495. */
  15496. blurKernelY: number;
  15497. private _autoComputeBlurKernel;
  15498. protected _onRatioRescale(): void;
  15499. private _updateGammaSpace;
  15500. private _imageProcessingConfigChangeObserver;
  15501. private _transformMatrix;
  15502. private _mirrorMatrix;
  15503. private _savedViewMatrix;
  15504. private _blurX;
  15505. private _blurY;
  15506. private _adaptiveBlurKernel;
  15507. private _blurKernelX;
  15508. private _blurKernelY;
  15509. private _blurRatio;
  15510. /**
  15511. * Instantiates a Mirror Texture.
  15512. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15513. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15514. * You can then easily use it as a reflectionTexture on a flat surface.
  15515. * In case the surface is not a plane, please consider relying on reflection probes.
  15516. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15517. * @param name
  15518. * @param size
  15519. * @param scene
  15520. * @param generateMipMaps
  15521. * @param type
  15522. * @param samplingMode
  15523. * @param generateDepthBuffer
  15524. */
  15525. constructor(name: string, size: number | {
  15526. width: number;
  15527. height: number;
  15528. } | {
  15529. ratio: number;
  15530. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15531. private _preparePostProcesses;
  15532. /**
  15533. * Clone the mirror texture.
  15534. * @returns the cloned texture
  15535. */
  15536. clone(): MirrorTexture;
  15537. /**
  15538. * Serialize the texture to a JSON representation you could use in Parse later on
  15539. * @returns the serialized JSON representation
  15540. */
  15541. serialize(): any;
  15542. /**
  15543. * Dispose the texture and release its associated resources.
  15544. */
  15545. dispose(): void;
  15546. }
  15547. }
  15548. declare module BABYLON {
  15549. /**
  15550. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15551. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15552. */
  15553. export class Texture extends BaseTexture {
  15554. /** @hidden */
  15555. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15556. /** @hidden */
  15557. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15558. /** @hidden */
  15559. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15560. /** nearest is mag = nearest and min = nearest and mip = linear */
  15561. static readonly NEAREST_SAMPLINGMODE: number;
  15562. /** nearest is mag = nearest and min = nearest and mip = linear */
  15563. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15565. static readonly BILINEAR_SAMPLINGMODE: number;
  15566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15567. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15568. /** Trilinear is mag = linear and min = linear and mip = linear */
  15569. static readonly TRILINEAR_SAMPLINGMODE: number;
  15570. /** Trilinear is mag = linear and min = linear and mip = linear */
  15571. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15572. /** mag = nearest and min = nearest and mip = nearest */
  15573. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15574. /** mag = nearest and min = linear and mip = nearest */
  15575. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15576. /** mag = nearest and min = linear and mip = linear */
  15577. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15578. /** mag = nearest and min = linear and mip = none */
  15579. static readonly NEAREST_LINEAR: number;
  15580. /** mag = nearest and min = nearest and mip = none */
  15581. static readonly NEAREST_NEAREST: number;
  15582. /** mag = linear and min = nearest and mip = nearest */
  15583. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15584. /** mag = linear and min = nearest and mip = linear */
  15585. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15586. /** mag = linear and min = linear and mip = none */
  15587. static readonly LINEAR_LINEAR: number;
  15588. /** mag = linear and min = nearest and mip = none */
  15589. static readonly LINEAR_NEAREST: number;
  15590. /** Explicit coordinates mode */
  15591. static readonly EXPLICIT_MODE: number;
  15592. /** Spherical coordinates mode */
  15593. static readonly SPHERICAL_MODE: number;
  15594. /** Planar coordinates mode */
  15595. static readonly PLANAR_MODE: number;
  15596. /** Cubic coordinates mode */
  15597. static readonly CUBIC_MODE: number;
  15598. /** Projection coordinates mode */
  15599. static readonly PROJECTION_MODE: number;
  15600. /** Inverse Cubic coordinates mode */
  15601. static readonly SKYBOX_MODE: number;
  15602. /** Inverse Cubic coordinates mode */
  15603. static readonly INVCUBIC_MODE: number;
  15604. /** Equirectangular coordinates mode */
  15605. static readonly EQUIRECTANGULAR_MODE: number;
  15606. /** Equirectangular Fixed coordinates mode */
  15607. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15608. /** Equirectangular Fixed Mirrored coordinates mode */
  15609. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15610. /** Texture is not repeating outside of 0..1 UVs */
  15611. static readonly CLAMP_ADDRESSMODE: number;
  15612. /** Texture is repeating outside of 0..1 UVs */
  15613. static readonly WRAP_ADDRESSMODE: number;
  15614. /** Texture is repeating and mirrored */
  15615. static readonly MIRROR_ADDRESSMODE: number;
  15616. /**
  15617. * 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
  15618. */
  15619. static UseSerializedUrlIfAny: boolean;
  15620. /**
  15621. * Define the url of the texture.
  15622. */
  15623. url: Nullable<string>;
  15624. /**
  15625. * Define an offset on the texture to offset the u coordinates of the UVs
  15626. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15627. */
  15628. uOffset: number;
  15629. /**
  15630. * Define an offset on the texture to offset the v coordinates of the UVs
  15631. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15632. */
  15633. vOffset: number;
  15634. /**
  15635. * Define an offset on the texture to scale the u coordinates of the UVs
  15636. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15637. */
  15638. uScale: number;
  15639. /**
  15640. * Define an offset on the texture to scale the v coordinates of the UVs
  15641. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15642. */
  15643. vScale: number;
  15644. /**
  15645. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15646. * @see http://doc.babylonjs.com/how_to/more_materials
  15647. */
  15648. uAng: number;
  15649. /**
  15650. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15651. * @see http://doc.babylonjs.com/how_to/more_materials
  15652. */
  15653. vAng: number;
  15654. /**
  15655. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15656. * @see http://doc.babylonjs.com/how_to/more_materials
  15657. */
  15658. wAng: number;
  15659. /**
  15660. * Defines the center of rotation (U)
  15661. */
  15662. uRotationCenter: number;
  15663. /**
  15664. * Defines the center of rotation (V)
  15665. */
  15666. vRotationCenter: number;
  15667. /**
  15668. * Defines the center of rotation (W)
  15669. */
  15670. wRotationCenter: number;
  15671. /**
  15672. * Are mip maps generated for this texture or not.
  15673. */
  15674. readonly noMipmap: boolean;
  15675. /**
  15676. * List of inspectable custom properties (used by the Inspector)
  15677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15678. */
  15679. inspectableCustomProperties: Nullable<IInspectable[]>;
  15680. private _noMipmap;
  15681. /** @hidden */
  15682. _invertY: boolean;
  15683. private _rowGenerationMatrix;
  15684. private _cachedTextureMatrix;
  15685. private _projectionModeMatrix;
  15686. private _t0;
  15687. private _t1;
  15688. private _t2;
  15689. private _cachedUOffset;
  15690. private _cachedVOffset;
  15691. private _cachedUScale;
  15692. private _cachedVScale;
  15693. private _cachedUAng;
  15694. private _cachedVAng;
  15695. private _cachedWAng;
  15696. private _cachedProjectionMatrixId;
  15697. private _cachedCoordinatesMode;
  15698. /** @hidden */
  15699. protected _initialSamplingMode: number;
  15700. /** @hidden */
  15701. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15702. private _deleteBuffer;
  15703. protected _format: Nullable<number>;
  15704. private _delayedOnLoad;
  15705. private _delayedOnError;
  15706. /**
  15707. * Observable triggered once the texture has been loaded.
  15708. */
  15709. onLoadObservable: Observable<Texture>;
  15710. protected _isBlocking: boolean;
  15711. /**
  15712. * Is the texture preventing material to render while loading.
  15713. * If false, a default texture will be used instead of the loading one during the preparation step.
  15714. */
  15715. isBlocking: boolean;
  15716. /**
  15717. * Get the current sampling mode associated with the texture.
  15718. */
  15719. readonly samplingMode: number;
  15720. /**
  15721. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15722. */
  15723. readonly invertY: boolean;
  15724. /**
  15725. * Instantiates a new texture.
  15726. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15727. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15728. * @param url define the url of the picture to load as a texture
  15729. * @param scene define the scene or engine the texture will belong to
  15730. * @param noMipmap define if the texture will require mip maps or not
  15731. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15732. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15733. * @param onLoad define a callback triggered when the texture has been loaded
  15734. * @param onError define a callback triggered when an error occurred during the loading session
  15735. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15736. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15737. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15738. */
  15739. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15740. /**
  15741. * Update the url (and optional buffer) of this texture if url was null during construction.
  15742. * @param url the url of the texture
  15743. * @param buffer the buffer of the texture (defaults to null)
  15744. * @param onLoad callback called when the texture is loaded (defaults to null)
  15745. */
  15746. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15747. /**
  15748. * Finish the loading sequence of a texture flagged as delayed load.
  15749. * @hidden
  15750. */
  15751. delayLoad(): void;
  15752. private _prepareRowForTextureGeneration;
  15753. /**
  15754. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15755. * @returns the transform matrix of the texture.
  15756. */
  15757. getTextureMatrix(): Matrix;
  15758. /**
  15759. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15760. * @returns The reflection texture transform
  15761. */
  15762. getReflectionTextureMatrix(): Matrix;
  15763. /**
  15764. * Clones the texture.
  15765. * @returns the cloned texture
  15766. */
  15767. clone(): Texture;
  15768. /**
  15769. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15770. * @returns The JSON representation of the texture
  15771. */
  15772. serialize(): any;
  15773. /**
  15774. * Get the current class name of the texture useful for serialization or dynamic coding.
  15775. * @returns "Texture"
  15776. */
  15777. getClassName(): string;
  15778. /**
  15779. * Dispose the texture and release its associated resources.
  15780. */
  15781. dispose(): void;
  15782. /**
  15783. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15784. * @param parsedTexture Define the JSON representation of the texture
  15785. * @param scene Define the scene the parsed texture should be instantiated in
  15786. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15787. * @returns The parsed texture if successful
  15788. */
  15789. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15790. /**
  15791. * Creates a texture from its base 64 representation.
  15792. * @param data Define the base64 payload without the data: prefix
  15793. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15794. * @param scene Define the scene the texture should belong to
  15795. * @param noMipmap Forces the texture to not create mip map information if true
  15796. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15797. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15798. * @param onLoad define a callback triggered when the texture has been loaded
  15799. * @param onError define a callback triggered when an error occurred during the loading session
  15800. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15801. * @returns the created texture
  15802. */
  15803. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15804. /**
  15805. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15806. * @param data Define the base64 payload without the data: prefix
  15807. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15808. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15809. * @param scene Define the scene the texture should belong to
  15810. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15811. * @param noMipmap Forces the texture to not create mip map information if true
  15812. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15813. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15814. * @param onLoad define a callback triggered when the texture has been loaded
  15815. * @param onError define a callback triggered when an error occurred during the loading session
  15816. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15817. * @returns the created texture
  15818. */
  15819. 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;
  15820. }
  15821. }
  15822. declare module BABYLON {
  15823. /**
  15824. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15825. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15826. */
  15827. export class PostProcessManager {
  15828. private _scene;
  15829. private _indexBuffer;
  15830. private _vertexBuffers;
  15831. /**
  15832. * Creates a new instance PostProcess
  15833. * @param scene The scene that the post process is associated with.
  15834. */
  15835. constructor(scene: Scene);
  15836. private _prepareBuffers;
  15837. private _buildIndexBuffer;
  15838. /**
  15839. * Rebuilds the vertex buffers of the manager.
  15840. * @hidden
  15841. */
  15842. _rebuild(): void;
  15843. /**
  15844. * Prepares a frame to be run through a post process.
  15845. * @param sourceTexture The input texture to the post procesess. (default: null)
  15846. * @param postProcesses An array of post processes to be run. (default: null)
  15847. * @returns True if the post processes were able to be run.
  15848. * @hidden
  15849. */
  15850. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15851. /**
  15852. * Manually render a set of post processes to a texture.
  15853. * @param postProcesses An array of post processes to be run.
  15854. * @param targetTexture The target texture to render to.
  15855. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15856. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15857. * @param lodLevel defines which lod of the texture to render to
  15858. */
  15859. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15860. /**
  15861. * Finalize the result of the output of the postprocesses.
  15862. * @param doNotPresent If true the result will not be displayed to the screen.
  15863. * @param targetTexture The target texture to render to.
  15864. * @param faceIndex The index of the face to bind the target texture to.
  15865. * @param postProcesses The array of post processes to render.
  15866. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15867. * @hidden
  15868. */
  15869. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15870. /**
  15871. * Disposes of the post process manager.
  15872. */
  15873. dispose(): void;
  15874. }
  15875. }
  15876. declare module BABYLON {
  15877. /** Interface used by value gradients (color, factor, ...) */
  15878. export interface IValueGradient {
  15879. /**
  15880. * Gets or sets the gradient value (between 0 and 1)
  15881. */
  15882. gradient: number;
  15883. }
  15884. /** Class used to store color4 gradient */
  15885. export class ColorGradient implements IValueGradient {
  15886. /**
  15887. * Gets or sets the gradient value (between 0 and 1)
  15888. */
  15889. gradient: number;
  15890. /**
  15891. * Gets or sets first associated color
  15892. */
  15893. color1: Color4;
  15894. /**
  15895. * Gets or sets second associated color
  15896. */
  15897. color2?: Color4;
  15898. /**
  15899. * Will get a color picked randomly between color1 and color2.
  15900. * If color2 is undefined then color1 will be used
  15901. * @param result defines the target Color4 to store the result in
  15902. */
  15903. getColorToRef(result: Color4): void;
  15904. }
  15905. /** Class used to store color 3 gradient */
  15906. export class Color3Gradient implements IValueGradient {
  15907. /**
  15908. * Gets or sets the gradient value (between 0 and 1)
  15909. */
  15910. gradient: number;
  15911. /**
  15912. * Gets or sets the associated color
  15913. */
  15914. color: Color3;
  15915. }
  15916. /** Class used to store factor gradient */
  15917. export class FactorGradient implements IValueGradient {
  15918. /**
  15919. * Gets or sets the gradient value (between 0 and 1)
  15920. */
  15921. gradient: number;
  15922. /**
  15923. * Gets or sets first associated factor
  15924. */
  15925. factor1: number;
  15926. /**
  15927. * Gets or sets second associated factor
  15928. */
  15929. factor2?: number;
  15930. /**
  15931. * Will get a number picked randomly between factor1 and factor2.
  15932. * If factor2 is undefined then factor1 will be used
  15933. * @returns the picked number
  15934. */
  15935. getFactor(): number;
  15936. }
  15937. /**
  15938. * Helper used to simplify some generic gradient tasks
  15939. */
  15940. export class GradientHelper {
  15941. /**
  15942. * Gets the current gradient from an array of IValueGradient
  15943. * @param ratio defines the current ratio to get
  15944. * @param gradients defines the array of IValueGradient
  15945. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15946. */
  15947. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15948. }
  15949. }
  15950. declare module BABYLON {
  15951. interface AbstractScene {
  15952. /**
  15953. * The list of procedural textures added to the scene
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15955. */
  15956. proceduralTextures: Array<ProceduralTexture>;
  15957. }
  15958. /**
  15959. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15960. * in a given scene.
  15961. */
  15962. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15963. /**
  15964. * The component name helpfull to identify the component in the list of scene components.
  15965. */
  15966. readonly name: string;
  15967. /**
  15968. * The scene the component belongs to.
  15969. */
  15970. scene: Scene;
  15971. /**
  15972. * Creates a new instance of the component for the given scene
  15973. * @param scene Defines the scene to register the component in
  15974. */
  15975. constructor(scene: Scene);
  15976. /**
  15977. * Registers the component in a given scene
  15978. */
  15979. register(): void;
  15980. /**
  15981. * Rebuilds the elements related to this component in case of
  15982. * context lost for instance.
  15983. */
  15984. rebuild(): void;
  15985. /**
  15986. * Disposes the component and the associated ressources.
  15987. */
  15988. dispose(): void;
  15989. private _beforeClear;
  15990. }
  15991. }
  15992. declare module BABYLON {
  15993. interface Engine {
  15994. /**
  15995. * Creates a new render target cube texture
  15996. * @param size defines the size of the texture
  15997. * @param options defines the options used to create the texture
  15998. * @returns a new render target cube texture stored in an InternalTexture
  15999. */
  16000. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16001. }
  16002. }
  16003. declare module BABYLON {
  16004. /** @hidden */
  16005. export var proceduralVertexShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module BABYLON {
  16011. /**
  16012. * 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.
  16013. * This is the base class of any Procedural texture and contains most of the shareable code.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16015. */
  16016. export class ProceduralTexture extends Texture {
  16017. isCube: boolean;
  16018. /**
  16019. * Define if the texture is enabled or not (disabled texture will not render)
  16020. */
  16021. isEnabled: boolean;
  16022. /**
  16023. * Define if the texture must be cleared before rendering (default is true)
  16024. */
  16025. autoClear: boolean;
  16026. /**
  16027. * Callback called when the texture is generated
  16028. */
  16029. onGenerated: () => void;
  16030. /**
  16031. * Event raised when the texture is generated
  16032. */
  16033. onGeneratedObservable: Observable<ProceduralTexture>;
  16034. /** @hidden */
  16035. _generateMipMaps: boolean;
  16036. /** @hidden **/
  16037. _effect: Effect;
  16038. /** @hidden */
  16039. _textures: {
  16040. [key: string]: Texture;
  16041. };
  16042. private _size;
  16043. private _currentRefreshId;
  16044. private _refreshRate;
  16045. private _vertexBuffers;
  16046. private _indexBuffer;
  16047. private _uniforms;
  16048. private _samplers;
  16049. private _fragment;
  16050. private _floats;
  16051. private _ints;
  16052. private _floatsArrays;
  16053. private _colors3;
  16054. private _colors4;
  16055. private _vectors2;
  16056. private _vectors3;
  16057. private _matrices;
  16058. private _fallbackTexture;
  16059. private _fallbackTextureUsed;
  16060. private _engine;
  16061. private _cachedDefines;
  16062. private _contentUpdateId;
  16063. private _contentData;
  16064. /**
  16065. * Instantiates a new procedural texture.
  16066. * 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.
  16067. * This is the base class of any Procedural texture and contains most of the shareable code.
  16068. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16069. * @param name Define the name of the texture
  16070. * @param size Define the size of the texture to create
  16071. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16072. * @param scene Define the scene the texture belongs to
  16073. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16074. * @param generateMipMaps Define if the texture should creates mip maps or not
  16075. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16076. */
  16077. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16078. /**
  16079. * The effect that is created when initializing the post process.
  16080. * @returns The created effect corresponding the the postprocess.
  16081. */
  16082. getEffect(): Effect;
  16083. /**
  16084. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16085. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16086. */
  16087. getContent(): Nullable<ArrayBufferView>;
  16088. private _createIndexBuffer;
  16089. /** @hidden */
  16090. _rebuild(): void;
  16091. /**
  16092. * Resets the texture in order to recreate its associated resources.
  16093. * This can be called in case of context loss
  16094. */
  16095. reset(): void;
  16096. protected _getDefines(): string;
  16097. /**
  16098. * Is the texture ready to be used ? (rendered at least once)
  16099. * @returns true if ready, otherwise, false.
  16100. */
  16101. isReady(): boolean;
  16102. /**
  16103. * Resets the refresh counter of the texture and start bak from scratch.
  16104. * Could be useful to regenerate the texture if it is setup to render only once.
  16105. */
  16106. resetRefreshCounter(): void;
  16107. /**
  16108. * Set the fragment shader to use in order to render the texture.
  16109. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16110. */
  16111. setFragment(fragment: any): void;
  16112. /**
  16113. * Define the refresh rate of the texture or the rendering frequency.
  16114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16115. */
  16116. refreshRate: number;
  16117. /** @hidden */
  16118. _shouldRender(): boolean;
  16119. /**
  16120. * Get the size the texture is rendering at.
  16121. * @returns the size (texture is always squared)
  16122. */
  16123. getRenderSize(): number;
  16124. /**
  16125. * Resize the texture to new value.
  16126. * @param size Define the new size the texture should have
  16127. * @param generateMipMaps Define whether the new texture should create mip maps
  16128. */
  16129. resize(size: number, generateMipMaps: boolean): void;
  16130. private _checkUniform;
  16131. /**
  16132. * Set a texture in the shader program used to render.
  16133. * @param name Define the name of the uniform samplers as defined in the shader
  16134. * @param texture Define the texture to bind to this sampler
  16135. * @return the texture itself allowing "fluent" like uniform updates
  16136. */
  16137. setTexture(name: string, texture: Texture): ProceduralTexture;
  16138. /**
  16139. * Set a float in the shader.
  16140. * @param name Define the name of the uniform as defined in the shader
  16141. * @param value Define the value to give to the uniform
  16142. * @return the texture itself allowing "fluent" like uniform updates
  16143. */
  16144. setFloat(name: string, value: number): ProceduralTexture;
  16145. /**
  16146. * Set a int in the shader.
  16147. * @param name Define the name of the uniform as defined in the shader
  16148. * @param value Define the value to give to the uniform
  16149. * @return the texture itself allowing "fluent" like uniform updates
  16150. */
  16151. setInt(name: string, value: number): ProceduralTexture;
  16152. /**
  16153. * Set an array of floats in the shader.
  16154. * @param name Define the name of the uniform as defined in the shader
  16155. * @param value Define the value to give to the uniform
  16156. * @return the texture itself allowing "fluent" like uniform updates
  16157. */
  16158. setFloats(name: string, value: number[]): ProceduralTexture;
  16159. /**
  16160. * Set a vec3 in the shader from a Color3.
  16161. * @param name Define the name of the uniform as defined in the shader
  16162. * @param value Define the value to give to the uniform
  16163. * @return the texture itself allowing "fluent" like uniform updates
  16164. */
  16165. setColor3(name: string, value: Color3): ProceduralTexture;
  16166. /**
  16167. * Set a vec4 in the shader from a Color4.
  16168. * @param name Define the name of the uniform as defined in the shader
  16169. * @param value Define the value to give to the uniform
  16170. * @return the texture itself allowing "fluent" like uniform updates
  16171. */
  16172. setColor4(name: string, value: Color4): ProceduralTexture;
  16173. /**
  16174. * Set a vec2 in the shader from a Vector2.
  16175. * @param name Define the name of the uniform as defined in the shader
  16176. * @param value Define the value to give to the uniform
  16177. * @return the texture itself allowing "fluent" like uniform updates
  16178. */
  16179. setVector2(name: string, value: Vector2): ProceduralTexture;
  16180. /**
  16181. * Set a vec3 in the shader from a Vector3.
  16182. * @param name Define the name of the uniform as defined in the shader
  16183. * @param value Define the value to give to the uniform
  16184. * @return the texture itself allowing "fluent" like uniform updates
  16185. */
  16186. setVector3(name: string, value: Vector3): ProceduralTexture;
  16187. /**
  16188. * Set a mat4 in the shader from a MAtrix.
  16189. * @param name Define the name of the uniform as defined in the shader
  16190. * @param value Define the value to give to the uniform
  16191. * @return the texture itself allowing "fluent" like uniform updates
  16192. */
  16193. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16194. /**
  16195. * Render the texture to its associated render target.
  16196. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16197. */
  16198. render(useCameraPostProcess?: boolean): void;
  16199. /**
  16200. * Clone the texture.
  16201. * @returns the cloned texture
  16202. */
  16203. clone(): ProceduralTexture;
  16204. /**
  16205. * Dispose the texture and release its asoociated resources.
  16206. */
  16207. dispose(): void;
  16208. }
  16209. }
  16210. declare module BABYLON {
  16211. /**
  16212. * This represents the base class for particle system in Babylon.
  16213. * 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.
  16214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16215. * @example https://doc.babylonjs.com/babylon101/particles
  16216. */
  16217. export class BaseParticleSystem {
  16218. /**
  16219. * Source color is added to the destination color without alpha affecting the result
  16220. */
  16221. static BLENDMODE_ONEONE: number;
  16222. /**
  16223. * Blend current color and particle color using particle’s alpha
  16224. */
  16225. static BLENDMODE_STANDARD: number;
  16226. /**
  16227. * Add current color and particle color multiplied by particle’s alpha
  16228. */
  16229. static BLENDMODE_ADD: number;
  16230. /**
  16231. * Multiply current color with particle color
  16232. */
  16233. static BLENDMODE_MULTIPLY: number;
  16234. /**
  16235. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16236. */
  16237. static BLENDMODE_MULTIPLYADD: number;
  16238. /**
  16239. * List of animations used by the particle system.
  16240. */
  16241. animations: Animation[];
  16242. /**
  16243. * The id of the Particle system.
  16244. */
  16245. id: string;
  16246. /**
  16247. * The friendly name of the Particle system.
  16248. */
  16249. name: string;
  16250. /**
  16251. * The rendering group used by the Particle system to chose when to render.
  16252. */
  16253. renderingGroupId: number;
  16254. /**
  16255. * The emitter represents the Mesh or position we are attaching the particle system to.
  16256. */
  16257. emitter: Nullable<AbstractMesh | Vector3>;
  16258. /**
  16259. * The maximum number of particles to emit per frame
  16260. */
  16261. emitRate: number;
  16262. /**
  16263. * If you want to launch only a few particles at once, that can be done, as well.
  16264. */
  16265. manualEmitCount: number;
  16266. /**
  16267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16268. */
  16269. updateSpeed: number;
  16270. /**
  16271. * The amount of time the particle system is running (depends of the overall update speed).
  16272. */
  16273. targetStopDuration: number;
  16274. /**
  16275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16276. */
  16277. disposeOnStop: boolean;
  16278. /**
  16279. * Minimum power of emitting particles.
  16280. */
  16281. minEmitPower: number;
  16282. /**
  16283. * Maximum power of emitting particles.
  16284. */
  16285. maxEmitPower: number;
  16286. /**
  16287. * Minimum life time of emitting particles.
  16288. */
  16289. minLifeTime: number;
  16290. /**
  16291. * Maximum life time of emitting particles.
  16292. */
  16293. maxLifeTime: number;
  16294. /**
  16295. * Minimum Size of emitting particles.
  16296. */
  16297. minSize: number;
  16298. /**
  16299. * Maximum Size of emitting particles.
  16300. */
  16301. maxSize: number;
  16302. /**
  16303. * Minimum scale of emitting particles on X axis.
  16304. */
  16305. minScaleX: number;
  16306. /**
  16307. * Maximum scale of emitting particles on X axis.
  16308. */
  16309. maxScaleX: number;
  16310. /**
  16311. * Minimum scale of emitting particles on Y axis.
  16312. */
  16313. minScaleY: number;
  16314. /**
  16315. * Maximum scale of emitting particles on Y axis.
  16316. */
  16317. maxScaleY: number;
  16318. /**
  16319. * Gets or sets the minimal initial rotation in radians.
  16320. */
  16321. minInitialRotation: number;
  16322. /**
  16323. * Gets or sets the maximal initial rotation in radians.
  16324. */
  16325. maxInitialRotation: number;
  16326. /**
  16327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16328. */
  16329. minAngularSpeed: number;
  16330. /**
  16331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16332. */
  16333. maxAngularSpeed: number;
  16334. /**
  16335. * The texture used to render each particle. (this can be a spritesheet)
  16336. */
  16337. particleTexture: Nullable<Texture>;
  16338. /**
  16339. * The layer mask we are rendering the particles through.
  16340. */
  16341. layerMask: number;
  16342. /**
  16343. * This can help using your own shader to render the particle system.
  16344. * The according effect will be created
  16345. */
  16346. customShader: any;
  16347. /**
  16348. * By default particle system starts as soon as they are created. This prevents the
  16349. * automatic start to happen and let you decide when to start emitting particles.
  16350. */
  16351. preventAutoStart: boolean;
  16352. private _noiseTexture;
  16353. /**
  16354. * Gets or sets a texture used to add random noise to particle positions
  16355. */
  16356. noiseTexture: Nullable<ProceduralTexture>;
  16357. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16358. noiseStrength: Vector3;
  16359. /**
  16360. * Callback triggered when the particle animation is ending.
  16361. */
  16362. onAnimationEnd: Nullable<() => void>;
  16363. /**
  16364. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16365. */
  16366. blendMode: number;
  16367. /**
  16368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16369. * to override the particles.
  16370. */
  16371. forceDepthWrite: boolean;
  16372. /** 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 */
  16373. preWarmCycles: number;
  16374. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16375. preWarmStepOffset: number;
  16376. /**
  16377. * 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)
  16378. */
  16379. spriteCellChangeSpeed: number;
  16380. /**
  16381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16382. */
  16383. startSpriteCellID: number;
  16384. /**
  16385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16386. */
  16387. endSpriteCellID: number;
  16388. /**
  16389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16390. */
  16391. spriteCellWidth: number;
  16392. /**
  16393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16394. */
  16395. spriteCellHeight: number;
  16396. /**
  16397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16398. */
  16399. spriteRandomStartCell: boolean;
  16400. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16401. translationPivot: Vector2;
  16402. /** @hidden */
  16403. protected _isAnimationSheetEnabled: boolean;
  16404. /**
  16405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16406. */
  16407. beginAnimationOnStart: boolean;
  16408. /**
  16409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16410. */
  16411. beginAnimationFrom: number;
  16412. /**
  16413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16414. */
  16415. beginAnimationTo: number;
  16416. /**
  16417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16418. */
  16419. beginAnimationLoop: boolean;
  16420. /**
  16421. * Gets or sets a world offset applied to all particles
  16422. */
  16423. worldOffset: Vector3;
  16424. /**
  16425. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16426. */
  16427. isAnimationSheetEnabled: boolean;
  16428. /**
  16429. * Get hosting scene
  16430. * @returns the scene
  16431. */
  16432. getScene(): Scene;
  16433. /**
  16434. * You can use gravity if you want to give an orientation to your particles.
  16435. */
  16436. gravity: Vector3;
  16437. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16438. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16439. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16440. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16441. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16442. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16443. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16444. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16445. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16446. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16447. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16448. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16449. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16450. /**
  16451. * Defines the delay in milliseconds before starting the system (0 by default)
  16452. */
  16453. startDelay: number;
  16454. /**
  16455. * Gets the current list of drag gradients.
  16456. * You must use addDragGradient and removeDragGradient to udpate this list
  16457. * @returns the list of drag gradients
  16458. */
  16459. getDragGradients(): Nullable<Array<FactorGradient>>;
  16460. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16461. limitVelocityDamping: number;
  16462. /**
  16463. * Gets the current list of limit velocity gradients.
  16464. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16465. * @returns the list of limit velocity gradients
  16466. */
  16467. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16468. /**
  16469. * Gets the current list of color gradients.
  16470. * You must use addColorGradient and removeColorGradient to udpate this list
  16471. * @returns the list of color gradients
  16472. */
  16473. getColorGradients(): Nullable<Array<ColorGradient>>;
  16474. /**
  16475. * Gets the current list of size gradients.
  16476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16477. * @returns the list of size gradients
  16478. */
  16479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of color remap gradients.
  16482. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16483. * @returns the list of color remap gradients
  16484. */
  16485. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Gets the current list of alpha remap gradients.
  16488. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16489. * @returns the list of alpha remap gradients
  16490. */
  16491. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16492. /**
  16493. * Gets the current list of life time gradients.
  16494. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16495. * @returns the list of life time gradients
  16496. */
  16497. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16498. /**
  16499. * Gets the current list of angular speed gradients.
  16500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16501. * @returns the list of angular speed gradients
  16502. */
  16503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of velocity gradients.
  16506. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16507. * @returns the list of velocity gradients
  16508. */
  16509. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16510. /**
  16511. * Gets the current list of start size gradients.
  16512. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16513. * @returns the list of start size gradients
  16514. */
  16515. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16516. /**
  16517. * Gets the current list of emit rate gradients.
  16518. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16519. * @returns the list of emit rate gradients
  16520. */
  16521. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16522. /**
  16523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16525. */
  16526. direction1: Vector3;
  16527. /**
  16528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16530. */
  16531. direction2: Vector3;
  16532. /**
  16533. * 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.
  16534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16535. */
  16536. minEmitBox: Vector3;
  16537. /**
  16538. * 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.
  16539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16540. */
  16541. maxEmitBox: Vector3;
  16542. /**
  16543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16544. */
  16545. color1: Color4;
  16546. /**
  16547. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16548. */
  16549. color2: Color4;
  16550. /**
  16551. * Color the particle will have at the end of its lifetime
  16552. */
  16553. colorDead: Color4;
  16554. /**
  16555. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16556. */
  16557. textureMask: Color4;
  16558. /**
  16559. * The particle emitter type defines the emitter used by the particle system.
  16560. * It can be for example box, sphere, or cone...
  16561. */
  16562. particleEmitterType: IParticleEmitterType;
  16563. /** @hidden */
  16564. _isSubEmitter: boolean;
  16565. /**
  16566. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16567. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16568. */
  16569. billboardMode: number;
  16570. protected _isBillboardBased: boolean;
  16571. /**
  16572. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16573. */
  16574. isBillboardBased: boolean;
  16575. /**
  16576. * The scene the particle system belongs to.
  16577. */
  16578. protected _scene: Scene;
  16579. /**
  16580. * Local cache of defines for image processing.
  16581. */
  16582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16583. /**
  16584. * Default configuration related to image processing available in the standard Material.
  16585. */
  16586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16587. /**
  16588. * Gets the image processing configuration used either in this material.
  16589. */
  16590. /**
  16591. * Sets the Default image processing configuration used either in the this material.
  16592. *
  16593. * If sets to null, the scene one is in use.
  16594. */
  16595. imageProcessingConfiguration: ImageProcessingConfiguration;
  16596. /**
  16597. * Attaches a new image processing configuration to the Standard Material.
  16598. * @param configuration
  16599. */
  16600. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16601. /** @hidden */
  16602. protected _reset(): void;
  16603. /** @hidden */
  16604. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16605. /**
  16606. * Instantiates a particle system.
  16607. * 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.
  16608. * @param name The name of the particle system
  16609. */
  16610. constructor(name: string);
  16611. /**
  16612. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16615. * @returns the emitter
  16616. */
  16617. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16618. /**
  16619. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16620. * @param radius The radius of the hemisphere to emit from
  16621. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16622. * @returns the emitter
  16623. */
  16624. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16625. /**
  16626. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16627. * @param radius The radius of the sphere to emit from
  16628. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16629. * @returns the emitter
  16630. */
  16631. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16632. /**
  16633. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16634. * @param radius The radius of the sphere to emit from
  16635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16637. * @returns the emitter
  16638. */
  16639. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16640. /**
  16641. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16642. * @param radius The radius of the emission cylinder
  16643. * @param height The height of the emission cylinder
  16644. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16645. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16646. * @returns the emitter
  16647. */
  16648. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16649. /**
  16650. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16651. * @param radius The radius of the cylinder to emit from
  16652. * @param height The height of the emission cylinder
  16653. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16656. * @returns the emitter
  16657. */
  16658. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16659. /**
  16660. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16661. * @param radius The radius of the cone to emit from
  16662. * @param angle The base angle of the cone
  16663. * @returns the emitter
  16664. */
  16665. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16666. /**
  16667. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16670. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16671. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16672. * @returns the emitter
  16673. */
  16674. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16675. }
  16676. }
  16677. declare module BABYLON {
  16678. /**
  16679. * Type of sub emitter
  16680. */
  16681. export enum SubEmitterType {
  16682. /**
  16683. * Attached to the particle over it's lifetime
  16684. */
  16685. ATTACHED = 0,
  16686. /**
  16687. * Created when the particle dies
  16688. */
  16689. END = 1
  16690. }
  16691. /**
  16692. * Sub emitter class used to emit particles from an existing particle
  16693. */
  16694. export class SubEmitter {
  16695. /**
  16696. * the particle system to be used by the sub emitter
  16697. */
  16698. particleSystem: ParticleSystem;
  16699. /**
  16700. * Type of the submitter (Default: END)
  16701. */
  16702. type: SubEmitterType;
  16703. /**
  16704. * 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)
  16705. * Note: This only is supported when using an emitter of type Mesh
  16706. */
  16707. inheritDirection: boolean;
  16708. /**
  16709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16710. */
  16711. inheritedVelocityAmount: number;
  16712. /**
  16713. * Creates a sub emitter
  16714. * @param particleSystem the particle system to be used by the sub emitter
  16715. */
  16716. constructor(
  16717. /**
  16718. * the particle system to be used by the sub emitter
  16719. */
  16720. particleSystem: ParticleSystem);
  16721. /**
  16722. * Clones the sub emitter
  16723. * @returns the cloned sub emitter
  16724. */
  16725. clone(): SubEmitter;
  16726. /**
  16727. * Serialize current object to a JSON object
  16728. * @returns the serialized object
  16729. */
  16730. serialize(): any;
  16731. /** @hidden */
  16732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16733. /**
  16734. * Creates a new SubEmitter from a serialized JSON version
  16735. * @param serializationObject defines the JSON object to read from
  16736. * @param scene defines the hosting scene
  16737. * @param rootUrl defines the rootUrl for data loading
  16738. * @returns a new SubEmitter
  16739. */
  16740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16741. /** Release associated resources */
  16742. dispose(): void;
  16743. }
  16744. }
  16745. declare module BABYLON {
  16746. /** @hidden */
  16747. export var clipPlaneFragmentDeclaration: {
  16748. name: string;
  16749. shader: string;
  16750. };
  16751. }
  16752. declare module BABYLON {
  16753. /** @hidden */
  16754. export var imageProcessingDeclaration: {
  16755. name: string;
  16756. shader: string;
  16757. };
  16758. }
  16759. declare module BABYLON {
  16760. /** @hidden */
  16761. export var imageProcessingFunctions: {
  16762. name: string;
  16763. shader: string;
  16764. };
  16765. }
  16766. declare module BABYLON {
  16767. /** @hidden */
  16768. export var clipPlaneFragment: {
  16769. name: string;
  16770. shader: string;
  16771. };
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var particlesPixelShader: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var clipPlaneVertexDeclaration: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. /** @hidden */
  16789. export var clipPlaneVertex: {
  16790. name: string;
  16791. shader: string;
  16792. };
  16793. }
  16794. declare module BABYLON {
  16795. /** @hidden */
  16796. export var particlesVertexShader: {
  16797. name: string;
  16798. shader: string;
  16799. };
  16800. }
  16801. declare module BABYLON {
  16802. /**
  16803. * This represents a particle system in Babylon.
  16804. * 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.
  16805. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16806. * @example https://doc.babylonjs.com/babylon101/particles
  16807. */
  16808. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16809. /**
  16810. * Billboard mode will only apply to Y axis
  16811. */
  16812. static readonly BILLBOARDMODE_Y: number;
  16813. /**
  16814. * Billboard mode will apply to all axes
  16815. */
  16816. static readonly BILLBOARDMODE_ALL: number;
  16817. /**
  16818. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16819. */
  16820. static readonly BILLBOARDMODE_STRETCHED: number;
  16821. /**
  16822. * This function can be defined to provide custom update for active particles.
  16823. * This function will be called instead of regular update (age, position, color, etc.).
  16824. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16825. */
  16826. updateFunction: (particles: Particle[]) => void;
  16827. private _emitterWorldMatrix;
  16828. /**
  16829. * This function can be defined to specify initial direction for every new particle.
  16830. * It by default use the emitterType defined function
  16831. */
  16832. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16833. /**
  16834. * This function can be defined to specify initial position for every new particle.
  16835. * It by default use the emitterType defined function
  16836. */
  16837. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16838. /**
  16839. * @hidden
  16840. */
  16841. _inheritedVelocityOffset: Vector3;
  16842. /**
  16843. * An event triggered when the system is disposed
  16844. */
  16845. onDisposeObservable: Observable<ParticleSystem>;
  16846. private _onDisposeObserver;
  16847. /**
  16848. * Sets a callback that will be triggered when the system is disposed
  16849. */
  16850. onDispose: () => void;
  16851. private _particles;
  16852. private _epsilon;
  16853. private _capacity;
  16854. private _stockParticles;
  16855. private _newPartsExcess;
  16856. private _vertexData;
  16857. private _vertexBuffer;
  16858. private _vertexBuffers;
  16859. private _spriteBuffer;
  16860. private _indexBuffer;
  16861. private _effect;
  16862. private _customEffect;
  16863. private _cachedDefines;
  16864. private _scaledColorStep;
  16865. private _colorDiff;
  16866. private _scaledDirection;
  16867. private _scaledGravity;
  16868. private _currentRenderId;
  16869. private _alive;
  16870. private _useInstancing;
  16871. private _started;
  16872. private _stopped;
  16873. private _actualFrame;
  16874. private _scaledUpdateSpeed;
  16875. private _vertexBufferSize;
  16876. /** @hidden */
  16877. _currentEmitRateGradient: Nullable<FactorGradient>;
  16878. /** @hidden */
  16879. _currentEmitRate1: number;
  16880. /** @hidden */
  16881. _currentEmitRate2: number;
  16882. /** @hidden */
  16883. _currentStartSizeGradient: Nullable<FactorGradient>;
  16884. /** @hidden */
  16885. _currentStartSize1: number;
  16886. /** @hidden */
  16887. _currentStartSize2: number;
  16888. private readonly _rawTextureWidth;
  16889. private _rampGradientsTexture;
  16890. private _useRampGradients;
  16891. /** Gets or sets a boolean indicating that ramp gradients must be used
  16892. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16893. */
  16894. useRampGradients: boolean;
  16895. /**
  16896. * 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.
  16897. * 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: [])
  16898. */
  16899. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16900. private _subEmitters;
  16901. /**
  16902. * @hidden
  16903. * If the particle systems emitter should be disposed when the particle system is disposed
  16904. */
  16905. _disposeEmitterOnDispose: boolean;
  16906. /**
  16907. * The current active Sub-systems, this property is used by the root particle system only.
  16908. */
  16909. activeSubSystems: Array<ParticleSystem>;
  16910. private _rootParticleSystem;
  16911. /**
  16912. * Gets the current list of active particles
  16913. */
  16914. readonly particles: Particle[];
  16915. /**
  16916. * Returns the string "ParticleSystem"
  16917. * @returns a string containing the class name
  16918. */
  16919. getClassName(): string;
  16920. /**
  16921. * Instantiates a particle system.
  16922. * 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.
  16923. * @param name The name of the particle system
  16924. * @param capacity The max number of particles alive at the same time
  16925. * @param scene The scene the particle system belongs to
  16926. * @param customEffect a custom effect used to change the way particles are rendered by default
  16927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16928. * @param epsilon Offset used to render the particles
  16929. */
  16930. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16931. private _addFactorGradient;
  16932. private _removeFactorGradient;
  16933. /**
  16934. * Adds a new life time gradient
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the life time factor to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific life time gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Adds a new size gradient
  16949. * @param gradient defines the gradient to use (between 0 and 1)
  16950. * @param factor defines the size factor to affect to the specified gradient
  16951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16952. * @returns the current particle system
  16953. */
  16954. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16955. /**
  16956. * Remove a specific size gradient
  16957. * @param gradient defines the gradient to remove
  16958. * @returns the current particle system
  16959. */
  16960. removeSizeGradient(gradient: number): IParticleSystem;
  16961. /**
  16962. * Adds a new color remap gradient
  16963. * @param gradient defines the gradient to use (between 0 and 1)
  16964. * @param min defines the color remap minimal range
  16965. * @param max defines the color remap maximal range
  16966. * @returns the current particle system
  16967. */
  16968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16969. /**
  16970. * Remove a specific color remap gradient
  16971. * @param gradient defines the gradient to remove
  16972. * @returns the current particle system
  16973. */
  16974. removeColorRemapGradient(gradient: number): IParticleSystem;
  16975. /**
  16976. * Adds a new alpha remap gradient
  16977. * @param gradient defines the gradient to use (between 0 and 1)
  16978. * @param min defines the alpha remap minimal range
  16979. * @param max defines the alpha remap maximal range
  16980. * @returns the current particle system
  16981. */
  16982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16983. /**
  16984. * Remove a specific alpha remap gradient
  16985. * @param gradient defines the gradient to remove
  16986. * @returns the current particle system
  16987. */
  16988. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16989. /**
  16990. * Adds a new angular speed gradient
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the angular speed to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific angular speed gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Adds a new velocity gradient
  17005. * @param gradient defines the gradient to use (between 0 and 1)
  17006. * @param factor defines the velocity to affect to the specified gradient
  17007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17008. * @returns the current particle system
  17009. */
  17010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17011. /**
  17012. * Remove a specific velocity gradient
  17013. * @param gradient defines the gradient to remove
  17014. * @returns the current particle system
  17015. */
  17016. removeVelocityGradient(gradient: number): IParticleSystem;
  17017. /**
  17018. * Adds a new limit velocity gradient
  17019. * @param gradient defines the gradient to use (between 0 and 1)
  17020. * @param factor defines the limit velocity value to affect to the specified gradient
  17021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17022. * @returns the current particle system
  17023. */
  17024. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17025. /**
  17026. * Remove a specific limit velocity gradient
  17027. * @param gradient defines the gradient to remove
  17028. * @returns the current particle system
  17029. */
  17030. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17031. /**
  17032. * Adds a new drag gradient
  17033. * @param gradient defines the gradient to use (between 0 and 1)
  17034. * @param factor defines the drag value to affect to the specified gradient
  17035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17036. * @returns the current particle system
  17037. */
  17038. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17039. /**
  17040. * Remove a specific drag gradient
  17041. * @param gradient defines the gradient to remove
  17042. * @returns the current particle system
  17043. */
  17044. removeDragGradient(gradient: number): IParticleSystem;
  17045. /**
  17046. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17047. * @param gradient defines the gradient to use (between 0 and 1)
  17048. * @param factor defines the emit rate value to affect to the specified gradient
  17049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17050. * @returns the current particle system
  17051. */
  17052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17053. /**
  17054. * Remove a specific emit rate gradient
  17055. * @param gradient defines the gradient to remove
  17056. * @returns the current particle system
  17057. */
  17058. removeEmitRateGradient(gradient: number): IParticleSystem;
  17059. /**
  17060. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17061. * @param gradient defines the gradient to use (between 0 and 1)
  17062. * @param factor defines the start size value to affect to the specified gradient
  17063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17064. * @returns the current particle system
  17065. */
  17066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17067. /**
  17068. * Remove a specific start size gradient
  17069. * @param gradient defines the gradient to remove
  17070. * @returns the current particle system
  17071. */
  17072. removeStartSizeGradient(gradient: number): IParticleSystem;
  17073. private _createRampGradientTexture;
  17074. /**
  17075. * Gets the current list of ramp gradients.
  17076. * You must use addRampGradient and removeRampGradient to udpate this list
  17077. * @returns the list of ramp gradients
  17078. */
  17079. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17080. /**
  17081. * Adds a new ramp gradient used to remap particle colors
  17082. * @param gradient defines the gradient to use (between 0 and 1)
  17083. * @param color defines the color to affect to the specified gradient
  17084. * @returns the current particle system
  17085. */
  17086. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17087. /**
  17088. * Remove a specific ramp gradient
  17089. * @param gradient defines the gradient to remove
  17090. * @returns the current particle system
  17091. */
  17092. removeRampGradient(gradient: number): ParticleSystem;
  17093. /**
  17094. * Adds a new color gradient
  17095. * @param gradient defines the gradient to use (between 0 and 1)
  17096. * @param color1 defines the color to affect to the specified gradient
  17097. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17098. * @returns this particle system
  17099. */
  17100. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17101. /**
  17102. * Remove a specific color gradient
  17103. * @param gradient defines the gradient to remove
  17104. * @returns this particle system
  17105. */
  17106. removeColorGradient(gradient: number): IParticleSystem;
  17107. private _fetchR;
  17108. protected _reset(): void;
  17109. private _resetEffect;
  17110. private _createVertexBuffers;
  17111. private _createIndexBuffer;
  17112. /**
  17113. * Gets the maximum number of particles active at the same time.
  17114. * @returns The max number of active particles.
  17115. */
  17116. getCapacity(): number;
  17117. /**
  17118. * Gets whether there are still active particles in the system.
  17119. * @returns True if it is alive, otherwise false.
  17120. */
  17121. isAlive(): boolean;
  17122. /**
  17123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17124. * @returns True if it has been started, otherwise false.
  17125. */
  17126. isStarted(): boolean;
  17127. private _prepareSubEmitterInternalArray;
  17128. /**
  17129. * Starts the particle system and begins to emit
  17130. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17131. */
  17132. start(delay?: number): void;
  17133. /**
  17134. * Stops the particle system.
  17135. * @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.
  17136. */
  17137. stop(stopSubEmitters?: boolean): void;
  17138. /**
  17139. * Remove all active particles
  17140. */
  17141. reset(): void;
  17142. /**
  17143. * @hidden (for internal use only)
  17144. */
  17145. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17146. /**
  17147. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17148. * Its lifetime will start back at 0.
  17149. */
  17150. recycleParticle: (particle: Particle) => void;
  17151. private _stopSubEmitters;
  17152. private _createParticle;
  17153. private _removeFromRoot;
  17154. private _emitFromParticle;
  17155. private _update;
  17156. /** @hidden */
  17157. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17158. /** @hidden */
  17159. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17160. /** @hidden */
  17161. private _getEffect;
  17162. /**
  17163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17164. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17165. */
  17166. animate(preWarmOnly?: boolean): void;
  17167. private _appendParticleVertices;
  17168. /**
  17169. * Rebuilds the particle system.
  17170. */
  17171. rebuild(): void;
  17172. /**
  17173. * Is this system ready to be used/rendered
  17174. * @return true if the system is ready
  17175. */
  17176. isReady(): boolean;
  17177. private _render;
  17178. /**
  17179. * Renders the particle system in its current state.
  17180. * @returns the current number of particles
  17181. */
  17182. render(): number;
  17183. /**
  17184. * Disposes the particle system and free the associated resources
  17185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17186. */
  17187. dispose(disposeTexture?: boolean): void;
  17188. /**
  17189. * Clones the particle system.
  17190. * @param name The name of the cloned object
  17191. * @param newEmitter The new emitter to use
  17192. * @returns the cloned particle system
  17193. */
  17194. clone(name: string, newEmitter: any): ParticleSystem;
  17195. /**
  17196. * Serializes the particle system to a JSON object.
  17197. * @returns the JSON object
  17198. */
  17199. serialize(): any;
  17200. /** @hidden */
  17201. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17202. /** @hidden */
  17203. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17204. /**
  17205. * Parses a JSON object to create a particle system.
  17206. * @param parsedParticleSystem The JSON object to parse
  17207. * @param scene The scene to create the particle system in
  17208. * @param rootUrl The root url to use to load external dependencies like texture
  17209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17210. * @returns the Parsed particle system
  17211. */
  17212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17213. }
  17214. }
  17215. declare module BABYLON {
  17216. /**
  17217. * A particle represents one of the element emitted by a particle system.
  17218. * This is mainly define by its coordinates, direction, velocity and age.
  17219. */
  17220. export class Particle {
  17221. /**
  17222. * The particle system the particle belongs to.
  17223. */
  17224. particleSystem: ParticleSystem;
  17225. private static _Count;
  17226. /**
  17227. * Unique ID of the particle
  17228. */
  17229. id: number;
  17230. /**
  17231. * The world position of the particle in the scene.
  17232. */
  17233. position: Vector3;
  17234. /**
  17235. * The world direction of the particle in the scene.
  17236. */
  17237. direction: Vector3;
  17238. /**
  17239. * The color of the particle.
  17240. */
  17241. color: Color4;
  17242. /**
  17243. * The color change of the particle per step.
  17244. */
  17245. colorStep: Color4;
  17246. /**
  17247. * Defines how long will the life of the particle be.
  17248. */
  17249. lifeTime: number;
  17250. /**
  17251. * The current age of the particle.
  17252. */
  17253. age: number;
  17254. /**
  17255. * The current size of the particle.
  17256. */
  17257. size: number;
  17258. /**
  17259. * The current scale of the particle.
  17260. */
  17261. scale: Vector2;
  17262. /**
  17263. * The current angle of the particle.
  17264. */
  17265. angle: number;
  17266. /**
  17267. * Defines how fast is the angle changing.
  17268. */
  17269. angularSpeed: number;
  17270. /**
  17271. * Defines the cell index used by the particle to be rendered from a sprite.
  17272. */
  17273. cellIndex: number;
  17274. /**
  17275. * The information required to support color remapping
  17276. */
  17277. remapData: Vector4;
  17278. /** @hidden */
  17279. _randomCellOffset?: number;
  17280. /** @hidden */
  17281. _initialDirection: Nullable<Vector3>;
  17282. /** @hidden */
  17283. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17284. /** @hidden */
  17285. _initialStartSpriteCellID: number;
  17286. /** @hidden */
  17287. _initialEndSpriteCellID: number;
  17288. /** @hidden */
  17289. _currentColorGradient: Nullable<ColorGradient>;
  17290. /** @hidden */
  17291. _currentColor1: Color4;
  17292. /** @hidden */
  17293. _currentColor2: Color4;
  17294. /** @hidden */
  17295. _currentSizeGradient: Nullable<FactorGradient>;
  17296. /** @hidden */
  17297. _currentSize1: number;
  17298. /** @hidden */
  17299. _currentSize2: number;
  17300. /** @hidden */
  17301. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17302. /** @hidden */
  17303. _currentAngularSpeed1: number;
  17304. /** @hidden */
  17305. _currentAngularSpeed2: number;
  17306. /** @hidden */
  17307. _currentVelocityGradient: Nullable<FactorGradient>;
  17308. /** @hidden */
  17309. _currentVelocity1: number;
  17310. /** @hidden */
  17311. _currentVelocity2: number;
  17312. /** @hidden */
  17313. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17314. /** @hidden */
  17315. _currentLimitVelocity1: number;
  17316. /** @hidden */
  17317. _currentLimitVelocity2: number;
  17318. /** @hidden */
  17319. _currentDragGradient: Nullable<FactorGradient>;
  17320. /** @hidden */
  17321. _currentDrag1: number;
  17322. /** @hidden */
  17323. _currentDrag2: number;
  17324. /** @hidden */
  17325. _randomNoiseCoordinates1: Vector3;
  17326. /** @hidden */
  17327. _randomNoiseCoordinates2: Vector3;
  17328. /**
  17329. * Creates a new instance Particle
  17330. * @param particleSystem the particle system the particle belongs to
  17331. */
  17332. constructor(
  17333. /**
  17334. * The particle system the particle belongs to.
  17335. */
  17336. particleSystem: ParticleSystem);
  17337. private updateCellInfoFromSystem;
  17338. /**
  17339. * Defines how the sprite cell index is updated for the particle
  17340. */
  17341. updateCellIndex(): void;
  17342. /** @hidden */
  17343. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17344. /** @hidden */
  17345. _inheritParticleInfoToSubEmitters(): void;
  17346. /** @hidden */
  17347. _reset(): void;
  17348. /**
  17349. * Copy the properties of particle to another one.
  17350. * @param other the particle to copy the information to.
  17351. */
  17352. copyTo(other: Particle): void;
  17353. }
  17354. }
  17355. declare module BABYLON {
  17356. /**
  17357. * Particle emitter represents a volume emitting particles.
  17358. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17359. */
  17360. export interface IParticleEmitterType {
  17361. /**
  17362. * Called by the particle System when the direction is computed for the created particle.
  17363. * @param worldMatrix is the world matrix of the particle system
  17364. * @param directionToUpdate is the direction vector to update with the result
  17365. * @param particle is the particle we are computed the direction for
  17366. */
  17367. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17368. /**
  17369. * Called by the particle System when the position is computed for the created particle.
  17370. * @param worldMatrix is the world matrix of the particle system
  17371. * @param positionToUpdate is the position vector to update with the result
  17372. * @param particle is the particle we are computed the position for
  17373. */
  17374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17375. /**
  17376. * Clones the current emitter and returns a copy of it
  17377. * @returns the new emitter
  17378. */
  17379. clone(): IParticleEmitterType;
  17380. /**
  17381. * Called by the GPUParticleSystem to setup the update shader
  17382. * @param effect defines the update shader
  17383. */
  17384. applyToShader(effect: Effect): void;
  17385. /**
  17386. * Returns a string to use to update the GPU particles update shader
  17387. * @returns the effect defines string
  17388. */
  17389. getEffectDefines(): string;
  17390. /**
  17391. * Returns a string representing the class name
  17392. * @returns a string containing the class name
  17393. */
  17394. getClassName(): string;
  17395. /**
  17396. * Serializes the particle system to a JSON object.
  17397. * @returns the JSON object
  17398. */
  17399. serialize(): any;
  17400. /**
  17401. * Parse properties from a JSON object
  17402. * @param serializationObject defines the JSON object
  17403. */
  17404. parse(serializationObject: any): void;
  17405. }
  17406. }
  17407. declare module BABYLON {
  17408. /**
  17409. * Particle emitter emitting particles from the inside of a box.
  17410. * It emits the particles randomly between 2 given directions.
  17411. */
  17412. export class BoxParticleEmitter implements IParticleEmitterType {
  17413. /**
  17414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17415. */
  17416. direction1: Vector3;
  17417. /**
  17418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17419. */
  17420. direction2: Vector3;
  17421. /**
  17422. * 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.
  17423. */
  17424. minEmitBox: Vector3;
  17425. /**
  17426. * 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.
  17427. */
  17428. maxEmitBox: Vector3;
  17429. /**
  17430. * Creates a new instance BoxParticleEmitter
  17431. */
  17432. constructor();
  17433. /**
  17434. * Called by the particle System when the direction is computed for the created particle.
  17435. * @param worldMatrix is the world matrix of the particle system
  17436. * @param directionToUpdate is the direction vector to update with the result
  17437. * @param particle is the particle we are computed the direction for
  17438. */
  17439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17440. /**
  17441. * Called by the particle System when the position is computed for the created particle.
  17442. * @param worldMatrix is the world matrix of the particle system
  17443. * @param positionToUpdate is the position vector to update with the result
  17444. * @param particle is the particle we are computed the position for
  17445. */
  17446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17447. /**
  17448. * Clones the current emitter and returns a copy of it
  17449. * @returns the new emitter
  17450. */
  17451. clone(): BoxParticleEmitter;
  17452. /**
  17453. * Called by the GPUParticleSystem to setup the update shader
  17454. * @param effect defines the update shader
  17455. */
  17456. applyToShader(effect: Effect): void;
  17457. /**
  17458. * Returns a string to use to update the GPU particles update shader
  17459. * @returns a string containng the defines string
  17460. */
  17461. getEffectDefines(): string;
  17462. /**
  17463. * Returns the string "BoxParticleEmitter"
  17464. * @returns a string containing the class name
  17465. */
  17466. getClassName(): string;
  17467. /**
  17468. * Serializes the particle system to a JSON object.
  17469. * @returns the JSON object
  17470. */
  17471. serialize(): any;
  17472. /**
  17473. * Parse properties from a JSON object
  17474. * @param serializationObject defines the JSON object
  17475. */
  17476. parse(serializationObject: any): void;
  17477. }
  17478. }
  17479. declare module BABYLON {
  17480. /**
  17481. * Particle emitter emitting particles from the inside of a cone.
  17482. * It emits the particles alongside the cone volume from the base to the particle.
  17483. * The emission direction might be randomized.
  17484. */
  17485. export class ConeParticleEmitter implements IParticleEmitterType {
  17486. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17487. directionRandomizer: number;
  17488. private _radius;
  17489. private _angle;
  17490. private _height;
  17491. /**
  17492. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17493. */
  17494. radiusRange: number;
  17495. /**
  17496. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17497. */
  17498. heightRange: number;
  17499. /**
  17500. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17501. */
  17502. emitFromSpawnPointOnly: boolean;
  17503. /**
  17504. * Gets or sets the radius of the emission cone
  17505. */
  17506. radius: number;
  17507. /**
  17508. * Gets or sets the angle of the emission cone
  17509. */
  17510. angle: number;
  17511. private _buildHeight;
  17512. /**
  17513. * Creates a new instance ConeParticleEmitter
  17514. * @param radius the radius of the emission cone (1 by default)
  17515. * @param angle the cone base angle (PI by default)
  17516. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17517. */
  17518. constructor(radius?: number, angle?: number,
  17519. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17520. directionRandomizer?: number);
  17521. /**
  17522. * Called by the particle System when the direction is computed for the created particle.
  17523. * @param worldMatrix is the world matrix of the particle system
  17524. * @param directionToUpdate is the direction vector to update with the result
  17525. * @param particle is the particle we are computed the direction for
  17526. */
  17527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17528. /**
  17529. * Called by the particle System when the position is computed for the created particle.
  17530. * @param worldMatrix is the world matrix of the particle system
  17531. * @param positionToUpdate is the position vector to update with the result
  17532. * @param particle is the particle we are computed the position for
  17533. */
  17534. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17535. /**
  17536. * Clones the current emitter and returns a copy of it
  17537. * @returns the new emitter
  17538. */
  17539. clone(): ConeParticleEmitter;
  17540. /**
  17541. * Called by the GPUParticleSystem to setup the update shader
  17542. * @param effect defines the update shader
  17543. */
  17544. applyToShader(effect: Effect): void;
  17545. /**
  17546. * Returns a string to use to update the GPU particles update shader
  17547. * @returns a string containng the defines string
  17548. */
  17549. getEffectDefines(): string;
  17550. /**
  17551. * Returns the string "ConeParticleEmitter"
  17552. * @returns a string containing the class name
  17553. */
  17554. getClassName(): string;
  17555. /**
  17556. * Serializes the particle system to a JSON object.
  17557. * @returns the JSON object
  17558. */
  17559. serialize(): any;
  17560. /**
  17561. * Parse properties from a JSON object
  17562. * @param serializationObject defines the JSON object
  17563. */
  17564. parse(serializationObject: any): void;
  17565. }
  17566. }
  17567. declare module BABYLON {
  17568. /**
  17569. * Particle emitter emitting particles from the inside of a cylinder.
  17570. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17571. */
  17572. export class CylinderParticleEmitter implements IParticleEmitterType {
  17573. /**
  17574. * The radius of the emission cylinder.
  17575. */
  17576. radius: number;
  17577. /**
  17578. * The height of the emission cylinder.
  17579. */
  17580. height: number;
  17581. /**
  17582. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17583. */
  17584. radiusRange: number;
  17585. /**
  17586. * How much to randomize the particle direction [0-1].
  17587. */
  17588. directionRandomizer: number;
  17589. /**
  17590. * Creates a new instance CylinderParticleEmitter
  17591. * @param radius the radius of the emission cylinder (1 by default)
  17592. * @param height the height of the emission cylinder (1 by default)
  17593. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17594. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17595. */
  17596. constructor(
  17597. /**
  17598. * The radius of the emission cylinder.
  17599. */
  17600. radius?: number,
  17601. /**
  17602. * The height of the emission cylinder.
  17603. */
  17604. height?: number,
  17605. /**
  17606. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17607. */
  17608. radiusRange?: number,
  17609. /**
  17610. * How much to randomize the particle direction [0-1].
  17611. */
  17612. directionRandomizer?: number);
  17613. /**
  17614. * Called by the particle System when the direction is computed for the created particle.
  17615. * @param worldMatrix is the world matrix of the particle system
  17616. * @param directionToUpdate is the direction vector to update with the result
  17617. * @param particle is the particle we are computed the direction for
  17618. */
  17619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17620. /**
  17621. * Called by the particle System when the position is computed for the created particle.
  17622. * @param worldMatrix is the world matrix of the particle system
  17623. * @param positionToUpdate is the position vector to update with the result
  17624. * @param particle is the particle we are computed the position for
  17625. */
  17626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17627. /**
  17628. * Clones the current emitter and returns a copy of it
  17629. * @returns the new emitter
  17630. */
  17631. clone(): CylinderParticleEmitter;
  17632. /**
  17633. * Called by the GPUParticleSystem to setup the update shader
  17634. * @param effect defines the update shader
  17635. */
  17636. applyToShader(effect: Effect): void;
  17637. /**
  17638. * Returns a string to use to update the GPU particles update shader
  17639. * @returns a string containng the defines string
  17640. */
  17641. getEffectDefines(): string;
  17642. /**
  17643. * Returns the string "CylinderParticleEmitter"
  17644. * @returns a string containing the class name
  17645. */
  17646. getClassName(): string;
  17647. /**
  17648. * Serializes the particle system to a JSON object.
  17649. * @returns the JSON object
  17650. */
  17651. serialize(): any;
  17652. /**
  17653. * Parse properties from a JSON object
  17654. * @param serializationObject defines the JSON object
  17655. */
  17656. parse(serializationObject: any): void;
  17657. }
  17658. /**
  17659. * Particle emitter emitting particles from the inside of a cylinder.
  17660. * It emits the particles randomly between two vectors.
  17661. */
  17662. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17663. /**
  17664. * The min limit of the emission direction.
  17665. */
  17666. direction1: Vector3;
  17667. /**
  17668. * The max limit of the emission direction.
  17669. */
  17670. direction2: Vector3;
  17671. /**
  17672. * Creates a new instance CylinderDirectedParticleEmitter
  17673. * @param radius the radius of the emission cylinder (1 by default)
  17674. * @param height the height of the emission cylinder (1 by default)
  17675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17676. * @param direction1 the min limit of the emission direction (up vector by default)
  17677. * @param direction2 the max limit of the emission direction (up vector by default)
  17678. */
  17679. constructor(radius?: number, height?: number, radiusRange?: number,
  17680. /**
  17681. * The min limit of the emission direction.
  17682. */
  17683. direction1?: Vector3,
  17684. /**
  17685. * The max limit of the emission direction.
  17686. */
  17687. direction2?: Vector3);
  17688. /**
  17689. * Called by the particle System when the direction is computed for the created particle.
  17690. * @param worldMatrix is the world matrix of the particle system
  17691. * @param directionToUpdate is the direction vector to update with the result
  17692. * @param particle is the particle we are computed the direction for
  17693. */
  17694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17695. /**
  17696. * Clones the current emitter and returns a copy of it
  17697. * @returns the new emitter
  17698. */
  17699. clone(): CylinderDirectedParticleEmitter;
  17700. /**
  17701. * Called by the GPUParticleSystem to setup the update shader
  17702. * @param effect defines the update shader
  17703. */
  17704. applyToShader(effect: Effect): void;
  17705. /**
  17706. * Returns a string to use to update the GPU particles update shader
  17707. * @returns a string containng the defines string
  17708. */
  17709. getEffectDefines(): string;
  17710. /**
  17711. * Returns the string "CylinderDirectedParticleEmitter"
  17712. * @returns a string containing the class name
  17713. */
  17714. getClassName(): string;
  17715. /**
  17716. * Serializes the particle system to a JSON object.
  17717. * @returns the JSON object
  17718. */
  17719. serialize(): any;
  17720. /**
  17721. * Parse properties from a JSON object
  17722. * @param serializationObject defines the JSON object
  17723. */
  17724. parse(serializationObject: any): void;
  17725. }
  17726. }
  17727. declare module BABYLON {
  17728. /**
  17729. * Particle emitter emitting particles from the inside of a hemisphere.
  17730. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17731. */
  17732. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17733. /**
  17734. * The radius of the emission hemisphere.
  17735. */
  17736. radius: number;
  17737. /**
  17738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17739. */
  17740. radiusRange: number;
  17741. /**
  17742. * How much to randomize the particle direction [0-1].
  17743. */
  17744. directionRandomizer: number;
  17745. /**
  17746. * Creates a new instance HemisphericParticleEmitter
  17747. * @param radius the radius of the emission hemisphere (1 by default)
  17748. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17749. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17750. */
  17751. constructor(
  17752. /**
  17753. * The radius of the emission hemisphere.
  17754. */
  17755. radius?: number,
  17756. /**
  17757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17758. */
  17759. radiusRange?: number,
  17760. /**
  17761. * How much to randomize the particle direction [0-1].
  17762. */
  17763. directionRandomizer?: number);
  17764. /**
  17765. * Called by the particle System when the direction is computed for the created particle.
  17766. * @param worldMatrix is the world matrix of the particle system
  17767. * @param directionToUpdate is the direction vector to update with the result
  17768. * @param particle is the particle we are computed the direction for
  17769. */
  17770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17771. /**
  17772. * Called by the particle System when the position is computed for the created particle.
  17773. * @param worldMatrix is the world matrix of the particle system
  17774. * @param positionToUpdate is the position vector to update with the result
  17775. * @param particle is the particle we are computed the position for
  17776. */
  17777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17778. /**
  17779. * Clones the current emitter and returns a copy of it
  17780. * @returns the new emitter
  17781. */
  17782. clone(): HemisphericParticleEmitter;
  17783. /**
  17784. * Called by the GPUParticleSystem to setup the update shader
  17785. * @param effect defines the update shader
  17786. */
  17787. applyToShader(effect: Effect): void;
  17788. /**
  17789. * Returns a string to use to update the GPU particles update shader
  17790. * @returns a string containng the defines string
  17791. */
  17792. getEffectDefines(): string;
  17793. /**
  17794. * Returns the string "HemisphericParticleEmitter"
  17795. * @returns a string containing the class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Serializes the particle system to a JSON object.
  17800. * @returns the JSON object
  17801. */
  17802. serialize(): any;
  17803. /**
  17804. * Parse properties from a JSON object
  17805. * @param serializationObject defines the JSON object
  17806. */
  17807. parse(serializationObject: any): void;
  17808. }
  17809. }
  17810. declare module BABYLON {
  17811. /**
  17812. * Particle emitter emitting particles from a point.
  17813. * It emits the particles randomly between 2 given directions.
  17814. */
  17815. export class PointParticleEmitter implements IParticleEmitterType {
  17816. /**
  17817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17818. */
  17819. direction1: Vector3;
  17820. /**
  17821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17822. */
  17823. direction2: Vector3;
  17824. /**
  17825. * Creates a new instance PointParticleEmitter
  17826. */
  17827. constructor();
  17828. /**
  17829. * Called by the particle System when the direction is computed for the created particle.
  17830. * @param worldMatrix is the world matrix of the particle system
  17831. * @param directionToUpdate is the direction vector to update with the result
  17832. * @param particle is the particle we are computed the direction for
  17833. */
  17834. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17835. /**
  17836. * Called by the particle System when the position is computed for the created particle.
  17837. * @param worldMatrix is the world matrix of the particle system
  17838. * @param positionToUpdate is the position vector to update with the result
  17839. * @param particle is the particle we are computed the position for
  17840. */
  17841. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17842. /**
  17843. * Clones the current emitter and returns a copy of it
  17844. * @returns the new emitter
  17845. */
  17846. clone(): PointParticleEmitter;
  17847. /**
  17848. * Called by the GPUParticleSystem to setup the update shader
  17849. * @param effect defines the update shader
  17850. */
  17851. applyToShader(effect: Effect): void;
  17852. /**
  17853. * Returns a string to use to update the GPU particles update shader
  17854. * @returns a string containng the defines string
  17855. */
  17856. getEffectDefines(): string;
  17857. /**
  17858. * Returns the string "PointParticleEmitter"
  17859. * @returns a string containing the class name
  17860. */
  17861. getClassName(): string;
  17862. /**
  17863. * Serializes the particle system to a JSON object.
  17864. * @returns the JSON object
  17865. */
  17866. serialize(): any;
  17867. /**
  17868. * Parse properties from a JSON object
  17869. * @param serializationObject defines the JSON object
  17870. */
  17871. parse(serializationObject: any): void;
  17872. }
  17873. }
  17874. declare module BABYLON {
  17875. /**
  17876. * Particle emitter emitting particles from the inside of a sphere.
  17877. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17878. */
  17879. export class SphereParticleEmitter implements IParticleEmitterType {
  17880. /**
  17881. * The radius of the emission sphere.
  17882. */
  17883. radius: number;
  17884. /**
  17885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17886. */
  17887. radiusRange: number;
  17888. /**
  17889. * How much to randomize the particle direction [0-1].
  17890. */
  17891. directionRandomizer: number;
  17892. /**
  17893. * Creates a new instance SphereParticleEmitter
  17894. * @param radius the radius of the emission sphere (1 by default)
  17895. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17897. */
  17898. constructor(
  17899. /**
  17900. * The radius of the emission sphere.
  17901. */
  17902. radius?: number,
  17903. /**
  17904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17905. */
  17906. radiusRange?: number,
  17907. /**
  17908. * How much to randomize the particle direction [0-1].
  17909. */
  17910. directionRandomizer?: number);
  17911. /**
  17912. * Called by the particle System when the direction is computed for the created particle.
  17913. * @param worldMatrix is the world matrix of the particle system
  17914. * @param directionToUpdate is the direction vector to update with the result
  17915. * @param particle is the particle we are computed the direction for
  17916. */
  17917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17918. /**
  17919. * Called by the particle System when the position is computed for the created particle.
  17920. * @param worldMatrix is the world matrix of the particle system
  17921. * @param positionToUpdate is the position vector to update with the result
  17922. * @param particle is the particle we are computed the position for
  17923. */
  17924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17925. /**
  17926. * Clones the current emitter and returns a copy of it
  17927. * @returns the new emitter
  17928. */
  17929. clone(): SphereParticleEmitter;
  17930. /**
  17931. * Called by the GPUParticleSystem to setup the update shader
  17932. * @param effect defines the update shader
  17933. */
  17934. applyToShader(effect: Effect): void;
  17935. /**
  17936. * Returns a string to use to update the GPU particles update shader
  17937. * @returns a string containng the defines string
  17938. */
  17939. getEffectDefines(): string;
  17940. /**
  17941. * Returns the string "SphereParticleEmitter"
  17942. * @returns a string containing the class name
  17943. */
  17944. getClassName(): string;
  17945. /**
  17946. * Serializes the particle system to a JSON object.
  17947. * @returns the JSON object
  17948. */
  17949. serialize(): any;
  17950. /**
  17951. * Parse properties from a JSON object
  17952. * @param serializationObject defines the JSON object
  17953. */
  17954. parse(serializationObject: any): void;
  17955. }
  17956. /**
  17957. * Particle emitter emitting particles from the inside of a sphere.
  17958. * It emits the particles randomly between two vectors.
  17959. */
  17960. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17961. /**
  17962. * The min limit of the emission direction.
  17963. */
  17964. direction1: Vector3;
  17965. /**
  17966. * The max limit of the emission direction.
  17967. */
  17968. direction2: Vector3;
  17969. /**
  17970. * Creates a new instance SphereDirectedParticleEmitter
  17971. * @param radius the radius of the emission sphere (1 by default)
  17972. * @param direction1 the min limit of the emission direction (up vector by default)
  17973. * @param direction2 the max limit of the emission direction (up vector by default)
  17974. */
  17975. constructor(radius?: number,
  17976. /**
  17977. * The min limit of the emission direction.
  17978. */
  17979. direction1?: Vector3,
  17980. /**
  17981. * The max limit of the emission direction.
  17982. */
  17983. direction2?: Vector3);
  17984. /**
  17985. * Called by the particle System when the direction is computed for the created particle.
  17986. * @param worldMatrix is the world matrix of the particle system
  17987. * @param directionToUpdate is the direction vector to update with the result
  17988. * @param particle is the particle we are computed the direction for
  17989. */
  17990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17991. /**
  17992. * Clones the current emitter and returns a copy of it
  17993. * @returns the new emitter
  17994. */
  17995. clone(): SphereDirectedParticleEmitter;
  17996. /**
  17997. * Called by the GPUParticleSystem to setup the update shader
  17998. * @param effect defines the update shader
  17999. */
  18000. applyToShader(effect: Effect): void;
  18001. /**
  18002. * Returns a string to use to update the GPU particles update shader
  18003. * @returns a string containng the defines string
  18004. */
  18005. getEffectDefines(): string;
  18006. /**
  18007. * Returns the string "SphereDirectedParticleEmitter"
  18008. * @returns a string containing the class name
  18009. */
  18010. getClassName(): string;
  18011. /**
  18012. * Serializes the particle system to a JSON object.
  18013. * @returns the JSON object
  18014. */
  18015. serialize(): any;
  18016. /**
  18017. * Parse properties from a JSON object
  18018. * @param serializationObject defines the JSON object
  18019. */
  18020. parse(serializationObject: any): void;
  18021. }
  18022. }
  18023. declare module BABYLON {
  18024. /**
  18025. * Interface representing a particle system in Babylon.js.
  18026. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18027. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18028. */
  18029. export interface IParticleSystem {
  18030. /**
  18031. * List of animations used by the particle system.
  18032. */
  18033. animations: Animation[];
  18034. /**
  18035. * The id of the Particle system.
  18036. */
  18037. id: string;
  18038. /**
  18039. * The name of the Particle system.
  18040. */
  18041. name: string;
  18042. /**
  18043. * The emitter represents the Mesh or position we are attaching the particle system to.
  18044. */
  18045. emitter: Nullable<AbstractMesh | Vector3>;
  18046. /**
  18047. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18048. */
  18049. isBillboardBased: boolean;
  18050. /**
  18051. * The rendering group used by the Particle system to chose when to render.
  18052. */
  18053. renderingGroupId: number;
  18054. /**
  18055. * The layer mask we are rendering the particles through.
  18056. */
  18057. layerMask: number;
  18058. /**
  18059. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18060. */
  18061. updateSpeed: number;
  18062. /**
  18063. * The amount of time the particle system is running (depends of the overall update speed).
  18064. */
  18065. targetStopDuration: number;
  18066. /**
  18067. * The texture used to render each particle. (this can be a spritesheet)
  18068. */
  18069. particleTexture: Nullable<Texture>;
  18070. /**
  18071. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18072. */
  18073. blendMode: number;
  18074. /**
  18075. * Minimum life time of emitting particles.
  18076. */
  18077. minLifeTime: number;
  18078. /**
  18079. * Maximum life time of emitting particles.
  18080. */
  18081. maxLifeTime: number;
  18082. /**
  18083. * Minimum Size of emitting particles.
  18084. */
  18085. minSize: number;
  18086. /**
  18087. * Maximum Size of emitting particles.
  18088. */
  18089. maxSize: number;
  18090. /**
  18091. * Minimum scale of emitting particles on X axis.
  18092. */
  18093. minScaleX: number;
  18094. /**
  18095. * Maximum scale of emitting particles on X axis.
  18096. */
  18097. maxScaleX: number;
  18098. /**
  18099. * Minimum scale of emitting particles on Y axis.
  18100. */
  18101. minScaleY: number;
  18102. /**
  18103. * Maximum scale of emitting particles on Y axis.
  18104. */
  18105. maxScaleY: number;
  18106. /**
  18107. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18108. */
  18109. color1: Color4;
  18110. /**
  18111. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18112. */
  18113. color2: Color4;
  18114. /**
  18115. * Color the particle will have at the end of its lifetime.
  18116. */
  18117. colorDead: Color4;
  18118. /**
  18119. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18120. */
  18121. emitRate: number;
  18122. /**
  18123. * You can use gravity if you want to give an orientation to your particles.
  18124. */
  18125. gravity: Vector3;
  18126. /**
  18127. * Minimum power of emitting particles.
  18128. */
  18129. minEmitPower: number;
  18130. /**
  18131. * Maximum power of emitting particles.
  18132. */
  18133. maxEmitPower: number;
  18134. /**
  18135. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18136. */
  18137. minAngularSpeed: number;
  18138. /**
  18139. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18140. */
  18141. maxAngularSpeed: number;
  18142. /**
  18143. * Gets or sets the minimal initial rotation in radians.
  18144. */
  18145. minInitialRotation: number;
  18146. /**
  18147. * Gets or sets the maximal initial rotation in radians.
  18148. */
  18149. maxInitialRotation: number;
  18150. /**
  18151. * The particle emitter type defines the emitter used by the particle system.
  18152. * It can be for example box, sphere, or cone...
  18153. */
  18154. particleEmitterType: Nullable<IParticleEmitterType>;
  18155. /**
  18156. * Defines the delay in milliseconds before starting the system (0 by default)
  18157. */
  18158. startDelay: number;
  18159. /**
  18160. * 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
  18161. */
  18162. preWarmCycles: number;
  18163. /**
  18164. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18165. */
  18166. preWarmStepOffset: number;
  18167. /**
  18168. * 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)
  18169. */
  18170. spriteCellChangeSpeed: number;
  18171. /**
  18172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18173. */
  18174. startSpriteCellID: number;
  18175. /**
  18176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18177. */
  18178. endSpriteCellID: number;
  18179. /**
  18180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18181. */
  18182. spriteCellWidth: number;
  18183. /**
  18184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18185. */
  18186. spriteCellHeight: number;
  18187. /**
  18188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18189. */
  18190. spriteRandomStartCell: boolean;
  18191. /**
  18192. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18193. */
  18194. isAnimationSheetEnabled: boolean;
  18195. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18196. translationPivot: Vector2;
  18197. /**
  18198. * Gets or sets a texture used to add random noise to particle positions
  18199. */
  18200. noiseTexture: Nullable<BaseTexture>;
  18201. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18202. noiseStrength: Vector3;
  18203. /**
  18204. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18205. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18206. */
  18207. billboardMode: number;
  18208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18209. limitVelocityDamping: number;
  18210. /**
  18211. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18212. */
  18213. beginAnimationOnStart: boolean;
  18214. /**
  18215. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18216. */
  18217. beginAnimationFrom: number;
  18218. /**
  18219. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18220. */
  18221. beginAnimationTo: number;
  18222. /**
  18223. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18224. */
  18225. beginAnimationLoop: boolean;
  18226. /**
  18227. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18228. */
  18229. disposeOnStop: boolean;
  18230. /**
  18231. * Gets the maximum number of particles active at the same time.
  18232. * @returns The max number of active particles.
  18233. */
  18234. getCapacity(): number;
  18235. /**
  18236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18237. * @returns True if it has been started, otherwise false.
  18238. */
  18239. isStarted(): boolean;
  18240. /**
  18241. * Animates the particle system for this frame.
  18242. */
  18243. animate(): void;
  18244. /**
  18245. * Renders the particle system in its current state.
  18246. * @returns the current number of particles
  18247. */
  18248. render(): number;
  18249. /**
  18250. * Dispose the particle system and frees its associated resources.
  18251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18252. */
  18253. dispose(disposeTexture?: boolean): void;
  18254. /**
  18255. * Clones the particle system.
  18256. * @param name The name of the cloned object
  18257. * @param newEmitter The new emitter to use
  18258. * @returns the cloned particle system
  18259. */
  18260. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Rebuild the particle system
  18268. */
  18269. rebuild(): void;
  18270. /**
  18271. * Starts the particle system and begins to emit
  18272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18273. */
  18274. start(delay?: number): void;
  18275. /**
  18276. * Stops the particle system.
  18277. */
  18278. stop(): void;
  18279. /**
  18280. * Remove all active particles
  18281. */
  18282. reset(): void;
  18283. /**
  18284. * Is this system ready to be used/rendered
  18285. * @return true if the system is ready
  18286. */
  18287. isReady(): boolean;
  18288. /**
  18289. * Adds a new color gradient
  18290. * @param gradient defines the gradient to use (between 0 and 1)
  18291. * @param color1 defines the color to affect to the specified gradient
  18292. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18293. * @returns the current particle system
  18294. */
  18295. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18296. /**
  18297. * Remove a specific color gradient
  18298. * @param gradient defines the gradient to remove
  18299. * @returns the current particle system
  18300. */
  18301. removeColorGradient(gradient: number): IParticleSystem;
  18302. /**
  18303. * Adds a new size gradient
  18304. * @param gradient defines the gradient to use (between 0 and 1)
  18305. * @param factor defines the size factor to affect to the specified gradient
  18306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18307. * @returns the current particle system
  18308. */
  18309. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18310. /**
  18311. * Remove a specific size gradient
  18312. * @param gradient defines the gradient to remove
  18313. * @returns the current particle system
  18314. */
  18315. removeSizeGradient(gradient: number): IParticleSystem;
  18316. /**
  18317. * Gets the current list of color gradients.
  18318. * You must use addColorGradient and removeColorGradient to udpate this list
  18319. * @returns the list of color gradients
  18320. */
  18321. getColorGradients(): Nullable<Array<ColorGradient>>;
  18322. /**
  18323. * Gets the current list of size gradients.
  18324. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18325. * @returns the list of size gradients
  18326. */
  18327. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18328. /**
  18329. * Gets the current list of angular speed gradients.
  18330. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18331. * @returns the list of angular speed gradients
  18332. */
  18333. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18334. /**
  18335. * Adds a new angular speed gradient
  18336. * @param gradient defines the gradient to use (between 0 and 1)
  18337. * @param factor defines the angular speed to affect to the specified gradient
  18338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18339. * @returns the current particle system
  18340. */
  18341. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18342. /**
  18343. * Remove a specific angular speed gradient
  18344. * @param gradient defines the gradient to remove
  18345. * @returns the current particle system
  18346. */
  18347. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18348. /**
  18349. * Gets the current list of velocity gradients.
  18350. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18351. * @returns the list of velocity gradients
  18352. */
  18353. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18354. /**
  18355. * Adds a new velocity gradient
  18356. * @param gradient defines the gradient to use (between 0 and 1)
  18357. * @param factor defines the velocity to affect to the specified gradient
  18358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18359. * @returns the current particle system
  18360. */
  18361. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18362. /**
  18363. * Remove a specific velocity gradient
  18364. * @param gradient defines the gradient to remove
  18365. * @returns the current particle system
  18366. */
  18367. removeVelocityGradient(gradient: number): IParticleSystem;
  18368. /**
  18369. * Gets the current list of limit velocity gradients.
  18370. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18371. * @returns the list of limit velocity gradients
  18372. */
  18373. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18374. /**
  18375. * Adds a new limit velocity gradient
  18376. * @param gradient defines the gradient to use (between 0 and 1)
  18377. * @param factor defines the limit velocity to affect to the specified gradient
  18378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18379. * @returns the current particle system
  18380. */
  18381. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18382. /**
  18383. * Remove a specific limit velocity gradient
  18384. * @param gradient defines the gradient to remove
  18385. * @returns the current particle system
  18386. */
  18387. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18388. /**
  18389. * Adds a new drag gradient
  18390. * @param gradient defines the gradient to use (between 0 and 1)
  18391. * @param factor defines the drag to affect to the specified gradient
  18392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18393. * @returns the current particle system
  18394. */
  18395. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18396. /**
  18397. * Remove a specific drag gradient
  18398. * @param gradient defines the gradient to remove
  18399. * @returns the current particle system
  18400. */
  18401. removeDragGradient(gradient: number): IParticleSystem;
  18402. /**
  18403. * Gets the current list of drag gradients.
  18404. * You must use addDragGradient and removeDragGradient to udpate this list
  18405. * @returns the list of drag gradients
  18406. */
  18407. getDragGradients(): Nullable<Array<FactorGradient>>;
  18408. /**
  18409. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18410. * @param gradient defines the gradient to use (between 0 and 1)
  18411. * @param factor defines the emit rate to affect to the specified gradient
  18412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18413. * @returns the current particle system
  18414. */
  18415. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18416. /**
  18417. * Remove a specific emit rate gradient
  18418. * @param gradient defines the gradient to remove
  18419. * @returns the current particle system
  18420. */
  18421. removeEmitRateGradient(gradient: number): IParticleSystem;
  18422. /**
  18423. * Gets the current list of emit rate gradients.
  18424. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18425. * @returns the list of emit rate gradients
  18426. */
  18427. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18428. /**
  18429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18430. * @param gradient defines the gradient to use (between 0 and 1)
  18431. * @param factor defines the start size to affect to the specified gradient
  18432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18433. * @returns the current particle system
  18434. */
  18435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18436. /**
  18437. * Remove a specific start size gradient
  18438. * @param gradient defines the gradient to remove
  18439. * @returns the current particle system
  18440. */
  18441. removeStartSizeGradient(gradient: number): IParticleSystem;
  18442. /**
  18443. * Gets the current list of start size gradients.
  18444. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18445. * @returns the list of start size gradients
  18446. */
  18447. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18448. /**
  18449. * Adds a new life time gradient
  18450. * @param gradient defines the gradient to use (between 0 and 1)
  18451. * @param factor defines the life time factor to affect to the specified gradient
  18452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18453. * @returns the current particle system
  18454. */
  18455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18456. /**
  18457. * Remove a specific life time gradient
  18458. * @param gradient defines the gradient to remove
  18459. * @returns the current particle system
  18460. */
  18461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18462. /**
  18463. * Gets the current list of life time gradients.
  18464. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18465. * @returns the list of life time gradients
  18466. */
  18467. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18468. /**
  18469. * Gets the current list of color gradients.
  18470. * You must use addColorGradient and removeColorGradient to udpate this list
  18471. * @returns the list of color gradients
  18472. */
  18473. getColorGradients(): Nullable<Array<ColorGradient>>;
  18474. /**
  18475. * Adds a new ramp gradient used to remap particle colors
  18476. * @param gradient defines the gradient to use (between 0 and 1)
  18477. * @param color defines the color to affect to the specified gradient
  18478. * @returns the current particle system
  18479. */
  18480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18481. /**
  18482. * Gets the current list of ramp gradients.
  18483. * You must use addRampGradient and removeRampGradient to udpate this list
  18484. * @returns the list of ramp gradients
  18485. */
  18486. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18487. /** Gets or sets a boolean indicating that ramp gradients must be used
  18488. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18489. */
  18490. useRampGradients: boolean;
  18491. /**
  18492. * Adds a new color remap gradient
  18493. * @param gradient defines the gradient to use (between 0 and 1)
  18494. * @param min defines the color remap minimal range
  18495. * @param max defines the color remap maximal range
  18496. * @returns the current particle system
  18497. */
  18498. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18499. /**
  18500. * Gets the current list of color remap gradients.
  18501. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18502. * @returns the list of color remap gradients
  18503. */
  18504. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18505. /**
  18506. * Adds a new alpha remap gradient
  18507. * @param gradient defines the gradient to use (between 0 and 1)
  18508. * @param min defines the alpha remap minimal range
  18509. * @param max defines the alpha remap maximal range
  18510. * @returns the current particle system
  18511. */
  18512. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18513. /**
  18514. * Gets the current list of alpha remap gradients.
  18515. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18516. * @returns the list of alpha remap gradients
  18517. */
  18518. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18519. /**
  18520. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18523. * @returns the emitter
  18524. */
  18525. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18526. /**
  18527. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18528. * @param radius The radius of the hemisphere to emit from
  18529. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18530. * @returns the emitter
  18531. */
  18532. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18533. /**
  18534. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18535. * @param radius The radius of the sphere to emit from
  18536. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18537. * @returns the emitter
  18538. */
  18539. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18540. /**
  18541. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18542. * @param radius The radius of the sphere to emit from
  18543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18545. * @returns the emitter
  18546. */
  18547. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18548. /**
  18549. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18550. * @param radius The radius of the emission cylinder
  18551. * @param height The height of the emission cylinder
  18552. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18553. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18554. * @returns the emitter
  18555. */
  18556. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18557. /**
  18558. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18559. * @param radius The radius of the cylinder to emit from
  18560. * @param height The height of the emission cylinder
  18561. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18564. * @returns the emitter
  18565. */
  18566. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18567. /**
  18568. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18569. * @param radius The radius of the cone to emit from
  18570. * @param angle The base angle of the cone
  18571. * @returns the emitter
  18572. */
  18573. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18574. /**
  18575. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18578. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18579. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18580. * @returns the emitter
  18581. */
  18582. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18583. /**
  18584. * Get hosting scene
  18585. * @returns the scene
  18586. */
  18587. getScene(): Scene;
  18588. }
  18589. }
  18590. declare module BABYLON {
  18591. /**
  18592. * Creates an instance based on a source mesh.
  18593. */
  18594. export class InstancedMesh extends AbstractMesh {
  18595. private _sourceMesh;
  18596. private _currentLOD;
  18597. /** @hidden */
  18598. _indexInSourceMeshInstanceArray: number;
  18599. constructor(name: string, source: Mesh);
  18600. /**
  18601. * Returns the string "InstancedMesh".
  18602. */
  18603. getClassName(): string;
  18604. /** Gets the list of lights affecting that mesh */
  18605. readonly lightSources: Light[];
  18606. _resyncLightSources(): void;
  18607. _resyncLighSource(light: Light): void;
  18608. _removeLightSource(light: Light, dispose: boolean): void;
  18609. /**
  18610. * If the source mesh receives shadows
  18611. */
  18612. readonly receiveShadows: boolean;
  18613. /**
  18614. * The material of the source mesh
  18615. */
  18616. readonly material: Nullable<Material>;
  18617. /**
  18618. * Visibility of the source mesh
  18619. */
  18620. readonly visibility: number;
  18621. /**
  18622. * Skeleton of the source mesh
  18623. */
  18624. readonly skeleton: Nullable<Skeleton>;
  18625. /**
  18626. * Rendering ground id of the source mesh
  18627. */
  18628. renderingGroupId: number;
  18629. /**
  18630. * Returns the total number of vertices (integer).
  18631. */
  18632. getTotalVertices(): number;
  18633. /**
  18634. * Returns a positive integer : the total number of indices in this mesh geometry.
  18635. * @returns the numner of indices or zero if the mesh has no geometry.
  18636. */
  18637. getTotalIndices(): number;
  18638. /**
  18639. * The source mesh of the instance
  18640. */
  18641. readonly sourceMesh: Mesh;
  18642. /**
  18643. * Is this node ready to be used/rendered
  18644. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18645. * @return {boolean} is it ready
  18646. */
  18647. isReady(completeCheck?: boolean): boolean;
  18648. /**
  18649. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18650. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18651. * @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.
  18652. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18653. */
  18654. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18655. /**
  18656. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18657. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18658. * The `data` are either a numeric array either a Float32Array.
  18659. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18660. * 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).
  18661. * Note that a new underlying VertexBuffer object is created each call.
  18662. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18663. *
  18664. * Possible `kind` values :
  18665. * - VertexBuffer.PositionKind
  18666. * - VertexBuffer.UVKind
  18667. * - VertexBuffer.UV2Kind
  18668. * - VertexBuffer.UV3Kind
  18669. * - VertexBuffer.UV4Kind
  18670. * - VertexBuffer.UV5Kind
  18671. * - VertexBuffer.UV6Kind
  18672. * - VertexBuffer.ColorKind
  18673. * - VertexBuffer.MatricesIndicesKind
  18674. * - VertexBuffer.MatricesIndicesExtraKind
  18675. * - VertexBuffer.MatricesWeightsKind
  18676. * - VertexBuffer.MatricesWeightsExtraKind
  18677. *
  18678. * Returns the Mesh.
  18679. */
  18680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18681. /**
  18682. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18683. * If the mesh has no geometry, it is simply returned as it is.
  18684. * The `data` are either a numeric array either a Float32Array.
  18685. * No new underlying VertexBuffer object is created.
  18686. * 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.
  18687. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18688. *
  18689. * Possible `kind` values :
  18690. * - VertexBuffer.PositionKind
  18691. * - VertexBuffer.UVKind
  18692. * - VertexBuffer.UV2Kind
  18693. * - VertexBuffer.UV3Kind
  18694. * - VertexBuffer.UV4Kind
  18695. * - VertexBuffer.UV5Kind
  18696. * - VertexBuffer.UV6Kind
  18697. * - VertexBuffer.ColorKind
  18698. * - VertexBuffer.MatricesIndicesKind
  18699. * - VertexBuffer.MatricesIndicesExtraKind
  18700. * - VertexBuffer.MatricesWeightsKind
  18701. * - VertexBuffer.MatricesWeightsExtraKind
  18702. *
  18703. * Returns the Mesh.
  18704. */
  18705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18706. /**
  18707. * Sets the mesh indices.
  18708. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18710. * This method creates a new index buffer each call.
  18711. * Returns the Mesh.
  18712. */
  18713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18714. /**
  18715. * Boolean : True if the mesh owns the requested kind of data.
  18716. */
  18717. isVerticesDataPresent(kind: string): boolean;
  18718. /**
  18719. * Returns an array of indices (IndicesArray).
  18720. */
  18721. getIndices(): Nullable<IndicesArray>;
  18722. readonly _positions: Nullable<Vector3[]>;
  18723. /**
  18724. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18725. * This means the mesh underlying bounding box and sphere are recomputed.
  18726. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18727. * @returns the current mesh
  18728. */
  18729. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18730. /** @hidden */
  18731. _preActivate(): InstancedMesh;
  18732. /** @hidden */
  18733. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18734. /** @hidden */
  18735. _postActivate(): void;
  18736. getWorldMatrix(): Matrix;
  18737. readonly isAnInstance: boolean;
  18738. /**
  18739. * Returns the current associated LOD AbstractMesh.
  18740. */
  18741. getLOD(camera: Camera): AbstractMesh;
  18742. /** @hidden */
  18743. _syncSubMeshes(): InstancedMesh;
  18744. /** @hidden */
  18745. _generatePointsArray(): boolean;
  18746. /**
  18747. * Creates a new InstancedMesh from the current mesh.
  18748. * - name (string) : the cloned mesh name
  18749. * - newParent (optional Node) : the optional Node to parent the clone to.
  18750. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18751. *
  18752. * Returns the clone.
  18753. */
  18754. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18755. /**
  18756. * Disposes the InstancedMesh.
  18757. * Returns nothing.
  18758. */
  18759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18760. }
  18761. }
  18762. declare module BABYLON {
  18763. /**
  18764. * Defines the options associated with the creation of a shader material.
  18765. */
  18766. export interface IShaderMaterialOptions {
  18767. /**
  18768. * Does the material work in alpha blend mode
  18769. */
  18770. needAlphaBlending: boolean;
  18771. /**
  18772. * Does the material work in alpha test mode
  18773. */
  18774. needAlphaTesting: boolean;
  18775. /**
  18776. * The list of attribute names used in the shader
  18777. */
  18778. attributes: string[];
  18779. /**
  18780. * The list of unifrom names used in the shader
  18781. */
  18782. uniforms: string[];
  18783. /**
  18784. * The list of UBO names used in the shader
  18785. */
  18786. uniformBuffers: string[];
  18787. /**
  18788. * The list of sampler names used in the shader
  18789. */
  18790. samplers: string[];
  18791. /**
  18792. * The list of defines used in the shader
  18793. */
  18794. defines: string[];
  18795. }
  18796. /**
  18797. * 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.
  18798. *
  18799. * This returned material effects how the mesh will look based on the code in the shaders.
  18800. *
  18801. * @see http://doc.babylonjs.com/how_to/shader_material
  18802. */
  18803. export class ShaderMaterial extends Material {
  18804. private _shaderPath;
  18805. private _options;
  18806. private _textures;
  18807. private _textureArrays;
  18808. private _floats;
  18809. private _ints;
  18810. private _floatsArrays;
  18811. private _colors3;
  18812. private _colors3Arrays;
  18813. private _colors4;
  18814. private _colors4Arrays;
  18815. private _vectors2;
  18816. private _vectors3;
  18817. private _vectors4;
  18818. private _matrices;
  18819. private _matrices3x3;
  18820. private _matrices2x2;
  18821. private _vectors2Arrays;
  18822. private _vectors3Arrays;
  18823. private _vectors4Arrays;
  18824. private _cachedWorldViewMatrix;
  18825. private _cachedWorldViewProjectionMatrix;
  18826. private _renderId;
  18827. /**
  18828. * Instantiate a new shader material.
  18829. * 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.
  18830. * This returned material effects how the mesh will look based on the code in the shaders.
  18831. * @see http://doc.babylonjs.com/how_to/shader_material
  18832. * @param name Define the name of the material in the scene
  18833. * @param scene Define the scene the material belongs to
  18834. * @param shaderPath Defines the route to the shader code in one of three ways:
  18835. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18836. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18837. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18838. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18839. * @param options Define the options used to create the shader
  18840. */
  18841. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18842. /**
  18843. * Gets the options used to compile the shader.
  18844. * They can be modified to trigger a new compilation
  18845. */
  18846. readonly options: IShaderMaterialOptions;
  18847. /**
  18848. * Gets the current class name of the material e.g. "ShaderMaterial"
  18849. * Mainly use in serialization.
  18850. * @returns the class name
  18851. */
  18852. getClassName(): string;
  18853. /**
  18854. * Specifies if the material will require alpha blending
  18855. * @returns a boolean specifying if alpha blending is needed
  18856. */
  18857. needAlphaBlending(): boolean;
  18858. /**
  18859. * Specifies if this material should be rendered in alpha test mode
  18860. * @returns a boolean specifying if an alpha test is needed.
  18861. */
  18862. needAlphaTesting(): boolean;
  18863. private _checkUniform;
  18864. /**
  18865. * Set a texture in the shader.
  18866. * @param name Define the name of the uniform samplers as defined in the shader
  18867. * @param texture Define the texture to bind to this sampler
  18868. * @return the material itself allowing "fluent" like uniform updates
  18869. */
  18870. setTexture(name: string, texture: Texture): ShaderMaterial;
  18871. /**
  18872. * Set a texture array in the shader.
  18873. * @param name Define the name of the uniform sampler array as defined in the shader
  18874. * @param textures Define the list of textures to bind to this sampler
  18875. * @return the material itself allowing "fluent" like uniform updates
  18876. */
  18877. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18878. /**
  18879. * Set a float in the shader.
  18880. * @param name Define the name of the uniform as defined in the shader
  18881. * @param value Define the value to give to the uniform
  18882. * @return the material itself allowing "fluent" like uniform updates
  18883. */
  18884. setFloat(name: string, value: number): ShaderMaterial;
  18885. /**
  18886. * Set a int in the shader.
  18887. * @param name Define the name of the uniform as defined in the shader
  18888. * @param value Define the value to give to the uniform
  18889. * @return the material itself allowing "fluent" like uniform updates
  18890. */
  18891. setInt(name: string, value: number): ShaderMaterial;
  18892. /**
  18893. * Set an array of floats in the shader.
  18894. * @param name Define the name of the uniform as defined in the shader
  18895. * @param value Define the value to give to the uniform
  18896. * @return the material itself allowing "fluent" like uniform updates
  18897. */
  18898. setFloats(name: string, value: number[]): ShaderMaterial;
  18899. /**
  18900. * Set a vec3 in the shader from a Color3.
  18901. * @param name Define the name of the uniform as defined in the shader
  18902. * @param value Define the value to give to the uniform
  18903. * @return the material itself allowing "fluent" like uniform updates
  18904. */
  18905. setColor3(name: string, value: Color3): ShaderMaterial;
  18906. /**
  18907. * Set a vec3 array in the shader from a Color3 array.
  18908. * @param name Define the name of the uniform as defined in the shader
  18909. * @param value Define the value to give to the uniform
  18910. * @return the material itself allowing "fluent" like uniform updates
  18911. */
  18912. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18913. /**
  18914. * Set a vec4 in the shader from a Color4.
  18915. * @param name Define the name of the uniform as defined in the shader
  18916. * @param value Define the value to give to the uniform
  18917. * @return the material itself allowing "fluent" like uniform updates
  18918. */
  18919. setColor4(name: string, value: Color4): ShaderMaterial;
  18920. /**
  18921. * Set a vec4 array in the shader from a Color4 array.
  18922. * @param name Define the name of the uniform as defined in the shader
  18923. * @param value Define the value to give to the uniform
  18924. * @return the material itself allowing "fluent" like uniform updates
  18925. */
  18926. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18927. /**
  18928. * Set a vec2 in the shader from a Vector2.
  18929. * @param name Define the name of the uniform as defined in the shader
  18930. * @param value Define the value to give to the uniform
  18931. * @return the material itself allowing "fluent" like uniform updates
  18932. */
  18933. setVector2(name: string, value: Vector2): ShaderMaterial;
  18934. /**
  18935. * Set a vec3 in the shader from a Vector3.
  18936. * @param name Define the name of the uniform as defined in the shader
  18937. * @param value Define the value to give to the uniform
  18938. * @return the material itself allowing "fluent" like uniform updates
  18939. */
  18940. setVector3(name: string, value: Vector3): ShaderMaterial;
  18941. /**
  18942. * Set a vec4 in the shader from a Vector4.
  18943. * @param name Define the name of the uniform as defined in the shader
  18944. * @param value Define the value to give to the uniform
  18945. * @return the material itself allowing "fluent" like uniform updates
  18946. */
  18947. setVector4(name: string, value: Vector4): ShaderMaterial;
  18948. /**
  18949. * Set a mat4 in the shader from a Matrix.
  18950. * @param name Define the name of the uniform as defined in the shader
  18951. * @param value Define the value to give to the uniform
  18952. * @return the material itself allowing "fluent" like uniform updates
  18953. */
  18954. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18955. /**
  18956. * Set a mat3 in the shader from a Float32Array.
  18957. * @param name Define the name of the uniform as defined in the shader
  18958. * @param value Define the value to give to the uniform
  18959. * @return the material itself allowing "fluent" like uniform updates
  18960. */
  18961. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18962. /**
  18963. * Set a mat2 in the shader from a Float32Array.
  18964. * @param name Define the name of the uniform as defined in the shader
  18965. * @param value Define the value to give to the uniform
  18966. * @return the material itself allowing "fluent" like uniform updates
  18967. */
  18968. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18969. /**
  18970. * Set a vec2 array in the shader from a number array.
  18971. * @param name Define the name of the uniform as defined in the shader
  18972. * @param value Define the value to give to the uniform
  18973. * @return the material itself allowing "fluent" like uniform updates
  18974. */
  18975. setArray2(name: string, value: number[]): ShaderMaterial;
  18976. /**
  18977. * Set a vec3 array in the shader from a number array.
  18978. * @param name Define the name of the uniform as defined in the shader
  18979. * @param value Define the value to give to the uniform
  18980. * @return the material itself allowing "fluent" like uniform updates
  18981. */
  18982. setArray3(name: string, value: number[]): ShaderMaterial;
  18983. /**
  18984. * Set a vec4 array in the shader from a number array.
  18985. * @param name Define the name of the uniform as defined in the shader
  18986. * @param value Define the value to give to the uniform
  18987. * @return the material itself allowing "fluent" like uniform updates
  18988. */
  18989. setArray4(name: string, value: number[]): ShaderMaterial;
  18990. private _checkCache;
  18991. /**
  18992. * Specifies that the submesh is ready to be used
  18993. * @param mesh defines the mesh to check
  18994. * @param subMesh defines which submesh to check
  18995. * @param useInstances specifies that instances should be used
  18996. * @returns a boolean indicating that the submesh is ready or not
  18997. */
  18998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18999. /**
  19000. * Checks if the material is ready to render the requested mesh
  19001. * @param mesh Define the mesh to render
  19002. * @param useInstances Define whether or not the material is used with instances
  19003. * @returns true if ready, otherwise false
  19004. */
  19005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19006. /**
  19007. * Binds the world matrix to the material
  19008. * @param world defines the world transformation matrix
  19009. */
  19010. bindOnlyWorldMatrix(world: Matrix): void;
  19011. /**
  19012. * Binds the material to the mesh
  19013. * @param world defines the world transformation matrix
  19014. * @param mesh defines the mesh to bind the material to
  19015. */
  19016. bind(world: Matrix, mesh?: Mesh): void;
  19017. /**
  19018. * Gets the active textures from the material
  19019. * @returns an array of textures
  19020. */
  19021. getActiveTextures(): BaseTexture[];
  19022. /**
  19023. * Specifies if the material uses a texture
  19024. * @param texture defines the texture to check against the material
  19025. * @returns a boolean specifying if the material uses the texture
  19026. */
  19027. hasTexture(texture: BaseTexture): boolean;
  19028. /**
  19029. * Makes a duplicate of the material, and gives it a new name
  19030. * @param name defines the new name for the duplicated material
  19031. * @returns the cloned material
  19032. */
  19033. clone(name: string): ShaderMaterial;
  19034. /**
  19035. * Disposes the material
  19036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19039. */
  19040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19041. /**
  19042. * Serializes this material in a JSON representation
  19043. * @returns the serialized material object
  19044. */
  19045. serialize(): any;
  19046. /**
  19047. * Creates a shader material from parsed shader material data
  19048. * @param source defines the JSON represnetation of the material
  19049. * @param scene defines the hosting scene
  19050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19051. * @returns a new material
  19052. */
  19053. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19054. }
  19055. }
  19056. declare module BABYLON {
  19057. /** @hidden */
  19058. export var colorPixelShader: {
  19059. name: string;
  19060. shader: string;
  19061. };
  19062. }
  19063. declare module BABYLON {
  19064. /** @hidden */
  19065. export var colorVertexShader: {
  19066. name: string;
  19067. shader: string;
  19068. };
  19069. }
  19070. declare module BABYLON {
  19071. /**
  19072. * Line mesh
  19073. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19074. */
  19075. export class LinesMesh extends Mesh {
  19076. /**
  19077. * If vertex color should be applied to the mesh
  19078. */
  19079. readonly useVertexColor?: boolean | undefined;
  19080. /**
  19081. * If vertex alpha should be applied to the mesh
  19082. */
  19083. readonly useVertexAlpha?: boolean | undefined;
  19084. /**
  19085. * Color of the line (Default: White)
  19086. */
  19087. color: Color3;
  19088. /**
  19089. * Alpha of the line (Default: 1)
  19090. */
  19091. alpha: number;
  19092. /**
  19093. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19094. * This margin is expressed in world space coordinates, so its value may vary.
  19095. * Default value is 0.1
  19096. */
  19097. intersectionThreshold: number;
  19098. private _colorShader;
  19099. private color4;
  19100. /**
  19101. * Creates a new LinesMesh
  19102. * @param name defines the name
  19103. * @param scene defines the hosting scene
  19104. * @param parent defines the parent mesh if any
  19105. * @param source defines the optional source LinesMesh used to clone data from
  19106. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19107. * When false, achieved by calling a clone(), also passing False.
  19108. * This will make creation of children, recursive.
  19109. * @param useVertexColor defines if this LinesMesh supports vertex color
  19110. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19111. */
  19112. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19113. /**
  19114. * If vertex color should be applied to the mesh
  19115. */
  19116. useVertexColor?: boolean | undefined,
  19117. /**
  19118. * If vertex alpha should be applied to the mesh
  19119. */
  19120. useVertexAlpha?: boolean | undefined);
  19121. private _addClipPlaneDefine;
  19122. private _removeClipPlaneDefine;
  19123. isReady(): boolean;
  19124. /**
  19125. * Returns the string "LineMesh"
  19126. */
  19127. getClassName(): string;
  19128. /**
  19129. * @hidden
  19130. */
  19131. /**
  19132. * @hidden
  19133. */
  19134. material: Material;
  19135. /**
  19136. * @hidden
  19137. */
  19138. readonly checkCollisions: boolean;
  19139. /** @hidden */
  19140. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19141. /** @hidden */
  19142. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19143. /**
  19144. * Disposes of the line mesh
  19145. * @param doNotRecurse If children should be disposed
  19146. */
  19147. dispose(doNotRecurse?: boolean): void;
  19148. /**
  19149. * Returns a new LineMesh object cloned from the current one.
  19150. */
  19151. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19152. /**
  19153. * Creates a new InstancedLinesMesh object from the mesh model.
  19154. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19155. * @param name defines the name of the new instance
  19156. * @returns a new InstancedLinesMesh
  19157. */
  19158. createInstance(name: string): InstancedLinesMesh;
  19159. }
  19160. /**
  19161. * Creates an instance based on a source LinesMesh
  19162. */
  19163. export class InstancedLinesMesh extends InstancedMesh {
  19164. /**
  19165. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19166. * This margin is expressed in world space coordinates, so its value may vary.
  19167. * Initilized with the intersectionThreshold value of the source LinesMesh
  19168. */
  19169. intersectionThreshold: number;
  19170. constructor(name: string, source: LinesMesh);
  19171. /**
  19172. * Returns the string "InstancedLinesMesh".
  19173. */
  19174. getClassName(): string;
  19175. }
  19176. }
  19177. declare module BABYLON {
  19178. /** @hidden */
  19179. export var linePixelShader: {
  19180. name: string;
  19181. shader: string;
  19182. };
  19183. }
  19184. declare module BABYLON {
  19185. /** @hidden */
  19186. export var lineVertexShader: {
  19187. name: string;
  19188. shader: string;
  19189. };
  19190. }
  19191. declare module BABYLON {
  19192. interface AbstractMesh {
  19193. /**
  19194. * Gets the edgesRenderer associated with the mesh
  19195. */
  19196. edgesRenderer: Nullable<EdgesRenderer>;
  19197. }
  19198. interface LinesMesh {
  19199. /**
  19200. * Enables the edge rendering mode on the mesh.
  19201. * This mode makes the mesh edges visible
  19202. * @param epsilon defines the maximal distance between two angles to detect a face
  19203. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19204. * @returns the currentAbstractMesh
  19205. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19206. */
  19207. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19208. }
  19209. interface InstancedLinesMesh {
  19210. /**
  19211. * Enables the edge rendering mode on the mesh.
  19212. * This mode makes the mesh edges visible
  19213. * @param epsilon defines the maximal distance between two angles to detect a face
  19214. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19215. * @returns the current InstancedLinesMesh
  19216. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19217. */
  19218. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19219. }
  19220. /**
  19221. * Defines the minimum contract an Edges renderer should follow.
  19222. */
  19223. export interface IEdgesRenderer extends IDisposable {
  19224. /**
  19225. * Gets or sets a boolean indicating if the edgesRenderer is active
  19226. */
  19227. isEnabled: boolean;
  19228. /**
  19229. * Renders the edges of the attached mesh,
  19230. */
  19231. render(): void;
  19232. /**
  19233. * Checks wether or not the edges renderer is ready to render.
  19234. * @return true if ready, otherwise false.
  19235. */
  19236. isReady(): boolean;
  19237. }
  19238. /**
  19239. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19240. */
  19241. export class EdgesRenderer implements IEdgesRenderer {
  19242. /**
  19243. * Define the size of the edges with an orthographic camera
  19244. */
  19245. edgesWidthScalerForOrthographic: number;
  19246. /**
  19247. * Define the size of the edges with a perspective camera
  19248. */
  19249. edgesWidthScalerForPerspective: number;
  19250. protected _source: AbstractMesh;
  19251. protected _linesPositions: number[];
  19252. protected _linesNormals: number[];
  19253. protected _linesIndices: number[];
  19254. protected _epsilon: number;
  19255. protected _indicesCount: number;
  19256. protected _lineShader: ShaderMaterial;
  19257. protected _ib: DataBuffer;
  19258. protected _buffers: {
  19259. [key: string]: Nullable<VertexBuffer>;
  19260. };
  19261. protected _checkVerticesInsteadOfIndices: boolean;
  19262. private _meshRebuildObserver;
  19263. private _meshDisposeObserver;
  19264. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19265. isEnabled: boolean;
  19266. /**
  19267. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19268. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19269. * @param source Mesh used to create edges
  19270. * @param epsilon sum of angles in adjacency to check for edge
  19271. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19272. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19273. */
  19274. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19275. protected _prepareRessources(): void;
  19276. /** @hidden */
  19277. _rebuild(): void;
  19278. /**
  19279. * Releases the required resources for the edges renderer
  19280. */
  19281. dispose(): void;
  19282. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19283. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19284. /**
  19285. * Checks if the pair of p0 and p1 is en edge
  19286. * @param faceIndex
  19287. * @param edge
  19288. * @param faceNormals
  19289. * @param p0
  19290. * @param p1
  19291. * @private
  19292. */
  19293. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19294. /**
  19295. * push line into the position, normal and index buffer
  19296. * @protected
  19297. */
  19298. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19299. /**
  19300. * Generates lines edges from adjacencjes
  19301. * @private
  19302. */
  19303. _generateEdgesLines(): void;
  19304. /**
  19305. * Checks wether or not the edges renderer is ready to render.
  19306. * @return true if ready, otherwise false.
  19307. */
  19308. isReady(): boolean;
  19309. /**
  19310. * Renders the edges of the attached mesh,
  19311. */
  19312. render(): void;
  19313. }
  19314. /**
  19315. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19316. */
  19317. export class LineEdgesRenderer extends EdgesRenderer {
  19318. /**
  19319. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19320. * @param source LineMesh used to generate edges
  19321. * @param epsilon not important (specified angle for edge detection)
  19322. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19323. */
  19324. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19325. /**
  19326. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19327. */
  19328. _generateEdgesLines(): void;
  19329. }
  19330. }
  19331. declare module BABYLON {
  19332. /**
  19333. * This represents the object necessary to create a rendering group.
  19334. * This is exclusively used and created by the rendering manager.
  19335. * To modify the behavior, you use the available helpers in your scene or meshes.
  19336. * @hidden
  19337. */
  19338. export class RenderingGroup {
  19339. index: number;
  19340. private static _zeroVector;
  19341. private _scene;
  19342. private _opaqueSubMeshes;
  19343. private _transparentSubMeshes;
  19344. private _alphaTestSubMeshes;
  19345. private _depthOnlySubMeshes;
  19346. private _particleSystems;
  19347. private _spriteManagers;
  19348. private _opaqueSortCompareFn;
  19349. private _alphaTestSortCompareFn;
  19350. private _transparentSortCompareFn;
  19351. private _renderOpaque;
  19352. private _renderAlphaTest;
  19353. private _renderTransparent;
  19354. /** @hidden */
  19355. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19356. onBeforeTransparentRendering: () => void;
  19357. /**
  19358. * Set the opaque sort comparison function.
  19359. * If null the sub meshes will be render in the order they were created
  19360. */
  19361. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19362. /**
  19363. * Set the alpha test sort comparison function.
  19364. * If null the sub meshes will be render in the order they were created
  19365. */
  19366. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19367. /**
  19368. * Set the transparent sort comparison function.
  19369. * If null the sub meshes will be render in the order they were created
  19370. */
  19371. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19372. /**
  19373. * Creates a new rendering group.
  19374. * @param index The rendering group index
  19375. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19376. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19377. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19378. */
  19379. 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>);
  19380. /**
  19381. * Render all the sub meshes contained in the group.
  19382. * @param customRenderFunction Used to override the default render behaviour of the group.
  19383. * @returns true if rendered some submeshes.
  19384. */
  19385. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19386. /**
  19387. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19388. * @param subMeshes The submeshes to render
  19389. */
  19390. private renderOpaqueSorted;
  19391. /**
  19392. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19393. * @param subMeshes The submeshes to render
  19394. */
  19395. private renderAlphaTestSorted;
  19396. /**
  19397. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19398. * @param subMeshes The submeshes to render
  19399. */
  19400. private renderTransparentSorted;
  19401. /**
  19402. * Renders the submeshes in a specified order.
  19403. * @param subMeshes The submeshes to sort before render
  19404. * @param sortCompareFn The comparison function use to sort
  19405. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19406. * @param transparent Specifies to activate blending if true
  19407. */
  19408. private static renderSorted;
  19409. /**
  19410. * Renders the submeshes in the order they were dispatched (no sort applied).
  19411. * @param subMeshes The submeshes to render
  19412. */
  19413. private static renderUnsorted;
  19414. /**
  19415. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19416. * are rendered back to front if in the same alpha index.
  19417. *
  19418. * @param a The first submesh
  19419. * @param b The second submesh
  19420. * @returns The result of the comparison
  19421. */
  19422. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19423. /**
  19424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19425. * are rendered back to front.
  19426. *
  19427. * @param a The first submesh
  19428. * @param b The second submesh
  19429. * @returns The result of the comparison
  19430. */
  19431. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19432. /**
  19433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19434. * are rendered front to back (prevent overdraw).
  19435. *
  19436. * @param a The first submesh
  19437. * @param b The second submesh
  19438. * @returns The result of the comparison
  19439. */
  19440. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19441. /**
  19442. * Resets the different lists of submeshes to prepare a new frame.
  19443. */
  19444. prepare(): void;
  19445. dispose(): void;
  19446. /**
  19447. * Inserts the submesh in its correct queue depending on its material.
  19448. * @param subMesh The submesh to dispatch
  19449. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19450. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19451. */
  19452. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19453. dispatchSprites(spriteManager: ISpriteManager): void;
  19454. dispatchParticles(particleSystem: IParticleSystem): void;
  19455. private _renderParticles;
  19456. private _renderSprites;
  19457. }
  19458. }
  19459. declare module BABYLON {
  19460. /**
  19461. * Interface describing the different options available in the rendering manager
  19462. * regarding Auto Clear between groups.
  19463. */
  19464. export interface IRenderingManagerAutoClearSetup {
  19465. /**
  19466. * Defines whether or not autoclear is enable.
  19467. */
  19468. autoClear: boolean;
  19469. /**
  19470. * Defines whether or not to autoclear the depth buffer.
  19471. */
  19472. depth: boolean;
  19473. /**
  19474. * Defines whether or not to autoclear the stencil buffer.
  19475. */
  19476. stencil: boolean;
  19477. }
  19478. /**
  19479. * This class is used by the onRenderingGroupObservable
  19480. */
  19481. export class RenderingGroupInfo {
  19482. /**
  19483. * The Scene that being rendered
  19484. */
  19485. scene: Scene;
  19486. /**
  19487. * The camera currently used for the rendering pass
  19488. */
  19489. camera: Nullable<Camera>;
  19490. /**
  19491. * The ID of the renderingGroup being processed
  19492. */
  19493. renderingGroupId: number;
  19494. }
  19495. /**
  19496. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19497. * It is enable to manage the different groups as well as the different necessary sort functions.
  19498. * This should not be used directly aside of the few static configurations
  19499. */
  19500. export class RenderingManager {
  19501. /**
  19502. * The max id used for rendering groups (not included)
  19503. */
  19504. static MAX_RENDERINGGROUPS: number;
  19505. /**
  19506. * The min id used for rendering groups (included)
  19507. */
  19508. static MIN_RENDERINGGROUPS: number;
  19509. /**
  19510. * Used to globally prevent autoclearing scenes.
  19511. */
  19512. static AUTOCLEAR: boolean;
  19513. /**
  19514. * @hidden
  19515. */
  19516. _useSceneAutoClearSetup: boolean;
  19517. private _scene;
  19518. private _renderingGroups;
  19519. private _depthStencilBufferAlreadyCleaned;
  19520. private _autoClearDepthStencil;
  19521. private _customOpaqueSortCompareFn;
  19522. private _customAlphaTestSortCompareFn;
  19523. private _customTransparentSortCompareFn;
  19524. private _renderingGroupInfo;
  19525. /**
  19526. * Instantiates a new rendering group for a particular scene
  19527. * @param scene Defines the scene the groups belongs to
  19528. */
  19529. constructor(scene: Scene);
  19530. private _clearDepthStencilBuffer;
  19531. /**
  19532. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19533. * @hidden
  19534. */
  19535. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19536. /**
  19537. * Resets the different information of the group to prepare a new frame
  19538. * @hidden
  19539. */
  19540. reset(): void;
  19541. /**
  19542. * Dispose and release the group and its associated resources.
  19543. * @hidden
  19544. */
  19545. dispose(): void;
  19546. /**
  19547. * Clear the info related to rendering groups preventing retention points during dispose.
  19548. */
  19549. freeRenderingGroups(): void;
  19550. private _prepareRenderingGroup;
  19551. /**
  19552. * Add a sprite manager to the rendering manager in order to render it this frame.
  19553. * @param spriteManager Define the sprite manager to render
  19554. */
  19555. dispatchSprites(spriteManager: ISpriteManager): void;
  19556. /**
  19557. * Add a particle system to the rendering manager in order to render it this frame.
  19558. * @param particleSystem Define the particle system to render
  19559. */
  19560. dispatchParticles(particleSystem: IParticleSystem): void;
  19561. /**
  19562. * Add a submesh to the manager in order to render it this frame
  19563. * @param subMesh The submesh to dispatch
  19564. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19565. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19566. */
  19567. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19568. /**
  19569. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19570. * This allowed control for front to back rendering or reversly depending of the special needs.
  19571. *
  19572. * @param renderingGroupId The rendering group id corresponding to its index
  19573. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19574. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19575. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19576. */
  19577. 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;
  19578. /**
  19579. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19580. *
  19581. * @param renderingGroupId The rendering group id corresponding to its index
  19582. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19583. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19584. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19585. */
  19586. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19587. /**
  19588. * Gets the current auto clear configuration for one rendering group of the rendering
  19589. * manager.
  19590. * @param index the rendering group index to get the information for
  19591. * @returns The auto clear setup for the requested rendering group
  19592. */
  19593. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19594. }
  19595. }
  19596. declare module BABYLON {
  19597. /**
  19598. * This Helps creating a texture that will be created from a camera in your scene.
  19599. * It is basically a dynamic texture that could be used to create special effects for instance.
  19600. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19601. */
  19602. export class RenderTargetTexture extends Texture {
  19603. isCube: boolean;
  19604. /**
  19605. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19606. */
  19607. static readonly REFRESHRATE_RENDER_ONCE: number;
  19608. /**
  19609. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19610. */
  19611. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19612. /**
  19613. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19614. * the central point of your effect and can save a lot of performances.
  19615. */
  19616. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19617. /**
  19618. * Use this predicate to dynamically define the list of mesh you want to render.
  19619. * If set, the renderList property will be overwritten.
  19620. */
  19621. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19622. private _renderList;
  19623. /**
  19624. * Use this list to define the list of mesh you want to render.
  19625. */
  19626. renderList: Nullable<Array<AbstractMesh>>;
  19627. private _hookArray;
  19628. /**
  19629. * Define if particles should be rendered in your texture.
  19630. */
  19631. renderParticles: boolean;
  19632. /**
  19633. * Define if sprites should be rendered in your texture.
  19634. */
  19635. renderSprites: boolean;
  19636. /**
  19637. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19638. */
  19639. coordinatesMode: number;
  19640. /**
  19641. * Define the camera used to render the texture.
  19642. */
  19643. activeCamera: Nullable<Camera>;
  19644. /**
  19645. * Override the render function of the texture with your own one.
  19646. */
  19647. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19648. /**
  19649. * Define if camera post processes should be use while rendering the texture.
  19650. */
  19651. useCameraPostProcesses: boolean;
  19652. /**
  19653. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19654. */
  19655. ignoreCameraViewport: boolean;
  19656. private _postProcessManager;
  19657. private _postProcesses;
  19658. private _resizeObserver;
  19659. /**
  19660. * An event triggered when the texture is unbind.
  19661. */
  19662. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19663. /**
  19664. * An event triggered when the texture is unbind.
  19665. */
  19666. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19667. private _onAfterUnbindObserver;
  19668. /**
  19669. * Set a after unbind callback in the texture.
  19670. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19671. */
  19672. onAfterUnbind: () => void;
  19673. /**
  19674. * An event triggered before rendering the texture
  19675. */
  19676. onBeforeRenderObservable: Observable<number>;
  19677. private _onBeforeRenderObserver;
  19678. /**
  19679. * Set a before render callback in the texture.
  19680. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19681. */
  19682. onBeforeRender: (faceIndex: number) => void;
  19683. /**
  19684. * An event triggered after rendering the texture
  19685. */
  19686. onAfterRenderObservable: Observable<number>;
  19687. private _onAfterRenderObserver;
  19688. /**
  19689. * Set a after render callback in the texture.
  19690. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19691. */
  19692. onAfterRender: (faceIndex: number) => void;
  19693. /**
  19694. * An event triggered after the texture clear
  19695. */
  19696. onClearObservable: Observable<Engine>;
  19697. private _onClearObserver;
  19698. /**
  19699. * Set a clear callback in the texture.
  19700. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19701. */
  19702. onClear: (Engine: Engine) => void;
  19703. /**
  19704. * An event triggered when the texture is resized.
  19705. */
  19706. onResizeObservable: Observable<RenderTargetTexture>;
  19707. /**
  19708. * Define the clear color of the Render Target if it should be different from the scene.
  19709. */
  19710. clearColor: Color4;
  19711. protected _size: number | {
  19712. width: number;
  19713. height: number;
  19714. };
  19715. protected _initialSizeParameter: number | {
  19716. width: number;
  19717. height: number;
  19718. } | {
  19719. ratio: number;
  19720. };
  19721. protected _sizeRatio: Nullable<number>;
  19722. /** @hidden */
  19723. _generateMipMaps: boolean;
  19724. protected _renderingManager: RenderingManager;
  19725. /** @hidden */
  19726. _waitingRenderList: string[];
  19727. protected _doNotChangeAspectRatio: boolean;
  19728. protected _currentRefreshId: number;
  19729. protected _refreshRate: number;
  19730. protected _textureMatrix: Matrix;
  19731. protected _samples: number;
  19732. protected _renderTargetOptions: RenderTargetCreationOptions;
  19733. /**
  19734. * Gets render target creation options that were used.
  19735. */
  19736. readonly renderTargetOptions: RenderTargetCreationOptions;
  19737. protected _engine: Engine;
  19738. protected _onRatioRescale(): void;
  19739. /**
  19740. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19741. * It must define where the camera used to render the texture is set
  19742. */
  19743. boundingBoxPosition: Vector3;
  19744. private _boundingBoxSize;
  19745. /**
  19746. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19747. * When defined, the cubemap will switch to local mode
  19748. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19749. * @example https://www.babylonjs-playground.com/#RNASML
  19750. */
  19751. boundingBoxSize: Vector3;
  19752. /**
  19753. * In case the RTT has been created with a depth texture, get the associated
  19754. * depth texture.
  19755. * Otherwise, return null.
  19756. */
  19757. depthStencilTexture: Nullable<InternalTexture>;
  19758. /**
  19759. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19760. * or used a shadow, depth texture...
  19761. * @param name The friendly name of the texture
  19762. * @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)
  19763. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19764. * @param generateMipMaps True if mip maps need to be generated after render.
  19765. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19766. * @param type The type of the buffer in the RTT (int, half float, float...)
  19767. * @param isCube True if a cube texture needs to be created
  19768. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19769. * @param generateDepthBuffer True to generate a depth buffer
  19770. * @param generateStencilBuffer True to generate a stencil buffer
  19771. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19772. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19773. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19774. */
  19775. constructor(name: string, size: number | {
  19776. width: number;
  19777. height: number;
  19778. } | {
  19779. ratio: number;
  19780. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19781. /**
  19782. * Creates a depth stencil texture.
  19783. * This is only available in WebGL 2 or with the depth texture extension available.
  19784. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19785. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19786. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19787. */
  19788. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19789. private _processSizeParameter;
  19790. /**
  19791. * Define the number of samples to use in case of MSAA.
  19792. * It defaults to one meaning no MSAA has been enabled.
  19793. */
  19794. samples: number;
  19795. /**
  19796. * Resets the refresh counter of the texture and start bak from scratch.
  19797. * Could be useful to regenerate the texture if it is setup to render only once.
  19798. */
  19799. resetRefreshCounter(): void;
  19800. /**
  19801. * Define the refresh rate of the texture or the rendering frequency.
  19802. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19803. */
  19804. refreshRate: number;
  19805. /**
  19806. * Adds a post process to the render target rendering passes.
  19807. * @param postProcess define the post process to add
  19808. */
  19809. addPostProcess(postProcess: PostProcess): void;
  19810. /**
  19811. * Clear all the post processes attached to the render target
  19812. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19813. */
  19814. clearPostProcesses(dispose?: boolean): void;
  19815. /**
  19816. * Remove one of the post process from the list of attached post processes to the texture
  19817. * @param postProcess define the post process to remove from the list
  19818. */
  19819. removePostProcess(postProcess: PostProcess): void;
  19820. /** @hidden */
  19821. _shouldRender(): boolean;
  19822. /**
  19823. * Gets the actual render size of the texture.
  19824. * @returns the width of the render size
  19825. */
  19826. getRenderSize(): number;
  19827. /**
  19828. * Gets the actual render width of the texture.
  19829. * @returns the width of the render size
  19830. */
  19831. getRenderWidth(): number;
  19832. /**
  19833. * Gets the actual render height of the texture.
  19834. * @returns the height of the render size
  19835. */
  19836. getRenderHeight(): number;
  19837. /**
  19838. * Get if the texture can be rescaled or not.
  19839. */
  19840. readonly canRescale: boolean;
  19841. /**
  19842. * Resize the texture using a ratio.
  19843. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19844. */
  19845. scale(ratio: number): void;
  19846. /**
  19847. * Get the texture reflection matrix used to rotate/transform the reflection.
  19848. * @returns the reflection matrix
  19849. */
  19850. getReflectionTextureMatrix(): Matrix;
  19851. /**
  19852. * Resize the texture to a new desired size.
  19853. * Be carrefull as it will recreate all the data in the new texture.
  19854. * @param size Define the new size. It can be:
  19855. * - a number for squared texture,
  19856. * - an object containing { width: number, height: number }
  19857. * - or an object containing a ratio { ratio: number }
  19858. */
  19859. resize(size: number | {
  19860. width: number;
  19861. height: number;
  19862. } | {
  19863. ratio: number;
  19864. }): void;
  19865. /**
  19866. * Renders all the objects from the render list into the texture.
  19867. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19868. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19869. */
  19870. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19871. private _bestReflectionRenderTargetDimension;
  19872. /**
  19873. * @hidden
  19874. * @param faceIndex face index to bind to if this is a cubetexture
  19875. */
  19876. _bindFrameBuffer(faceIndex?: number): void;
  19877. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19878. private renderToTarget;
  19879. /**
  19880. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19881. * This allowed control for front to back rendering or reversly depending of the special needs.
  19882. *
  19883. * @param renderingGroupId The rendering group id corresponding to its index
  19884. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19885. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19886. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19887. */
  19888. 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;
  19889. /**
  19890. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19891. *
  19892. * @param renderingGroupId The rendering group id corresponding to its index
  19893. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19894. */
  19895. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19896. /**
  19897. * Clones the texture.
  19898. * @returns the cloned texture
  19899. */
  19900. clone(): RenderTargetTexture;
  19901. /**
  19902. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19903. * @returns The JSON representation of the texture
  19904. */
  19905. serialize(): any;
  19906. /**
  19907. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19908. */
  19909. disposeFramebufferObjects(): void;
  19910. /**
  19911. * Dispose the texture and release its associated resources.
  19912. */
  19913. dispose(): void;
  19914. /** @hidden */
  19915. _rebuild(): void;
  19916. /**
  19917. * Clear the info related to rendering groups preventing retention point in material dispose.
  19918. */
  19919. freeRenderingGroups(): void;
  19920. /**
  19921. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19922. * @returns the view count
  19923. */
  19924. getViewCount(): number;
  19925. }
  19926. }
  19927. declare module BABYLON {
  19928. /**
  19929. * Base class for the main features of a material in Babylon.js
  19930. */
  19931. export class Material implements IAnimatable {
  19932. /**
  19933. * Returns the triangle fill mode
  19934. */
  19935. static readonly TriangleFillMode: number;
  19936. /**
  19937. * Returns the wireframe mode
  19938. */
  19939. static readonly WireFrameFillMode: number;
  19940. /**
  19941. * Returns the point fill mode
  19942. */
  19943. static readonly PointFillMode: number;
  19944. /**
  19945. * Returns the point list draw mode
  19946. */
  19947. static readonly PointListDrawMode: number;
  19948. /**
  19949. * Returns the line list draw mode
  19950. */
  19951. static readonly LineListDrawMode: number;
  19952. /**
  19953. * Returns the line loop draw mode
  19954. */
  19955. static readonly LineLoopDrawMode: number;
  19956. /**
  19957. * Returns the line strip draw mode
  19958. */
  19959. static readonly LineStripDrawMode: number;
  19960. /**
  19961. * Returns the triangle strip draw mode
  19962. */
  19963. static readonly TriangleStripDrawMode: number;
  19964. /**
  19965. * Returns the triangle fan draw mode
  19966. */
  19967. static readonly TriangleFanDrawMode: number;
  19968. /**
  19969. * Stores the clock-wise side orientation
  19970. */
  19971. static readonly ClockWiseSideOrientation: number;
  19972. /**
  19973. * Stores the counter clock-wise side orientation
  19974. */
  19975. static readonly CounterClockWiseSideOrientation: number;
  19976. /**
  19977. * The dirty texture flag value
  19978. */
  19979. static readonly TextureDirtyFlag: number;
  19980. /**
  19981. * The dirty light flag value
  19982. */
  19983. static readonly LightDirtyFlag: number;
  19984. /**
  19985. * The dirty fresnel flag value
  19986. */
  19987. static readonly FresnelDirtyFlag: number;
  19988. /**
  19989. * The dirty attribute flag value
  19990. */
  19991. static readonly AttributesDirtyFlag: number;
  19992. /**
  19993. * The dirty misc flag value
  19994. */
  19995. static readonly MiscDirtyFlag: number;
  19996. /**
  19997. * The all dirty flag value
  19998. */
  19999. static readonly AllDirtyFlag: number;
  20000. /**
  20001. * The ID of the material
  20002. */
  20003. id: string;
  20004. /**
  20005. * Gets or sets the unique id of the material
  20006. */
  20007. uniqueId: number;
  20008. /**
  20009. * The name of the material
  20010. */
  20011. name: string;
  20012. /**
  20013. * Gets or sets user defined metadata
  20014. */
  20015. metadata: any;
  20016. /**
  20017. * For internal use only. Please do not use.
  20018. */
  20019. reservedDataStore: any;
  20020. /**
  20021. * Specifies if the ready state should be checked on each call
  20022. */
  20023. checkReadyOnEveryCall: boolean;
  20024. /**
  20025. * Specifies if the ready state should be checked once
  20026. */
  20027. checkReadyOnlyOnce: boolean;
  20028. /**
  20029. * The state of the material
  20030. */
  20031. state: string;
  20032. /**
  20033. * The alpha value of the material
  20034. */
  20035. protected _alpha: number;
  20036. /**
  20037. * List of inspectable custom properties (used by the Inspector)
  20038. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20039. */
  20040. inspectableCustomProperties: IInspectable[];
  20041. /**
  20042. * Sets the alpha value of the material
  20043. */
  20044. /**
  20045. * Gets the alpha value of the material
  20046. */
  20047. alpha: number;
  20048. /**
  20049. * Specifies if back face culling is enabled
  20050. */
  20051. protected _backFaceCulling: boolean;
  20052. /**
  20053. * Sets the back-face culling state
  20054. */
  20055. /**
  20056. * Gets the back-face culling state
  20057. */
  20058. backFaceCulling: boolean;
  20059. /**
  20060. * Stores the value for side orientation
  20061. */
  20062. sideOrientation: number;
  20063. /**
  20064. * Callback triggered when the material is compiled
  20065. */
  20066. onCompiled: Nullable<(effect: Effect) => void>;
  20067. /**
  20068. * Callback triggered when an error occurs
  20069. */
  20070. onError: Nullable<(effect: Effect, errors: string) => void>;
  20071. /**
  20072. * Callback triggered to get the render target textures
  20073. */
  20074. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20075. /**
  20076. * Gets a boolean indicating that current material needs to register RTT
  20077. */
  20078. readonly hasRenderTargetTextures: boolean;
  20079. /**
  20080. * Specifies if the material should be serialized
  20081. */
  20082. doNotSerialize: boolean;
  20083. /**
  20084. * @hidden
  20085. */
  20086. _storeEffectOnSubMeshes: boolean;
  20087. /**
  20088. * Stores the animations for the material
  20089. */
  20090. animations: Nullable<Array<Animation>>;
  20091. /**
  20092. * An event triggered when the material is disposed
  20093. */
  20094. onDisposeObservable: Observable<Material>;
  20095. /**
  20096. * An observer which watches for dispose events
  20097. */
  20098. private _onDisposeObserver;
  20099. private _onUnBindObservable;
  20100. /**
  20101. * Called during a dispose event
  20102. */
  20103. onDispose: () => void;
  20104. private _onBindObservable;
  20105. /**
  20106. * An event triggered when the material is bound
  20107. */
  20108. readonly onBindObservable: Observable<AbstractMesh>;
  20109. /**
  20110. * An observer which watches for bind events
  20111. */
  20112. private _onBindObserver;
  20113. /**
  20114. * Called during a bind event
  20115. */
  20116. onBind: (Mesh: AbstractMesh) => void;
  20117. /**
  20118. * An event triggered when the material is unbound
  20119. */
  20120. readonly onUnBindObservable: Observable<Material>;
  20121. /**
  20122. * Stores the value of the alpha mode
  20123. */
  20124. private _alphaMode;
  20125. /**
  20126. * Sets the value of the alpha mode.
  20127. *
  20128. * | Value | Type | Description |
  20129. * | --- | --- | --- |
  20130. * | 0 | ALPHA_DISABLE | |
  20131. * | 1 | ALPHA_ADD | |
  20132. * | 2 | ALPHA_COMBINE | |
  20133. * | 3 | ALPHA_SUBTRACT | |
  20134. * | 4 | ALPHA_MULTIPLY | |
  20135. * | 5 | ALPHA_MAXIMIZED | |
  20136. * | 6 | ALPHA_ONEONE | |
  20137. * | 7 | ALPHA_PREMULTIPLIED | |
  20138. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20139. * | 9 | ALPHA_INTERPOLATE | |
  20140. * | 10 | ALPHA_SCREENMODE | |
  20141. *
  20142. */
  20143. /**
  20144. * Gets the value of the alpha mode
  20145. */
  20146. alphaMode: number;
  20147. /**
  20148. * Stores the state of the need depth pre-pass value
  20149. */
  20150. private _needDepthPrePass;
  20151. /**
  20152. * Sets the need depth pre-pass value
  20153. */
  20154. /**
  20155. * Gets the depth pre-pass value
  20156. */
  20157. needDepthPrePass: boolean;
  20158. /**
  20159. * Specifies if depth writing should be disabled
  20160. */
  20161. disableDepthWrite: boolean;
  20162. /**
  20163. * Specifies if depth writing should be forced
  20164. */
  20165. forceDepthWrite: boolean;
  20166. /**
  20167. * Specifies if there should be a separate pass for culling
  20168. */
  20169. separateCullingPass: boolean;
  20170. /**
  20171. * Stores the state specifing if fog should be enabled
  20172. */
  20173. private _fogEnabled;
  20174. /**
  20175. * Sets the state for enabling fog
  20176. */
  20177. /**
  20178. * Gets the value of the fog enabled state
  20179. */
  20180. fogEnabled: boolean;
  20181. /**
  20182. * Stores the size of points
  20183. */
  20184. pointSize: number;
  20185. /**
  20186. * Stores the z offset value
  20187. */
  20188. zOffset: number;
  20189. /**
  20190. * Gets a value specifying if wireframe mode is enabled
  20191. */
  20192. /**
  20193. * Sets the state of wireframe mode
  20194. */
  20195. wireframe: boolean;
  20196. /**
  20197. * Gets the value specifying if point clouds are enabled
  20198. */
  20199. /**
  20200. * Sets the state of point cloud mode
  20201. */
  20202. pointsCloud: boolean;
  20203. /**
  20204. * Gets the material fill mode
  20205. */
  20206. /**
  20207. * Sets the material fill mode
  20208. */
  20209. fillMode: number;
  20210. /**
  20211. * @hidden
  20212. * Stores the effects for the material
  20213. */
  20214. _effect: Nullable<Effect>;
  20215. /**
  20216. * @hidden
  20217. * Specifies if the material was previously ready
  20218. */
  20219. _wasPreviouslyReady: boolean;
  20220. /**
  20221. * Specifies if uniform buffers should be used
  20222. */
  20223. private _useUBO;
  20224. /**
  20225. * Stores a reference to the scene
  20226. */
  20227. private _scene;
  20228. /**
  20229. * Stores the fill mode state
  20230. */
  20231. private _fillMode;
  20232. /**
  20233. * Specifies if the depth write state should be cached
  20234. */
  20235. private _cachedDepthWriteState;
  20236. /**
  20237. * Stores the uniform buffer
  20238. */
  20239. protected _uniformBuffer: UniformBuffer;
  20240. /** @hidden */
  20241. _indexInSceneMaterialArray: number;
  20242. /** @hidden */
  20243. meshMap: Nullable<{
  20244. [id: string]: AbstractMesh | undefined;
  20245. }>;
  20246. /**
  20247. * Creates a material instance
  20248. * @param name defines the name of the material
  20249. * @param scene defines the scene to reference
  20250. * @param doNotAdd specifies if the material should be added to the scene
  20251. */
  20252. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20253. /**
  20254. * Returns a string representation of the current material
  20255. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20256. * @returns a string with material information
  20257. */
  20258. toString(fullDetails?: boolean): string;
  20259. /**
  20260. * Gets the class name of the material
  20261. * @returns a string with the class name of the material
  20262. */
  20263. getClassName(): string;
  20264. /**
  20265. * Specifies if updates for the material been locked
  20266. */
  20267. readonly isFrozen: boolean;
  20268. /**
  20269. * Locks updates for the material
  20270. */
  20271. freeze(): void;
  20272. /**
  20273. * Unlocks updates for the material
  20274. */
  20275. unfreeze(): void;
  20276. /**
  20277. * Specifies if the material is ready to be used
  20278. * @param mesh defines the mesh to check
  20279. * @param useInstances specifies if instances should be used
  20280. * @returns a boolean indicating if the material is ready to be used
  20281. */
  20282. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20283. /**
  20284. * Specifies that the submesh is ready to be used
  20285. * @param mesh defines the mesh to check
  20286. * @param subMesh defines which submesh to check
  20287. * @param useInstances specifies that instances should be used
  20288. * @returns a boolean indicating that the submesh is ready or not
  20289. */
  20290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20291. /**
  20292. * Returns the material effect
  20293. * @returns the effect associated with the material
  20294. */
  20295. getEffect(): Nullable<Effect>;
  20296. /**
  20297. * Returns the current scene
  20298. * @returns a Scene
  20299. */
  20300. getScene(): Scene;
  20301. /**
  20302. * Specifies if the material will require alpha blending
  20303. * @returns a boolean specifying if alpha blending is needed
  20304. */
  20305. needAlphaBlending(): boolean;
  20306. /**
  20307. * Specifies if the mesh will require alpha blending
  20308. * @param mesh defines the mesh to check
  20309. * @returns a boolean specifying if alpha blending is needed for the mesh
  20310. */
  20311. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20312. /**
  20313. * Specifies if this material should be rendered in alpha test mode
  20314. * @returns a boolean specifying if an alpha test is needed.
  20315. */
  20316. needAlphaTesting(): boolean;
  20317. /**
  20318. * Gets the texture used for the alpha test
  20319. * @returns the texture to use for alpha testing
  20320. */
  20321. getAlphaTestTexture(): Nullable<BaseTexture>;
  20322. /**
  20323. * Marks the material to indicate that it needs to be re-calculated
  20324. */
  20325. markDirty(): void;
  20326. /** @hidden */
  20327. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20328. /**
  20329. * Binds the material to the mesh
  20330. * @param world defines the world transformation matrix
  20331. * @param mesh defines the mesh to bind the material to
  20332. */
  20333. bind(world: Matrix, mesh?: Mesh): void;
  20334. /**
  20335. * Binds the submesh to the material
  20336. * @param world defines the world transformation matrix
  20337. * @param mesh defines the mesh containing the submesh
  20338. * @param subMesh defines the submesh to bind the material to
  20339. */
  20340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20341. /**
  20342. * Binds the world matrix to the material
  20343. * @param world defines the world transformation matrix
  20344. */
  20345. bindOnlyWorldMatrix(world: Matrix): void;
  20346. /**
  20347. * Binds the scene's uniform buffer to the effect.
  20348. * @param effect defines the effect to bind to the scene uniform buffer
  20349. * @param sceneUbo defines the uniform buffer storing scene data
  20350. */
  20351. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20352. /**
  20353. * Binds the view matrix to the effect
  20354. * @param effect defines the effect to bind the view matrix to
  20355. */
  20356. bindView(effect: Effect): void;
  20357. /**
  20358. * Binds the view projection matrix to the effect
  20359. * @param effect defines the effect to bind the view projection matrix to
  20360. */
  20361. bindViewProjection(effect: Effect): void;
  20362. /**
  20363. * Specifies if material alpha testing should be turned on for the mesh
  20364. * @param mesh defines the mesh to check
  20365. */
  20366. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20367. /**
  20368. * Processes to execute after binding the material to a mesh
  20369. * @param mesh defines the rendered mesh
  20370. */
  20371. protected _afterBind(mesh?: Mesh): void;
  20372. /**
  20373. * Unbinds the material from the mesh
  20374. */
  20375. unbind(): void;
  20376. /**
  20377. * Gets the active textures from the material
  20378. * @returns an array of textures
  20379. */
  20380. getActiveTextures(): BaseTexture[];
  20381. /**
  20382. * Specifies if the material uses a texture
  20383. * @param texture defines the texture to check against the material
  20384. * @returns a boolean specifying if the material uses the texture
  20385. */
  20386. hasTexture(texture: BaseTexture): boolean;
  20387. /**
  20388. * Makes a duplicate of the material, and gives it a new name
  20389. * @param name defines the new name for the duplicated material
  20390. * @returns the cloned material
  20391. */
  20392. clone(name: string): Nullable<Material>;
  20393. /**
  20394. * Gets the meshes bound to the material
  20395. * @returns an array of meshes bound to the material
  20396. */
  20397. getBindedMeshes(): AbstractMesh[];
  20398. /**
  20399. * Force shader compilation
  20400. * @param mesh defines the mesh associated with this material
  20401. * @param onCompiled defines a function to execute once the material is compiled
  20402. * @param options defines the options to configure the compilation
  20403. */
  20404. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20405. clipPlane: boolean;
  20406. }>): void;
  20407. /**
  20408. * Force shader compilation
  20409. * @param mesh defines the mesh that will use this material
  20410. * @param options defines additional options for compiling the shaders
  20411. * @returns a promise that resolves when the compilation completes
  20412. */
  20413. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20414. clipPlane: boolean;
  20415. }>): Promise<void>;
  20416. private static readonly _AllDirtyCallBack;
  20417. private static readonly _ImageProcessingDirtyCallBack;
  20418. private static readonly _TextureDirtyCallBack;
  20419. private static readonly _FresnelDirtyCallBack;
  20420. private static readonly _MiscDirtyCallBack;
  20421. private static readonly _LightsDirtyCallBack;
  20422. private static readonly _AttributeDirtyCallBack;
  20423. private static _FresnelAndMiscDirtyCallBack;
  20424. private static _TextureAndMiscDirtyCallBack;
  20425. private static readonly _DirtyCallbackArray;
  20426. private static readonly _RunDirtyCallBacks;
  20427. /**
  20428. * Marks a define in the material to indicate that it needs to be re-computed
  20429. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20430. */
  20431. markAsDirty(flag: number): void;
  20432. /**
  20433. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20434. * @param func defines a function which checks material defines against the submeshes
  20435. */
  20436. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20437. /**
  20438. * Indicates that we need to re-calculated for all submeshes
  20439. */
  20440. protected _markAllSubMeshesAsAllDirty(): void;
  20441. /**
  20442. * Indicates that image processing needs to be re-calculated for all submeshes
  20443. */
  20444. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20445. /**
  20446. * Indicates that textures need to be re-calculated for all submeshes
  20447. */
  20448. protected _markAllSubMeshesAsTexturesDirty(): void;
  20449. /**
  20450. * Indicates that fresnel needs to be re-calculated for all submeshes
  20451. */
  20452. protected _markAllSubMeshesAsFresnelDirty(): void;
  20453. /**
  20454. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20455. */
  20456. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20457. /**
  20458. * Indicates that lights need to be re-calculated for all submeshes
  20459. */
  20460. protected _markAllSubMeshesAsLightsDirty(): void;
  20461. /**
  20462. * Indicates that attributes need to be re-calculated for all submeshes
  20463. */
  20464. protected _markAllSubMeshesAsAttributesDirty(): void;
  20465. /**
  20466. * Indicates that misc needs to be re-calculated for all submeshes
  20467. */
  20468. protected _markAllSubMeshesAsMiscDirty(): void;
  20469. /**
  20470. * Indicates that textures and misc need to be re-calculated for all submeshes
  20471. */
  20472. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20473. /**
  20474. * Disposes the material
  20475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20477. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20478. */
  20479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20480. /** @hidden */
  20481. private releaseVertexArrayObject;
  20482. /**
  20483. * Serializes this material
  20484. * @returns the serialized material object
  20485. */
  20486. serialize(): any;
  20487. /**
  20488. * Creates a material from parsed material data
  20489. * @param parsedMaterial defines parsed material data
  20490. * @param scene defines the hosting scene
  20491. * @param rootUrl defines the root URL to use to load textures
  20492. * @returns a new material
  20493. */
  20494. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20495. }
  20496. }
  20497. declare module BABYLON {
  20498. /**
  20499. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20500. * separate meshes. This can be use to improve performances.
  20501. * @see http://doc.babylonjs.com/how_to/multi_materials
  20502. */
  20503. export class MultiMaterial extends Material {
  20504. private _subMaterials;
  20505. /**
  20506. * Gets or Sets the list of Materials used within the multi material.
  20507. * They need to be ordered according to the submeshes order in the associated mesh
  20508. */
  20509. subMaterials: Nullable<Material>[];
  20510. /**
  20511. * Function used to align with Node.getChildren()
  20512. * @returns the list of Materials used within the multi material
  20513. */
  20514. getChildren(): Nullable<Material>[];
  20515. /**
  20516. * Instantiates a new Multi Material
  20517. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20518. * separate meshes. This can be use to improve performances.
  20519. * @see http://doc.babylonjs.com/how_to/multi_materials
  20520. * @param name Define the name in the scene
  20521. * @param scene Define the scene the material belongs to
  20522. */
  20523. constructor(name: string, scene: Scene);
  20524. private _hookArray;
  20525. /**
  20526. * Get one of the submaterial by its index in the submaterials array
  20527. * @param index The index to look the sub material at
  20528. * @returns The Material if the index has been defined
  20529. */
  20530. getSubMaterial(index: number): Nullable<Material>;
  20531. /**
  20532. * Get the list of active textures for the whole sub materials list.
  20533. * @returns All the textures that will be used during the rendering
  20534. */
  20535. getActiveTextures(): BaseTexture[];
  20536. /**
  20537. * Gets the current class name of the material e.g. "MultiMaterial"
  20538. * Mainly use in serialization.
  20539. * @returns the class name
  20540. */
  20541. getClassName(): string;
  20542. /**
  20543. * Checks if the material is ready to render the requested sub mesh
  20544. * @param mesh Define the mesh the submesh belongs to
  20545. * @param subMesh Define the sub mesh to look readyness for
  20546. * @param useInstances Define whether or not the material is used with instances
  20547. * @returns true if ready, otherwise false
  20548. */
  20549. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20550. /**
  20551. * Clones the current material and its related sub materials
  20552. * @param name Define the name of the newly cloned material
  20553. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20554. * @returns the cloned material
  20555. */
  20556. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20557. /**
  20558. * Serializes the materials into a JSON representation.
  20559. * @returns the JSON representation
  20560. */
  20561. serialize(): any;
  20562. /**
  20563. * Dispose the material and release its associated resources
  20564. * @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)
  20565. * @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)
  20566. * @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)
  20567. */
  20568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20569. /**
  20570. * Creates a MultiMaterial from parsed MultiMaterial data.
  20571. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20572. * @param scene defines the hosting scene
  20573. * @returns a new MultiMaterial
  20574. */
  20575. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20576. }
  20577. }
  20578. declare module BABYLON {
  20579. /**
  20580. * Base class for submeshes
  20581. */
  20582. export class BaseSubMesh {
  20583. /** @hidden */
  20584. _materialDefines: Nullable<MaterialDefines>;
  20585. /** @hidden */
  20586. _materialEffect: Nullable<Effect>;
  20587. /**
  20588. * Gets associated effect
  20589. */
  20590. readonly effect: Nullable<Effect>;
  20591. /**
  20592. * Sets associated effect (effect used to render this submesh)
  20593. * @param effect defines the effect to associate with
  20594. * @param defines defines the set of defines used to compile this effect
  20595. */
  20596. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20597. }
  20598. /**
  20599. * Defines a subdivision inside a mesh
  20600. */
  20601. export class SubMesh extends BaseSubMesh implements ICullable {
  20602. /** the material index to use */
  20603. materialIndex: number;
  20604. /** vertex index start */
  20605. verticesStart: number;
  20606. /** vertices count */
  20607. verticesCount: number;
  20608. /** index start */
  20609. indexStart: number;
  20610. /** indices count */
  20611. indexCount: number;
  20612. /** @hidden */
  20613. _linesIndexCount: number;
  20614. private _mesh;
  20615. private _renderingMesh;
  20616. private _boundingInfo;
  20617. private _linesIndexBuffer;
  20618. /** @hidden */
  20619. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20620. /** @hidden */
  20621. _trianglePlanes: Plane[];
  20622. /** @hidden */
  20623. _lastColliderTransformMatrix: Nullable<Matrix>;
  20624. /** @hidden */
  20625. _renderId: number;
  20626. /** @hidden */
  20627. _alphaIndex: number;
  20628. /** @hidden */
  20629. _distanceToCamera: number;
  20630. /** @hidden */
  20631. _id: number;
  20632. private _currentMaterial;
  20633. /**
  20634. * Add a new submesh to a mesh
  20635. * @param materialIndex defines the material index to use
  20636. * @param verticesStart defines vertex index start
  20637. * @param verticesCount defines vertices count
  20638. * @param indexStart defines index start
  20639. * @param indexCount defines indices count
  20640. * @param mesh defines the parent mesh
  20641. * @param renderingMesh defines an optional rendering mesh
  20642. * @param createBoundingBox defines if bounding box should be created for this submesh
  20643. * @returns the new submesh
  20644. */
  20645. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20646. /**
  20647. * Creates a new submesh
  20648. * @param materialIndex defines the material index to use
  20649. * @param verticesStart defines vertex index start
  20650. * @param verticesCount defines vertices count
  20651. * @param indexStart defines index start
  20652. * @param indexCount defines indices count
  20653. * @param mesh defines the parent mesh
  20654. * @param renderingMesh defines an optional rendering mesh
  20655. * @param createBoundingBox defines if bounding box should be created for this submesh
  20656. */
  20657. constructor(
  20658. /** the material index to use */
  20659. materialIndex: number,
  20660. /** vertex index start */
  20661. verticesStart: number,
  20662. /** vertices count */
  20663. verticesCount: number,
  20664. /** index start */
  20665. indexStart: number,
  20666. /** indices count */
  20667. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20668. /**
  20669. * Returns true if this submesh covers the entire parent mesh
  20670. * @ignorenaming
  20671. */
  20672. readonly IsGlobal: boolean;
  20673. /**
  20674. * Returns the submesh BoudingInfo object
  20675. * @returns current bounding info (or mesh's one if the submesh is global)
  20676. */
  20677. getBoundingInfo(): BoundingInfo;
  20678. /**
  20679. * Sets the submesh BoundingInfo
  20680. * @param boundingInfo defines the new bounding info to use
  20681. * @returns the SubMesh
  20682. */
  20683. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20684. /**
  20685. * Returns the mesh of the current submesh
  20686. * @return the parent mesh
  20687. */
  20688. getMesh(): AbstractMesh;
  20689. /**
  20690. * Returns the rendering mesh of the submesh
  20691. * @returns the rendering mesh (could be different from parent mesh)
  20692. */
  20693. getRenderingMesh(): Mesh;
  20694. /**
  20695. * Returns the submesh material
  20696. * @returns null or the current material
  20697. */
  20698. getMaterial(): Nullable<Material>;
  20699. /**
  20700. * Sets a new updated BoundingInfo object to the submesh
  20701. * @param data defines an optional position array to use to determine the bounding info
  20702. * @returns the SubMesh
  20703. */
  20704. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20705. /** @hidden */
  20706. _checkCollision(collider: Collider): boolean;
  20707. /**
  20708. * Updates the submesh BoundingInfo
  20709. * @param world defines the world matrix to use to update the bounding info
  20710. * @returns the submesh
  20711. */
  20712. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20713. /**
  20714. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20715. * @param frustumPlanes defines the frustum planes
  20716. * @returns true if the submesh is intersecting with the frustum
  20717. */
  20718. isInFrustum(frustumPlanes: Plane[]): boolean;
  20719. /**
  20720. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20721. * @param frustumPlanes defines the frustum planes
  20722. * @returns true if the submesh is inside the frustum
  20723. */
  20724. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20725. /**
  20726. * Renders the submesh
  20727. * @param enableAlphaMode defines if alpha needs to be used
  20728. * @returns the submesh
  20729. */
  20730. render(enableAlphaMode: boolean): SubMesh;
  20731. /**
  20732. * @hidden
  20733. */
  20734. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20735. /**
  20736. * Checks if the submesh intersects with a ray
  20737. * @param ray defines the ray to test
  20738. * @returns true is the passed ray intersects the submesh bounding box
  20739. */
  20740. canIntersects(ray: Ray): boolean;
  20741. /**
  20742. * Intersects current submesh with a ray
  20743. * @param ray defines the ray to test
  20744. * @param positions defines mesh's positions array
  20745. * @param indices defines mesh's indices array
  20746. * @param fastCheck defines if only bounding info should be used
  20747. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20748. * @returns intersection info or null if no intersection
  20749. */
  20750. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20751. /** @hidden */
  20752. private _intersectLines;
  20753. /** @hidden */
  20754. private _intersectUnIndexedLines;
  20755. /** @hidden */
  20756. private _intersectTriangles;
  20757. /** @hidden */
  20758. private _intersectUnIndexedTriangles;
  20759. /** @hidden */
  20760. _rebuild(): void;
  20761. /**
  20762. * Creates a new submesh from the passed mesh
  20763. * @param newMesh defines the new hosting mesh
  20764. * @param newRenderingMesh defines an optional rendering mesh
  20765. * @returns the new submesh
  20766. */
  20767. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20768. /**
  20769. * Release associated resources
  20770. */
  20771. dispose(): void;
  20772. /**
  20773. * Gets the class name
  20774. * @returns the string "SubMesh".
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Creates a new submesh from indices data
  20779. * @param materialIndex the index of the main mesh material
  20780. * @param startIndex the index where to start the copy in the mesh indices array
  20781. * @param indexCount the number of indices to copy then from the startIndex
  20782. * @param mesh the main mesh to create the submesh from
  20783. * @param renderingMesh the optional rendering mesh
  20784. * @returns a new submesh
  20785. */
  20786. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20787. }
  20788. }
  20789. declare module BABYLON {
  20790. /**
  20791. * Class used to represent data loading progression
  20792. */
  20793. export class SceneLoaderFlags {
  20794. private static _ForceFullSceneLoadingForIncremental;
  20795. private static _ShowLoadingScreen;
  20796. private static _CleanBoneMatrixWeights;
  20797. private static _loggingLevel;
  20798. /**
  20799. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20800. */
  20801. static ForceFullSceneLoadingForIncremental: boolean;
  20802. /**
  20803. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20804. */
  20805. static ShowLoadingScreen: boolean;
  20806. /**
  20807. * Defines the current logging level (while loading the scene)
  20808. * @ignorenaming
  20809. */
  20810. static loggingLevel: number;
  20811. /**
  20812. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20813. */
  20814. static CleanBoneMatrixWeights: boolean;
  20815. }
  20816. }
  20817. declare module BABYLON {
  20818. /**
  20819. * Class used to store geometry data (vertex buffers + index buffer)
  20820. */
  20821. export class Geometry implements IGetSetVerticesData {
  20822. /**
  20823. * Gets or sets the ID of the geometry
  20824. */
  20825. id: string;
  20826. /**
  20827. * Gets or sets the unique ID of the geometry
  20828. */
  20829. uniqueId: number;
  20830. /**
  20831. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20832. */
  20833. delayLoadState: number;
  20834. /**
  20835. * Gets the file containing the data to load when running in delay load state
  20836. */
  20837. delayLoadingFile: Nullable<string>;
  20838. /**
  20839. * Callback called when the geometry is updated
  20840. */
  20841. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20842. private _scene;
  20843. private _engine;
  20844. private _meshes;
  20845. private _totalVertices;
  20846. /** @hidden */
  20847. _indices: IndicesArray;
  20848. /** @hidden */
  20849. _vertexBuffers: {
  20850. [key: string]: VertexBuffer;
  20851. };
  20852. private _isDisposed;
  20853. private _extend;
  20854. private _boundingBias;
  20855. /** @hidden */
  20856. _delayInfo: Array<string>;
  20857. private _indexBuffer;
  20858. private _indexBufferIsUpdatable;
  20859. /** @hidden */
  20860. _boundingInfo: Nullable<BoundingInfo>;
  20861. /** @hidden */
  20862. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20863. /** @hidden */
  20864. _softwareSkinningFrameId: number;
  20865. private _vertexArrayObjects;
  20866. private _updatable;
  20867. /** @hidden */
  20868. _positions: Nullable<Vector3[]>;
  20869. /**
  20870. * 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
  20871. */
  20872. /**
  20873. * 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
  20874. */
  20875. boundingBias: Vector2;
  20876. /**
  20877. * Static function used to attach a new empty geometry to a mesh
  20878. * @param mesh defines the mesh to attach the geometry to
  20879. * @returns the new Geometry
  20880. */
  20881. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20882. /**
  20883. * Creates a new geometry
  20884. * @param id defines the unique ID
  20885. * @param scene defines the hosting scene
  20886. * @param vertexData defines the VertexData used to get geometry data
  20887. * @param updatable defines if geometry must be updatable (false by default)
  20888. * @param mesh defines the mesh that will be associated with the geometry
  20889. */
  20890. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20891. /**
  20892. * Gets the current extend of the geometry
  20893. */
  20894. readonly extend: {
  20895. minimum: Vector3;
  20896. maximum: Vector3;
  20897. };
  20898. /**
  20899. * Gets the hosting scene
  20900. * @returns the hosting Scene
  20901. */
  20902. getScene(): Scene;
  20903. /**
  20904. * Gets the hosting engine
  20905. * @returns the hosting Engine
  20906. */
  20907. getEngine(): Engine;
  20908. /**
  20909. * Defines if the geometry is ready to use
  20910. * @returns true if the geometry is ready to be used
  20911. */
  20912. isReady(): boolean;
  20913. /**
  20914. * Gets a value indicating that the geometry should not be serialized
  20915. */
  20916. readonly doNotSerialize: boolean;
  20917. /** @hidden */
  20918. _rebuild(): void;
  20919. /**
  20920. * Affects all geometry data in one call
  20921. * @param vertexData defines the geometry data
  20922. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20923. */
  20924. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20925. /**
  20926. * Set specific vertex data
  20927. * @param kind defines the data kind (Position, normal, etc...)
  20928. * @param data defines the vertex data to use
  20929. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20930. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20931. */
  20932. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20933. /**
  20934. * Removes a specific vertex data
  20935. * @param kind defines the data kind (Position, normal, etc...)
  20936. */
  20937. removeVerticesData(kind: string): void;
  20938. /**
  20939. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20940. * @param buffer defines the vertex buffer to use
  20941. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20942. */
  20943. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20944. /**
  20945. * Update a specific vertex buffer
  20946. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20947. * It will do nothing if the buffer is not updatable
  20948. * @param kind defines the data kind (Position, normal, etc...)
  20949. * @param data defines the data to use
  20950. * @param offset defines the offset in the target buffer where to store the data
  20951. * @param useBytes set to true if the offset is in bytes
  20952. */
  20953. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20954. /**
  20955. * Update a specific vertex buffer
  20956. * This function will create a new buffer if the current one is not updatable
  20957. * @param kind defines the data kind (Position, normal, etc...)
  20958. * @param data defines the data to use
  20959. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20960. */
  20961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20962. private _updateBoundingInfo;
  20963. /** @hidden */
  20964. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20965. /**
  20966. * Gets total number of vertices
  20967. * @returns the total number of vertices
  20968. */
  20969. getTotalVertices(): number;
  20970. /**
  20971. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20972. * @param kind defines the data kind (Position, normal, etc...)
  20973. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20974. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20975. * @returns a float array containing vertex data
  20976. */
  20977. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20978. /**
  20979. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20980. * @param kind defines the data kind (Position, normal, etc...)
  20981. * @returns true if the vertex buffer with the specified kind is updatable
  20982. */
  20983. isVertexBufferUpdatable(kind: string): boolean;
  20984. /**
  20985. * Gets a specific vertex buffer
  20986. * @param kind defines the data kind (Position, normal, etc...)
  20987. * @returns a VertexBuffer
  20988. */
  20989. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20990. /**
  20991. * Returns all vertex buffers
  20992. * @return an object holding all vertex buffers indexed by kind
  20993. */
  20994. getVertexBuffers(): Nullable<{
  20995. [key: string]: VertexBuffer;
  20996. }>;
  20997. /**
  20998. * Gets a boolean indicating if specific vertex buffer is present
  20999. * @param kind defines the data kind (Position, normal, etc...)
  21000. * @returns true if data is present
  21001. */
  21002. isVerticesDataPresent(kind: string): boolean;
  21003. /**
  21004. * Gets a list of all attached data kinds (Position, normal, etc...)
  21005. * @returns a list of string containing all kinds
  21006. */
  21007. getVerticesDataKinds(): string[];
  21008. /**
  21009. * Update index buffer
  21010. * @param indices defines the indices to store in the index buffer
  21011. * @param offset defines the offset in the target buffer where to store the data
  21012. * @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)
  21013. */
  21014. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21015. /**
  21016. * Creates a new index buffer
  21017. * @param indices defines the indices to store in the index buffer
  21018. * @param totalVertices defines the total number of vertices (could be null)
  21019. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21020. */
  21021. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21022. /**
  21023. * Return the total number of indices
  21024. * @returns the total number of indices
  21025. */
  21026. getTotalIndices(): number;
  21027. /**
  21028. * Gets the index buffer array
  21029. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21030. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21031. * @returns the index buffer array
  21032. */
  21033. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21034. /**
  21035. * Gets the index buffer
  21036. * @return the index buffer
  21037. */
  21038. getIndexBuffer(): Nullable<DataBuffer>;
  21039. /** @hidden */
  21040. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21041. /**
  21042. * Release the associated resources for a specific mesh
  21043. * @param mesh defines the source mesh
  21044. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21045. */
  21046. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21047. /**
  21048. * Apply current geometry to a given mesh
  21049. * @param mesh defines the mesh to apply geometry to
  21050. */
  21051. applyToMesh(mesh: Mesh): void;
  21052. private _updateExtend;
  21053. private _applyToMesh;
  21054. private notifyUpdate;
  21055. /**
  21056. * Load the geometry if it was flagged as delay loaded
  21057. * @param scene defines the hosting scene
  21058. * @param onLoaded defines a callback called when the geometry is loaded
  21059. */
  21060. load(scene: Scene, onLoaded?: () => void): void;
  21061. private _queueLoad;
  21062. /**
  21063. * Invert the geometry to move from a right handed system to a left handed one.
  21064. */
  21065. toLeftHanded(): void;
  21066. /** @hidden */
  21067. _resetPointsArrayCache(): void;
  21068. /** @hidden */
  21069. _generatePointsArray(): boolean;
  21070. /**
  21071. * Gets a value indicating if the geometry is disposed
  21072. * @returns true if the geometry was disposed
  21073. */
  21074. isDisposed(): boolean;
  21075. private _disposeVertexArrayObjects;
  21076. /**
  21077. * Free all associated resources
  21078. */
  21079. dispose(): void;
  21080. /**
  21081. * Clone the current geometry into a new geometry
  21082. * @param id defines the unique ID of the new geometry
  21083. * @returns a new geometry object
  21084. */
  21085. copy(id: string): Geometry;
  21086. /**
  21087. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21088. * @return a JSON representation of the current geometry data (without the vertices data)
  21089. */
  21090. serialize(): any;
  21091. private toNumberArray;
  21092. /**
  21093. * Serialize all vertices data into a JSON oject
  21094. * @returns a JSON representation of the current geometry data
  21095. */
  21096. serializeVerticeData(): any;
  21097. /**
  21098. * Extracts a clone of a mesh geometry
  21099. * @param mesh defines the source mesh
  21100. * @param id defines the unique ID of the new geometry object
  21101. * @returns the new geometry object
  21102. */
  21103. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21104. /**
  21105. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21106. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21107. * Be aware Math.random() could cause collisions, but:
  21108. * "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"
  21109. * @returns a string containing a new GUID
  21110. */
  21111. static RandomId(): string;
  21112. /** @hidden */
  21113. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21114. private static _CleanMatricesWeights;
  21115. /**
  21116. * Create a new geometry from persisted data (Using .babylon file format)
  21117. * @param parsedVertexData defines the persisted data
  21118. * @param scene defines the hosting scene
  21119. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21120. * @returns the new geometry object
  21121. */
  21122. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21123. }
  21124. }
  21125. declare module BABYLON {
  21126. /**
  21127. * Define an interface for all classes that will get and set the data on vertices
  21128. */
  21129. export interface IGetSetVerticesData {
  21130. /**
  21131. * Gets a boolean indicating if specific vertex data is present
  21132. * @param kind defines the vertex data kind to use
  21133. * @returns true is data kind is present
  21134. */
  21135. isVerticesDataPresent(kind: string): boolean;
  21136. /**
  21137. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21138. * @param kind defines the data kind (Position, normal, etc...)
  21139. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21140. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21141. * @returns a float array containing vertex data
  21142. */
  21143. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21144. /**
  21145. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21146. * @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.
  21147. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21148. * @returns the indices array or an empty array if the mesh has no geometry
  21149. */
  21150. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21151. /**
  21152. * Set specific vertex data
  21153. * @param kind defines the data kind (Position, normal, etc...)
  21154. * @param data defines the vertex data to use
  21155. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21156. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21157. */
  21158. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21159. /**
  21160. * Update a specific associated vertex buffer
  21161. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21162. * - VertexBuffer.PositionKind
  21163. * - VertexBuffer.UVKind
  21164. * - VertexBuffer.UV2Kind
  21165. * - VertexBuffer.UV3Kind
  21166. * - VertexBuffer.UV4Kind
  21167. * - VertexBuffer.UV5Kind
  21168. * - VertexBuffer.UV6Kind
  21169. * - VertexBuffer.ColorKind
  21170. * - VertexBuffer.MatricesIndicesKind
  21171. * - VertexBuffer.MatricesIndicesExtraKind
  21172. * - VertexBuffer.MatricesWeightsKind
  21173. * - VertexBuffer.MatricesWeightsExtraKind
  21174. * @param data defines the data source
  21175. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21176. * @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)
  21177. */
  21178. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21179. /**
  21180. * Creates a new index buffer
  21181. * @param indices defines the indices to store in the index buffer
  21182. * @param totalVertices defines the total number of vertices (could be null)
  21183. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21184. */
  21185. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21186. }
  21187. /**
  21188. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21189. */
  21190. export class VertexData {
  21191. /**
  21192. * Mesh side orientation : usually the external or front surface
  21193. */
  21194. static readonly FRONTSIDE: number;
  21195. /**
  21196. * Mesh side orientation : usually the internal or back surface
  21197. */
  21198. static readonly BACKSIDE: number;
  21199. /**
  21200. * Mesh side orientation : both internal and external or front and back surfaces
  21201. */
  21202. static readonly DOUBLESIDE: number;
  21203. /**
  21204. * Mesh side orientation : by default, `FRONTSIDE`
  21205. */
  21206. static readonly DEFAULTSIDE: number;
  21207. /**
  21208. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21209. */
  21210. positions: Nullable<FloatArray>;
  21211. /**
  21212. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21213. */
  21214. normals: Nullable<FloatArray>;
  21215. /**
  21216. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21217. */
  21218. tangents: Nullable<FloatArray>;
  21219. /**
  21220. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21221. */
  21222. uvs: Nullable<FloatArray>;
  21223. /**
  21224. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21225. */
  21226. uvs2: Nullable<FloatArray>;
  21227. /**
  21228. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21229. */
  21230. uvs3: Nullable<FloatArray>;
  21231. /**
  21232. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21233. */
  21234. uvs4: Nullable<FloatArray>;
  21235. /**
  21236. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21237. */
  21238. uvs5: Nullable<FloatArray>;
  21239. /**
  21240. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21241. */
  21242. uvs6: Nullable<FloatArray>;
  21243. /**
  21244. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21245. */
  21246. colors: Nullable<FloatArray>;
  21247. /**
  21248. * 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).
  21249. */
  21250. matricesIndices: Nullable<FloatArray>;
  21251. /**
  21252. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21253. */
  21254. matricesWeights: Nullable<FloatArray>;
  21255. /**
  21256. * An array extending the number of possible indices
  21257. */
  21258. matricesIndicesExtra: Nullable<FloatArray>;
  21259. /**
  21260. * An array extending the number of possible weights when the number of indices is extended
  21261. */
  21262. matricesWeightsExtra: Nullable<FloatArray>;
  21263. /**
  21264. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21265. */
  21266. indices: Nullable<IndicesArray>;
  21267. /**
  21268. * Uses the passed data array to set the set the values for the specified kind of data
  21269. * @param data a linear array of floating numbers
  21270. * @param kind the type of data that is being set, eg positions, colors etc
  21271. */
  21272. set(data: FloatArray, kind: string): void;
  21273. /**
  21274. * Associates the vertexData to the passed Mesh.
  21275. * Sets it as updatable or not (default `false`)
  21276. * @param mesh the mesh the vertexData is applied to
  21277. * @param updatable when used and having the value true allows new data to update the vertexData
  21278. * @returns the VertexData
  21279. */
  21280. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21281. /**
  21282. * Associates the vertexData to the passed Geometry.
  21283. * Sets it as updatable or not (default `false`)
  21284. * @param geometry the geometry the vertexData is applied to
  21285. * @param updatable when used and having the value true allows new data to update the vertexData
  21286. * @returns VertexData
  21287. */
  21288. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21289. /**
  21290. * Updates the associated mesh
  21291. * @param mesh the mesh to be updated
  21292. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21293. * @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
  21294. * @returns VertexData
  21295. */
  21296. updateMesh(mesh: Mesh): VertexData;
  21297. /**
  21298. * Updates the associated geometry
  21299. * @param geometry the geometry to be updated
  21300. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21301. * @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
  21302. * @returns VertexData.
  21303. */
  21304. updateGeometry(geometry: Geometry): VertexData;
  21305. private _applyTo;
  21306. private _update;
  21307. /**
  21308. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21309. * @param matrix the transforming matrix
  21310. * @returns the VertexData
  21311. */
  21312. transform(matrix: Matrix): VertexData;
  21313. /**
  21314. * Merges the passed VertexData into the current one
  21315. * @param other the VertexData to be merged into the current one
  21316. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21317. * @returns the modified VertexData
  21318. */
  21319. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21320. private _mergeElement;
  21321. private _validate;
  21322. /**
  21323. * Serializes the VertexData
  21324. * @returns a serialized object
  21325. */
  21326. serialize(): any;
  21327. /**
  21328. * Extracts the vertexData from a mesh
  21329. * @param mesh the mesh from which to extract the VertexData
  21330. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21331. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21332. * @returns the object VertexData associated to the passed mesh
  21333. */
  21334. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21335. /**
  21336. * Extracts the vertexData from the geometry
  21337. * @param geometry the geometry from which to extract the VertexData
  21338. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21339. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21340. * @returns the object VertexData associated to the passed mesh
  21341. */
  21342. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21343. private static _ExtractFrom;
  21344. /**
  21345. * Creates the VertexData for a Ribbon
  21346. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21347. * * pathArray array of paths, each of which an array of successive Vector3
  21348. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21349. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21350. * * 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
  21351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21352. * * 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)
  21353. * * 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)
  21354. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21355. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21356. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21357. * @returns the VertexData of the ribbon
  21358. */
  21359. static CreateRibbon(options: {
  21360. pathArray: Vector3[][];
  21361. closeArray?: boolean;
  21362. closePath?: boolean;
  21363. offset?: number;
  21364. sideOrientation?: number;
  21365. frontUVs?: Vector4;
  21366. backUVs?: Vector4;
  21367. invertUV?: boolean;
  21368. uvs?: Vector2[];
  21369. colors?: Color4[];
  21370. }): VertexData;
  21371. /**
  21372. * Creates the VertexData for a box
  21373. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21374. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21375. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21376. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21377. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21378. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21379. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21381. * * 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)
  21382. * * 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)
  21383. * @returns the VertexData of the box
  21384. */
  21385. static CreateBox(options: {
  21386. size?: number;
  21387. width?: number;
  21388. height?: number;
  21389. depth?: number;
  21390. faceUV?: Vector4[];
  21391. faceColors?: Color4[];
  21392. sideOrientation?: number;
  21393. frontUVs?: Vector4;
  21394. backUVs?: Vector4;
  21395. }): VertexData;
  21396. /**
  21397. * Creates the VertexData for a tiled box
  21398. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21399. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21400. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21401. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21403. * @returns the VertexData of the box
  21404. */
  21405. static CreateTiledBox(options: {
  21406. pattern?: number;
  21407. width?: number;
  21408. height?: number;
  21409. depth?: number;
  21410. tileSize?: number;
  21411. tileWidth?: number;
  21412. tileHeight?: number;
  21413. alignHorizontal?: number;
  21414. alignVertical?: number;
  21415. faceUV?: Vector4[];
  21416. faceColors?: Color4[];
  21417. sideOrientation?: number;
  21418. }): VertexData;
  21419. /**
  21420. * Creates the VertexData for a tiled plane
  21421. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21422. * * pattern a limited pattern arrangement depending on the number
  21423. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21424. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21425. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21427. * * 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)
  21428. * * 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)
  21429. * @returns the VertexData of the tiled plane
  21430. */
  21431. static CreateTiledPlane(options: {
  21432. pattern?: number;
  21433. tileSize?: number;
  21434. tileWidth?: number;
  21435. tileHeight?: number;
  21436. size?: number;
  21437. width?: number;
  21438. height?: number;
  21439. alignHorizontal?: number;
  21440. alignVertical?: number;
  21441. sideOrientation?: number;
  21442. frontUVs?: Vector4;
  21443. backUVs?: Vector4;
  21444. }): VertexData;
  21445. /**
  21446. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21447. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21448. * * segments sets the number of horizontal strips optional, default 32
  21449. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21450. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21451. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21452. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21453. * * 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
  21454. * * 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
  21455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21456. * * 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)
  21457. * * 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)
  21458. * @returns the VertexData of the ellipsoid
  21459. */
  21460. static CreateSphere(options: {
  21461. segments?: number;
  21462. diameter?: number;
  21463. diameterX?: number;
  21464. diameterY?: number;
  21465. diameterZ?: number;
  21466. arc?: number;
  21467. slice?: number;
  21468. sideOrientation?: number;
  21469. frontUVs?: Vector4;
  21470. backUVs?: Vector4;
  21471. }): VertexData;
  21472. /**
  21473. * Creates the VertexData for a cylinder, cone or prism
  21474. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21475. * * height sets the height (y direction) of the cylinder, optional, default 2
  21476. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21477. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21478. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21479. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21480. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21481. * * 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
  21482. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21483. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21484. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21485. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21487. * * 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)
  21488. * * 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)
  21489. * @returns the VertexData of the cylinder, cone or prism
  21490. */
  21491. static CreateCylinder(options: {
  21492. height?: number;
  21493. diameterTop?: number;
  21494. diameterBottom?: number;
  21495. diameter?: number;
  21496. tessellation?: number;
  21497. subdivisions?: number;
  21498. arc?: number;
  21499. faceColors?: Color4[];
  21500. faceUV?: Vector4[];
  21501. hasRings?: boolean;
  21502. enclose?: boolean;
  21503. sideOrientation?: number;
  21504. frontUVs?: Vector4;
  21505. backUVs?: Vector4;
  21506. }): VertexData;
  21507. /**
  21508. * Creates the VertexData for a torus
  21509. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21510. * * diameter the diameter of the torus, optional default 1
  21511. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21512. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21514. * * 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)
  21515. * * 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)
  21516. * @returns the VertexData of the torus
  21517. */
  21518. static CreateTorus(options: {
  21519. diameter?: number;
  21520. thickness?: number;
  21521. tessellation?: number;
  21522. sideOrientation?: number;
  21523. frontUVs?: Vector4;
  21524. backUVs?: Vector4;
  21525. }): VertexData;
  21526. /**
  21527. * Creates the VertexData of the LineSystem
  21528. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21529. * - lines an array of lines, each line being an array of successive Vector3
  21530. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21531. * @returns the VertexData of the LineSystem
  21532. */
  21533. static CreateLineSystem(options: {
  21534. lines: Vector3[][];
  21535. colors?: Nullable<Color4[][]>;
  21536. }): VertexData;
  21537. /**
  21538. * Create the VertexData for a DashedLines
  21539. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21540. * - points an array successive Vector3
  21541. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21542. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21543. * - dashNb the intended total number of dashes, optional, default 200
  21544. * @returns the VertexData for the DashedLines
  21545. */
  21546. static CreateDashedLines(options: {
  21547. points: Vector3[];
  21548. dashSize?: number;
  21549. gapSize?: number;
  21550. dashNb?: number;
  21551. }): VertexData;
  21552. /**
  21553. * Creates the VertexData for a Ground
  21554. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21555. * - width the width (x direction) of the ground, optional, default 1
  21556. * - height the height (z direction) of the ground, optional, default 1
  21557. * - subdivisions the number of subdivisions per side, optional, default 1
  21558. * @returns the VertexData of the Ground
  21559. */
  21560. static CreateGround(options: {
  21561. width?: number;
  21562. height?: number;
  21563. subdivisions?: number;
  21564. subdivisionsX?: number;
  21565. subdivisionsY?: number;
  21566. }): VertexData;
  21567. /**
  21568. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21569. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21570. * * xmin the ground minimum X coordinate, optional, default -1
  21571. * * zmin the ground minimum Z coordinate, optional, default -1
  21572. * * xmax the ground maximum X coordinate, optional, default 1
  21573. * * zmax the ground maximum Z coordinate, optional, default 1
  21574. * * 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}
  21575. * * 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}
  21576. * @returns the VertexData of the TiledGround
  21577. */
  21578. static CreateTiledGround(options: {
  21579. xmin: number;
  21580. zmin: number;
  21581. xmax: number;
  21582. zmax: number;
  21583. subdivisions?: {
  21584. w: number;
  21585. h: number;
  21586. };
  21587. precision?: {
  21588. w: number;
  21589. h: number;
  21590. };
  21591. }): VertexData;
  21592. /**
  21593. * Creates the VertexData of the Ground designed from a heightmap
  21594. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21595. * * width the width (x direction) of the ground
  21596. * * height the height (z direction) of the ground
  21597. * * subdivisions the number of subdivisions per side
  21598. * * minHeight the minimum altitude on the ground, optional, default 0
  21599. * * maxHeight the maximum altitude on the ground, optional default 1
  21600. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21601. * * buffer the array holding the image color data
  21602. * * bufferWidth the width of image
  21603. * * bufferHeight the height of image
  21604. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21605. * @returns the VertexData of the Ground designed from a heightmap
  21606. */
  21607. static CreateGroundFromHeightMap(options: {
  21608. width: number;
  21609. height: number;
  21610. subdivisions: number;
  21611. minHeight: number;
  21612. maxHeight: number;
  21613. colorFilter: Color3;
  21614. buffer: Uint8Array;
  21615. bufferWidth: number;
  21616. bufferHeight: number;
  21617. alphaFilter: number;
  21618. }): VertexData;
  21619. /**
  21620. * Creates the VertexData for a Plane
  21621. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21622. * * size sets the width and height of the plane to the value of size, optional default 1
  21623. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21624. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21625. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21626. * * 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)
  21627. * * 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)
  21628. * @returns the VertexData of the box
  21629. */
  21630. static CreatePlane(options: {
  21631. size?: number;
  21632. width?: number;
  21633. height?: number;
  21634. sideOrientation?: number;
  21635. frontUVs?: Vector4;
  21636. backUVs?: Vector4;
  21637. }): VertexData;
  21638. /**
  21639. * Creates the VertexData of the Disc or regular Polygon
  21640. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21641. * * radius the radius of the disc, optional default 0.5
  21642. * * tessellation the number of polygon sides, optional, default 64
  21643. * * 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
  21644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21645. * * 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)
  21646. * * 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)
  21647. * @returns the VertexData of the box
  21648. */
  21649. static CreateDisc(options: {
  21650. radius?: number;
  21651. tessellation?: number;
  21652. arc?: number;
  21653. sideOrientation?: number;
  21654. frontUVs?: Vector4;
  21655. backUVs?: Vector4;
  21656. }): VertexData;
  21657. /**
  21658. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21659. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21660. * @param polygon a mesh built from polygonTriangulation.build()
  21661. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21662. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21663. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21664. * @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)
  21665. * @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)
  21666. * @returns the VertexData of the Polygon
  21667. */
  21668. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21669. /**
  21670. * Creates the VertexData of the IcoSphere
  21671. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21672. * * radius the radius of the IcoSphere, optional default 1
  21673. * * radiusX allows stretching in the x direction, optional, default radius
  21674. * * radiusY allows stretching in the y direction, optional, default radius
  21675. * * radiusZ allows stretching in the z direction, optional, default radius
  21676. * * flat when true creates a flat shaded mesh, optional, default true
  21677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21679. * * 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)
  21680. * * 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)
  21681. * @returns the VertexData of the IcoSphere
  21682. */
  21683. static CreateIcoSphere(options: {
  21684. radius?: number;
  21685. radiusX?: number;
  21686. radiusY?: number;
  21687. radiusZ?: number;
  21688. flat?: boolean;
  21689. subdivisions?: number;
  21690. sideOrientation?: number;
  21691. frontUVs?: Vector4;
  21692. backUVs?: Vector4;
  21693. }): VertexData;
  21694. /**
  21695. * Creates the VertexData for a Polyhedron
  21696. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21697. * * type provided types are:
  21698. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21699. * * 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)
  21700. * * size the size of the IcoSphere, optional default 1
  21701. * * sizeX allows stretching in the x direction, optional, default size
  21702. * * sizeY allows stretching in the y direction, optional, default size
  21703. * * sizeZ allows stretching in the z direction, optional, default size
  21704. * * 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
  21705. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21706. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21707. * * flat when true creates a flat shaded mesh, optional, default true
  21708. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21710. * * 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)
  21711. * * 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)
  21712. * @returns the VertexData of the Polyhedron
  21713. */
  21714. static CreatePolyhedron(options: {
  21715. type?: number;
  21716. size?: number;
  21717. sizeX?: number;
  21718. sizeY?: number;
  21719. sizeZ?: number;
  21720. custom?: any;
  21721. faceUV?: Vector4[];
  21722. faceColors?: Color4[];
  21723. flat?: boolean;
  21724. sideOrientation?: number;
  21725. frontUVs?: Vector4;
  21726. backUVs?: Vector4;
  21727. }): VertexData;
  21728. /**
  21729. * Creates the VertexData for a TorusKnot
  21730. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21731. * * radius the radius of the torus knot, optional, default 2
  21732. * * tube the thickness of the tube, optional, default 0.5
  21733. * * radialSegments the number of sides on each tube segments, optional, default 32
  21734. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21735. * * p the number of windings around the z axis, optional, default 2
  21736. * * q the number of windings around the x axis, optional, default 3
  21737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21738. * * 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)
  21739. * * 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)
  21740. * @returns the VertexData of the Torus Knot
  21741. */
  21742. static CreateTorusKnot(options: {
  21743. radius?: number;
  21744. tube?: number;
  21745. radialSegments?: number;
  21746. tubularSegments?: number;
  21747. p?: number;
  21748. q?: number;
  21749. sideOrientation?: number;
  21750. frontUVs?: Vector4;
  21751. backUVs?: Vector4;
  21752. }): VertexData;
  21753. /**
  21754. * Compute normals for given positions and indices
  21755. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21756. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21757. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21758. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21759. * * facetNormals : optional array of facet normals (vector3)
  21760. * * facetPositions : optional array of facet positions (vector3)
  21761. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21762. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21763. * * bInfo : optional bounding info, required for facetPartitioning computation
  21764. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21765. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21766. * * useRightHandedSystem: optional boolean to for right handed system computation
  21767. * * depthSort : optional boolean to enable the facet depth sort computation
  21768. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21769. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21770. */
  21771. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21772. facetNormals?: any;
  21773. facetPositions?: any;
  21774. facetPartitioning?: any;
  21775. ratio?: number;
  21776. bInfo?: any;
  21777. bbSize?: Vector3;
  21778. subDiv?: any;
  21779. useRightHandedSystem?: boolean;
  21780. depthSort?: boolean;
  21781. distanceTo?: Vector3;
  21782. depthSortedFacets?: any;
  21783. }): void;
  21784. /** @hidden */
  21785. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21786. /**
  21787. * Applies VertexData created from the imported parameters to the geometry
  21788. * @param parsedVertexData the parsed data from an imported file
  21789. * @param geometry the geometry to apply the VertexData to
  21790. */
  21791. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21792. }
  21793. }
  21794. declare module BABYLON {
  21795. /**
  21796. * Defines a target to use with MorphTargetManager
  21797. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21798. */
  21799. export class MorphTarget implements IAnimatable {
  21800. /** defines the name of the target */
  21801. name: string;
  21802. /**
  21803. * Gets or sets the list of animations
  21804. */
  21805. animations: Animation[];
  21806. private _scene;
  21807. private _positions;
  21808. private _normals;
  21809. private _tangents;
  21810. private _uvs;
  21811. private _influence;
  21812. /**
  21813. * Observable raised when the influence changes
  21814. */
  21815. onInfluenceChanged: Observable<boolean>;
  21816. /** @hidden */
  21817. _onDataLayoutChanged: Observable<void>;
  21818. /**
  21819. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21820. */
  21821. influence: number;
  21822. /**
  21823. * Gets or sets the id of the morph Target
  21824. */
  21825. id: string;
  21826. private _animationPropertiesOverride;
  21827. /**
  21828. * Gets or sets the animation properties override
  21829. */
  21830. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21831. /**
  21832. * Creates a new MorphTarget
  21833. * @param name defines the name of the target
  21834. * @param influence defines the influence to use
  21835. * @param scene defines the scene the morphtarget belongs to
  21836. */
  21837. constructor(
  21838. /** defines the name of the target */
  21839. name: string, influence?: number, scene?: Nullable<Scene>);
  21840. /**
  21841. * Gets a boolean defining if the target contains position data
  21842. */
  21843. readonly hasPositions: boolean;
  21844. /**
  21845. * Gets a boolean defining if the target contains normal data
  21846. */
  21847. readonly hasNormals: boolean;
  21848. /**
  21849. * Gets a boolean defining if the target contains tangent data
  21850. */
  21851. readonly hasTangents: boolean;
  21852. /**
  21853. * Gets a boolean defining if the target contains texture coordinates data
  21854. */
  21855. readonly hasUVs: boolean;
  21856. /**
  21857. * Affects position data to this target
  21858. * @param data defines the position data to use
  21859. */
  21860. setPositions(data: Nullable<FloatArray>): void;
  21861. /**
  21862. * Gets the position data stored in this target
  21863. * @returns a FloatArray containing the position data (or null if not present)
  21864. */
  21865. getPositions(): Nullable<FloatArray>;
  21866. /**
  21867. * Affects normal data to this target
  21868. * @param data defines the normal data to use
  21869. */
  21870. setNormals(data: Nullable<FloatArray>): void;
  21871. /**
  21872. * Gets the normal data stored in this target
  21873. * @returns a FloatArray containing the normal data (or null if not present)
  21874. */
  21875. getNormals(): Nullable<FloatArray>;
  21876. /**
  21877. * Affects tangent data to this target
  21878. * @param data defines the tangent data to use
  21879. */
  21880. setTangents(data: Nullable<FloatArray>): void;
  21881. /**
  21882. * Gets the tangent data stored in this target
  21883. * @returns a FloatArray containing the tangent data (or null if not present)
  21884. */
  21885. getTangents(): Nullable<FloatArray>;
  21886. /**
  21887. * Affects texture coordinates data to this target
  21888. * @param data defines the texture coordinates data to use
  21889. */
  21890. setUVs(data: Nullable<FloatArray>): void;
  21891. /**
  21892. * Gets the texture coordinates data stored in this target
  21893. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21894. */
  21895. getUVs(): Nullable<FloatArray>;
  21896. /**
  21897. * Serializes the current target into a Serialization object
  21898. * @returns the serialized object
  21899. */
  21900. serialize(): any;
  21901. /**
  21902. * Returns the string "MorphTarget"
  21903. * @returns "MorphTarget"
  21904. */
  21905. getClassName(): string;
  21906. /**
  21907. * Creates a new target from serialized data
  21908. * @param serializationObject defines the serialized data to use
  21909. * @returns a new MorphTarget
  21910. */
  21911. static Parse(serializationObject: any): MorphTarget;
  21912. /**
  21913. * Creates a MorphTarget from mesh data
  21914. * @param mesh defines the source mesh
  21915. * @param name defines the name to use for the new target
  21916. * @param influence defines the influence to attach to the target
  21917. * @returns a new MorphTarget
  21918. */
  21919. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21920. }
  21921. }
  21922. declare module BABYLON {
  21923. /**
  21924. * This class is used to deform meshes using morphing between different targets
  21925. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21926. */
  21927. export class MorphTargetManager {
  21928. private _targets;
  21929. private _targetInfluenceChangedObservers;
  21930. private _targetDataLayoutChangedObservers;
  21931. private _activeTargets;
  21932. private _scene;
  21933. private _influences;
  21934. private _supportsNormals;
  21935. private _supportsTangents;
  21936. private _supportsUVs;
  21937. private _vertexCount;
  21938. private _uniqueId;
  21939. private _tempInfluences;
  21940. /**
  21941. * Gets or sets a boolean indicating if normals must be morphed
  21942. */
  21943. enableNormalMorphing: boolean;
  21944. /**
  21945. * Gets or sets a boolean indicating if tangents must be morphed
  21946. */
  21947. enableTangentMorphing: boolean;
  21948. /**
  21949. * Gets or sets a boolean indicating if UV must be morphed
  21950. */
  21951. enableUVMorphing: boolean;
  21952. /**
  21953. * Creates a new MorphTargetManager
  21954. * @param scene defines the current scene
  21955. */
  21956. constructor(scene?: Nullable<Scene>);
  21957. /**
  21958. * Gets the unique ID of this manager
  21959. */
  21960. readonly uniqueId: number;
  21961. /**
  21962. * Gets the number of vertices handled by this manager
  21963. */
  21964. readonly vertexCount: number;
  21965. /**
  21966. * Gets a boolean indicating if this manager supports morphing of normals
  21967. */
  21968. readonly supportsNormals: boolean;
  21969. /**
  21970. * Gets a boolean indicating if this manager supports morphing of tangents
  21971. */
  21972. readonly supportsTangents: boolean;
  21973. /**
  21974. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21975. */
  21976. readonly supportsUVs: boolean;
  21977. /**
  21978. * Gets the number of targets stored in this manager
  21979. */
  21980. readonly numTargets: number;
  21981. /**
  21982. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21983. */
  21984. readonly numInfluencers: number;
  21985. /**
  21986. * Gets the list of influences (one per target)
  21987. */
  21988. readonly influences: Float32Array;
  21989. /**
  21990. * Gets the active target at specified index. An active target is a target with an influence > 0
  21991. * @param index defines the index to check
  21992. * @returns the requested target
  21993. */
  21994. getActiveTarget(index: number): MorphTarget;
  21995. /**
  21996. * Gets the target at specified index
  21997. * @param index defines the index to check
  21998. * @returns the requested target
  21999. */
  22000. getTarget(index: number): MorphTarget;
  22001. /**
  22002. * Add a new target to this manager
  22003. * @param target defines the target to add
  22004. */
  22005. addTarget(target: MorphTarget): void;
  22006. /**
  22007. * Removes a target from the manager
  22008. * @param target defines the target to remove
  22009. */
  22010. removeTarget(target: MorphTarget): void;
  22011. /**
  22012. * Serializes the current manager into a Serialization object
  22013. * @returns the serialized object
  22014. */
  22015. serialize(): any;
  22016. private _syncActiveTargets;
  22017. /**
  22018. * Syncrhonize the targets with all the meshes using this morph target manager
  22019. */
  22020. synchronize(): void;
  22021. /**
  22022. * Creates a new MorphTargetManager from serialized data
  22023. * @param serializationObject defines the serialized data
  22024. * @param scene defines the hosting scene
  22025. * @returns the new MorphTargetManager
  22026. */
  22027. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22028. }
  22029. }
  22030. declare module BABYLON {
  22031. /**
  22032. * Class used to represent a specific level of detail of a mesh
  22033. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22034. */
  22035. export class MeshLODLevel {
  22036. /** Defines the distance where this level should start being displayed */
  22037. distance: number;
  22038. /** Defines the mesh to use to render this level */
  22039. mesh: Nullable<Mesh>;
  22040. /**
  22041. * Creates a new LOD level
  22042. * @param distance defines the distance where this level should star being displayed
  22043. * @param mesh defines the mesh to use to render this level
  22044. */
  22045. constructor(
  22046. /** Defines the distance where this level should start being displayed */
  22047. distance: number,
  22048. /** Defines the mesh to use to render this level */
  22049. mesh: Nullable<Mesh>);
  22050. }
  22051. }
  22052. declare module BABYLON {
  22053. /**
  22054. * Mesh representing the gorund
  22055. */
  22056. export class GroundMesh extends Mesh {
  22057. /** If octree should be generated */
  22058. generateOctree: boolean;
  22059. private _heightQuads;
  22060. /** @hidden */
  22061. _subdivisionsX: number;
  22062. /** @hidden */
  22063. _subdivisionsY: number;
  22064. /** @hidden */
  22065. _width: number;
  22066. /** @hidden */
  22067. _height: number;
  22068. /** @hidden */
  22069. _minX: number;
  22070. /** @hidden */
  22071. _maxX: number;
  22072. /** @hidden */
  22073. _minZ: number;
  22074. /** @hidden */
  22075. _maxZ: number;
  22076. constructor(name: string, scene: Scene);
  22077. /**
  22078. * "GroundMesh"
  22079. * @returns "GroundMesh"
  22080. */
  22081. getClassName(): string;
  22082. /**
  22083. * The minimum of x and y subdivisions
  22084. */
  22085. readonly subdivisions: number;
  22086. /**
  22087. * X subdivisions
  22088. */
  22089. readonly subdivisionsX: number;
  22090. /**
  22091. * Y subdivisions
  22092. */
  22093. readonly subdivisionsY: number;
  22094. /**
  22095. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22096. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22097. * @param chunksCount the number of subdivisions for x and y
  22098. * @param octreeBlocksSize (Default: 32)
  22099. */
  22100. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22101. /**
  22102. * Returns a height (y) value in the Worl system :
  22103. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22104. * @param x x coordinate
  22105. * @param z z coordinate
  22106. * @returns the ground y position if (x, z) are outside the ground surface.
  22107. */
  22108. getHeightAtCoordinates(x: number, z: number): number;
  22109. /**
  22110. * Returns a normalized vector (Vector3) orthogonal to the ground
  22111. * at the ground coordinates (x, z) expressed in the World system.
  22112. * @param x x coordinate
  22113. * @param z z coordinate
  22114. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22115. */
  22116. getNormalAtCoordinates(x: number, z: number): Vector3;
  22117. /**
  22118. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22119. * at the ground coordinates (x, z) expressed in the World system.
  22120. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22121. * @param x x coordinate
  22122. * @param z z coordinate
  22123. * @param ref vector to store the result
  22124. * @returns the GroundMesh.
  22125. */
  22126. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22127. /**
  22128. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22129. * if the ground has been updated.
  22130. * This can be used in the render loop.
  22131. * @returns the GroundMesh.
  22132. */
  22133. updateCoordinateHeights(): GroundMesh;
  22134. private _getFacetAt;
  22135. private _initHeightQuads;
  22136. private _computeHeightQuads;
  22137. /**
  22138. * Serializes this ground mesh
  22139. * @param serializationObject object to write serialization to
  22140. */
  22141. serialize(serializationObject: any): void;
  22142. /**
  22143. * Parses a serialized ground mesh
  22144. * @param parsedMesh the serialized mesh
  22145. * @param scene the scene to create the ground mesh in
  22146. * @returns the created ground mesh
  22147. */
  22148. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22149. }
  22150. }
  22151. declare module BABYLON {
  22152. /**
  22153. * Interface for Physics-Joint data
  22154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22155. */
  22156. export interface PhysicsJointData {
  22157. /**
  22158. * The main pivot of the joint
  22159. */
  22160. mainPivot?: Vector3;
  22161. /**
  22162. * The connected pivot of the joint
  22163. */
  22164. connectedPivot?: Vector3;
  22165. /**
  22166. * The main axis of the joint
  22167. */
  22168. mainAxis?: Vector3;
  22169. /**
  22170. * The connected axis of the joint
  22171. */
  22172. connectedAxis?: Vector3;
  22173. /**
  22174. * The collision of the joint
  22175. */
  22176. collision?: boolean;
  22177. /**
  22178. * Native Oimo/Cannon/Energy data
  22179. */
  22180. nativeParams?: any;
  22181. }
  22182. /**
  22183. * This is a holder class for the physics joint created by the physics plugin
  22184. * It holds a set of functions to control the underlying joint
  22185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22186. */
  22187. export class PhysicsJoint {
  22188. /**
  22189. * The type of the physics joint
  22190. */
  22191. type: number;
  22192. /**
  22193. * The data for the physics joint
  22194. */
  22195. jointData: PhysicsJointData;
  22196. private _physicsJoint;
  22197. protected _physicsPlugin: IPhysicsEnginePlugin;
  22198. /**
  22199. * Initializes the physics joint
  22200. * @param type The type of the physics joint
  22201. * @param jointData The data for the physics joint
  22202. */
  22203. constructor(
  22204. /**
  22205. * The type of the physics joint
  22206. */
  22207. type: number,
  22208. /**
  22209. * The data for the physics joint
  22210. */
  22211. jointData: PhysicsJointData);
  22212. /**
  22213. * Gets the physics joint
  22214. */
  22215. /**
  22216. * Sets the physics joint
  22217. */
  22218. physicsJoint: any;
  22219. /**
  22220. * Sets the physics plugin
  22221. */
  22222. physicsPlugin: IPhysicsEnginePlugin;
  22223. /**
  22224. * Execute a function that is physics-plugin specific.
  22225. * @param {Function} func the function that will be executed.
  22226. * It accepts two parameters: the physics world and the physics joint
  22227. */
  22228. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22229. /**
  22230. * Distance-Joint type
  22231. */
  22232. static DistanceJoint: number;
  22233. /**
  22234. * Hinge-Joint type
  22235. */
  22236. static HingeJoint: number;
  22237. /**
  22238. * Ball-and-Socket joint type
  22239. */
  22240. static BallAndSocketJoint: number;
  22241. /**
  22242. * Wheel-Joint type
  22243. */
  22244. static WheelJoint: number;
  22245. /**
  22246. * Slider-Joint type
  22247. */
  22248. static SliderJoint: number;
  22249. /**
  22250. * Prismatic-Joint type
  22251. */
  22252. static PrismaticJoint: number;
  22253. /**
  22254. * Universal-Joint type
  22255. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22256. */
  22257. static UniversalJoint: number;
  22258. /**
  22259. * Hinge-Joint 2 type
  22260. */
  22261. static Hinge2Joint: number;
  22262. /**
  22263. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22264. */
  22265. static PointToPointJoint: number;
  22266. /**
  22267. * Spring-Joint type
  22268. */
  22269. static SpringJoint: number;
  22270. /**
  22271. * Lock-Joint type
  22272. */
  22273. static LockJoint: number;
  22274. }
  22275. /**
  22276. * A class representing a physics distance joint
  22277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22278. */
  22279. export class DistanceJoint extends PhysicsJoint {
  22280. /**
  22281. *
  22282. * @param jointData The data for the Distance-Joint
  22283. */
  22284. constructor(jointData: DistanceJointData);
  22285. /**
  22286. * Update the predefined distance.
  22287. * @param maxDistance The maximum preferred distance
  22288. * @param minDistance The minimum preferred distance
  22289. */
  22290. updateDistance(maxDistance: number, minDistance?: number): void;
  22291. }
  22292. /**
  22293. * Represents a Motor-Enabled Joint
  22294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22295. */
  22296. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22297. /**
  22298. * Initializes the Motor-Enabled Joint
  22299. * @param type The type of the joint
  22300. * @param jointData The physica joint data for the joint
  22301. */
  22302. constructor(type: number, jointData: PhysicsJointData);
  22303. /**
  22304. * Set the motor values.
  22305. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22306. * @param force the force to apply
  22307. * @param maxForce max force for this motor.
  22308. */
  22309. setMotor(force?: number, maxForce?: number): void;
  22310. /**
  22311. * Set the motor's limits.
  22312. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22313. * @param upperLimit The upper limit of the motor
  22314. * @param lowerLimit The lower limit of the motor
  22315. */
  22316. setLimit(upperLimit: number, lowerLimit?: number): void;
  22317. }
  22318. /**
  22319. * This class represents a single physics Hinge-Joint
  22320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22321. */
  22322. export class HingeJoint extends MotorEnabledJoint {
  22323. /**
  22324. * Initializes the Hinge-Joint
  22325. * @param jointData The joint data for the Hinge-Joint
  22326. */
  22327. constructor(jointData: PhysicsJointData);
  22328. /**
  22329. * Set the motor values.
  22330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22331. * @param {number} force the force to apply
  22332. * @param {number} maxForce max force for this motor.
  22333. */
  22334. setMotor(force?: number, maxForce?: number): void;
  22335. /**
  22336. * Set the motor's limits.
  22337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22338. * @param upperLimit The upper limit of the motor
  22339. * @param lowerLimit The lower limit of the motor
  22340. */
  22341. setLimit(upperLimit: number, lowerLimit?: number): void;
  22342. }
  22343. /**
  22344. * This class represents a dual hinge physics joint (same as wheel joint)
  22345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22346. */
  22347. export class Hinge2Joint extends MotorEnabledJoint {
  22348. /**
  22349. * Initializes the Hinge2-Joint
  22350. * @param jointData The joint data for the Hinge2-Joint
  22351. */
  22352. constructor(jointData: PhysicsJointData);
  22353. /**
  22354. * Set the motor values.
  22355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22356. * @param {number} targetSpeed the speed the motor is to reach
  22357. * @param {number} maxForce max force for this motor.
  22358. * @param {motorIndex} the motor's index, 0 or 1.
  22359. */
  22360. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22361. /**
  22362. * Set the motor limits.
  22363. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22364. * @param {number} upperLimit the upper limit
  22365. * @param {number} lowerLimit lower limit
  22366. * @param {motorIndex} the motor's index, 0 or 1.
  22367. */
  22368. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22369. }
  22370. /**
  22371. * Interface for a motor enabled joint
  22372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22373. */
  22374. export interface IMotorEnabledJoint {
  22375. /**
  22376. * Physics joint
  22377. */
  22378. physicsJoint: any;
  22379. /**
  22380. * Sets the motor of the motor-enabled joint
  22381. * @param force The force of the motor
  22382. * @param maxForce The maximum force of the motor
  22383. * @param motorIndex The index of the motor
  22384. */
  22385. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22386. /**
  22387. * Sets the limit of the motor
  22388. * @param upperLimit The upper limit of the motor
  22389. * @param lowerLimit The lower limit of the motor
  22390. * @param motorIndex The index of the motor
  22391. */
  22392. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22393. }
  22394. /**
  22395. * Joint data for a Distance-Joint
  22396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22397. */
  22398. export interface DistanceJointData extends PhysicsJointData {
  22399. /**
  22400. * Max distance the 2 joint objects can be apart
  22401. */
  22402. maxDistance: number;
  22403. }
  22404. /**
  22405. * Joint data from a spring joint
  22406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22407. */
  22408. export interface SpringJointData extends PhysicsJointData {
  22409. /**
  22410. * Length of the spring
  22411. */
  22412. length: number;
  22413. /**
  22414. * Stiffness of the spring
  22415. */
  22416. stiffness: number;
  22417. /**
  22418. * Damping of the spring
  22419. */
  22420. damping: number;
  22421. /** this callback will be called when applying the force to the impostors. */
  22422. forceApplicationCallback: () => void;
  22423. }
  22424. }
  22425. declare module BABYLON {
  22426. /**
  22427. * Holds the data for the raycast result
  22428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22429. */
  22430. export class PhysicsRaycastResult {
  22431. private _hasHit;
  22432. private _hitDistance;
  22433. private _hitNormalWorld;
  22434. private _hitPointWorld;
  22435. private _rayFromWorld;
  22436. private _rayToWorld;
  22437. /**
  22438. * Gets if there was a hit
  22439. */
  22440. readonly hasHit: boolean;
  22441. /**
  22442. * Gets the distance from the hit
  22443. */
  22444. readonly hitDistance: number;
  22445. /**
  22446. * Gets the hit normal/direction in the world
  22447. */
  22448. readonly hitNormalWorld: Vector3;
  22449. /**
  22450. * Gets the hit point in the world
  22451. */
  22452. readonly hitPointWorld: Vector3;
  22453. /**
  22454. * Gets the ray "start point" of the ray in the world
  22455. */
  22456. readonly rayFromWorld: Vector3;
  22457. /**
  22458. * Gets the ray "end point" of the ray in the world
  22459. */
  22460. readonly rayToWorld: Vector3;
  22461. /**
  22462. * Sets the hit data (normal & point in world space)
  22463. * @param hitNormalWorld defines the normal in world space
  22464. * @param hitPointWorld defines the point in world space
  22465. */
  22466. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22467. /**
  22468. * Sets the distance from the start point to the hit point
  22469. * @param distance
  22470. */
  22471. setHitDistance(distance: number): void;
  22472. /**
  22473. * Calculates the distance manually
  22474. */
  22475. calculateHitDistance(): void;
  22476. /**
  22477. * Resets all the values to default
  22478. * @param from The from point on world space
  22479. * @param to The to point on world space
  22480. */
  22481. reset(from?: Vector3, to?: Vector3): void;
  22482. }
  22483. /**
  22484. * Interface for the size containing width and height
  22485. */
  22486. interface IXYZ {
  22487. /**
  22488. * X
  22489. */
  22490. x: number;
  22491. /**
  22492. * Y
  22493. */
  22494. y: number;
  22495. /**
  22496. * Z
  22497. */
  22498. z: number;
  22499. }
  22500. }
  22501. declare module BABYLON {
  22502. /**
  22503. * Interface used to describe a physics joint
  22504. */
  22505. export interface PhysicsImpostorJoint {
  22506. /** Defines the main impostor to which the joint is linked */
  22507. mainImpostor: PhysicsImpostor;
  22508. /** Defines the impostor that is connected to the main impostor using this joint */
  22509. connectedImpostor: PhysicsImpostor;
  22510. /** Defines the joint itself */
  22511. joint: PhysicsJoint;
  22512. }
  22513. /** @hidden */
  22514. export interface IPhysicsEnginePlugin {
  22515. world: any;
  22516. name: string;
  22517. setGravity(gravity: Vector3): void;
  22518. setTimeStep(timeStep: number): void;
  22519. getTimeStep(): number;
  22520. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22521. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22522. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22523. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22524. removePhysicsBody(impostor: PhysicsImpostor): void;
  22525. generateJoint(joint: PhysicsImpostorJoint): void;
  22526. removeJoint(joint: PhysicsImpostorJoint): void;
  22527. isSupported(): boolean;
  22528. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22529. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22530. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22531. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22532. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22533. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22534. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22535. getBodyMass(impostor: PhysicsImpostor): number;
  22536. getBodyFriction(impostor: PhysicsImpostor): number;
  22537. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22538. getBodyRestitution(impostor: PhysicsImpostor): number;
  22539. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22540. getBodyPressure?(impostor: PhysicsImpostor): number;
  22541. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22542. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22543. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22544. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22545. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22546. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22547. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22548. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22549. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22550. sleepBody(impostor: PhysicsImpostor): void;
  22551. wakeUpBody(impostor: PhysicsImpostor): void;
  22552. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22554. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22556. getRadius(impostor: PhysicsImpostor): number;
  22557. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22558. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22559. dispose(): void;
  22560. }
  22561. /**
  22562. * Interface used to define a physics engine
  22563. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22564. */
  22565. export interface IPhysicsEngine {
  22566. /**
  22567. * Gets the gravity vector used by the simulation
  22568. */
  22569. gravity: Vector3;
  22570. /**
  22571. * Sets the gravity vector used by the simulation
  22572. * @param gravity defines the gravity vector to use
  22573. */
  22574. setGravity(gravity: Vector3): void;
  22575. /**
  22576. * Set the time step of the physics engine.
  22577. * Default is 1/60.
  22578. * To slow it down, enter 1/600 for example.
  22579. * To speed it up, 1/30
  22580. * @param newTimeStep the new timestep to apply to this world.
  22581. */
  22582. setTimeStep(newTimeStep: number): void;
  22583. /**
  22584. * Get the time step of the physics engine.
  22585. * @returns the current time step
  22586. */
  22587. getTimeStep(): number;
  22588. /**
  22589. * Release all resources
  22590. */
  22591. dispose(): void;
  22592. /**
  22593. * Gets the name of the current physics plugin
  22594. * @returns the name of the plugin
  22595. */
  22596. getPhysicsPluginName(): string;
  22597. /**
  22598. * Adding a new impostor for the impostor tracking.
  22599. * This will be done by the impostor itself.
  22600. * @param impostor the impostor to add
  22601. */
  22602. addImpostor(impostor: PhysicsImpostor): void;
  22603. /**
  22604. * Remove an impostor from the engine.
  22605. * This impostor and its mesh will not longer be updated by the physics engine.
  22606. * @param impostor the impostor to remove
  22607. */
  22608. removeImpostor(impostor: PhysicsImpostor): void;
  22609. /**
  22610. * Add a joint to the physics engine
  22611. * @param mainImpostor defines the main impostor to which the joint is added.
  22612. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22613. * @param joint defines the joint that will connect both impostors.
  22614. */
  22615. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22616. /**
  22617. * Removes a joint from the simulation
  22618. * @param mainImpostor defines the impostor used with the joint
  22619. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22620. * @param joint defines the joint to remove
  22621. */
  22622. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22623. /**
  22624. * Gets the current plugin used to run the simulation
  22625. * @returns current plugin
  22626. */
  22627. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22628. /**
  22629. * Gets the list of physic impostors
  22630. * @returns an array of PhysicsImpostor
  22631. */
  22632. getImpostors(): Array<PhysicsImpostor>;
  22633. /**
  22634. * Gets the impostor for a physics enabled object
  22635. * @param object defines the object impersonated by the impostor
  22636. * @returns the PhysicsImpostor or null if not found
  22637. */
  22638. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22639. /**
  22640. * Gets the impostor for a physics body object
  22641. * @param body defines physics body used by the impostor
  22642. * @returns the PhysicsImpostor or null if not found
  22643. */
  22644. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22645. /**
  22646. * Does a raycast in the physics world
  22647. * @param from when should the ray start?
  22648. * @param to when should the ray end?
  22649. * @returns PhysicsRaycastResult
  22650. */
  22651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22652. /**
  22653. * Called by the scene. No need to call it.
  22654. * @param delta defines the timespam between frames
  22655. */
  22656. _step(delta: number): void;
  22657. }
  22658. }
  22659. declare module BABYLON {
  22660. /**
  22661. * The interface for the physics imposter parameters
  22662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22663. */
  22664. export interface PhysicsImpostorParameters {
  22665. /**
  22666. * The mass of the physics imposter
  22667. */
  22668. mass: number;
  22669. /**
  22670. * The friction of the physics imposter
  22671. */
  22672. friction?: number;
  22673. /**
  22674. * The coefficient of restitution of the physics imposter
  22675. */
  22676. restitution?: number;
  22677. /**
  22678. * The native options of the physics imposter
  22679. */
  22680. nativeOptions?: any;
  22681. /**
  22682. * Specifies if the parent should be ignored
  22683. */
  22684. ignoreParent?: boolean;
  22685. /**
  22686. * Specifies if bi-directional transformations should be disabled
  22687. */
  22688. disableBidirectionalTransformation?: boolean;
  22689. /**
  22690. * The pressure inside the physics imposter, soft object only
  22691. */
  22692. pressure?: number;
  22693. /**
  22694. * The stiffness the physics imposter, soft object only
  22695. */
  22696. stiffness?: number;
  22697. /**
  22698. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22699. */
  22700. velocityIterations?: number;
  22701. /**
  22702. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22703. */
  22704. positionIterations?: number;
  22705. /**
  22706. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22707. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22708. * Add to fix multiple points
  22709. */
  22710. fixedPoints?: number;
  22711. /**
  22712. * The collision margin around a soft object
  22713. */
  22714. margin?: number;
  22715. /**
  22716. * The collision margin around a soft object
  22717. */
  22718. damping?: number;
  22719. /**
  22720. * The path for a rope based on an extrusion
  22721. */
  22722. path?: any;
  22723. /**
  22724. * The shape of an extrusion used for a rope based on an extrusion
  22725. */
  22726. shape?: any;
  22727. }
  22728. /**
  22729. * Interface for a physics-enabled object
  22730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22731. */
  22732. export interface IPhysicsEnabledObject {
  22733. /**
  22734. * The position of the physics-enabled object
  22735. */
  22736. position: Vector3;
  22737. /**
  22738. * The rotation of the physics-enabled object
  22739. */
  22740. rotationQuaternion: Nullable<Quaternion>;
  22741. /**
  22742. * The scale of the physics-enabled object
  22743. */
  22744. scaling: Vector3;
  22745. /**
  22746. * The rotation of the physics-enabled object
  22747. */
  22748. rotation?: Vector3;
  22749. /**
  22750. * The parent of the physics-enabled object
  22751. */
  22752. parent?: any;
  22753. /**
  22754. * The bounding info of the physics-enabled object
  22755. * @returns The bounding info of the physics-enabled object
  22756. */
  22757. getBoundingInfo(): BoundingInfo;
  22758. /**
  22759. * Computes the world matrix
  22760. * @param force Specifies if the world matrix should be computed by force
  22761. * @returns A world matrix
  22762. */
  22763. computeWorldMatrix(force: boolean): Matrix;
  22764. /**
  22765. * Gets the world matrix
  22766. * @returns A world matrix
  22767. */
  22768. getWorldMatrix?(): Matrix;
  22769. /**
  22770. * Gets the child meshes
  22771. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22772. * @returns An array of abstract meshes
  22773. */
  22774. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22775. /**
  22776. * Gets the vertex data
  22777. * @param kind The type of vertex data
  22778. * @returns A nullable array of numbers, or a float32 array
  22779. */
  22780. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22781. /**
  22782. * Gets the indices from the mesh
  22783. * @returns A nullable array of index arrays
  22784. */
  22785. getIndices?(): Nullable<IndicesArray>;
  22786. /**
  22787. * Gets the scene from the mesh
  22788. * @returns the indices array or null
  22789. */
  22790. getScene?(): Scene;
  22791. /**
  22792. * Gets the absolute position from the mesh
  22793. * @returns the absolute position
  22794. */
  22795. getAbsolutePosition(): Vector3;
  22796. /**
  22797. * Gets the absolute pivot point from the mesh
  22798. * @returns the absolute pivot point
  22799. */
  22800. getAbsolutePivotPoint(): Vector3;
  22801. /**
  22802. * Rotates the mesh
  22803. * @param axis The axis of rotation
  22804. * @param amount The amount of rotation
  22805. * @param space The space of the rotation
  22806. * @returns The rotation transform node
  22807. */
  22808. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22809. /**
  22810. * Translates the mesh
  22811. * @param axis The axis of translation
  22812. * @param distance The distance of translation
  22813. * @param space The space of the translation
  22814. * @returns The transform node
  22815. */
  22816. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22817. /**
  22818. * Sets the absolute position of the mesh
  22819. * @param absolutePosition The absolute position of the mesh
  22820. * @returns The transform node
  22821. */
  22822. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22823. /**
  22824. * Gets the class name of the mesh
  22825. * @returns The class name
  22826. */
  22827. getClassName(): string;
  22828. }
  22829. /**
  22830. * Represents a physics imposter
  22831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22832. */
  22833. export class PhysicsImpostor {
  22834. /**
  22835. * The physics-enabled object used as the physics imposter
  22836. */
  22837. object: IPhysicsEnabledObject;
  22838. /**
  22839. * The type of the physics imposter
  22840. */
  22841. type: number;
  22842. private _options;
  22843. private _scene?;
  22844. /**
  22845. * The default object size of the imposter
  22846. */
  22847. static DEFAULT_OBJECT_SIZE: Vector3;
  22848. /**
  22849. * The identity quaternion of the imposter
  22850. */
  22851. static IDENTITY_QUATERNION: Quaternion;
  22852. /** @hidden */
  22853. _pluginData: any;
  22854. private _physicsEngine;
  22855. private _physicsBody;
  22856. private _bodyUpdateRequired;
  22857. private _onBeforePhysicsStepCallbacks;
  22858. private _onAfterPhysicsStepCallbacks;
  22859. /** @hidden */
  22860. _onPhysicsCollideCallbacks: Array<{
  22861. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22862. otherImpostors: Array<PhysicsImpostor>;
  22863. }>;
  22864. private _deltaPosition;
  22865. private _deltaRotation;
  22866. private _deltaRotationConjugated;
  22867. /** @hidden */
  22868. _isFromLine: boolean;
  22869. private _parent;
  22870. private _isDisposed;
  22871. private static _tmpVecs;
  22872. private static _tmpQuat;
  22873. /**
  22874. * Specifies if the physics imposter is disposed
  22875. */
  22876. readonly isDisposed: boolean;
  22877. /**
  22878. * Gets the mass of the physics imposter
  22879. */
  22880. mass: number;
  22881. /**
  22882. * Gets the coefficient of friction
  22883. */
  22884. /**
  22885. * Sets the coefficient of friction
  22886. */
  22887. friction: number;
  22888. /**
  22889. * Gets the coefficient of restitution
  22890. */
  22891. /**
  22892. * Sets the coefficient of restitution
  22893. */
  22894. restitution: number;
  22895. /**
  22896. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22897. */
  22898. /**
  22899. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22900. */
  22901. pressure: number;
  22902. /**
  22903. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22904. */
  22905. /**
  22906. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22907. */
  22908. stiffness: number;
  22909. /**
  22910. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22911. */
  22912. /**
  22913. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22914. */
  22915. velocityIterations: number;
  22916. /**
  22917. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22918. */
  22919. /**
  22920. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22921. */
  22922. positionIterations: number;
  22923. /**
  22924. * The unique id of the physics imposter
  22925. * set by the physics engine when adding this impostor to the array
  22926. */
  22927. uniqueId: number;
  22928. /**
  22929. * @hidden
  22930. */
  22931. soft: boolean;
  22932. /**
  22933. * @hidden
  22934. */
  22935. segments: number;
  22936. private _joints;
  22937. /**
  22938. * Initializes the physics imposter
  22939. * @param object The physics-enabled object used as the physics imposter
  22940. * @param type The type of the physics imposter
  22941. * @param _options The options for the physics imposter
  22942. * @param _scene The Babylon scene
  22943. */
  22944. constructor(
  22945. /**
  22946. * The physics-enabled object used as the physics imposter
  22947. */
  22948. object: IPhysicsEnabledObject,
  22949. /**
  22950. * The type of the physics imposter
  22951. */
  22952. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22953. /**
  22954. * This function will completly initialize this impostor.
  22955. * It will create a new body - but only if this mesh has no parent.
  22956. * If it has, this impostor will not be used other than to define the impostor
  22957. * of the child mesh.
  22958. * @hidden
  22959. */
  22960. _init(): void;
  22961. private _getPhysicsParent;
  22962. /**
  22963. * Should a new body be generated.
  22964. * @returns boolean specifying if body initialization is required
  22965. */
  22966. isBodyInitRequired(): boolean;
  22967. /**
  22968. * Sets the updated scaling
  22969. * @param updated Specifies if the scaling is updated
  22970. */
  22971. setScalingUpdated(): void;
  22972. /**
  22973. * Force a regeneration of this or the parent's impostor's body.
  22974. * Use under cautious - This will remove all joints already implemented.
  22975. */
  22976. forceUpdate(): void;
  22977. /**
  22978. * Gets the body that holds this impostor. Either its own, or its parent.
  22979. */
  22980. /**
  22981. * Set the physics body. Used mainly by the physics engine/plugin
  22982. */
  22983. physicsBody: any;
  22984. /**
  22985. * Get the parent of the physics imposter
  22986. * @returns Physics imposter or null
  22987. */
  22988. /**
  22989. * Sets the parent of the physics imposter
  22990. */
  22991. parent: Nullable<PhysicsImpostor>;
  22992. /**
  22993. * Resets the update flags
  22994. */
  22995. resetUpdateFlags(): void;
  22996. /**
  22997. * Gets the object extend size
  22998. * @returns the object extend size
  22999. */
  23000. getObjectExtendSize(): Vector3;
  23001. /**
  23002. * Gets the object center
  23003. * @returns The object center
  23004. */
  23005. getObjectCenter(): Vector3;
  23006. /**
  23007. * Get a specific parametes from the options parameter
  23008. * @param paramName The object parameter name
  23009. * @returns The object parameter
  23010. */
  23011. getParam(paramName: string): any;
  23012. /**
  23013. * Sets a specific parameter in the options given to the physics plugin
  23014. * @param paramName The parameter name
  23015. * @param value The value of the parameter
  23016. */
  23017. setParam(paramName: string, value: number): void;
  23018. /**
  23019. * Specifically change the body's mass option. Won't recreate the physics body object
  23020. * @param mass The mass of the physics imposter
  23021. */
  23022. setMass(mass: number): void;
  23023. /**
  23024. * Gets the linear velocity
  23025. * @returns linear velocity or null
  23026. */
  23027. getLinearVelocity(): Nullable<Vector3>;
  23028. /**
  23029. * Sets the linear velocity
  23030. * @param velocity linear velocity or null
  23031. */
  23032. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23033. /**
  23034. * Gets the angular velocity
  23035. * @returns angular velocity or null
  23036. */
  23037. getAngularVelocity(): Nullable<Vector3>;
  23038. /**
  23039. * Sets the angular velocity
  23040. * @param velocity The velocity or null
  23041. */
  23042. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23043. /**
  23044. * Execute a function with the physics plugin native code
  23045. * Provide a function the will have two variables - the world object and the physics body object
  23046. * @param func The function to execute with the physics plugin native code
  23047. */
  23048. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23049. /**
  23050. * Register a function that will be executed before the physics world is stepping forward
  23051. * @param func The function to execute before the physics world is stepped forward
  23052. */
  23053. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23054. /**
  23055. * Unregister a function that will be executed before the physics world is stepping forward
  23056. * @param func The function to execute before the physics world is stepped forward
  23057. */
  23058. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23059. /**
  23060. * Register a function that will be executed after the physics step
  23061. * @param func The function to execute after physics step
  23062. */
  23063. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23064. /**
  23065. * Unregisters a function that will be executed after the physics step
  23066. * @param func The function to execute after physics step
  23067. */
  23068. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23069. /**
  23070. * register a function that will be executed when this impostor collides against a different body
  23071. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23072. * @param func Callback that is executed on collision
  23073. */
  23074. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23075. /**
  23076. * Unregisters the physics imposter on contact
  23077. * @param collideAgainst The physics object to collide against
  23078. * @param func Callback to execute on collision
  23079. */
  23080. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23081. private _tmpQuat;
  23082. private _tmpQuat2;
  23083. /**
  23084. * Get the parent rotation
  23085. * @returns The parent rotation
  23086. */
  23087. getParentsRotation(): Quaternion;
  23088. /**
  23089. * this function is executed by the physics engine.
  23090. */
  23091. beforeStep: () => void;
  23092. /**
  23093. * this function is executed by the physics engine
  23094. */
  23095. afterStep: () => void;
  23096. /**
  23097. * Legacy collision detection event support
  23098. */
  23099. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23100. /**
  23101. * event and body object due to cannon's event-based architecture.
  23102. */
  23103. onCollide: (e: {
  23104. body: any;
  23105. }) => void;
  23106. /**
  23107. * Apply a force
  23108. * @param force The force to apply
  23109. * @param contactPoint The contact point for the force
  23110. * @returns The physics imposter
  23111. */
  23112. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23113. /**
  23114. * Apply an impulse
  23115. * @param force The impulse force
  23116. * @param contactPoint The contact point for the impulse force
  23117. * @returns The physics imposter
  23118. */
  23119. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23120. /**
  23121. * A help function to create a joint
  23122. * @param otherImpostor A physics imposter used to create a joint
  23123. * @param jointType The type of joint
  23124. * @param jointData The data for the joint
  23125. * @returns The physics imposter
  23126. */
  23127. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23128. /**
  23129. * Add a joint to this impostor with a different impostor
  23130. * @param otherImpostor A physics imposter used to add a joint
  23131. * @param joint The joint to add
  23132. * @returns The physics imposter
  23133. */
  23134. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23135. /**
  23136. * Add an anchor to a cloth impostor
  23137. * @param otherImpostor rigid impostor to anchor to
  23138. * @param width ratio across width from 0 to 1
  23139. * @param height ratio up height from 0 to 1
  23140. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23141. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23142. * @returns impostor the soft imposter
  23143. */
  23144. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23145. /**
  23146. * Add a hook to a rope impostor
  23147. * @param otherImpostor rigid impostor to anchor to
  23148. * @param length ratio across rope from 0 to 1
  23149. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23150. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23151. * @returns impostor the rope imposter
  23152. */
  23153. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23154. /**
  23155. * Will keep this body still, in a sleep mode.
  23156. * @returns the physics imposter
  23157. */
  23158. sleep(): PhysicsImpostor;
  23159. /**
  23160. * Wake the body up.
  23161. * @returns The physics imposter
  23162. */
  23163. wakeUp(): PhysicsImpostor;
  23164. /**
  23165. * Clones the physics imposter
  23166. * @param newObject The physics imposter clones to this physics-enabled object
  23167. * @returns A nullable physics imposter
  23168. */
  23169. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23170. /**
  23171. * Disposes the physics imposter
  23172. */
  23173. dispose(): void;
  23174. /**
  23175. * Sets the delta position
  23176. * @param position The delta position amount
  23177. */
  23178. setDeltaPosition(position: Vector3): void;
  23179. /**
  23180. * Sets the delta rotation
  23181. * @param rotation The delta rotation amount
  23182. */
  23183. setDeltaRotation(rotation: Quaternion): void;
  23184. /**
  23185. * Gets the box size of the physics imposter and stores the result in the input parameter
  23186. * @param result Stores the box size
  23187. * @returns The physics imposter
  23188. */
  23189. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23190. /**
  23191. * Gets the radius of the physics imposter
  23192. * @returns Radius of the physics imposter
  23193. */
  23194. getRadius(): number;
  23195. /**
  23196. * Sync a bone with this impostor
  23197. * @param bone The bone to sync to the impostor.
  23198. * @param boneMesh The mesh that the bone is influencing.
  23199. * @param jointPivot The pivot of the joint / bone in local space.
  23200. * @param distToJoint Optional distance from the impostor to the joint.
  23201. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23202. */
  23203. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23204. /**
  23205. * Sync impostor to a bone
  23206. * @param bone The bone that the impostor will be synced to.
  23207. * @param boneMesh The mesh that the bone is influencing.
  23208. * @param jointPivot The pivot of the joint / bone in local space.
  23209. * @param distToJoint Optional distance from the impostor to the joint.
  23210. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23211. * @param boneAxis Optional vector3 axis the bone is aligned with
  23212. */
  23213. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23214. /**
  23215. * No-Imposter type
  23216. */
  23217. static NoImpostor: number;
  23218. /**
  23219. * Sphere-Imposter type
  23220. */
  23221. static SphereImpostor: number;
  23222. /**
  23223. * Box-Imposter type
  23224. */
  23225. static BoxImpostor: number;
  23226. /**
  23227. * Plane-Imposter type
  23228. */
  23229. static PlaneImpostor: number;
  23230. /**
  23231. * Mesh-imposter type
  23232. */
  23233. static MeshImpostor: number;
  23234. /**
  23235. * Capsule-Impostor type (Ammo.js plugin only)
  23236. */
  23237. static CapsuleImpostor: number;
  23238. /**
  23239. * Cylinder-Imposter type
  23240. */
  23241. static CylinderImpostor: number;
  23242. /**
  23243. * Particle-Imposter type
  23244. */
  23245. static ParticleImpostor: number;
  23246. /**
  23247. * Heightmap-Imposter type
  23248. */
  23249. static HeightmapImpostor: number;
  23250. /**
  23251. * ConvexHull-Impostor type (Ammo.js plugin only)
  23252. */
  23253. static ConvexHullImpostor: number;
  23254. /**
  23255. * Rope-Imposter type
  23256. */
  23257. static RopeImpostor: number;
  23258. /**
  23259. * Cloth-Imposter type
  23260. */
  23261. static ClothImpostor: number;
  23262. /**
  23263. * Softbody-Imposter type
  23264. */
  23265. static SoftbodyImpostor: number;
  23266. }
  23267. }
  23268. declare module BABYLON {
  23269. /**
  23270. * @hidden
  23271. **/
  23272. export class _CreationDataStorage {
  23273. closePath?: boolean;
  23274. closeArray?: boolean;
  23275. idx: number[];
  23276. dashSize: number;
  23277. gapSize: number;
  23278. path3D: Path3D;
  23279. pathArray: Vector3[][];
  23280. arc: number;
  23281. radius: number;
  23282. cap: number;
  23283. tessellation: number;
  23284. }
  23285. /**
  23286. * @hidden
  23287. **/
  23288. class _InstanceDataStorage {
  23289. visibleInstances: any;
  23290. batchCache: _InstancesBatch;
  23291. instancesBufferSize: number;
  23292. instancesBuffer: Nullable<Buffer>;
  23293. instancesData: Float32Array;
  23294. overridenInstanceCount: number;
  23295. isFrozen: boolean;
  23296. previousBatch: Nullable<_InstancesBatch>;
  23297. hardwareInstancedRendering: boolean;
  23298. sideOrientation: number;
  23299. }
  23300. /**
  23301. * @hidden
  23302. **/
  23303. export class _InstancesBatch {
  23304. mustReturn: boolean;
  23305. visibleInstances: Nullable<InstancedMesh[]>[];
  23306. renderSelf: boolean[];
  23307. hardwareInstancedRendering: boolean[];
  23308. }
  23309. /**
  23310. * Class used to represent renderable models
  23311. */
  23312. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23313. /**
  23314. * Mesh side orientation : usually the external or front surface
  23315. */
  23316. static readonly FRONTSIDE: number;
  23317. /**
  23318. * Mesh side orientation : usually the internal or back surface
  23319. */
  23320. static readonly BACKSIDE: number;
  23321. /**
  23322. * Mesh side orientation : both internal and external or front and back surfaces
  23323. */
  23324. static readonly DOUBLESIDE: number;
  23325. /**
  23326. * Mesh side orientation : by default, `FRONTSIDE`
  23327. */
  23328. static readonly DEFAULTSIDE: number;
  23329. /**
  23330. * Mesh cap setting : no cap
  23331. */
  23332. static readonly NO_CAP: number;
  23333. /**
  23334. * Mesh cap setting : one cap at the beginning of the mesh
  23335. */
  23336. static readonly CAP_START: number;
  23337. /**
  23338. * Mesh cap setting : one cap at the end of the mesh
  23339. */
  23340. static readonly CAP_END: number;
  23341. /**
  23342. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23343. */
  23344. static readonly CAP_ALL: number;
  23345. /**
  23346. * Mesh pattern setting : no flip or rotate
  23347. */
  23348. static readonly NO_FLIP: number;
  23349. /**
  23350. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23351. */
  23352. static readonly FLIP_TILE: number;
  23353. /**
  23354. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23355. */
  23356. static readonly ROTATE_TILE: number;
  23357. /**
  23358. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23359. */
  23360. static readonly FLIP_ROW: number;
  23361. /**
  23362. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23363. */
  23364. static readonly ROTATE_ROW: number;
  23365. /**
  23366. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23367. */
  23368. static readonly FLIP_N_ROTATE_TILE: number;
  23369. /**
  23370. * Mesh pattern setting : rotate pattern and rotate
  23371. */
  23372. static readonly FLIP_N_ROTATE_ROW: number;
  23373. /**
  23374. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23375. */
  23376. static readonly CENTER: number;
  23377. /**
  23378. * Mesh tile positioning : part tiles on left
  23379. */
  23380. static readonly LEFT: number;
  23381. /**
  23382. * Mesh tile positioning : part tiles on right
  23383. */
  23384. static readonly RIGHT: number;
  23385. /**
  23386. * Mesh tile positioning : part tiles on top
  23387. */
  23388. static readonly TOP: number;
  23389. /**
  23390. * Mesh tile positioning : part tiles on bottom
  23391. */
  23392. static readonly BOTTOM: number;
  23393. /**
  23394. * Gets the default side orientation.
  23395. * @param orientation the orientation to value to attempt to get
  23396. * @returns the default orientation
  23397. * @hidden
  23398. */
  23399. static _GetDefaultSideOrientation(orientation?: number): number;
  23400. private _internalMeshDataInfo;
  23401. /**
  23402. * An event triggered before rendering the mesh
  23403. */
  23404. readonly onBeforeRenderObservable: Observable<Mesh>;
  23405. /**
  23406. * An event triggered before binding the mesh
  23407. */
  23408. readonly onBeforeBindObservable: Observable<Mesh>;
  23409. /**
  23410. * An event triggered after rendering the mesh
  23411. */
  23412. readonly onAfterRenderObservable: Observable<Mesh>;
  23413. /**
  23414. * An event triggered before drawing the mesh
  23415. */
  23416. readonly onBeforeDrawObservable: Observable<Mesh>;
  23417. private _onBeforeDrawObserver;
  23418. /**
  23419. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23420. */
  23421. onBeforeDraw: () => void;
  23422. readonly hasInstances: boolean;
  23423. /**
  23424. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23425. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23426. */
  23427. delayLoadState: number;
  23428. /**
  23429. * Gets the list of instances created from this mesh
  23430. * it is not supposed to be modified manually.
  23431. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23432. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23433. */
  23434. instances: InstancedMesh[];
  23435. /**
  23436. * Gets the file containing delay loading data for this mesh
  23437. */
  23438. delayLoadingFile: string;
  23439. /** @hidden */
  23440. _binaryInfo: any;
  23441. /**
  23442. * User defined function used to change how LOD level selection is done
  23443. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23444. */
  23445. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23446. /**
  23447. * Gets or sets the morph target manager
  23448. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23449. */
  23450. morphTargetManager: Nullable<MorphTargetManager>;
  23451. /** @hidden */
  23452. _creationDataStorage: Nullable<_CreationDataStorage>;
  23453. /** @hidden */
  23454. _geometry: Nullable<Geometry>;
  23455. /** @hidden */
  23456. _delayInfo: Array<string>;
  23457. /** @hidden */
  23458. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23459. /** @hidden */
  23460. _instanceDataStorage: _InstanceDataStorage;
  23461. private _effectiveMaterial;
  23462. /** @hidden */
  23463. _shouldGenerateFlatShading: boolean;
  23464. /** @hidden */
  23465. _originalBuilderSideOrientation: number;
  23466. /**
  23467. * Use this property to change the original side orientation defined at construction time
  23468. */
  23469. overrideMaterialSideOrientation: Nullable<number>;
  23470. /**
  23471. * Gets the source mesh (the one used to clone this one from)
  23472. */
  23473. readonly source: Nullable<Mesh>;
  23474. /**
  23475. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23476. */
  23477. isUnIndexed: boolean;
  23478. /**
  23479. * @constructor
  23480. * @param name The value used by scene.getMeshByName() to do a lookup.
  23481. * @param scene The scene to add this mesh to.
  23482. * @param parent The parent of this mesh, if it has one
  23483. * @param source An optional Mesh from which geometry is shared, cloned.
  23484. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23485. * When false, achieved by calling a clone(), also passing False.
  23486. * This will make creation of children, recursive.
  23487. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23488. */
  23489. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23490. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23491. /**
  23492. * Gets the class name
  23493. * @returns the string "Mesh".
  23494. */
  23495. getClassName(): string;
  23496. /** @hidden */
  23497. readonly _isMesh: boolean;
  23498. /**
  23499. * Returns a description of this mesh
  23500. * @param fullDetails define if full details about this mesh must be used
  23501. * @returns a descriptive string representing this mesh
  23502. */
  23503. toString(fullDetails?: boolean): string;
  23504. /** @hidden */
  23505. _unBindEffect(): void;
  23506. /**
  23507. * Gets a boolean indicating if this mesh has LOD
  23508. */
  23509. readonly hasLODLevels: boolean;
  23510. /**
  23511. * Gets the list of MeshLODLevel associated with the current mesh
  23512. * @returns an array of MeshLODLevel
  23513. */
  23514. getLODLevels(): MeshLODLevel[];
  23515. private _sortLODLevels;
  23516. /**
  23517. * Add a mesh as LOD level triggered at the given distance.
  23518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23519. * @param distance The distance from the center of the object to show this level
  23520. * @param mesh The mesh to be added as LOD level (can be null)
  23521. * @return This mesh (for chaining)
  23522. */
  23523. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23524. /**
  23525. * Returns the LOD level mesh at the passed distance or null if not found.
  23526. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23527. * @param distance The distance from the center of the object to show this level
  23528. * @returns a Mesh or `null`
  23529. */
  23530. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23531. /**
  23532. * Remove a mesh from the LOD array
  23533. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23534. * @param mesh defines the mesh to be removed
  23535. * @return This mesh (for chaining)
  23536. */
  23537. removeLODLevel(mesh: Mesh): Mesh;
  23538. /**
  23539. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23541. * @param camera defines the camera to use to compute distance
  23542. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23543. * @return This mesh (for chaining)
  23544. */
  23545. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23546. /**
  23547. * Gets the mesh internal Geometry object
  23548. */
  23549. readonly geometry: Nullable<Geometry>;
  23550. /**
  23551. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23552. * @returns the total number of vertices
  23553. */
  23554. getTotalVertices(): number;
  23555. /**
  23556. * Returns the content of an associated vertex buffer
  23557. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23558. * - VertexBuffer.PositionKind
  23559. * - VertexBuffer.UVKind
  23560. * - VertexBuffer.UV2Kind
  23561. * - VertexBuffer.UV3Kind
  23562. * - VertexBuffer.UV4Kind
  23563. * - VertexBuffer.UV5Kind
  23564. * - VertexBuffer.UV6Kind
  23565. * - VertexBuffer.ColorKind
  23566. * - VertexBuffer.MatricesIndicesKind
  23567. * - VertexBuffer.MatricesIndicesExtraKind
  23568. * - VertexBuffer.MatricesWeightsKind
  23569. * - VertexBuffer.MatricesWeightsExtraKind
  23570. * @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
  23571. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23572. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23573. */
  23574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23575. /**
  23576. * Returns the mesh VertexBuffer object from the requested `kind`
  23577. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23578. * - VertexBuffer.PositionKind
  23579. * - VertexBuffer.NormalKind
  23580. * - VertexBuffer.UVKind
  23581. * - VertexBuffer.UV2Kind
  23582. * - VertexBuffer.UV3Kind
  23583. * - VertexBuffer.UV4Kind
  23584. * - VertexBuffer.UV5Kind
  23585. * - VertexBuffer.UV6Kind
  23586. * - VertexBuffer.ColorKind
  23587. * - VertexBuffer.MatricesIndicesKind
  23588. * - VertexBuffer.MatricesIndicesExtraKind
  23589. * - VertexBuffer.MatricesWeightsKind
  23590. * - VertexBuffer.MatricesWeightsExtraKind
  23591. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23592. */
  23593. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23594. /**
  23595. * Tests if a specific vertex buffer is associated with this mesh
  23596. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23597. * - VertexBuffer.PositionKind
  23598. * - VertexBuffer.NormalKind
  23599. * - VertexBuffer.UVKind
  23600. * - VertexBuffer.UV2Kind
  23601. * - VertexBuffer.UV3Kind
  23602. * - VertexBuffer.UV4Kind
  23603. * - VertexBuffer.UV5Kind
  23604. * - VertexBuffer.UV6Kind
  23605. * - VertexBuffer.ColorKind
  23606. * - VertexBuffer.MatricesIndicesKind
  23607. * - VertexBuffer.MatricesIndicesExtraKind
  23608. * - VertexBuffer.MatricesWeightsKind
  23609. * - VertexBuffer.MatricesWeightsExtraKind
  23610. * @returns a boolean
  23611. */
  23612. isVerticesDataPresent(kind: string): boolean;
  23613. /**
  23614. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23615. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23616. * - VertexBuffer.PositionKind
  23617. * - VertexBuffer.UVKind
  23618. * - VertexBuffer.UV2Kind
  23619. * - VertexBuffer.UV3Kind
  23620. * - VertexBuffer.UV4Kind
  23621. * - VertexBuffer.UV5Kind
  23622. * - VertexBuffer.UV6Kind
  23623. * - VertexBuffer.ColorKind
  23624. * - VertexBuffer.MatricesIndicesKind
  23625. * - VertexBuffer.MatricesIndicesExtraKind
  23626. * - VertexBuffer.MatricesWeightsKind
  23627. * - VertexBuffer.MatricesWeightsExtraKind
  23628. * @returns a boolean
  23629. */
  23630. isVertexBufferUpdatable(kind: string): boolean;
  23631. /**
  23632. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23633. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23634. * - VertexBuffer.PositionKind
  23635. * - VertexBuffer.NormalKind
  23636. * - VertexBuffer.UVKind
  23637. * - VertexBuffer.UV2Kind
  23638. * - VertexBuffer.UV3Kind
  23639. * - VertexBuffer.UV4Kind
  23640. * - VertexBuffer.UV5Kind
  23641. * - VertexBuffer.UV6Kind
  23642. * - VertexBuffer.ColorKind
  23643. * - VertexBuffer.MatricesIndicesKind
  23644. * - VertexBuffer.MatricesIndicesExtraKind
  23645. * - VertexBuffer.MatricesWeightsKind
  23646. * - VertexBuffer.MatricesWeightsExtraKind
  23647. * @returns an array of strings
  23648. */
  23649. getVerticesDataKinds(): string[];
  23650. /**
  23651. * Returns a positive integer : the total number of indices in this mesh geometry.
  23652. * @returns the numner of indices or zero if the mesh has no geometry.
  23653. */
  23654. getTotalIndices(): number;
  23655. /**
  23656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23657. * @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.
  23658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23659. * @returns the indices array or an empty array if the mesh has no geometry
  23660. */
  23661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23662. readonly isBlocked: boolean;
  23663. /**
  23664. * Determine if the current mesh is ready to be rendered
  23665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23667. * @returns true if all associated assets are ready (material, textures, shaders)
  23668. */
  23669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23670. /**
  23671. * 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.
  23672. */
  23673. readonly areNormalsFrozen: boolean;
  23674. /**
  23675. * 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.
  23676. * @returns the current mesh
  23677. */
  23678. freezeNormals(): Mesh;
  23679. /**
  23680. * 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
  23681. * @returns the current mesh
  23682. */
  23683. unfreezeNormals(): Mesh;
  23684. /**
  23685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23686. */
  23687. overridenInstanceCount: number;
  23688. /** @hidden */
  23689. _preActivate(): Mesh;
  23690. /** @hidden */
  23691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23692. /** @hidden */
  23693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23694. /**
  23695. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23696. * This means the mesh underlying bounding box and sphere are recomputed.
  23697. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23698. * @returns the current mesh
  23699. */
  23700. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23701. /** @hidden */
  23702. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23703. /**
  23704. * This function will subdivide the mesh into multiple submeshes
  23705. * @param count defines the expected number of submeshes
  23706. */
  23707. subdivide(count: number): void;
  23708. /**
  23709. * Copy a FloatArray into a specific associated vertex buffer
  23710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23711. * - VertexBuffer.PositionKind
  23712. * - VertexBuffer.UVKind
  23713. * - VertexBuffer.UV2Kind
  23714. * - VertexBuffer.UV3Kind
  23715. * - VertexBuffer.UV4Kind
  23716. * - VertexBuffer.UV5Kind
  23717. * - VertexBuffer.UV6Kind
  23718. * - VertexBuffer.ColorKind
  23719. * - VertexBuffer.MatricesIndicesKind
  23720. * - VertexBuffer.MatricesIndicesExtraKind
  23721. * - VertexBuffer.MatricesWeightsKind
  23722. * - VertexBuffer.MatricesWeightsExtraKind
  23723. * @param data defines the data source
  23724. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23725. * @param stride defines the data stride size (can be null)
  23726. * @returns the current mesh
  23727. */
  23728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23729. /**
  23730. * Flags an associated vertex buffer as updatable
  23731. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23732. * - VertexBuffer.PositionKind
  23733. * - VertexBuffer.UVKind
  23734. * - VertexBuffer.UV2Kind
  23735. * - VertexBuffer.UV3Kind
  23736. * - VertexBuffer.UV4Kind
  23737. * - VertexBuffer.UV5Kind
  23738. * - VertexBuffer.UV6Kind
  23739. * - VertexBuffer.ColorKind
  23740. * - VertexBuffer.MatricesIndicesKind
  23741. * - VertexBuffer.MatricesIndicesExtraKind
  23742. * - VertexBuffer.MatricesWeightsKind
  23743. * - VertexBuffer.MatricesWeightsExtraKind
  23744. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23745. */
  23746. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23747. /**
  23748. * Sets the mesh global Vertex Buffer
  23749. * @param buffer defines the buffer to use
  23750. * @returns the current mesh
  23751. */
  23752. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23753. /**
  23754. * Update a specific associated vertex buffer
  23755. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23756. * - VertexBuffer.PositionKind
  23757. * - VertexBuffer.UVKind
  23758. * - VertexBuffer.UV2Kind
  23759. * - VertexBuffer.UV3Kind
  23760. * - VertexBuffer.UV4Kind
  23761. * - VertexBuffer.UV5Kind
  23762. * - VertexBuffer.UV6Kind
  23763. * - VertexBuffer.ColorKind
  23764. * - VertexBuffer.MatricesIndicesKind
  23765. * - VertexBuffer.MatricesIndicesExtraKind
  23766. * - VertexBuffer.MatricesWeightsKind
  23767. * - VertexBuffer.MatricesWeightsExtraKind
  23768. * @param data defines the data source
  23769. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23770. * @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)
  23771. * @returns the current mesh
  23772. */
  23773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23774. /**
  23775. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23776. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23777. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23778. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23779. * @returns the current mesh
  23780. */
  23781. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23782. /**
  23783. * Creates a un-shared specific occurence of the geometry for the mesh.
  23784. * @returns the current mesh
  23785. */
  23786. makeGeometryUnique(): Mesh;
  23787. /**
  23788. * Set the index buffer of this mesh
  23789. * @param indices defines the source data
  23790. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23791. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23792. * @returns the current mesh
  23793. */
  23794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23795. /**
  23796. * Update the current index buffer
  23797. * @param indices defines the source data
  23798. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23799. * @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)
  23800. * @returns the current mesh
  23801. */
  23802. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23803. /**
  23804. * Invert the geometry to move from a right handed system to a left handed one.
  23805. * @returns the current mesh
  23806. */
  23807. toLeftHanded(): Mesh;
  23808. /** @hidden */
  23809. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23810. /** @hidden */
  23811. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23812. /**
  23813. * Registers for this mesh a javascript function called just before the rendering process
  23814. * @param func defines the function to call before rendering this mesh
  23815. * @returns the current mesh
  23816. */
  23817. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23818. /**
  23819. * Disposes a previously registered javascript function called before the rendering
  23820. * @param func defines the function to remove
  23821. * @returns the current mesh
  23822. */
  23823. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23824. /**
  23825. * Registers for this mesh a javascript function called just after the rendering is complete
  23826. * @param func defines the function to call after rendering this mesh
  23827. * @returns the current mesh
  23828. */
  23829. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23830. /**
  23831. * Disposes a previously registered javascript function called after the rendering.
  23832. * @param func defines the function to remove
  23833. * @returns the current mesh
  23834. */
  23835. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23836. /** @hidden */
  23837. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23838. /** @hidden */
  23839. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23840. /** @hidden */
  23841. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23842. /** @hidden */
  23843. _rebuild(): void;
  23844. /** @hidden */
  23845. _freeze(): void;
  23846. /** @hidden */
  23847. _unFreeze(): void;
  23848. /**
  23849. * 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
  23850. * @param subMesh defines the subMesh to render
  23851. * @param enableAlphaMode defines if alpha mode can be changed
  23852. * @returns the current mesh
  23853. */
  23854. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23855. private _onBeforeDraw;
  23856. /**
  23857. * Renormalize the mesh and patch it up if there are no weights
  23858. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23859. * However in the case of zero weights then we set just a single influence to 1.
  23860. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23861. */
  23862. cleanMatrixWeights(): void;
  23863. private normalizeSkinFourWeights;
  23864. private normalizeSkinWeightsAndExtra;
  23865. /**
  23866. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23867. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23868. * the user know there was an issue with importing the mesh
  23869. * @returns a validation object with skinned, valid and report string
  23870. */
  23871. validateSkinning(): {
  23872. skinned: boolean;
  23873. valid: boolean;
  23874. report: string;
  23875. };
  23876. /** @hidden */
  23877. _checkDelayState(): Mesh;
  23878. private _queueLoad;
  23879. /**
  23880. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23881. * A mesh is in the frustum if its bounding box intersects the frustum
  23882. * @param frustumPlanes defines the frustum to test
  23883. * @returns true if the mesh is in the frustum planes
  23884. */
  23885. isInFrustum(frustumPlanes: Plane[]): boolean;
  23886. /**
  23887. * Sets the mesh material by the material or multiMaterial `id` property
  23888. * @param id is a string identifying the material or the multiMaterial
  23889. * @returns the current mesh
  23890. */
  23891. setMaterialByID(id: string): Mesh;
  23892. /**
  23893. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23894. * @returns an array of IAnimatable
  23895. */
  23896. getAnimatables(): IAnimatable[];
  23897. /**
  23898. * Modifies the mesh geometry according to the passed transformation matrix.
  23899. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23900. * The mesh normals are modified using the same transformation.
  23901. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23902. * @param transform defines the transform matrix to use
  23903. * @see http://doc.babylonjs.com/resources/baking_transformations
  23904. * @returns the current mesh
  23905. */
  23906. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23907. /**
  23908. * Modifies the mesh geometry according to its own current World Matrix.
  23909. * The mesh World Matrix is then reset.
  23910. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23911. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23912. * @see http://doc.babylonjs.com/resources/baking_transformations
  23913. * @returns the current mesh
  23914. */
  23915. bakeCurrentTransformIntoVertices(): Mesh;
  23916. /** @hidden */
  23917. readonly _positions: Nullable<Vector3[]>;
  23918. /** @hidden */
  23919. _resetPointsArrayCache(): Mesh;
  23920. /** @hidden */
  23921. _generatePointsArray(): boolean;
  23922. /**
  23923. * Returns a new Mesh object generated from the current mesh properties.
  23924. * This method must not get confused with createInstance()
  23925. * @param name is a string, the name given to the new mesh
  23926. * @param newParent can be any Node object (default `null`)
  23927. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23928. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23929. * @returns a new mesh
  23930. */
  23931. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23932. /**
  23933. * Releases resources associated with this mesh.
  23934. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23935. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23936. */
  23937. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23938. /**
  23939. * Modifies the mesh geometry according to a displacement map.
  23940. * 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.
  23941. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23942. * @param url is a string, the URL from the image file is to be downloaded.
  23943. * @param minHeight is the lower limit of the displacement.
  23944. * @param maxHeight is the upper limit of the displacement.
  23945. * @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.
  23946. * @param uvOffset is an optional vector2 used to offset UV.
  23947. * @param uvScale is an optional vector2 used to scale UV.
  23948. * @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.
  23949. * @returns the Mesh.
  23950. */
  23951. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23952. /**
  23953. * Modifies the mesh geometry according to a displacementMap buffer.
  23954. * 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.
  23955. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23956. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23957. * @param heightMapWidth is the width of the buffer image.
  23958. * @param heightMapHeight is the height of the buffer image.
  23959. * @param minHeight is the lower limit of the displacement.
  23960. * @param maxHeight is the upper limit of the displacement.
  23961. * @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.
  23962. * @param uvOffset is an optional vector2 used to offset UV.
  23963. * @param uvScale is an optional vector2 used to scale UV.
  23964. * @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.
  23965. * @returns the Mesh.
  23966. */
  23967. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23968. /**
  23969. * Modify the mesh to get a flat shading rendering.
  23970. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23971. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23972. * @returns current mesh
  23973. */
  23974. convertToFlatShadedMesh(): Mesh;
  23975. /**
  23976. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23977. * In other words, more vertices, no more indices and a single bigger VBO.
  23978. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23979. * @returns current mesh
  23980. */
  23981. convertToUnIndexedMesh(): Mesh;
  23982. /**
  23983. * Inverses facet orientations.
  23984. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23985. * @param flipNormals will also inverts the normals
  23986. * @returns current mesh
  23987. */
  23988. flipFaces(flipNormals?: boolean): Mesh;
  23989. /**
  23990. * Increase the number of facets and hence vertices in a mesh
  23991. * Vertex normals are interpolated from existing vertex normals
  23992. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23993. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23994. */
  23995. increaseVertices(numberPerEdge: number): void;
  23996. /**
  23997. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23998. * This will undo any application of covertToFlatShadedMesh
  23999. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24000. */
  24001. forceSharedVertices(): void;
  24002. /** @hidden */
  24003. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24004. /** @hidden */
  24005. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24006. /**
  24007. * Creates a new InstancedMesh object from the mesh model.
  24008. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24009. * @param name defines the name of the new instance
  24010. * @returns a new InstancedMesh
  24011. */
  24012. createInstance(name: string): InstancedMesh;
  24013. /**
  24014. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24015. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24016. * @returns the current mesh
  24017. */
  24018. synchronizeInstances(): Mesh;
  24019. /**
  24020. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24021. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24022. * This should be used together with the simplification to avoid disappearing triangles.
  24023. * @param successCallback an optional success callback to be called after the optimization finished.
  24024. * @returns the current mesh
  24025. */
  24026. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24027. /**
  24028. * Serialize current mesh
  24029. * @param serializationObject defines the object which will receive the serialization data
  24030. */
  24031. serialize(serializationObject: any): void;
  24032. /** @hidden */
  24033. _syncGeometryWithMorphTargetManager(): void;
  24034. /** @hidden */
  24035. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24036. /**
  24037. * Returns a new Mesh object parsed from the source provided.
  24038. * @param parsedMesh is the source
  24039. * @param scene defines the hosting scene
  24040. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24041. * @returns a new Mesh
  24042. */
  24043. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24044. /**
  24045. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24046. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24047. * @param name defines the name of the mesh to create
  24048. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24049. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24050. * @param closePath creates a seam between the first and the last points of each path of the path array
  24051. * @param offset is taken in account only if the `pathArray` is containing a single path
  24052. * @param scene defines the hosting scene
  24053. * @param updatable defines if the mesh must be flagged as updatable
  24054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24055. * @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)
  24056. * @returns a new Mesh
  24057. */
  24058. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24059. /**
  24060. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24061. * @param name defines the name of the mesh to create
  24062. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24063. * @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
  24064. * @param scene defines the hosting scene
  24065. * @param updatable defines if the mesh must be flagged as updatable
  24066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24067. * @returns a new Mesh
  24068. */
  24069. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24070. /**
  24071. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24072. * @param name defines the name of the mesh to create
  24073. * @param size sets the size (float) of each box side (default 1)
  24074. * @param scene defines the hosting scene
  24075. * @param updatable defines if the mesh must be flagged as updatable
  24076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24077. * @returns a new Mesh
  24078. */
  24079. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24080. /**
  24081. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24082. * @param name defines the name of the mesh to create
  24083. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24084. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24085. * @param scene defines the hosting scene
  24086. * @param updatable defines if the mesh must be flagged as updatable
  24087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24088. * @returns a new Mesh
  24089. */
  24090. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24091. /**
  24092. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24093. * @param name defines the name of the mesh to create
  24094. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24095. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24096. * @param scene defines the hosting scene
  24097. * @returns a new Mesh
  24098. */
  24099. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24100. /**
  24101. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24102. * @param name defines the name of the mesh to create
  24103. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24104. * @param diameterTop set the top cap diameter (floats, default 1)
  24105. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24106. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24107. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24108. * @param scene defines the hosting scene
  24109. * @param updatable defines if the mesh must be flagged as updatable
  24110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24111. * @returns a new Mesh
  24112. */
  24113. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24114. /**
  24115. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24116. * @param name defines the name of the mesh to create
  24117. * @param diameter sets the diameter size (float) of the torus (default 1)
  24118. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24119. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24120. * @param scene defines the hosting scene
  24121. * @param updatable defines if the mesh must be flagged as updatable
  24122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24123. * @returns a new Mesh
  24124. */
  24125. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24126. /**
  24127. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24128. * @param name defines the name of the mesh to create
  24129. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24130. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24131. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24132. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24133. * @param p the number of windings on X axis (positive integers, default 2)
  24134. * @param q the number of windings on Y axis (positive integers, default 3)
  24135. * @param scene defines the hosting scene
  24136. * @param updatable defines if the mesh must be flagged as updatable
  24137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24138. * @returns a new Mesh
  24139. */
  24140. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24141. /**
  24142. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24143. * @param name defines the name of the mesh to create
  24144. * @param points is an array successive Vector3
  24145. * @param scene defines the hosting scene
  24146. * @param updatable defines if the mesh must be flagged as updatable
  24147. * @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).
  24148. * @returns a new Mesh
  24149. */
  24150. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24151. /**
  24152. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24153. * @param name defines the name of the mesh to create
  24154. * @param points is an array successive Vector3
  24155. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24156. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24157. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24158. * @param scene defines the hosting scene
  24159. * @param updatable defines if the mesh must be flagged as updatable
  24160. * @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)
  24161. * @returns a new Mesh
  24162. */
  24163. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24164. /**
  24165. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24166. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24167. * 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.
  24168. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24169. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24170. * Remember you can only change the shape positions, not their number when updating a polygon.
  24171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24172. * @param name defines the name of the mesh to create
  24173. * @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
  24174. * @param scene defines the hosting scene
  24175. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24176. * @param updatable defines if the mesh must be flagged as updatable
  24177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24178. * @param earcutInjection can be used to inject your own earcut reference
  24179. * @returns a new Mesh
  24180. */
  24181. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24182. /**
  24183. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24184. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24185. * @param name defines the name of the mesh to create
  24186. * @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
  24187. * @param depth defines the height of extrusion
  24188. * @param scene defines the hosting scene
  24189. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24190. * @param updatable defines if the mesh must be flagged as updatable
  24191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24192. * @param earcutInjection can be used to inject your own earcut reference
  24193. * @returns a new Mesh
  24194. */
  24195. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24196. /**
  24197. * Creates an extruded shape mesh.
  24198. * 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
  24199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24200. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24201. * @param name defines the name of the mesh to create
  24202. * @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
  24203. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24204. * @param scale is the value to scale the shape
  24205. * @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
  24206. * @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
  24207. * @param scene defines the hosting scene
  24208. * @param updatable defines if the mesh must be flagged as updatable
  24209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24210. * @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)
  24211. * @returns a new Mesh
  24212. */
  24213. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24214. /**
  24215. * Creates an custom extruded shape mesh.
  24216. * The custom extrusion is a parametric shape.
  24217. * It has no predefined shape. Its final shape will depend on the input parameters.
  24218. * Please consider using the same method from the MeshBuilder class instead
  24219. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24220. * @param name defines the name of the mesh to create
  24221. * @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
  24222. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24223. * @param scaleFunction is a custom Javascript function called on each path point
  24224. * @param rotationFunction is a custom Javascript function called on each path point
  24225. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24226. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24227. * @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
  24228. * @param scene defines the hosting scene
  24229. * @param updatable defines if the mesh must be flagged as updatable
  24230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24231. * @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)
  24232. * @returns a new Mesh
  24233. */
  24234. 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;
  24235. /**
  24236. * Creates lathe mesh.
  24237. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24238. * Please consider using the same method from the MeshBuilder class instead
  24239. * @param name defines the name of the mesh to create
  24240. * @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
  24241. * @param radius is the radius value of the lathe
  24242. * @param tessellation is the side number of the lathe.
  24243. * @param scene defines the hosting scene
  24244. * @param updatable defines if the mesh must be flagged as updatable
  24245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24246. * @returns a new Mesh
  24247. */
  24248. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24249. /**
  24250. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24251. * @param name defines the name of the mesh to create
  24252. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24253. * @param scene defines the hosting scene
  24254. * @param updatable defines if the mesh must be flagged as updatable
  24255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24256. * @returns a new Mesh
  24257. */
  24258. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24259. /**
  24260. * Creates a ground mesh.
  24261. * Please consider using the same method from the MeshBuilder class instead
  24262. * @param name defines the name of the mesh to create
  24263. * @param width set the width of the ground
  24264. * @param height set the height of the ground
  24265. * @param subdivisions sets the number of subdivisions per side
  24266. * @param scene defines the hosting scene
  24267. * @param updatable defines if the mesh must be flagged as updatable
  24268. * @returns a new Mesh
  24269. */
  24270. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24271. /**
  24272. * Creates a tiled ground mesh.
  24273. * Please consider using the same method from the MeshBuilder class instead
  24274. * @param name defines the name of the mesh to create
  24275. * @param xmin set the ground minimum X coordinate
  24276. * @param zmin set the ground minimum Y coordinate
  24277. * @param xmax set the ground maximum X coordinate
  24278. * @param zmax set the ground maximum Z coordinate
  24279. * @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
  24280. * @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
  24281. * @param scene defines the hosting scene
  24282. * @param updatable defines if the mesh must be flagged as updatable
  24283. * @returns a new Mesh
  24284. */
  24285. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24286. w: number;
  24287. h: number;
  24288. }, precision: {
  24289. w: number;
  24290. h: number;
  24291. }, scene: Scene, updatable?: boolean): Mesh;
  24292. /**
  24293. * Creates a ground mesh from a height map.
  24294. * Please consider using the same method from the MeshBuilder class instead
  24295. * @see http://doc.babylonjs.com/babylon101/height_map
  24296. * @param name defines the name of the mesh to create
  24297. * @param url sets the URL of the height map image resource
  24298. * @param width set the ground width size
  24299. * @param height set the ground height size
  24300. * @param subdivisions sets the number of subdivision per side
  24301. * @param minHeight is the minimum altitude on the ground
  24302. * @param maxHeight is the maximum altitude on the ground
  24303. * @param scene defines the hosting scene
  24304. * @param updatable defines if the mesh must be flagged as updatable
  24305. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24306. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24307. * @returns a new Mesh
  24308. */
  24309. 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;
  24310. /**
  24311. * Creates a tube mesh.
  24312. * The tube is a parametric shape.
  24313. * It has no predefined shape. Its final shape will depend on the input parameters.
  24314. * Please consider using the same method from the MeshBuilder class instead
  24315. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24316. * @param name defines the name of the mesh to create
  24317. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24318. * @param radius sets the tube radius size
  24319. * @param tessellation is the number of sides on the tubular surface
  24320. * @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
  24321. * @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
  24322. * @param scene defines the hosting scene
  24323. * @param updatable defines if the mesh must be flagged as updatable
  24324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24325. * @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)
  24326. * @returns a new Mesh
  24327. */
  24328. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24329. (i: number, distance: number): number;
  24330. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24331. /**
  24332. * Creates a polyhedron mesh.
  24333. * Please consider using the same method from the MeshBuilder class instead.
  24334. * * 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
  24335. * * The parameter `size` (positive float, default 1) sets the polygon size
  24336. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24337. * * 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`
  24338. * * 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
  24339. * * 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)`)
  24340. * * 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
  24341. * * 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
  24342. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24343. * * 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
  24344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24345. * @param name defines the name of the mesh to create
  24346. * @param options defines the options used to create the mesh
  24347. * @param scene defines the hosting scene
  24348. * @returns a new Mesh
  24349. */
  24350. static CreatePolyhedron(name: string, options: {
  24351. type?: number;
  24352. size?: number;
  24353. sizeX?: number;
  24354. sizeY?: number;
  24355. sizeZ?: number;
  24356. custom?: any;
  24357. faceUV?: Vector4[];
  24358. faceColors?: Color4[];
  24359. updatable?: boolean;
  24360. sideOrientation?: number;
  24361. }, scene: Scene): Mesh;
  24362. /**
  24363. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24364. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24365. * * 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`)
  24366. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24367. * * 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
  24368. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * * 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
  24370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24371. * @param name defines the name of the mesh
  24372. * @param options defines the options used to create the mesh
  24373. * @param scene defines the hosting scene
  24374. * @returns a new Mesh
  24375. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24376. */
  24377. static CreateIcoSphere(name: string, options: {
  24378. radius?: number;
  24379. flat?: boolean;
  24380. subdivisions?: number;
  24381. sideOrientation?: number;
  24382. updatable?: boolean;
  24383. }, scene: Scene): Mesh;
  24384. /**
  24385. * Creates a decal mesh.
  24386. * Please consider using the same method from the MeshBuilder class instead.
  24387. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24388. * @param name defines the name of the mesh
  24389. * @param sourceMesh defines the mesh receiving the decal
  24390. * @param position sets the position of the decal in world coordinates
  24391. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24392. * @param size sets the decal scaling
  24393. * @param angle sets the angle to rotate the decal
  24394. * @returns a new Mesh
  24395. */
  24396. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24397. /**
  24398. * Prepare internal position array for software CPU skinning
  24399. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24400. */
  24401. setPositionsForCPUSkinning(): Float32Array;
  24402. /**
  24403. * Prepare internal normal array for software CPU skinning
  24404. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24405. */
  24406. setNormalsForCPUSkinning(): Float32Array;
  24407. /**
  24408. * Updates the vertex buffer by applying transformation from the bones
  24409. * @param skeleton defines the skeleton to apply to current mesh
  24410. * @returns the current mesh
  24411. */
  24412. applySkeleton(skeleton: Skeleton): Mesh;
  24413. /**
  24414. * 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
  24415. * @param meshes defines the list of meshes to scan
  24416. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24417. */
  24418. static MinMax(meshes: AbstractMesh[]): {
  24419. min: Vector3;
  24420. max: Vector3;
  24421. };
  24422. /**
  24423. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24424. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24425. * @returns a vector3
  24426. */
  24427. static Center(meshesOrMinMaxVector: {
  24428. min: Vector3;
  24429. max: Vector3;
  24430. } | AbstractMesh[]): Vector3;
  24431. /**
  24432. * Merge the array of meshes into a single mesh for performance reasons.
  24433. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24434. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24435. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24436. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24437. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24438. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24439. * @returns a new mesh
  24440. */
  24441. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24442. /** @hidden */
  24443. addInstance(instance: InstancedMesh): void;
  24444. /** @hidden */
  24445. removeInstance(instance: InstancedMesh): void;
  24446. }
  24447. }
  24448. declare module BABYLON {
  24449. /**
  24450. * This is the base class of all the camera used in the application.
  24451. * @see http://doc.babylonjs.com/features/cameras
  24452. */
  24453. export class Camera extends Node {
  24454. /** @hidden */
  24455. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24456. /**
  24457. * This is the default projection mode used by the cameras.
  24458. * It helps recreating a feeling of perspective and better appreciate depth.
  24459. * This is the best way to simulate real life cameras.
  24460. */
  24461. static readonly PERSPECTIVE_CAMERA: number;
  24462. /**
  24463. * This helps creating camera with an orthographic mode.
  24464. * 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.
  24465. */
  24466. static readonly ORTHOGRAPHIC_CAMERA: number;
  24467. /**
  24468. * This is the default FOV mode for perspective cameras.
  24469. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24470. */
  24471. static readonly FOVMODE_VERTICAL_FIXED: number;
  24472. /**
  24473. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24474. */
  24475. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24476. /**
  24477. * This specifies ther is no need for a camera rig.
  24478. * Basically only one eye is rendered corresponding to the camera.
  24479. */
  24480. static readonly RIG_MODE_NONE: number;
  24481. /**
  24482. * Simulates a camera Rig with one blue eye and one red eye.
  24483. * This can be use with 3d blue and red glasses.
  24484. */
  24485. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24486. /**
  24487. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24488. */
  24489. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24490. /**
  24491. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24492. */
  24493. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24494. /**
  24495. * Defines that both eyes of the camera will be rendered over under each other.
  24496. */
  24497. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24498. /**
  24499. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24500. */
  24501. static readonly RIG_MODE_VR: number;
  24502. /**
  24503. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24504. */
  24505. static readonly RIG_MODE_WEBVR: number;
  24506. /**
  24507. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24508. */
  24509. static readonly RIG_MODE_CUSTOM: number;
  24510. /**
  24511. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24512. */
  24513. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24514. /**
  24515. * Define the input manager associated with the camera.
  24516. */
  24517. inputs: CameraInputsManager<Camera>;
  24518. /** @hidden */
  24519. _position: Vector3;
  24520. /**
  24521. * Define the current local position of the camera in the scene
  24522. */
  24523. position: Vector3;
  24524. /**
  24525. * The vector the camera should consider as up.
  24526. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24527. */
  24528. upVector: Vector3;
  24529. /**
  24530. * Define the current limit on the left side for an orthographic camera
  24531. * In scene unit
  24532. */
  24533. orthoLeft: Nullable<number>;
  24534. /**
  24535. * Define the current limit on the right side for an orthographic camera
  24536. * In scene unit
  24537. */
  24538. orthoRight: Nullable<number>;
  24539. /**
  24540. * Define the current limit on the bottom side for an orthographic camera
  24541. * In scene unit
  24542. */
  24543. orthoBottom: Nullable<number>;
  24544. /**
  24545. * Define the current limit on the top side for an orthographic camera
  24546. * In scene unit
  24547. */
  24548. orthoTop: Nullable<number>;
  24549. /**
  24550. * Field Of View is set in Radians. (default is 0.8)
  24551. */
  24552. fov: number;
  24553. /**
  24554. * Define the minimum distance the camera can see from.
  24555. * This is important to note that the depth buffer are not infinite and the closer it starts
  24556. * the more your scene might encounter depth fighting issue.
  24557. */
  24558. minZ: number;
  24559. /**
  24560. * Define the maximum distance the camera can see to.
  24561. * This is important to note that the depth buffer are not infinite and the further it end
  24562. * the more your scene might encounter depth fighting issue.
  24563. */
  24564. maxZ: number;
  24565. /**
  24566. * Define the default inertia of the camera.
  24567. * This helps giving a smooth feeling to the camera movement.
  24568. */
  24569. inertia: number;
  24570. /**
  24571. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24572. */
  24573. mode: number;
  24574. /**
  24575. * Define wether the camera is intermediate.
  24576. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24577. */
  24578. isIntermediate: boolean;
  24579. /**
  24580. * Define the viewport of the camera.
  24581. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24582. */
  24583. viewport: Viewport;
  24584. /**
  24585. * Restricts the camera to viewing objects with the same layerMask.
  24586. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24587. */
  24588. layerMask: number;
  24589. /**
  24590. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24591. */
  24592. fovMode: number;
  24593. /**
  24594. * Rig mode of the camera.
  24595. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24596. * This is normally controlled byt the camera themselves as internal use.
  24597. */
  24598. cameraRigMode: number;
  24599. /**
  24600. * Defines the distance between both "eyes" in case of a RIG
  24601. */
  24602. interaxialDistance: number;
  24603. /**
  24604. * Defines if stereoscopic rendering is done side by side or over under.
  24605. */
  24606. isStereoscopicSideBySide: boolean;
  24607. /**
  24608. * 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
  24609. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24610. * else in the scene. (Eg. security camera)
  24611. *
  24612. * 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)
  24613. */
  24614. customRenderTargets: RenderTargetTexture[];
  24615. /**
  24616. * When set, the camera will render to this render target instead of the default canvas
  24617. *
  24618. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24619. */
  24620. outputRenderTarget: Nullable<RenderTargetTexture>;
  24621. /**
  24622. * Observable triggered when the camera view matrix has changed.
  24623. */
  24624. onViewMatrixChangedObservable: Observable<Camera>;
  24625. /**
  24626. * Observable triggered when the camera Projection matrix has changed.
  24627. */
  24628. onProjectionMatrixChangedObservable: Observable<Camera>;
  24629. /**
  24630. * Observable triggered when the inputs have been processed.
  24631. */
  24632. onAfterCheckInputsObservable: Observable<Camera>;
  24633. /**
  24634. * Observable triggered when reset has been called and applied to the camera.
  24635. */
  24636. onRestoreStateObservable: Observable<Camera>;
  24637. /** @hidden */
  24638. _cameraRigParams: any;
  24639. /** @hidden */
  24640. _rigCameras: Camera[];
  24641. /** @hidden */
  24642. _rigPostProcess: Nullable<PostProcess>;
  24643. protected _webvrViewMatrix: Matrix;
  24644. /** @hidden */
  24645. _skipRendering: boolean;
  24646. /** @hidden */
  24647. _projectionMatrix: Matrix;
  24648. /** @hidden */
  24649. _postProcesses: Nullable<PostProcess>[];
  24650. /** @hidden */
  24651. _activeMeshes: SmartArray<AbstractMesh>;
  24652. protected _globalPosition: Vector3;
  24653. /** @hidden */
  24654. _computedViewMatrix: Matrix;
  24655. private _doNotComputeProjectionMatrix;
  24656. private _transformMatrix;
  24657. private _frustumPlanes;
  24658. private _refreshFrustumPlanes;
  24659. private _storedFov;
  24660. private _stateStored;
  24661. /**
  24662. * Instantiates a new camera object.
  24663. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24664. * @see http://doc.babylonjs.com/features/cameras
  24665. * @param name Defines the name of the camera in the scene
  24666. * @param position Defines the position of the camera
  24667. * @param scene Defines the scene the camera belongs too
  24668. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24669. */
  24670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24671. /**
  24672. * Store current camera state (fov, position, etc..)
  24673. * @returns the camera
  24674. */
  24675. storeState(): Camera;
  24676. /**
  24677. * Restores the camera state values if it has been stored. You must call storeState() first
  24678. */
  24679. protected _restoreStateValues(): boolean;
  24680. /**
  24681. * Restored camera state. You must call storeState() first.
  24682. * @returns true if restored and false otherwise
  24683. */
  24684. restoreState(): boolean;
  24685. /**
  24686. * Gets the class name of the camera.
  24687. * @returns the class name
  24688. */
  24689. getClassName(): string;
  24690. /** @hidden */
  24691. readonly _isCamera: boolean;
  24692. /**
  24693. * Gets a string representation of the camera useful for debug purpose.
  24694. * @param fullDetails Defines that a more verboe level of logging is required
  24695. * @returns the string representation
  24696. */
  24697. toString(fullDetails?: boolean): string;
  24698. /**
  24699. * Gets the current world space position of the camera.
  24700. */
  24701. readonly globalPosition: Vector3;
  24702. /**
  24703. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24704. * @returns the active meshe list
  24705. */
  24706. getActiveMeshes(): SmartArray<AbstractMesh>;
  24707. /**
  24708. * Check wether a mesh is part of the current active mesh list of the camera
  24709. * @param mesh Defines the mesh to check
  24710. * @returns true if active, false otherwise
  24711. */
  24712. isActiveMesh(mesh: Mesh): boolean;
  24713. /**
  24714. * Is this camera ready to be used/rendered
  24715. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24716. * @return true if the camera is ready
  24717. */
  24718. isReady(completeCheck?: boolean): boolean;
  24719. /** @hidden */
  24720. _initCache(): void;
  24721. /** @hidden */
  24722. _updateCache(ignoreParentClass?: boolean): void;
  24723. /** @hidden */
  24724. _isSynchronized(): boolean;
  24725. /** @hidden */
  24726. _isSynchronizedViewMatrix(): boolean;
  24727. /** @hidden */
  24728. _isSynchronizedProjectionMatrix(): boolean;
  24729. /**
  24730. * Attach the input controls to a specific dom element to get the input from.
  24731. * @param element Defines the element the controls should be listened from
  24732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24733. */
  24734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24735. /**
  24736. * Detach the current controls from the specified dom element.
  24737. * @param element Defines the element to stop listening the inputs from
  24738. */
  24739. detachControl(element: HTMLElement): void;
  24740. /**
  24741. * Update the camera state according to the different inputs gathered during the frame.
  24742. */
  24743. update(): void;
  24744. /** @hidden */
  24745. _checkInputs(): void;
  24746. /** @hidden */
  24747. readonly rigCameras: Camera[];
  24748. /**
  24749. * Gets the post process used by the rig cameras
  24750. */
  24751. readonly rigPostProcess: Nullable<PostProcess>;
  24752. /**
  24753. * Internal, gets the first post proces.
  24754. * @returns the first post process to be run on this camera.
  24755. */
  24756. _getFirstPostProcess(): Nullable<PostProcess>;
  24757. private _cascadePostProcessesToRigCams;
  24758. /**
  24759. * Attach a post process to the camera.
  24760. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24761. * @param postProcess The post process to attach to the camera
  24762. * @param insertAt The position of the post process in case several of them are in use in the scene
  24763. * @returns the position the post process has been inserted at
  24764. */
  24765. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24766. /**
  24767. * Detach a post process to the camera.
  24768. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24769. * @param postProcess The post process to detach from the camera
  24770. */
  24771. detachPostProcess(postProcess: PostProcess): void;
  24772. /**
  24773. * Gets the current world matrix of the camera
  24774. */
  24775. getWorldMatrix(): Matrix;
  24776. /** @hidden */
  24777. _getViewMatrix(): Matrix;
  24778. /**
  24779. * Gets the current view matrix of the camera.
  24780. * @param force forces the camera to recompute the matrix without looking at the cached state
  24781. * @returns the view matrix
  24782. */
  24783. getViewMatrix(force?: boolean): Matrix;
  24784. /**
  24785. * Freeze the projection matrix.
  24786. * It will prevent the cache check of the camera projection compute and can speed up perf
  24787. * if no parameter of the camera are meant to change
  24788. * @param projection Defines manually a projection if necessary
  24789. */
  24790. freezeProjectionMatrix(projection?: Matrix): void;
  24791. /**
  24792. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24793. */
  24794. unfreezeProjectionMatrix(): void;
  24795. /**
  24796. * Gets the current projection matrix of the camera.
  24797. * @param force forces the camera to recompute the matrix without looking at the cached state
  24798. * @returns the projection matrix
  24799. */
  24800. getProjectionMatrix(force?: boolean): Matrix;
  24801. /**
  24802. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24803. * @returns a Matrix
  24804. */
  24805. getTransformationMatrix(): Matrix;
  24806. private _updateFrustumPlanes;
  24807. /**
  24808. * Checks if a cullable object (mesh...) is in the camera frustum
  24809. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24810. * @param target The object to check
  24811. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24812. * @returns true if the object is in frustum otherwise false
  24813. */
  24814. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24815. /**
  24816. * Checks if a cullable object (mesh...) is in the camera frustum
  24817. * Unlike isInFrustum this cheks the full bounding box
  24818. * @param target The object to check
  24819. * @returns true if the object is in frustum otherwise false
  24820. */
  24821. isCompletelyInFrustum(target: ICullable): boolean;
  24822. /**
  24823. * Gets a ray in the forward direction from the camera.
  24824. * @param length Defines the length of the ray to create
  24825. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24826. * @param origin Defines the start point of the ray which defaults to the camera position
  24827. * @returns the forward ray
  24828. */
  24829. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24830. /**
  24831. * Releases resources associated with this node.
  24832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24834. */
  24835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24836. /** @hidden */
  24837. _isLeftCamera: boolean;
  24838. /**
  24839. * Gets the left camera of a rig setup in case of Rigged Camera
  24840. */
  24841. readonly isLeftCamera: boolean;
  24842. /** @hidden */
  24843. _isRightCamera: boolean;
  24844. /**
  24845. * Gets the right camera of a rig setup in case of Rigged Camera
  24846. */
  24847. readonly isRightCamera: boolean;
  24848. /**
  24849. * Gets the left camera of a rig setup in case of Rigged Camera
  24850. */
  24851. readonly leftCamera: Nullable<FreeCamera>;
  24852. /**
  24853. * Gets the right camera of a rig setup in case of Rigged Camera
  24854. */
  24855. readonly rightCamera: Nullable<FreeCamera>;
  24856. /**
  24857. * Gets the left camera target of a rig setup in case of Rigged Camera
  24858. * @returns the target position
  24859. */
  24860. getLeftTarget(): Nullable<Vector3>;
  24861. /**
  24862. * Gets the right camera target of a rig setup in case of Rigged Camera
  24863. * @returns the target position
  24864. */
  24865. getRightTarget(): Nullable<Vector3>;
  24866. /**
  24867. * @hidden
  24868. */
  24869. setCameraRigMode(mode: number, rigParams: any): void;
  24870. /** @hidden */
  24871. static _setStereoscopicRigMode(camera: Camera): void;
  24872. /** @hidden */
  24873. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24874. /** @hidden */
  24875. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24876. /** @hidden */
  24877. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24878. /** @hidden */
  24879. _getVRProjectionMatrix(): Matrix;
  24880. protected _updateCameraRotationMatrix(): void;
  24881. protected _updateWebVRCameraRotationMatrix(): void;
  24882. /**
  24883. * This function MUST be overwritten by the different WebVR cameras available.
  24884. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24885. * @hidden
  24886. */
  24887. _getWebVRProjectionMatrix(): Matrix;
  24888. /**
  24889. * This function MUST be overwritten by the different WebVR cameras available.
  24890. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24891. * @hidden
  24892. */
  24893. _getWebVRViewMatrix(): Matrix;
  24894. /** @hidden */
  24895. setCameraRigParameter(name: string, value: any): void;
  24896. /**
  24897. * needs to be overridden by children so sub has required properties to be copied
  24898. * @hidden
  24899. */
  24900. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24901. /**
  24902. * May need to be overridden by children
  24903. * @hidden
  24904. */
  24905. _updateRigCameras(): void;
  24906. /** @hidden */
  24907. _setupInputs(): void;
  24908. /**
  24909. * Serialiaze the camera setup to a json represention
  24910. * @returns the JSON representation
  24911. */
  24912. serialize(): any;
  24913. /**
  24914. * Clones the current camera.
  24915. * @param name The cloned camera name
  24916. * @returns the cloned camera
  24917. */
  24918. clone(name: string): Camera;
  24919. /**
  24920. * Gets the direction of the camera relative to a given local axis.
  24921. * @param localAxis Defines the reference axis to provide a relative direction.
  24922. * @return the direction
  24923. */
  24924. getDirection(localAxis: Vector3): Vector3;
  24925. /**
  24926. * Returns the current camera absolute rotation
  24927. */
  24928. readonly absoluteRotation: Quaternion;
  24929. /**
  24930. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24931. * @param localAxis Defines the reference axis to provide a relative direction.
  24932. * @param result Defines the vector to store the result in
  24933. */
  24934. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24935. /**
  24936. * Gets a camera constructor for a given camera type
  24937. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24938. * @param name The name of the camera the result will be able to instantiate
  24939. * @param scene The scene the result will construct the camera in
  24940. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24941. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24942. * @returns a factory method to construc the camera
  24943. */
  24944. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24945. /**
  24946. * Compute the world matrix of the camera.
  24947. * @returns the camera workd matrix
  24948. */
  24949. computeWorldMatrix(): Matrix;
  24950. /**
  24951. * Parse a JSON and creates the camera from the parsed information
  24952. * @param parsedCamera The JSON to parse
  24953. * @param scene The scene to instantiate the camera in
  24954. * @returns the newly constructed camera
  24955. */
  24956. static Parse(parsedCamera: any, scene: Scene): Camera;
  24957. }
  24958. }
  24959. declare module BABYLON {
  24960. /**
  24961. * Class containing static functions to help procedurally build meshes
  24962. */
  24963. export class DiscBuilder {
  24964. /**
  24965. * Creates a plane polygonal mesh. By default, this is a disc
  24966. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24967. * * 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
  24968. * * 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
  24969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24970. * * 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
  24971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24972. * @param name defines the name of the mesh
  24973. * @param options defines the options used to create the mesh
  24974. * @param scene defines the hosting scene
  24975. * @returns the plane polygonal mesh
  24976. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24977. */
  24978. static CreateDisc(name: string, options: {
  24979. radius?: number;
  24980. tessellation?: number;
  24981. arc?: number;
  24982. updatable?: boolean;
  24983. sideOrientation?: number;
  24984. frontUVs?: Vector4;
  24985. backUVs?: Vector4;
  24986. }, scene?: Nullable<Scene>): Mesh;
  24987. }
  24988. }
  24989. declare module BABYLON {
  24990. /**
  24991. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24992. *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.
  24993. * The SPS is also a particle system. It provides some methods to manage the particles.
  24994. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24995. *
  24996. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24997. */
  24998. export class SolidParticleSystem implements IDisposable {
  24999. /**
  25000. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25001. * Example : var p = SPS.particles[i];
  25002. */
  25003. particles: SolidParticle[];
  25004. /**
  25005. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25006. */
  25007. nbParticles: number;
  25008. /**
  25009. * If the particles must ever face the camera (default false). Useful for planar particles.
  25010. */
  25011. billboard: boolean;
  25012. /**
  25013. * Recompute normals when adding a shape
  25014. */
  25015. recomputeNormals: boolean;
  25016. /**
  25017. * This a counter ofr your own usage. It's not set by any SPS functions.
  25018. */
  25019. counter: number;
  25020. /**
  25021. * The SPS name. This name is also given to the underlying mesh.
  25022. */
  25023. name: string;
  25024. /**
  25025. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25026. */
  25027. mesh: Mesh;
  25028. /**
  25029. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25030. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25031. */
  25032. vars: any;
  25033. /**
  25034. * This array is populated when the SPS is set as 'pickable'.
  25035. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25036. * Each element of this array is an object `{idx: int, faceId: int}`.
  25037. * `idx` is the picked particle index in the `SPS.particles` array
  25038. * `faceId` is the picked face index counted within this particle.
  25039. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25040. */
  25041. pickedParticles: {
  25042. idx: number;
  25043. faceId: number;
  25044. }[];
  25045. /**
  25046. * This array is populated when `enableDepthSort` is set to true.
  25047. * Each element of this array is an instance of the class DepthSortedParticle.
  25048. */
  25049. depthSortedParticles: DepthSortedParticle[];
  25050. /**
  25051. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25052. * @hidden
  25053. */
  25054. _bSphereOnly: boolean;
  25055. /**
  25056. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25057. * @hidden
  25058. */
  25059. _bSphereRadiusFactor: number;
  25060. private _scene;
  25061. private _positions;
  25062. private _indices;
  25063. private _normals;
  25064. private _colors;
  25065. private _uvs;
  25066. private _indices32;
  25067. private _positions32;
  25068. private _normals32;
  25069. private _fixedNormal32;
  25070. private _colors32;
  25071. private _uvs32;
  25072. private _index;
  25073. private _updatable;
  25074. private _pickable;
  25075. private _isVisibilityBoxLocked;
  25076. private _alwaysVisible;
  25077. private _depthSort;
  25078. private _shapeCounter;
  25079. private _copy;
  25080. private _color;
  25081. private _computeParticleColor;
  25082. private _computeParticleTexture;
  25083. private _computeParticleRotation;
  25084. private _computeParticleVertex;
  25085. private _computeBoundingBox;
  25086. private _depthSortParticles;
  25087. private _camera;
  25088. private _mustUnrotateFixedNormals;
  25089. private _particlesIntersect;
  25090. private _needs32Bits;
  25091. /**
  25092. * Creates a SPS (Solid Particle System) object.
  25093. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25094. * @param scene (Scene) is the scene in which the SPS is added.
  25095. * @param options defines the options of the sps e.g.
  25096. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25097. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25098. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25099. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25100. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25101. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25102. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25103. */
  25104. constructor(name: string, scene: Scene, options?: {
  25105. updatable?: boolean;
  25106. isPickable?: boolean;
  25107. enableDepthSort?: boolean;
  25108. particleIntersection?: boolean;
  25109. boundingSphereOnly?: boolean;
  25110. bSphereRadiusFactor?: number;
  25111. });
  25112. /**
  25113. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25114. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25115. * @returns the created mesh
  25116. */
  25117. buildMesh(): Mesh;
  25118. /**
  25119. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25120. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25121. * Thus the particles generated from `digest()` have their property `position` set yet.
  25122. * @param mesh ( Mesh ) is the mesh to be digested
  25123. * @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
  25124. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25125. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25126. * @returns the current SPS
  25127. */
  25128. digest(mesh: Mesh, options?: {
  25129. facetNb?: number;
  25130. number?: number;
  25131. delta?: number;
  25132. }): SolidParticleSystem;
  25133. private _unrotateFixedNormals;
  25134. private _resetCopy;
  25135. private _meshBuilder;
  25136. private _posToShape;
  25137. private _uvsToShapeUV;
  25138. private _addParticle;
  25139. /**
  25140. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25141. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25142. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25143. * @param nb (positive integer) the number of particles to be created from this model
  25144. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25145. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25146. * @returns the number of shapes in the system
  25147. */
  25148. addShape(mesh: Mesh, nb: number, options?: {
  25149. positionFunction?: any;
  25150. vertexFunction?: any;
  25151. }): number;
  25152. private _rebuildParticle;
  25153. /**
  25154. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25155. * @returns the SPS.
  25156. */
  25157. rebuildMesh(): SolidParticleSystem;
  25158. /**
  25159. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25160. * This method calls `updateParticle()` for each particle of the SPS.
  25161. * For an animated SPS, it is usually called within the render loop.
  25162. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25163. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25164. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25165. * @returns the SPS.
  25166. */
  25167. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25168. /**
  25169. * Disposes the SPS.
  25170. */
  25171. dispose(): void;
  25172. /**
  25173. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25175. * @returns the SPS.
  25176. */
  25177. refreshVisibleSize(): SolidParticleSystem;
  25178. /**
  25179. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25180. * @param size the size (float) of the visibility box
  25181. * note : this doesn't lock the SPS mesh bounding box.
  25182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25183. */
  25184. setVisibilityBox(size: number): void;
  25185. /**
  25186. * Gets whether the SPS as always visible or not
  25187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25188. */
  25189. /**
  25190. * Sets the SPS as always visible or not
  25191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25192. */
  25193. isAlwaysVisible: boolean;
  25194. /**
  25195. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25196. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25197. */
  25198. /**
  25199. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25201. */
  25202. isVisibilityBoxLocked: boolean;
  25203. /**
  25204. * Tells to `setParticles()` to compute the particle rotations or not.
  25205. * Default value : true. The SPS is faster when it's set to false.
  25206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25207. */
  25208. /**
  25209. * Gets if `setParticles()` computes the particle rotations or not.
  25210. * Default value : true. The SPS is faster when it's set to false.
  25211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25212. */
  25213. computeParticleRotation: boolean;
  25214. /**
  25215. * Tells to `setParticles()` to compute the particle colors or not.
  25216. * Default value : true. The SPS is faster when it's set to false.
  25217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25218. */
  25219. /**
  25220. * Gets if `setParticles()` computes the particle colors or not.
  25221. * Default value : true. The SPS is faster when it's set to false.
  25222. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25223. */
  25224. computeParticleColor: boolean;
  25225. /**
  25226. * Gets if `setParticles()` computes the particle textures or not.
  25227. * Default value : true. The SPS is faster when it's set to false.
  25228. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25229. */
  25230. computeParticleTexture: boolean;
  25231. /**
  25232. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25233. * Default value : false. The SPS is faster when it's set to false.
  25234. * Note : the particle custom vertex positions aren't stored values.
  25235. */
  25236. /**
  25237. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25238. * Default value : false. The SPS is faster when it's set to false.
  25239. * Note : the particle custom vertex positions aren't stored values.
  25240. */
  25241. computeParticleVertex: boolean;
  25242. /**
  25243. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25244. */
  25245. /**
  25246. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25247. */
  25248. computeBoundingBox: boolean;
  25249. /**
  25250. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25251. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25252. * Default : `true`
  25253. */
  25254. /**
  25255. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25256. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25257. * Default : `true`
  25258. */
  25259. depthSortParticles: boolean;
  25260. /**
  25261. * This function does nothing. It may be overwritten to set all the particle first values.
  25262. * The SPS doesn't call this function, you may have to call it by your own.
  25263. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25264. */
  25265. initParticles(): void;
  25266. /**
  25267. * This function does nothing. It may be overwritten to recycle a particle.
  25268. * The SPS doesn't call this function, you may have to call it by your own.
  25269. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25270. * @param particle The particle to recycle
  25271. * @returns the recycled particle
  25272. */
  25273. recycleParticle(particle: SolidParticle): SolidParticle;
  25274. /**
  25275. * Updates a particle : this function should be overwritten by the user.
  25276. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25277. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25278. * @example : just set a particle position or velocity and recycle conditions
  25279. * @param particle The particle to update
  25280. * @returns the updated particle
  25281. */
  25282. updateParticle(particle: SolidParticle): SolidParticle;
  25283. /**
  25284. * Updates a vertex of a particle : it can be overwritten by the user.
  25285. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25286. * @param particle the current particle
  25287. * @param vertex the current index of the current particle
  25288. * @param pt the index of the current vertex in the particle shape
  25289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25290. * @example : just set a vertex particle position
  25291. * @returns the updated vertex
  25292. */
  25293. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25294. /**
  25295. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25296. * This does nothing and may be overwritten by the user.
  25297. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25298. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25299. * @param update the boolean update value actually passed to setParticles()
  25300. */
  25301. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25302. /**
  25303. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25304. * This will be passed three parameters.
  25305. * This does nothing and may be overwritten by the user.
  25306. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25307. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25308. * @param update the boolean update value actually passed to setParticles()
  25309. */
  25310. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25311. }
  25312. }
  25313. declare module BABYLON {
  25314. /**
  25315. * Represents one particle of a solid particle system.
  25316. */
  25317. export class SolidParticle {
  25318. /**
  25319. * particle global index
  25320. */
  25321. idx: number;
  25322. /**
  25323. * The color of the particle
  25324. */
  25325. color: Nullable<Color4>;
  25326. /**
  25327. * The world space position of the particle.
  25328. */
  25329. position: Vector3;
  25330. /**
  25331. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25332. */
  25333. rotation: Vector3;
  25334. /**
  25335. * The world space rotation quaternion of the particle.
  25336. */
  25337. rotationQuaternion: Nullable<Quaternion>;
  25338. /**
  25339. * The scaling of the particle.
  25340. */
  25341. scaling: Vector3;
  25342. /**
  25343. * The uvs of the particle.
  25344. */
  25345. uvs: Vector4;
  25346. /**
  25347. * The current speed of the particle.
  25348. */
  25349. velocity: Vector3;
  25350. /**
  25351. * The pivot point in the particle local space.
  25352. */
  25353. pivot: Vector3;
  25354. /**
  25355. * Must the particle be translated from its pivot point in its local space ?
  25356. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25357. * Default : false
  25358. */
  25359. translateFromPivot: boolean;
  25360. /**
  25361. * Is the particle active or not ?
  25362. */
  25363. alive: boolean;
  25364. /**
  25365. * Is the particle visible or not ?
  25366. */
  25367. isVisible: boolean;
  25368. /**
  25369. * Index of this particle in the global "positions" array (Internal use)
  25370. * @hidden
  25371. */
  25372. _pos: number;
  25373. /**
  25374. * @hidden Index of this particle in the global "indices" array (Internal use)
  25375. */
  25376. _ind: number;
  25377. /**
  25378. * @hidden ModelShape of this particle (Internal use)
  25379. */
  25380. _model: ModelShape;
  25381. /**
  25382. * ModelShape id of this particle
  25383. */
  25384. shapeId: number;
  25385. /**
  25386. * Index of the particle in its shape id
  25387. */
  25388. idxInShape: number;
  25389. /**
  25390. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25391. */
  25392. _modelBoundingInfo: BoundingInfo;
  25393. /**
  25394. * @hidden Particle BoundingInfo object (Internal use)
  25395. */
  25396. _boundingInfo: BoundingInfo;
  25397. /**
  25398. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25399. */
  25400. _sps: SolidParticleSystem;
  25401. /**
  25402. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25403. */
  25404. _stillInvisible: boolean;
  25405. /**
  25406. * @hidden Last computed particle rotation matrix
  25407. */
  25408. _rotationMatrix: number[];
  25409. /**
  25410. * Parent particle Id, if any.
  25411. * Default null.
  25412. */
  25413. parentId: Nullable<number>;
  25414. /**
  25415. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25416. * The possible values are :
  25417. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25418. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25419. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25420. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25421. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25422. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25423. * */
  25424. cullingStrategy: number;
  25425. /**
  25426. * @hidden Internal global position in the SPS.
  25427. */
  25428. _globalPosition: Vector3;
  25429. /**
  25430. * Creates a Solid Particle object.
  25431. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25432. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25433. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25434. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25435. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25436. * @param shapeId (integer) is the model shape identifier in the SPS.
  25437. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25438. * @param sps defines the sps it is associated to
  25439. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25440. */
  25441. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25442. /**
  25443. * Legacy support, changed scale to scaling
  25444. */
  25445. /**
  25446. * Legacy support, changed scale to scaling
  25447. */
  25448. scale: Vector3;
  25449. /**
  25450. * Legacy support, changed quaternion to rotationQuaternion
  25451. */
  25452. /**
  25453. * Legacy support, changed quaternion to rotationQuaternion
  25454. */
  25455. quaternion: Nullable<Quaternion>;
  25456. /**
  25457. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25458. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25459. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25460. * @returns true if it intersects
  25461. */
  25462. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25463. /**
  25464. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25465. * A particle is in the frustum if its bounding box intersects the frustum
  25466. * @param frustumPlanes defines the frustum to test
  25467. * @returns true if the particle is in the frustum planes
  25468. */
  25469. isInFrustum(frustumPlanes: Plane[]): boolean;
  25470. /**
  25471. * get the rotation matrix of the particle
  25472. * @hidden
  25473. */
  25474. getRotationMatrix(m: Matrix): void;
  25475. }
  25476. /**
  25477. * Represents the shape of the model used by one particle of a solid particle system.
  25478. * SPS internal tool, don't use it manually.
  25479. */
  25480. export class ModelShape {
  25481. /**
  25482. * The shape id
  25483. * @hidden
  25484. */
  25485. shapeID: number;
  25486. /**
  25487. * flat array of model positions (internal use)
  25488. * @hidden
  25489. */
  25490. _shape: Vector3[];
  25491. /**
  25492. * flat array of model UVs (internal use)
  25493. * @hidden
  25494. */
  25495. _shapeUV: number[];
  25496. /**
  25497. * length of the shape in the model indices array (internal use)
  25498. * @hidden
  25499. */
  25500. _indicesLength: number;
  25501. /**
  25502. * Custom position function (internal use)
  25503. * @hidden
  25504. */
  25505. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25506. /**
  25507. * Custom vertex function (internal use)
  25508. * @hidden
  25509. */
  25510. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25511. /**
  25512. * 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.
  25513. * SPS internal tool, don't use it manually.
  25514. * @hidden
  25515. */
  25516. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25517. }
  25518. /**
  25519. * Represents a Depth Sorted Particle in the solid particle system.
  25520. */
  25521. export class DepthSortedParticle {
  25522. /**
  25523. * Index of the particle in the "indices" array
  25524. */
  25525. ind: number;
  25526. /**
  25527. * Length of the particle shape in the "indices" array
  25528. */
  25529. indicesLength: number;
  25530. /**
  25531. * Squared distance from the particle to the camera
  25532. */
  25533. sqDistance: number;
  25534. }
  25535. }
  25536. declare module BABYLON {
  25537. /**
  25538. * @hidden
  25539. */
  25540. export class _MeshCollisionData {
  25541. _checkCollisions: boolean;
  25542. _collisionMask: number;
  25543. _collisionGroup: number;
  25544. _collider: Nullable<Collider>;
  25545. _oldPositionForCollisions: Vector3;
  25546. _diffPositionForCollisions: Vector3;
  25547. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25548. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25549. }
  25550. }
  25551. declare module BABYLON {
  25552. /** @hidden */
  25553. class _FacetDataStorage {
  25554. facetPositions: Vector3[];
  25555. facetNormals: Vector3[];
  25556. facetPartitioning: number[][];
  25557. facetNb: number;
  25558. partitioningSubdivisions: number;
  25559. partitioningBBoxRatio: number;
  25560. facetDataEnabled: boolean;
  25561. facetParameters: any;
  25562. bbSize: Vector3;
  25563. subDiv: {
  25564. max: number;
  25565. X: number;
  25566. Y: number;
  25567. Z: number;
  25568. };
  25569. facetDepthSort: boolean;
  25570. facetDepthSortEnabled: boolean;
  25571. depthSortedIndices: IndicesArray;
  25572. depthSortedFacets: {
  25573. ind: number;
  25574. sqDistance: number;
  25575. }[];
  25576. facetDepthSortFunction: (f1: {
  25577. ind: number;
  25578. sqDistance: number;
  25579. }, f2: {
  25580. ind: number;
  25581. sqDistance: number;
  25582. }) => number;
  25583. facetDepthSortFrom: Vector3;
  25584. facetDepthSortOrigin: Vector3;
  25585. invertedMatrix: Matrix;
  25586. }
  25587. /**
  25588. * @hidden
  25589. **/
  25590. class _InternalAbstractMeshDataInfo {
  25591. _hasVertexAlpha: boolean;
  25592. _useVertexColors: boolean;
  25593. _numBoneInfluencers: number;
  25594. _applyFog: boolean;
  25595. _receiveShadows: boolean;
  25596. _facetData: _FacetDataStorage;
  25597. _visibility: number;
  25598. _skeleton: Nullable<Skeleton>;
  25599. _layerMask: number;
  25600. _computeBonesUsingShaders: boolean;
  25601. _isActive: boolean;
  25602. _onlyForInstances: boolean;
  25603. _isActiveIntermediate: boolean;
  25604. _onlyForInstancesIntermediate: boolean;
  25605. }
  25606. /**
  25607. * Class used to store all common mesh properties
  25608. */
  25609. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25610. /** No occlusion */
  25611. static OCCLUSION_TYPE_NONE: number;
  25612. /** Occlusion set to optimisitic */
  25613. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25614. /** Occlusion set to strict */
  25615. static OCCLUSION_TYPE_STRICT: number;
  25616. /** Use an accurante occlusion algorithm */
  25617. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25618. /** Use a conservative occlusion algorithm */
  25619. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25620. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25621. * Test order :
  25622. * Is the bounding sphere outside the frustum ?
  25623. * If not, are the bounding box vertices outside the frustum ?
  25624. * It not, then the cullable object is in the frustum.
  25625. */
  25626. static readonly CULLINGSTRATEGY_STANDARD: number;
  25627. /** Culling strategy : Bounding Sphere Only.
  25628. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25629. * It's also less accurate than the standard because some not visible objects can still be selected.
  25630. * Test : is the bounding sphere outside the frustum ?
  25631. * If not, then the cullable object is in the frustum.
  25632. */
  25633. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25634. /** Culling strategy : Optimistic Inclusion.
  25635. * This in an inclusion test first, then the standard exclusion test.
  25636. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25637. * 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.
  25638. * Anyway, it's as accurate as the standard strategy.
  25639. * Test :
  25640. * Is the cullable object bounding sphere center in the frustum ?
  25641. * If not, apply the default culling strategy.
  25642. */
  25643. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25644. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25645. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25646. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25647. * 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.
  25648. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25649. * Test :
  25650. * Is the cullable object bounding sphere center in the frustum ?
  25651. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25652. */
  25653. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25654. /**
  25655. * No billboard
  25656. */
  25657. static readonly BILLBOARDMODE_NONE: number;
  25658. /** Billboard on X axis */
  25659. static readonly BILLBOARDMODE_X: number;
  25660. /** Billboard on Y axis */
  25661. static readonly BILLBOARDMODE_Y: number;
  25662. /** Billboard on Z axis */
  25663. static readonly BILLBOARDMODE_Z: number;
  25664. /** Billboard on all axes */
  25665. static readonly BILLBOARDMODE_ALL: number;
  25666. /** Billboard on using position instead of orientation */
  25667. static readonly BILLBOARDMODE_USE_POSITION: number;
  25668. /** @hidden */
  25669. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25670. /**
  25671. * The culling strategy to use to check whether the mesh must be rendered or not.
  25672. * This value can be changed at any time and will be used on the next render mesh selection.
  25673. * The possible values are :
  25674. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25675. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25676. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25677. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25678. * Please read each static variable documentation to get details about the culling process.
  25679. * */
  25680. cullingStrategy: number;
  25681. /**
  25682. * Gets the number of facets in the mesh
  25683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25684. */
  25685. readonly facetNb: number;
  25686. /**
  25687. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25689. */
  25690. partitioningSubdivisions: number;
  25691. /**
  25692. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25693. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25695. */
  25696. partitioningBBoxRatio: number;
  25697. /**
  25698. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25699. * Works only for updatable meshes.
  25700. * Doesn't work with multi-materials
  25701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25702. */
  25703. mustDepthSortFacets: boolean;
  25704. /**
  25705. * The location (Vector3) where the facet depth sort must be computed from.
  25706. * By default, the active camera position.
  25707. * Used only when facet depth sort is enabled
  25708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25709. */
  25710. facetDepthSortFrom: Vector3;
  25711. /**
  25712. * gets a boolean indicating if facetData is enabled
  25713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25714. */
  25715. readonly isFacetDataEnabled: boolean;
  25716. /** @hidden */
  25717. _updateNonUniformScalingState(value: boolean): boolean;
  25718. /**
  25719. * An event triggered when this mesh collides with another one
  25720. */
  25721. onCollideObservable: Observable<AbstractMesh>;
  25722. /** Set a function to call when this mesh collides with another one */
  25723. onCollide: () => void;
  25724. /**
  25725. * An event triggered when the collision's position changes
  25726. */
  25727. onCollisionPositionChangeObservable: Observable<Vector3>;
  25728. /** Set a function to call when the collision's position changes */
  25729. onCollisionPositionChange: () => void;
  25730. /**
  25731. * An event triggered when material is changed
  25732. */
  25733. onMaterialChangedObservable: Observable<AbstractMesh>;
  25734. /**
  25735. * Gets or sets the orientation for POV movement & rotation
  25736. */
  25737. definedFacingForward: boolean;
  25738. /** @hidden */
  25739. _occlusionQuery: Nullable<WebGLQuery>;
  25740. /** @hidden */
  25741. _renderingGroup: Nullable<RenderingGroup>;
  25742. /**
  25743. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25744. */
  25745. /**
  25746. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25747. */
  25748. visibility: number;
  25749. /** Gets or sets the alpha index used to sort transparent meshes
  25750. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25751. */
  25752. alphaIndex: number;
  25753. /**
  25754. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25755. */
  25756. isVisible: boolean;
  25757. /**
  25758. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25759. */
  25760. isPickable: boolean;
  25761. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25762. showSubMeshesBoundingBox: boolean;
  25763. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25764. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25765. */
  25766. isBlocker: boolean;
  25767. /**
  25768. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25769. */
  25770. enablePointerMoveEvents: boolean;
  25771. /**
  25772. * Specifies the rendering group id for this mesh (0 by default)
  25773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25774. */
  25775. renderingGroupId: number;
  25776. private _material;
  25777. /** Gets or sets current material */
  25778. material: Nullable<Material>;
  25779. /**
  25780. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25781. * @see http://doc.babylonjs.com/babylon101/shadows
  25782. */
  25783. receiveShadows: boolean;
  25784. /** Defines color to use when rendering outline */
  25785. outlineColor: Color3;
  25786. /** Define width to use when rendering outline */
  25787. outlineWidth: number;
  25788. /** Defines color to use when rendering overlay */
  25789. overlayColor: Color3;
  25790. /** Defines alpha to use when rendering overlay */
  25791. overlayAlpha: number;
  25792. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25793. hasVertexAlpha: boolean;
  25794. /** 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) */
  25795. useVertexColors: boolean;
  25796. /**
  25797. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25798. */
  25799. computeBonesUsingShaders: boolean;
  25800. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25801. numBoneInfluencers: number;
  25802. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25803. applyFog: boolean;
  25804. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25805. useOctreeForRenderingSelection: boolean;
  25806. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25807. useOctreeForPicking: boolean;
  25808. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25809. useOctreeForCollisions: boolean;
  25810. /**
  25811. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25812. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25813. */
  25814. layerMask: number;
  25815. /**
  25816. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25817. */
  25818. alwaysSelectAsActiveMesh: boolean;
  25819. /**
  25820. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25821. */
  25822. doNotSyncBoundingInfo: boolean;
  25823. /**
  25824. * Gets or sets the current action manager
  25825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25826. */
  25827. actionManager: Nullable<AbstractActionManager>;
  25828. private _meshCollisionData;
  25829. /**
  25830. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25832. */
  25833. ellipsoid: Vector3;
  25834. /**
  25835. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25837. */
  25838. ellipsoidOffset: Vector3;
  25839. /**
  25840. * Gets or sets a collision mask used to mask collisions (default is -1).
  25841. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25842. */
  25843. collisionMask: number;
  25844. /**
  25845. * Gets or sets the current collision group mask (-1 by default).
  25846. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25847. */
  25848. collisionGroup: number;
  25849. /**
  25850. * Defines edge width used when edgesRenderer is enabled
  25851. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25852. */
  25853. edgesWidth: number;
  25854. /**
  25855. * Defines edge color used when edgesRenderer is enabled
  25856. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25857. */
  25858. edgesColor: Color4;
  25859. /** @hidden */
  25860. _edgesRenderer: Nullable<IEdgesRenderer>;
  25861. /** @hidden */
  25862. _masterMesh: Nullable<AbstractMesh>;
  25863. /** @hidden */
  25864. _boundingInfo: Nullable<BoundingInfo>;
  25865. /** @hidden */
  25866. _renderId: number;
  25867. /**
  25868. * Gets or sets the list of subMeshes
  25869. * @see http://doc.babylonjs.com/how_to/multi_materials
  25870. */
  25871. subMeshes: SubMesh[];
  25872. /** @hidden */
  25873. _intersectionsInProgress: AbstractMesh[];
  25874. /** @hidden */
  25875. _unIndexed: boolean;
  25876. /** @hidden */
  25877. _lightSources: Light[];
  25878. /** Gets the list of lights affecting that mesh */
  25879. readonly lightSources: Light[];
  25880. /** @hidden */
  25881. readonly _positions: Nullable<Vector3[]>;
  25882. /** @hidden */
  25883. _waitingData: {
  25884. lods: Nullable<any>;
  25885. actions: Nullable<any>;
  25886. freezeWorldMatrix: Nullable<boolean>;
  25887. };
  25888. /** @hidden */
  25889. _bonesTransformMatrices: Nullable<Float32Array>;
  25890. /** @hidden */
  25891. _transformMatrixTexture: Nullable<RawTexture>;
  25892. /**
  25893. * Gets or sets a skeleton to apply skining transformations
  25894. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25895. */
  25896. skeleton: Nullable<Skeleton>;
  25897. /**
  25898. * An event triggered when the mesh is rebuilt.
  25899. */
  25900. onRebuildObservable: Observable<AbstractMesh>;
  25901. /**
  25902. * Creates a new AbstractMesh
  25903. * @param name defines the name of the mesh
  25904. * @param scene defines the hosting scene
  25905. */
  25906. constructor(name: string, scene?: Nullable<Scene>);
  25907. /**
  25908. * Returns the string "AbstractMesh"
  25909. * @returns "AbstractMesh"
  25910. */
  25911. getClassName(): string;
  25912. /**
  25913. * Gets a string representation of the current mesh
  25914. * @param fullDetails defines a boolean indicating if full details must be included
  25915. * @returns a string representation of the current mesh
  25916. */
  25917. toString(fullDetails?: boolean): string;
  25918. /**
  25919. * @hidden
  25920. */
  25921. protected _getEffectiveParent(): Nullable<Node>;
  25922. /** @hidden */
  25923. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25924. /** @hidden */
  25925. _rebuild(): void;
  25926. /** @hidden */
  25927. _resyncLightSources(): void;
  25928. /** @hidden */
  25929. _resyncLighSource(light: Light): void;
  25930. /** @hidden */
  25931. _unBindEffect(): void;
  25932. /** @hidden */
  25933. _removeLightSource(light: Light, dispose: boolean): void;
  25934. private _markSubMeshesAsDirty;
  25935. /** @hidden */
  25936. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25937. /** @hidden */
  25938. _markSubMeshesAsAttributesDirty(): void;
  25939. /** @hidden */
  25940. _markSubMeshesAsMiscDirty(): void;
  25941. /**
  25942. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25943. */
  25944. scaling: Vector3;
  25945. /**
  25946. * Returns true if the mesh is blocked. Implemented by child classes
  25947. */
  25948. readonly isBlocked: boolean;
  25949. /**
  25950. * Returns the mesh itself by default. Implemented by child classes
  25951. * @param camera defines the camera to use to pick the right LOD level
  25952. * @returns the currentAbstractMesh
  25953. */
  25954. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25955. /**
  25956. * Returns 0 by default. Implemented by child classes
  25957. * @returns an integer
  25958. */
  25959. getTotalVertices(): number;
  25960. /**
  25961. * Returns a positive integer : the total number of indices in this mesh geometry.
  25962. * @returns the numner of indices or zero if the mesh has no geometry.
  25963. */
  25964. getTotalIndices(): number;
  25965. /**
  25966. * Returns null by default. Implemented by child classes
  25967. * @returns null
  25968. */
  25969. getIndices(): Nullable<IndicesArray>;
  25970. /**
  25971. * Returns the array of the requested vertex data kind. Implemented by child classes
  25972. * @param kind defines the vertex data kind to use
  25973. * @returns null
  25974. */
  25975. getVerticesData(kind: string): Nullable<FloatArray>;
  25976. /**
  25977. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25978. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25979. * Note that a new underlying VertexBuffer object is created each call.
  25980. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25981. * @param kind defines vertex data kind:
  25982. * * VertexBuffer.PositionKind
  25983. * * VertexBuffer.UVKind
  25984. * * VertexBuffer.UV2Kind
  25985. * * VertexBuffer.UV3Kind
  25986. * * VertexBuffer.UV4Kind
  25987. * * VertexBuffer.UV5Kind
  25988. * * VertexBuffer.UV6Kind
  25989. * * VertexBuffer.ColorKind
  25990. * * VertexBuffer.MatricesIndicesKind
  25991. * * VertexBuffer.MatricesIndicesExtraKind
  25992. * * VertexBuffer.MatricesWeightsKind
  25993. * * VertexBuffer.MatricesWeightsExtraKind
  25994. * @param data defines the data source
  25995. * @param updatable defines if the data must be flagged as updatable (or static)
  25996. * @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
  25997. * @returns the current mesh
  25998. */
  25999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26000. /**
  26001. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26002. * If the mesh has no geometry, it is simply returned as it is.
  26003. * @param kind defines vertex data kind:
  26004. * * VertexBuffer.PositionKind
  26005. * * VertexBuffer.UVKind
  26006. * * VertexBuffer.UV2Kind
  26007. * * VertexBuffer.UV3Kind
  26008. * * VertexBuffer.UV4Kind
  26009. * * VertexBuffer.UV5Kind
  26010. * * VertexBuffer.UV6Kind
  26011. * * VertexBuffer.ColorKind
  26012. * * VertexBuffer.MatricesIndicesKind
  26013. * * VertexBuffer.MatricesIndicesExtraKind
  26014. * * VertexBuffer.MatricesWeightsKind
  26015. * * VertexBuffer.MatricesWeightsExtraKind
  26016. * @param data defines the data source
  26017. * @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
  26018. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26019. * @returns the current mesh
  26020. */
  26021. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26022. /**
  26023. * Sets the mesh indices,
  26024. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26025. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26026. * @param totalVertices Defines the total number of vertices
  26027. * @returns the current mesh
  26028. */
  26029. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26030. /**
  26031. * Gets a boolean indicating if specific vertex data is present
  26032. * @param kind defines the vertex data kind to use
  26033. * @returns true is data kind is present
  26034. */
  26035. isVerticesDataPresent(kind: string): boolean;
  26036. /**
  26037. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26038. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26039. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26040. * @returns a BoundingInfo
  26041. */
  26042. getBoundingInfo(): BoundingInfo;
  26043. /**
  26044. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26045. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26046. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26047. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26048. * @returns the current mesh
  26049. */
  26050. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26051. /**
  26052. * Overwrite the current bounding info
  26053. * @param boundingInfo defines the new bounding info
  26054. * @returns the current mesh
  26055. */
  26056. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26057. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26058. readonly useBones: boolean;
  26059. /** @hidden */
  26060. _preActivate(): void;
  26061. /** @hidden */
  26062. _preActivateForIntermediateRendering(renderId: number): void;
  26063. /** @hidden */
  26064. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26065. /** @hidden */
  26066. _postActivate(): void;
  26067. /** @hidden */
  26068. _freeze(): void;
  26069. /** @hidden */
  26070. _unFreeze(): void;
  26071. /**
  26072. * Gets the current world matrix
  26073. * @returns a Matrix
  26074. */
  26075. getWorldMatrix(): Matrix;
  26076. /** @hidden */
  26077. _getWorldMatrixDeterminant(): number;
  26078. /**
  26079. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26080. */
  26081. readonly isAnInstance: boolean;
  26082. /**
  26083. * Gets a boolean indicating if this mesh has instances
  26084. */
  26085. readonly hasInstances: boolean;
  26086. /**
  26087. * Perform relative position change from the point of view of behind the front of the mesh.
  26088. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26089. * Supports definition of mesh facing forward or backward
  26090. * @param amountRight defines the distance on the right axis
  26091. * @param amountUp defines the distance on the up axis
  26092. * @param amountForward defines the distance on the forward axis
  26093. * @returns the current mesh
  26094. */
  26095. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26096. /**
  26097. * Calculate relative position change from the point of view of behind the front of the mesh.
  26098. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26099. * Supports definition of mesh facing forward or backward
  26100. * @param amountRight defines the distance on the right axis
  26101. * @param amountUp defines the distance on the up axis
  26102. * @param amountForward defines the distance on the forward axis
  26103. * @returns the new displacement vector
  26104. */
  26105. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26106. /**
  26107. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26108. * Supports definition of mesh facing forward or backward
  26109. * @param flipBack defines the flip
  26110. * @param twirlClockwise defines the twirl
  26111. * @param tiltRight defines the tilt
  26112. * @returns the current mesh
  26113. */
  26114. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26115. /**
  26116. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26117. * Supports definition of mesh facing forward or backward.
  26118. * @param flipBack defines the flip
  26119. * @param twirlClockwise defines the twirl
  26120. * @param tiltRight defines the tilt
  26121. * @returns the new rotation vector
  26122. */
  26123. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26124. /**
  26125. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26126. * This means the mesh underlying bounding box and sphere are recomputed.
  26127. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26128. * @returns the current mesh
  26129. */
  26130. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26131. /** @hidden */
  26132. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26133. /** @hidden */
  26134. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26135. /** @hidden */
  26136. _updateBoundingInfo(): AbstractMesh;
  26137. /** @hidden */
  26138. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26139. /** @hidden */
  26140. protected _afterComputeWorldMatrix(): void;
  26141. /** @hidden */
  26142. readonly _effectiveMesh: AbstractMesh;
  26143. /**
  26144. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26145. * A mesh is in the frustum if its bounding box intersects the frustum
  26146. * @param frustumPlanes defines the frustum to test
  26147. * @returns true if the mesh is in the frustum planes
  26148. */
  26149. isInFrustum(frustumPlanes: Plane[]): boolean;
  26150. /**
  26151. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26152. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26153. * @param frustumPlanes defines the frustum to test
  26154. * @returns true if the mesh is completely in the frustum planes
  26155. */
  26156. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26157. /**
  26158. * True if the mesh intersects another mesh or a SolidParticle object
  26159. * @param mesh defines a target mesh or SolidParticle to test
  26160. * @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)
  26161. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26162. * @returns true if there is an intersection
  26163. */
  26164. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26165. /**
  26166. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26167. * @param point defines the point to test
  26168. * @returns true if there is an intersection
  26169. */
  26170. intersectsPoint(point: Vector3): boolean;
  26171. /**
  26172. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26174. */
  26175. checkCollisions: boolean;
  26176. /**
  26177. * Gets Collider object used to compute collisions (not physics)
  26178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26179. */
  26180. readonly collider: Nullable<Collider>;
  26181. /**
  26182. * Move the mesh using collision engine
  26183. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26184. * @param displacement defines the requested displacement vector
  26185. * @returns the current mesh
  26186. */
  26187. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26188. private _onCollisionPositionChange;
  26189. /** @hidden */
  26190. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26191. /** @hidden */
  26192. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26193. /** @hidden */
  26194. _checkCollision(collider: Collider): AbstractMesh;
  26195. /** @hidden */
  26196. _generatePointsArray(): boolean;
  26197. /**
  26198. * Checks if the passed Ray intersects with the mesh
  26199. * @param ray defines the ray to use
  26200. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26201. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26202. * @returns the picking info
  26203. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26204. */
  26205. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26206. /**
  26207. * Clones the current mesh
  26208. * @param name defines the mesh name
  26209. * @param newParent defines the new mesh parent
  26210. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26211. * @returns the new mesh
  26212. */
  26213. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26214. /**
  26215. * Disposes all the submeshes of the current meshnp
  26216. * @returns the current mesh
  26217. */
  26218. releaseSubMeshes(): AbstractMesh;
  26219. /**
  26220. * Releases resources associated with this abstract mesh.
  26221. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26222. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26223. */
  26224. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26225. /**
  26226. * Adds the passed mesh as a child to the current mesh
  26227. * @param mesh defines the child mesh
  26228. * @returns the current mesh
  26229. */
  26230. addChild(mesh: AbstractMesh): AbstractMesh;
  26231. /**
  26232. * Removes the passed mesh from the current mesh children list
  26233. * @param mesh defines the child mesh
  26234. * @returns the current mesh
  26235. */
  26236. removeChild(mesh: AbstractMesh): AbstractMesh;
  26237. /** @hidden */
  26238. private _initFacetData;
  26239. /**
  26240. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26241. * This method can be called within the render loop.
  26242. * 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
  26243. * @returns the current mesh
  26244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26245. */
  26246. updateFacetData(): AbstractMesh;
  26247. /**
  26248. * Returns the facetLocalNormals array.
  26249. * The normals are expressed in the mesh local spac
  26250. * @returns an array of Vector3
  26251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26252. */
  26253. getFacetLocalNormals(): Vector3[];
  26254. /**
  26255. * Returns the facetLocalPositions array.
  26256. * The facet positions are expressed in the mesh local space
  26257. * @returns an array of Vector3
  26258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26259. */
  26260. getFacetLocalPositions(): Vector3[];
  26261. /**
  26262. * Returns the facetLocalPartioning array
  26263. * @returns an array of array of numbers
  26264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26265. */
  26266. getFacetLocalPartitioning(): number[][];
  26267. /**
  26268. * Returns the i-th facet position in the world system.
  26269. * This method allocates a new Vector3 per call
  26270. * @param i defines the facet index
  26271. * @returns a new Vector3
  26272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26273. */
  26274. getFacetPosition(i: number): Vector3;
  26275. /**
  26276. * Sets the reference Vector3 with the i-th facet position in the world system
  26277. * @param i defines the facet index
  26278. * @param ref defines the target vector
  26279. * @returns the current mesh
  26280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26281. */
  26282. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26283. /**
  26284. * Returns the i-th facet normal in the world system.
  26285. * This method allocates a new Vector3 per call
  26286. * @param i defines the facet index
  26287. * @returns a new Vector3
  26288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26289. */
  26290. getFacetNormal(i: number): Vector3;
  26291. /**
  26292. * Sets the reference Vector3 with the i-th facet normal in the world system
  26293. * @param i defines the facet index
  26294. * @param ref defines the target vector
  26295. * @returns the current mesh
  26296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26297. */
  26298. getFacetNormalToRef(i: number, ref: Vector3): this;
  26299. /**
  26300. * 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)
  26301. * @param x defines x coordinate
  26302. * @param y defines y coordinate
  26303. * @param z defines z coordinate
  26304. * @returns the array of facet indexes
  26305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26306. */
  26307. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26308. /**
  26309. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26310. * @param projected sets as the (x,y,z) world projection on the facet
  26311. * @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
  26312. * @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
  26313. * @param x defines x coordinate
  26314. * @param y defines y coordinate
  26315. * @param z defines z coordinate
  26316. * @returns the face index if found (or null instead)
  26317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26318. */
  26319. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26320. /**
  26321. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26322. * @param projected sets as the (x,y,z) local projection on the facet
  26323. * @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
  26324. * @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
  26325. * @param x defines x coordinate
  26326. * @param y defines y coordinate
  26327. * @param z defines z coordinate
  26328. * @returns the face index if found (or null instead)
  26329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26330. */
  26331. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26332. /**
  26333. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26334. * @returns the parameters
  26335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26336. */
  26337. getFacetDataParameters(): any;
  26338. /**
  26339. * Disables the feature FacetData and frees the related memory
  26340. * @returns the current mesh
  26341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26342. */
  26343. disableFacetData(): AbstractMesh;
  26344. /**
  26345. * Updates the AbstractMesh indices array
  26346. * @param indices defines the data source
  26347. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26348. * @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)
  26349. * @returns the current mesh
  26350. */
  26351. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26352. /**
  26353. * Creates new normals data for the mesh
  26354. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26355. * @returns the current mesh
  26356. */
  26357. createNormals(updatable: boolean): AbstractMesh;
  26358. /**
  26359. * Align the mesh with a normal
  26360. * @param normal defines the normal to use
  26361. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26362. * @returns the current mesh
  26363. */
  26364. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26365. /** @hidden */
  26366. _checkOcclusionQuery(): boolean;
  26367. /**
  26368. * Disables the mesh edge rendering mode
  26369. * @returns the currentAbstractMesh
  26370. */
  26371. disableEdgesRendering(): AbstractMesh;
  26372. /**
  26373. * Enables the edge rendering mode on the mesh.
  26374. * This mode makes the mesh edges visible
  26375. * @param epsilon defines the maximal distance between two angles to detect a face
  26376. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26377. * @returns the currentAbstractMesh
  26378. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26379. */
  26380. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26381. }
  26382. }
  26383. declare module BABYLON {
  26384. /**
  26385. * Interface used to define ActionEvent
  26386. */
  26387. export interface IActionEvent {
  26388. /** The mesh or sprite that triggered the action */
  26389. source: any;
  26390. /** The X mouse cursor position at the time of the event */
  26391. pointerX: number;
  26392. /** The Y mouse cursor position at the time of the event */
  26393. pointerY: number;
  26394. /** The mesh that is currently pointed at (can be null) */
  26395. meshUnderPointer: Nullable<AbstractMesh>;
  26396. /** the original (browser) event that triggered the ActionEvent */
  26397. sourceEvent?: any;
  26398. /** additional data for the event */
  26399. additionalData?: any;
  26400. }
  26401. /**
  26402. * ActionEvent is the event being sent when an action is triggered.
  26403. */
  26404. export class ActionEvent implements IActionEvent {
  26405. /** The mesh or sprite that triggered the action */
  26406. source: any;
  26407. /** The X mouse cursor position at the time of the event */
  26408. pointerX: number;
  26409. /** The Y mouse cursor position at the time of the event */
  26410. pointerY: number;
  26411. /** The mesh that is currently pointed at (can be null) */
  26412. meshUnderPointer: Nullable<AbstractMesh>;
  26413. /** the original (browser) event that triggered the ActionEvent */
  26414. sourceEvent?: any;
  26415. /** additional data for the event */
  26416. additionalData?: any;
  26417. /**
  26418. * Creates a new ActionEvent
  26419. * @param source The mesh or sprite that triggered the action
  26420. * @param pointerX The X mouse cursor position at the time of the event
  26421. * @param pointerY The Y mouse cursor position at the time of the event
  26422. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26423. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26424. * @param additionalData additional data for the event
  26425. */
  26426. constructor(
  26427. /** The mesh or sprite that triggered the action */
  26428. source: any,
  26429. /** The X mouse cursor position at the time of the event */
  26430. pointerX: number,
  26431. /** The Y mouse cursor position at the time of the event */
  26432. pointerY: number,
  26433. /** The mesh that is currently pointed at (can be null) */
  26434. meshUnderPointer: Nullable<AbstractMesh>,
  26435. /** the original (browser) event that triggered the ActionEvent */
  26436. sourceEvent?: any,
  26437. /** additional data for the event */
  26438. additionalData?: any);
  26439. /**
  26440. * Helper function to auto-create an ActionEvent from a source mesh.
  26441. * @param source The source mesh that triggered the event
  26442. * @param evt The original (browser) event
  26443. * @param additionalData additional data for the event
  26444. * @returns the new ActionEvent
  26445. */
  26446. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26447. /**
  26448. * Helper function to auto-create an ActionEvent from a source sprite
  26449. * @param source The source sprite that triggered the event
  26450. * @param scene Scene associated with the sprite
  26451. * @param evt The original (browser) event
  26452. * @param additionalData additional data for the event
  26453. * @returns the new ActionEvent
  26454. */
  26455. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26456. /**
  26457. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26458. * @param scene the scene where the event occurred
  26459. * @param evt The original (browser) event
  26460. * @returns the new ActionEvent
  26461. */
  26462. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26463. /**
  26464. * Helper function to auto-create an ActionEvent from a primitive
  26465. * @param prim defines the target primitive
  26466. * @param pointerPos defines the pointer position
  26467. * @param evt The original (browser) event
  26468. * @param additionalData additional data for the event
  26469. * @returns the new ActionEvent
  26470. */
  26471. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26472. }
  26473. }
  26474. declare module BABYLON {
  26475. /**
  26476. * Abstract class used to decouple action Manager from scene and meshes.
  26477. * Do not instantiate.
  26478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26479. */
  26480. export abstract class AbstractActionManager implements IDisposable {
  26481. /** Gets the list of active triggers */
  26482. static Triggers: {
  26483. [key: string]: number;
  26484. };
  26485. /** Gets the cursor to use when hovering items */
  26486. hoverCursor: string;
  26487. /** Gets the list of actions */
  26488. actions: IAction[];
  26489. /**
  26490. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26491. */
  26492. isRecursive: boolean;
  26493. /**
  26494. * Releases all associated resources
  26495. */
  26496. abstract dispose(): void;
  26497. /**
  26498. * Does this action manager has pointer triggers
  26499. */
  26500. abstract readonly hasPointerTriggers: boolean;
  26501. /**
  26502. * Does this action manager has pick triggers
  26503. */
  26504. abstract readonly hasPickTriggers: boolean;
  26505. /**
  26506. * Process a specific trigger
  26507. * @param trigger defines the trigger to process
  26508. * @param evt defines the event details to be processed
  26509. */
  26510. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26511. /**
  26512. * Does this action manager handles actions of any of the given triggers
  26513. * @param triggers defines the triggers to be tested
  26514. * @return a boolean indicating whether one (or more) of the triggers is handled
  26515. */
  26516. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26517. /**
  26518. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26519. * speed.
  26520. * @param triggerA defines the trigger to be tested
  26521. * @param triggerB defines the trigger to be tested
  26522. * @return a boolean indicating whether one (or more) of the triggers is handled
  26523. */
  26524. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26525. /**
  26526. * Does this action manager handles actions of a given trigger
  26527. * @param trigger defines the trigger to be tested
  26528. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26529. * @return whether the trigger is handled
  26530. */
  26531. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26532. /**
  26533. * Serialize this manager to a JSON object
  26534. * @param name defines the property name to store this manager
  26535. * @returns a JSON representation of this manager
  26536. */
  26537. abstract serialize(name: string): any;
  26538. /**
  26539. * Registers an action to this action manager
  26540. * @param action defines the action to be registered
  26541. * @return the action amended (prepared) after registration
  26542. */
  26543. abstract registerAction(action: IAction): Nullable<IAction>;
  26544. /**
  26545. * Unregisters an action to this action manager
  26546. * @param action defines the action to be unregistered
  26547. * @return a boolean indicating whether the action has been unregistered
  26548. */
  26549. abstract unregisterAction(action: IAction): Boolean;
  26550. /**
  26551. * Does exist one action manager with at least one trigger
  26552. **/
  26553. static readonly HasTriggers: boolean;
  26554. /**
  26555. * Does exist one action manager with at least one pick trigger
  26556. **/
  26557. static readonly HasPickTriggers: boolean;
  26558. /**
  26559. * Does exist one action manager that handles actions of a given trigger
  26560. * @param trigger defines the trigger to be tested
  26561. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26562. **/
  26563. static HasSpecificTrigger(trigger: number): boolean;
  26564. }
  26565. }
  26566. declare module BABYLON {
  26567. /**
  26568. * Defines how a node can be built from a string name.
  26569. */
  26570. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26571. /**
  26572. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26573. */
  26574. export class Node implements IBehaviorAware<Node> {
  26575. /** @hidden */
  26576. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26577. private static _NodeConstructors;
  26578. /**
  26579. * Add a new node constructor
  26580. * @param type defines the type name of the node to construct
  26581. * @param constructorFunc defines the constructor function
  26582. */
  26583. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26584. /**
  26585. * Returns a node constructor based on type name
  26586. * @param type defines the type name
  26587. * @param name defines the new node name
  26588. * @param scene defines the hosting scene
  26589. * @param options defines optional options to transmit to constructors
  26590. * @returns the new constructor or null
  26591. */
  26592. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26593. /**
  26594. * Gets or sets the name of the node
  26595. */
  26596. name: string;
  26597. /**
  26598. * Gets or sets the id of the node
  26599. */
  26600. id: string;
  26601. /**
  26602. * Gets or sets the unique id of the node
  26603. */
  26604. uniqueId: number;
  26605. /**
  26606. * Gets or sets a string used to store user defined state for the node
  26607. */
  26608. state: string;
  26609. /**
  26610. * Gets or sets an object used to store user defined information for the node
  26611. */
  26612. metadata: any;
  26613. /**
  26614. * For internal use only. Please do not use.
  26615. */
  26616. reservedDataStore: any;
  26617. /**
  26618. * List of inspectable custom properties (used by the Inspector)
  26619. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26620. */
  26621. inspectableCustomProperties: IInspectable[];
  26622. /**
  26623. * Gets or sets a boolean used to define if the node must be serialized
  26624. */
  26625. doNotSerialize: boolean;
  26626. /** @hidden */
  26627. _isDisposed: boolean;
  26628. /**
  26629. * Gets a list of Animations associated with the node
  26630. */
  26631. animations: Animation[];
  26632. protected _ranges: {
  26633. [name: string]: Nullable<AnimationRange>;
  26634. };
  26635. /**
  26636. * Callback raised when the node is ready to be used
  26637. */
  26638. onReady: Nullable<(node: Node) => void>;
  26639. private _isEnabled;
  26640. private _isParentEnabled;
  26641. private _isReady;
  26642. /** @hidden */
  26643. _currentRenderId: number;
  26644. private _parentUpdateId;
  26645. /** @hidden */
  26646. _childUpdateId: number;
  26647. /** @hidden */
  26648. _waitingParentId: Nullable<string>;
  26649. /** @hidden */
  26650. _scene: Scene;
  26651. /** @hidden */
  26652. _cache: any;
  26653. private _parentNode;
  26654. private _children;
  26655. /** @hidden */
  26656. _worldMatrix: Matrix;
  26657. /** @hidden */
  26658. _worldMatrixDeterminant: number;
  26659. /** @hidden */
  26660. _worldMatrixDeterminantIsDirty: boolean;
  26661. /** @hidden */
  26662. private _sceneRootNodesIndex;
  26663. /**
  26664. * Gets a boolean indicating if the node has been disposed
  26665. * @returns true if the node was disposed
  26666. */
  26667. isDisposed(): boolean;
  26668. /**
  26669. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26670. * @see https://doc.babylonjs.com/how_to/parenting
  26671. */
  26672. parent: Nullable<Node>;
  26673. private addToSceneRootNodes;
  26674. private removeFromSceneRootNodes;
  26675. private _animationPropertiesOverride;
  26676. /**
  26677. * Gets or sets the animation properties override
  26678. */
  26679. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26680. /**
  26681. * Gets a string idenfifying the name of the class
  26682. * @returns "Node" string
  26683. */
  26684. getClassName(): string;
  26685. /** @hidden */
  26686. readonly _isNode: boolean;
  26687. /**
  26688. * An event triggered when the mesh is disposed
  26689. */
  26690. onDisposeObservable: Observable<Node>;
  26691. private _onDisposeObserver;
  26692. /**
  26693. * Sets a callback that will be raised when the node will be disposed
  26694. */
  26695. onDispose: () => void;
  26696. /**
  26697. * Creates a new Node
  26698. * @param name the name and id to be given to this node
  26699. * @param scene the scene this node will be added to
  26700. * @param addToRootNodes the node will be added to scene.rootNodes
  26701. */
  26702. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26703. /**
  26704. * Gets the scene of the node
  26705. * @returns a scene
  26706. */
  26707. getScene(): Scene;
  26708. /**
  26709. * Gets the engine of the node
  26710. * @returns a Engine
  26711. */
  26712. getEngine(): Engine;
  26713. private _behaviors;
  26714. /**
  26715. * Attach a behavior to the node
  26716. * @see http://doc.babylonjs.com/features/behaviour
  26717. * @param behavior defines the behavior to attach
  26718. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26719. * @returns the current Node
  26720. */
  26721. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26722. /**
  26723. * Remove an attached behavior
  26724. * @see http://doc.babylonjs.com/features/behaviour
  26725. * @param behavior defines the behavior to attach
  26726. * @returns the current Node
  26727. */
  26728. removeBehavior(behavior: Behavior<Node>): Node;
  26729. /**
  26730. * Gets the list of attached behaviors
  26731. * @see http://doc.babylonjs.com/features/behaviour
  26732. */
  26733. readonly behaviors: Behavior<Node>[];
  26734. /**
  26735. * Gets an attached behavior by name
  26736. * @param name defines the name of the behavior to look for
  26737. * @see http://doc.babylonjs.com/features/behaviour
  26738. * @returns null if behavior was not found else the requested behavior
  26739. */
  26740. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26741. /**
  26742. * Returns the latest update of the World matrix
  26743. * @returns a Matrix
  26744. */
  26745. getWorldMatrix(): Matrix;
  26746. /** @hidden */
  26747. _getWorldMatrixDeterminant(): number;
  26748. /**
  26749. * Returns directly the latest state of the mesh World matrix.
  26750. * A Matrix is returned.
  26751. */
  26752. readonly worldMatrixFromCache: Matrix;
  26753. /** @hidden */
  26754. _initCache(): void;
  26755. /** @hidden */
  26756. updateCache(force?: boolean): void;
  26757. /** @hidden */
  26758. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26759. /** @hidden */
  26760. _updateCache(ignoreParentClass?: boolean): void;
  26761. /** @hidden */
  26762. _isSynchronized(): boolean;
  26763. /** @hidden */
  26764. _markSyncedWithParent(): void;
  26765. /** @hidden */
  26766. isSynchronizedWithParent(): boolean;
  26767. /** @hidden */
  26768. isSynchronized(): boolean;
  26769. /**
  26770. * Is this node ready to be used/rendered
  26771. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26772. * @return true if the node is ready
  26773. */
  26774. isReady(completeCheck?: boolean): boolean;
  26775. /**
  26776. * Is this node enabled?
  26777. * 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
  26778. * @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
  26779. * @return whether this node (and its parent) is enabled
  26780. */
  26781. isEnabled(checkAncestors?: boolean): boolean;
  26782. /** @hidden */
  26783. protected _syncParentEnabledState(): void;
  26784. /**
  26785. * Set the enabled state of this node
  26786. * @param value defines the new enabled state
  26787. */
  26788. setEnabled(value: boolean): void;
  26789. /**
  26790. * Is this node a descendant of the given node?
  26791. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26792. * @param ancestor defines the parent node to inspect
  26793. * @returns a boolean indicating if this node is a descendant of the given node
  26794. */
  26795. isDescendantOf(ancestor: Node): boolean;
  26796. /** @hidden */
  26797. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26798. /**
  26799. * Will return all nodes that have this node as ascendant
  26800. * @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
  26801. * @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
  26802. * @return all children nodes of all types
  26803. */
  26804. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26805. /**
  26806. * Get all child-meshes of this node
  26807. * @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)
  26808. * @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
  26809. * @returns an array of AbstractMesh
  26810. */
  26811. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26812. /**
  26813. * Get all direct children of this node
  26814. * @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
  26815. * @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)
  26816. * @returns an array of Node
  26817. */
  26818. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26819. /** @hidden */
  26820. _setReady(state: boolean): void;
  26821. /**
  26822. * Get an animation by name
  26823. * @param name defines the name of the animation to look for
  26824. * @returns null if not found else the requested animation
  26825. */
  26826. getAnimationByName(name: string): Nullable<Animation>;
  26827. /**
  26828. * Creates an animation range for this node
  26829. * @param name defines the name of the range
  26830. * @param from defines the starting key
  26831. * @param to defines the end key
  26832. */
  26833. createAnimationRange(name: string, from: number, to: number): void;
  26834. /**
  26835. * Delete a specific animation range
  26836. * @param name defines the name of the range to delete
  26837. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26838. */
  26839. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26840. /**
  26841. * Get an animation range by name
  26842. * @param name defines the name of the animation range to look for
  26843. * @returns null if not found else the requested animation range
  26844. */
  26845. getAnimationRange(name: string): Nullable<AnimationRange>;
  26846. /**
  26847. * Gets the list of all animation ranges defined on this node
  26848. * @returns an array
  26849. */
  26850. getAnimationRanges(): Nullable<AnimationRange>[];
  26851. /**
  26852. * Will start the animation sequence
  26853. * @param name defines the range frames for animation sequence
  26854. * @param loop defines if the animation should loop (false by default)
  26855. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26856. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26857. * @returns the object created for this animation. If range does not exist, it will return null
  26858. */
  26859. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26860. /**
  26861. * Serialize animation ranges into a JSON compatible object
  26862. * @returns serialization object
  26863. */
  26864. serializeAnimationRanges(): any;
  26865. /**
  26866. * Computes the world matrix of the node
  26867. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26868. * @returns the world matrix
  26869. */
  26870. computeWorldMatrix(force?: boolean): Matrix;
  26871. /**
  26872. * Releases resources associated with this node.
  26873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26875. */
  26876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26877. /**
  26878. * Parse animation range data from a serialization object and store them into a given node
  26879. * @param node defines where to store the animation ranges
  26880. * @param parsedNode defines the serialization object to read data from
  26881. * @param scene defines the hosting scene
  26882. */
  26883. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26884. /**
  26885. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26886. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26887. * @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
  26888. * @returns the new bounding vectors
  26889. */
  26890. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26891. min: Vector3;
  26892. max: Vector3;
  26893. };
  26894. }
  26895. }
  26896. declare module BABYLON {
  26897. /**
  26898. * @hidden
  26899. */
  26900. export class _IAnimationState {
  26901. key: number;
  26902. repeatCount: number;
  26903. workValue?: any;
  26904. loopMode?: number;
  26905. offsetValue?: any;
  26906. highLimitValue?: any;
  26907. }
  26908. /**
  26909. * Class used to store any kind of animation
  26910. */
  26911. export class Animation {
  26912. /**Name of the animation */
  26913. name: string;
  26914. /**Property to animate */
  26915. targetProperty: string;
  26916. /**The frames per second of the animation */
  26917. framePerSecond: number;
  26918. /**The data type of the animation */
  26919. dataType: number;
  26920. /**The loop mode of the animation */
  26921. loopMode?: number | undefined;
  26922. /**Specifies if blending should be enabled */
  26923. enableBlending?: boolean | undefined;
  26924. /**
  26925. * Use matrix interpolation instead of using direct key value when animating matrices
  26926. */
  26927. static AllowMatricesInterpolation: boolean;
  26928. /**
  26929. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26930. */
  26931. static AllowMatrixDecomposeForInterpolation: boolean;
  26932. /**
  26933. * Stores the key frames of the animation
  26934. */
  26935. private _keys;
  26936. /**
  26937. * Stores the easing function of the animation
  26938. */
  26939. private _easingFunction;
  26940. /**
  26941. * @hidden Internal use only
  26942. */
  26943. _runtimeAnimations: RuntimeAnimation[];
  26944. /**
  26945. * The set of event that will be linked to this animation
  26946. */
  26947. private _events;
  26948. /**
  26949. * Stores an array of target property paths
  26950. */
  26951. targetPropertyPath: string[];
  26952. /**
  26953. * Stores the blending speed of the animation
  26954. */
  26955. blendingSpeed: number;
  26956. /**
  26957. * Stores the animation ranges for the animation
  26958. */
  26959. private _ranges;
  26960. /**
  26961. * @hidden Internal use
  26962. */
  26963. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26964. /**
  26965. * Sets up an animation
  26966. * @param property The property to animate
  26967. * @param animationType The animation type to apply
  26968. * @param framePerSecond The frames per second of the animation
  26969. * @param easingFunction The easing function used in the animation
  26970. * @returns The created animation
  26971. */
  26972. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26973. /**
  26974. * Create and start an animation on a node
  26975. * @param name defines the name of the global animation that will be run on all nodes
  26976. * @param node defines the root node where the animation will take place
  26977. * @param targetProperty defines property to animate
  26978. * @param framePerSecond defines the number of frame per second yo use
  26979. * @param totalFrame defines the number of frames in total
  26980. * @param from defines the initial value
  26981. * @param to defines the final value
  26982. * @param loopMode defines which loop mode you want to use (off by default)
  26983. * @param easingFunction defines the easing function to use (linear by default)
  26984. * @param onAnimationEnd defines the callback to call when animation end
  26985. * @returns the animatable created for this animation
  26986. */
  26987. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26988. /**
  26989. * Create and start an animation on a node and its descendants
  26990. * @param name defines the name of the global animation that will be run on all nodes
  26991. * @param node defines the root node where the animation will take place
  26992. * @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
  26993. * @param targetProperty defines property to animate
  26994. * @param framePerSecond defines the number of frame per second to use
  26995. * @param totalFrame defines the number of frames in total
  26996. * @param from defines the initial value
  26997. * @param to defines the final value
  26998. * @param loopMode defines which loop mode you want to use (off by default)
  26999. * @param easingFunction defines the easing function to use (linear by default)
  27000. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27001. * @returns the list of animatables created for all nodes
  27002. * @example https://www.babylonjs-playground.com/#MH0VLI
  27003. */
  27004. 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[]>;
  27005. /**
  27006. * Creates a new animation, merges it with the existing animations and starts it
  27007. * @param name Name of the animation
  27008. * @param node Node which contains the scene that begins the animations
  27009. * @param targetProperty Specifies which property to animate
  27010. * @param framePerSecond The frames per second of the animation
  27011. * @param totalFrame The total number of frames
  27012. * @param from The frame at the beginning of the animation
  27013. * @param to The frame at the end of the animation
  27014. * @param loopMode Specifies the loop mode of the animation
  27015. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27016. * @param onAnimationEnd Callback to run once the animation is complete
  27017. * @returns Nullable animation
  27018. */
  27019. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27020. /**
  27021. * Transition property of an host to the target Value
  27022. * @param property The property to transition
  27023. * @param targetValue The target Value of the property
  27024. * @param host The object where the property to animate belongs
  27025. * @param scene Scene used to run the animation
  27026. * @param frameRate Framerate (in frame/s) to use
  27027. * @param transition The transition type we want to use
  27028. * @param duration The duration of the animation, in milliseconds
  27029. * @param onAnimationEnd Callback trigger at the end of the animation
  27030. * @returns Nullable animation
  27031. */
  27032. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27033. /**
  27034. * Return the array of runtime animations currently using this animation
  27035. */
  27036. readonly runtimeAnimations: RuntimeAnimation[];
  27037. /**
  27038. * Specifies if any of the runtime animations are currently running
  27039. */
  27040. readonly hasRunningRuntimeAnimations: boolean;
  27041. /**
  27042. * Initializes the animation
  27043. * @param name Name of the animation
  27044. * @param targetProperty Property to animate
  27045. * @param framePerSecond The frames per second of the animation
  27046. * @param dataType The data type of the animation
  27047. * @param loopMode The loop mode of the animation
  27048. * @param enableBlending Specifies if blending should be enabled
  27049. */
  27050. constructor(
  27051. /**Name of the animation */
  27052. name: string,
  27053. /**Property to animate */
  27054. targetProperty: string,
  27055. /**The frames per second of the animation */
  27056. framePerSecond: number,
  27057. /**The data type of the animation */
  27058. dataType: number,
  27059. /**The loop mode of the animation */
  27060. loopMode?: number | undefined,
  27061. /**Specifies if blending should be enabled */
  27062. enableBlending?: boolean | undefined);
  27063. /**
  27064. * Converts the animation to a string
  27065. * @param fullDetails support for multiple levels of logging within scene loading
  27066. * @returns String form of the animation
  27067. */
  27068. toString(fullDetails?: boolean): string;
  27069. /**
  27070. * Add an event to this animation
  27071. * @param event Event to add
  27072. */
  27073. addEvent(event: AnimationEvent): void;
  27074. /**
  27075. * Remove all events found at the given frame
  27076. * @param frame The frame to remove events from
  27077. */
  27078. removeEvents(frame: number): void;
  27079. /**
  27080. * Retrieves all the events from the animation
  27081. * @returns Events from the animation
  27082. */
  27083. getEvents(): AnimationEvent[];
  27084. /**
  27085. * Creates an animation range
  27086. * @param name Name of the animation range
  27087. * @param from Starting frame of the animation range
  27088. * @param to Ending frame of the animation
  27089. */
  27090. createRange(name: string, from: number, to: number): void;
  27091. /**
  27092. * Deletes an animation range by name
  27093. * @param name Name of the animation range to delete
  27094. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27095. */
  27096. deleteRange(name: string, deleteFrames?: boolean): void;
  27097. /**
  27098. * Gets the animation range by name, or null if not defined
  27099. * @param name Name of the animation range
  27100. * @returns Nullable animation range
  27101. */
  27102. getRange(name: string): Nullable<AnimationRange>;
  27103. /**
  27104. * Gets the key frames from the animation
  27105. * @returns The key frames of the animation
  27106. */
  27107. getKeys(): Array<IAnimationKey>;
  27108. /**
  27109. * Gets the highest frame rate of the animation
  27110. * @returns Highest frame rate of the animation
  27111. */
  27112. getHighestFrame(): number;
  27113. /**
  27114. * Gets the easing function of the animation
  27115. * @returns Easing function of the animation
  27116. */
  27117. getEasingFunction(): IEasingFunction;
  27118. /**
  27119. * Sets the easing function of the animation
  27120. * @param easingFunction A custom mathematical formula for animation
  27121. */
  27122. setEasingFunction(easingFunction: EasingFunction): void;
  27123. /**
  27124. * Interpolates a scalar linearly
  27125. * @param startValue Start value of the animation curve
  27126. * @param endValue End value of the animation curve
  27127. * @param gradient Scalar amount to interpolate
  27128. * @returns Interpolated scalar value
  27129. */
  27130. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27131. /**
  27132. * Interpolates a scalar cubically
  27133. * @param startValue Start value of the animation curve
  27134. * @param outTangent End tangent of the animation
  27135. * @param endValue End value of the animation curve
  27136. * @param inTangent Start tangent of the animation curve
  27137. * @param gradient Scalar amount to interpolate
  27138. * @returns Interpolated scalar value
  27139. */
  27140. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27141. /**
  27142. * Interpolates a quaternion using a spherical linear interpolation
  27143. * @param startValue Start value of the animation curve
  27144. * @param endValue End value of the animation curve
  27145. * @param gradient Scalar amount to interpolate
  27146. * @returns Interpolated quaternion value
  27147. */
  27148. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27149. /**
  27150. * Interpolates a quaternion cubically
  27151. * @param startValue Start value of the animation curve
  27152. * @param outTangent End tangent of the animation curve
  27153. * @param endValue End value of the animation curve
  27154. * @param inTangent Start tangent of the animation curve
  27155. * @param gradient Scalar amount to interpolate
  27156. * @returns Interpolated quaternion value
  27157. */
  27158. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27159. /**
  27160. * Interpolates a Vector3 linearl
  27161. * @param startValue Start value of the animation curve
  27162. * @param endValue End value of the animation curve
  27163. * @param gradient Scalar amount to interpolate
  27164. * @returns Interpolated scalar value
  27165. */
  27166. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27167. /**
  27168. * Interpolates a Vector3 cubically
  27169. * @param startValue Start value of the animation curve
  27170. * @param outTangent End tangent of the animation
  27171. * @param endValue End value of the animation curve
  27172. * @param inTangent Start tangent of the animation curve
  27173. * @param gradient Scalar amount to interpolate
  27174. * @returns InterpolatedVector3 value
  27175. */
  27176. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27177. /**
  27178. * Interpolates a Vector2 linearly
  27179. * @param startValue Start value of the animation curve
  27180. * @param endValue End value of the animation curve
  27181. * @param gradient Scalar amount to interpolate
  27182. * @returns Interpolated Vector2 value
  27183. */
  27184. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27185. /**
  27186. * Interpolates a Vector2 cubically
  27187. * @param startValue Start value of the animation curve
  27188. * @param outTangent End tangent of the animation
  27189. * @param endValue End value of the animation curve
  27190. * @param inTangent Start tangent of the animation curve
  27191. * @param gradient Scalar amount to interpolate
  27192. * @returns Interpolated Vector2 value
  27193. */
  27194. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27195. /**
  27196. * Interpolates a size linearly
  27197. * @param startValue Start value of the animation curve
  27198. * @param endValue End value of the animation curve
  27199. * @param gradient Scalar amount to interpolate
  27200. * @returns Interpolated Size value
  27201. */
  27202. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27203. /**
  27204. * Interpolates a Color3 linearly
  27205. * @param startValue Start value of the animation curve
  27206. * @param endValue End value of the animation curve
  27207. * @param gradient Scalar amount to interpolate
  27208. * @returns Interpolated Color3 value
  27209. */
  27210. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27211. /**
  27212. * @hidden Internal use only
  27213. */
  27214. _getKeyValue(value: any): any;
  27215. /**
  27216. * @hidden Internal use only
  27217. */
  27218. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27219. /**
  27220. * Defines the function to use to interpolate matrices
  27221. * @param startValue defines the start matrix
  27222. * @param endValue defines the end matrix
  27223. * @param gradient defines the gradient between both matrices
  27224. * @param result defines an optional target matrix where to store the interpolation
  27225. * @returns the interpolated matrix
  27226. */
  27227. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27228. /**
  27229. * Makes a copy of the animation
  27230. * @returns Cloned animation
  27231. */
  27232. clone(): Animation;
  27233. /**
  27234. * Sets the key frames of the animation
  27235. * @param values The animation key frames to set
  27236. */
  27237. setKeys(values: Array<IAnimationKey>): void;
  27238. /**
  27239. * Serializes the animation to an object
  27240. * @returns Serialized object
  27241. */
  27242. serialize(): any;
  27243. /**
  27244. * Float animation type
  27245. */
  27246. private static _ANIMATIONTYPE_FLOAT;
  27247. /**
  27248. * Vector3 animation type
  27249. */
  27250. private static _ANIMATIONTYPE_VECTOR3;
  27251. /**
  27252. * Quaternion animation type
  27253. */
  27254. private static _ANIMATIONTYPE_QUATERNION;
  27255. /**
  27256. * Matrix animation type
  27257. */
  27258. private static _ANIMATIONTYPE_MATRIX;
  27259. /**
  27260. * Color3 animation type
  27261. */
  27262. private static _ANIMATIONTYPE_COLOR3;
  27263. /**
  27264. * Vector2 animation type
  27265. */
  27266. private static _ANIMATIONTYPE_VECTOR2;
  27267. /**
  27268. * Size animation type
  27269. */
  27270. private static _ANIMATIONTYPE_SIZE;
  27271. /**
  27272. * Relative Loop Mode
  27273. */
  27274. private static _ANIMATIONLOOPMODE_RELATIVE;
  27275. /**
  27276. * Cycle Loop Mode
  27277. */
  27278. private static _ANIMATIONLOOPMODE_CYCLE;
  27279. /**
  27280. * Constant Loop Mode
  27281. */
  27282. private static _ANIMATIONLOOPMODE_CONSTANT;
  27283. /**
  27284. * Get the float animation type
  27285. */
  27286. static readonly ANIMATIONTYPE_FLOAT: number;
  27287. /**
  27288. * Get the Vector3 animation type
  27289. */
  27290. static readonly ANIMATIONTYPE_VECTOR3: number;
  27291. /**
  27292. * Get the Vector2 animation type
  27293. */
  27294. static readonly ANIMATIONTYPE_VECTOR2: number;
  27295. /**
  27296. * Get the Size animation type
  27297. */
  27298. static readonly ANIMATIONTYPE_SIZE: number;
  27299. /**
  27300. * Get the Quaternion animation type
  27301. */
  27302. static readonly ANIMATIONTYPE_QUATERNION: number;
  27303. /**
  27304. * Get the Matrix animation type
  27305. */
  27306. static readonly ANIMATIONTYPE_MATRIX: number;
  27307. /**
  27308. * Get the Color3 animation type
  27309. */
  27310. static readonly ANIMATIONTYPE_COLOR3: number;
  27311. /**
  27312. * Get the Relative Loop Mode
  27313. */
  27314. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27315. /**
  27316. * Get the Cycle Loop Mode
  27317. */
  27318. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27319. /**
  27320. * Get the Constant Loop Mode
  27321. */
  27322. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27323. /** @hidden */
  27324. static _UniversalLerp(left: any, right: any, amount: number): any;
  27325. /**
  27326. * Parses an animation object and creates an animation
  27327. * @param parsedAnimation Parsed animation object
  27328. * @returns Animation object
  27329. */
  27330. static Parse(parsedAnimation: any): Animation;
  27331. /**
  27332. * Appends the serialized animations from the source animations
  27333. * @param source Source containing the animations
  27334. * @param destination Target to store the animations
  27335. */
  27336. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27337. }
  27338. }
  27339. declare module BABYLON {
  27340. /**
  27341. * Interface containing an array of animations
  27342. */
  27343. export interface IAnimatable {
  27344. /**
  27345. * Array of animations
  27346. */
  27347. animations: Nullable<Array<Animation>>;
  27348. }
  27349. }
  27350. declare module BABYLON {
  27351. /**
  27352. * This represents all the required information to add a fresnel effect on a material:
  27353. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27354. */
  27355. export class FresnelParameters {
  27356. private _isEnabled;
  27357. /**
  27358. * Define if the fresnel effect is enable or not.
  27359. */
  27360. isEnabled: boolean;
  27361. /**
  27362. * Define the color used on edges (grazing angle)
  27363. */
  27364. leftColor: Color3;
  27365. /**
  27366. * Define the color used on center
  27367. */
  27368. rightColor: Color3;
  27369. /**
  27370. * Define bias applied to computed fresnel term
  27371. */
  27372. bias: number;
  27373. /**
  27374. * Defined the power exponent applied to fresnel term
  27375. */
  27376. power: number;
  27377. /**
  27378. * Clones the current fresnel and its valuues
  27379. * @returns a clone fresnel configuration
  27380. */
  27381. clone(): FresnelParameters;
  27382. /**
  27383. * Serializes the current fresnel parameters to a JSON representation.
  27384. * @return the JSON serialization
  27385. */
  27386. serialize(): any;
  27387. /**
  27388. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27389. * @param parsedFresnelParameters Define the JSON representation
  27390. * @returns the parsed parameters
  27391. */
  27392. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27393. }
  27394. }
  27395. declare module BABYLON {
  27396. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27397. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27398. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27399. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27400. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27401. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27402. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27403. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27404. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27405. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27406. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27407. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27408. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27409. /**
  27410. * Decorator used to define property that can be serialized as reference to a camera
  27411. * @param sourceName defines the name of the property to decorate
  27412. */
  27413. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27414. /**
  27415. * Class used to help serialization objects
  27416. */
  27417. export class SerializationHelper {
  27418. /** @hidden */
  27419. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27420. /** @hidden */
  27421. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27422. /** @hidden */
  27423. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27424. /** @hidden */
  27425. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27426. /**
  27427. * Appends the serialized animations from the source animations
  27428. * @param source Source containing the animations
  27429. * @param destination Target to store the animations
  27430. */
  27431. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27432. /**
  27433. * Static function used to serialized a specific entity
  27434. * @param entity defines the entity to serialize
  27435. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27436. * @returns a JSON compatible object representing the serialization of the entity
  27437. */
  27438. static Serialize<T>(entity: T, serializationObject?: any): any;
  27439. /**
  27440. * Creates a new entity from a serialization data object
  27441. * @param creationFunction defines a function used to instanciated the new entity
  27442. * @param source defines the source serialization data
  27443. * @param scene defines the hosting scene
  27444. * @param rootUrl defines the root url for resources
  27445. * @returns a new entity
  27446. */
  27447. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27448. /**
  27449. * Clones an object
  27450. * @param creationFunction defines the function used to instanciate the new object
  27451. * @param source defines the source object
  27452. * @returns the cloned object
  27453. */
  27454. static Clone<T>(creationFunction: () => T, source: T): T;
  27455. /**
  27456. * Instanciates a new object based on a source one (some data will be shared between both object)
  27457. * @param creationFunction defines the function used to instanciate the new object
  27458. * @param source defines the source object
  27459. * @returns the new object
  27460. */
  27461. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27462. }
  27463. }
  27464. declare module BABYLON {
  27465. /**
  27466. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27467. */
  27468. export interface CubeMapInfo {
  27469. /**
  27470. * The pixel array for the front face.
  27471. * This is stored in format, left to right, up to down format.
  27472. */
  27473. front: Nullable<ArrayBufferView>;
  27474. /**
  27475. * The pixel array for the back face.
  27476. * This is stored in format, left to right, up to down format.
  27477. */
  27478. back: Nullable<ArrayBufferView>;
  27479. /**
  27480. * The pixel array for the left face.
  27481. * This is stored in format, left to right, up to down format.
  27482. */
  27483. left: Nullable<ArrayBufferView>;
  27484. /**
  27485. * The pixel array for the right face.
  27486. * This is stored in format, left to right, up to down format.
  27487. */
  27488. right: Nullable<ArrayBufferView>;
  27489. /**
  27490. * The pixel array for the up face.
  27491. * This is stored in format, left to right, up to down format.
  27492. */
  27493. up: Nullable<ArrayBufferView>;
  27494. /**
  27495. * The pixel array for the down face.
  27496. * This is stored in format, left to right, up to down format.
  27497. */
  27498. down: Nullable<ArrayBufferView>;
  27499. /**
  27500. * The size of the cubemap stored.
  27501. *
  27502. * Each faces will be size * size pixels.
  27503. */
  27504. size: number;
  27505. /**
  27506. * The format of the texture.
  27507. *
  27508. * RGBA, RGB.
  27509. */
  27510. format: number;
  27511. /**
  27512. * The type of the texture data.
  27513. *
  27514. * UNSIGNED_INT, FLOAT.
  27515. */
  27516. type: number;
  27517. /**
  27518. * Specifies whether the texture is in gamma space.
  27519. */
  27520. gammaSpace: boolean;
  27521. }
  27522. /**
  27523. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27524. */
  27525. export class PanoramaToCubeMapTools {
  27526. private static FACE_FRONT;
  27527. private static FACE_BACK;
  27528. private static FACE_RIGHT;
  27529. private static FACE_LEFT;
  27530. private static FACE_DOWN;
  27531. private static FACE_UP;
  27532. /**
  27533. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27534. *
  27535. * @param float32Array The source data.
  27536. * @param inputWidth The width of the input panorama.
  27537. * @param inputHeight The height of the input panorama.
  27538. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27539. * @return The cubemap data
  27540. */
  27541. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27542. private static CreateCubemapTexture;
  27543. private static CalcProjectionSpherical;
  27544. }
  27545. }
  27546. declare module BABYLON {
  27547. /**
  27548. * Helper class dealing with the extraction of spherical polynomial dataArray
  27549. * from a cube map.
  27550. */
  27551. export class CubeMapToSphericalPolynomialTools {
  27552. private static FileFaces;
  27553. /**
  27554. * Converts a texture to the according Spherical Polynomial data.
  27555. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27556. *
  27557. * @param texture The texture to extract the information from.
  27558. * @return The Spherical Polynomial data.
  27559. */
  27560. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27561. /**
  27562. * Converts a cubemap to the according Spherical Polynomial data.
  27563. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27564. *
  27565. * @param cubeInfo The Cube map to extract the information from.
  27566. * @return The Spherical Polynomial data.
  27567. */
  27568. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27569. }
  27570. }
  27571. declare module BABYLON {
  27572. /**
  27573. * Class used to manipulate GUIDs
  27574. */
  27575. export class GUID {
  27576. /**
  27577. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27578. * Be aware Math.random() could cause collisions, but:
  27579. * "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"
  27580. * @returns a pseudo random id
  27581. */
  27582. static RandomId(): string;
  27583. }
  27584. }
  27585. declare module BABYLON {
  27586. /**
  27587. * Base class of all the textures in babylon.
  27588. * It groups all the common properties the materials, post process, lights... might need
  27589. * in order to make a correct use of the texture.
  27590. */
  27591. export class BaseTexture implements IAnimatable {
  27592. /**
  27593. * Default anisotropic filtering level for the application.
  27594. * It is set to 4 as a good tradeoff between perf and quality.
  27595. */
  27596. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27597. /**
  27598. * Gets or sets the unique id of the texture
  27599. */
  27600. uniqueId: number;
  27601. /**
  27602. * Define the name of the texture.
  27603. */
  27604. name: string;
  27605. /**
  27606. * Gets or sets an object used to store user defined information.
  27607. */
  27608. metadata: any;
  27609. /**
  27610. * For internal use only. Please do not use.
  27611. */
  27612. reservedDataStore: any;
  27613. private _hasAlpha;
  27614. /**
  27615. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27616. */
  27617. hasAlpha: boolean;
  27618. /**
  27619. * Defines if the alpha value should be determined via the rgb values.
  27620. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27621. */
  27622. getAlphaFromRGB: boolean;
  27623. /**
  27624. * Intensity or strength of the texture.
  27625. * It is commonly used by materials to fine tune the intensity of the texture
  27626. */
  27627. level: number;
  27628. /**
  27629. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27630. * This is part of the texture as textures usually maps to one uv set.
  27631. */
  27632. coordinatesIndex: number;
  27633. private _coordinatesMode;
  27634. /**
  27635. * How a texture is mapped.
  27636. *
  27637. * | Value | Type | Description |
  27638. * | ----- | ----------------------------------- | ----------- |
  27639. * | 0 | EXPLICIT_MODE | |
  27640. * | 1 | SPHERICAL_MODE | |
  27641. * | 2 | PLANAR_MODE | |
  27642. * | 3 | CUBIC_MODE | |
  27643. * | 4 | PROJECTION_MODE | |
  27644. * | 5 | SKYBOX_MODE | |
  27645. * | 6 | INVCUBIC_MODE | |
  27646. * | 7 | EQUIRECTANGULAR_MODE | |
  27647. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27648. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27649. */
  27650. coordinatesMode: number;
  27651. /**
  27652. * | Value | Type | Description |
  27653. * | ----- | ------------------ | ----------- |
  27654. * | 0 | CLAMP_ADDRESSMODE | |
  27655. * | 1 | WRAP_ADDRESSMODE | |
  27656. * | 2 | MIRROR_ADDRESSMODE | |
  27657. */
  27658. wrapU: number;
  27659. /**
  27660. * | Value | Type | Description |
  27661. * | ----- | ------------------ | ----------- |
  27662. * | 0 | CLAMP_ADDRESSMODE | |
  27663. * | 1 | WRAP_ADDRESSMODE | |
  27664. * | 2 | MIRROR_ADDRESSMODE | |
  27665. */
  27666. wrapV: number;
  27667. /**
  27668. * | Value | Type | Description |
  27669. * | ----- | ------------------ | ----------- |
  27670. * | 0 | CLAMP_ADDRESSMODE | |
  27671. * | 1 | WRAP_ADDRESSMODE | |
  27672. * | 2 | MIRROR_ADDRESSMODE | |
  27673. */
  27674. wrapR: number;
  27675. /**
  27676. * With compliant hardware and browser (supporting anisotropic filtering)
  27677. * this defines the level of anisotropic filtering in the texture.
  27678. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27679. */
  27680. anisotropicFilteringLevel: number;
  27681. /**
  27682. * Define if the texture is a cube texture or if false a 2d texture.
  27683. */
  27684. isCube: boolean;
  27685. /**
  27686. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27687. */
  27688. is3D: boolean;
  27689. /**
  27690. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27691. * HDR texture are usually stored in linear space.
  27692. * This only impacts the PBR and Background materials
  27693. */
  27694. gammaSpace: boolean;
  27695. /**
  27696. * Gets or sets whether or not the texture contains RGBD data.
  27697. */
  27698. isRGBD: boolean;
  27699. /**
  27700. * Is Z inverted in the texture (useful in a cube texture).
  27701. */
  27702. invertZ: boolean;
  27703. /**
  27704. * Are mip maps generated for this texture or not.
  27705. */
  27706. readonly noMipmap: boolean;
  27707. /**
  27708. * @hidden
  27709. */
  27710. lodLevelInAlpha: boolean;
  27711. /**
  27712. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27713. */
  27714. lodGenerationOffset: number;
  27715. /**
  27716. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27717. */
  27718. lodGenerationScale: number;
  27719. /**
  27720. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27721. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27722. * average roughness values.
  27723. */
  27724. linearSpecularLOD: boolean;
  27725. /**
  27726. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27727. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27728. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27729. */
  27730. irradianceTexture: Nullable<BaseTexture>;
  27731. /**
  27732. * Define if the texture is a render target.
  27733. */
  27734. isRenderTarget: boolean;
  27735. /**
  27736. * Define the unique id of the texture in the scene.
  27737. */
  27738. readonly uid: string;
  27739. /**
  27740. * Return a string representation of the texture.
  27741. * @returns the texture as a string
  27742. */
  27743. toString(): string;
  27744. /**
  27745. * Get the class name of the texture.
  27746. * @returns "BaseTexture"
  27747. */
  27748. getClassName(): string;
  27749. /**
  27750. * Define the list of animation attached to the texture.
  27751. */
  27752. animations: Animation[];
  27753. /**
  27754. * An event triggered when the texture is disposed.
  27755. */
  27756. onDisposeObservable: Observable<BaseTexture>;
  27757. private _onDisposeObserver;
  27758. /**
  27759. * Callback triggered when the texture has been disposed.
  27760. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27761. */
  27762. onDispose: () => void;
  27763. /**
  27764. * Define the current state of the loading sequence when in delayed load mode.
  27765. */
  27766. delayLoadState: number;
  27767. private _scene;
  27768. /** @hidden */
  27769. _texture: Nullable<InternalTexture>;
  27770. private _uid;
  27771. /**
  27772. * Define if the texture is preventinga material to render or not.
  27773. * If not and the texture is not ready, the engine will use a default black texture instead.
  27774. */
  27775. readonly isBlocking: boolean;
  27776. /**
  27777. * Instantiates a new BaseTexture.
  27778. * Base class of all the textures in babylon.
  27779. * It groups all the common properties the materials, post process, lights... might need
  27780. * in order to make a correct use of the texture.
  27781. * @param scene Define the scene the texture blongs to
  27782. */
  27783. constructor(scene: Nullable<Scene>);
  27784. /**
  27785. * Get the scene the texture belongs to.
  27786. * @returns the scene or null if undefined
  27787. */
  27788. getScene(): Nullable<Scene>;
  27789. /**
  27790. * Get the texture transform matrix used to offset tile the texture for istance.
  27791. * @returns the transformation matrix
  27792. */
  27793. getTextureMatrix(): Matrix;
  27794. /**
  27795. * Get the texture reflection matrix used to rotate/transform the reflection.
  27796. * @returns the reflection matrix
  27797. */
  27798. getReflectionTextureMatrix(): Matrix;
  27799. /**
  27800. * Get the underlying lower level texture from Babylon.
  27801. * @returns the insternal texture
  27802. */
  27803. getInternalTexture(): Nullable<InternalTexture>;
  27804. /**
  27805. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27806. * @returns true if ready or not blocking
  27807. */
  27808. isReadyOrNotBlocking(): boolean;
  27809. /**
  27810. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27811. * @returns true if fully ready
  27812. */
  27813. isReady(): boolean;
  27814. private _cachedSize;
  27815. /**
  27816. * Get the size of the texture.
  27817. * @returns the texture size.
  27818. */
  27819. getSize(): ISize;
  27820. /**
  27821. * Get the base size of the texture.
  27822. * It can be different from the size if the texture has been resized for POT for instance
  27823. * @returns the base size
  27824. */
  27825. getBaseSize(): ISize;
  27826. /**
  27827. * Update the sampling mode of the texture.
  27828. * Default is Trilinear mode.
  27829. *
  27830. * | Value | Type | Description |
  27831. * | ----- | ------------------ | ----------- |
  27832. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27833. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27834. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27835. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27836. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27837. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27838. * | 7 | NEAREST_LINEAR | |
  27839. * | 8 | NEAREST_NEAREST | |
  27840. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27841. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27842. * | 11 | LINEAR_LINEAR | |
  27843. * | 12 | LINEAR_NEAREST | |
  27844. *
  27845. * > _mag_: magnification filter (close to the viewer)
  27846. * > _min_: minification filter (far from the viewer)
  27847. * > _mip_: filter used between mip map levels
  27848. *@param samplingMode Define the new sampling mode of the texture
  27849. */
  27850. updateSamplingMode(samplingMode: number): void;
  27851. /**
  27852. * Scales the texture if is `canRescale()`
  27853. * @param ratio the resize factor we want to use to rescale
  27854. */
  27855. scale(ratio: number): void;
  27856. /**
  27857. * Get if the texture can rescale.
  27858. */
  27859. readonly canRescale: boolean;
  27860. /** @hidden */
  27861. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27862. /** @hidden */
  27863. _rebuild(): void;
  27864. /**
  27865. * Triggers the load sequence in delayed load mode.
  27866. */
  27867. delayLoad(): void;
  27868. /**
  27869. * Clones the texture.
  27870. * @returns the cloned texture
  27871. */
  27872. clone(): Nullable<BaseTexture>;
  27873. /**
  27874. * Get the texture underlying type (INT, FLOAT...)
  27875. */
  27876. readonly textureType: number;
  27877. /**
  27878. * Get the texture underlying format (RGB, RGBA...)
  27879. */
  27880. readonly textureFormat: number;
  27881. /**
  27882. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27883. * This will returns an RGBA array buffer containing either in values (0-255) or
  27884. * float values (0-1) depending of the underlying buffer type.
  27885. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27886. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27887. * @param buffer defines a user defined buffer to fill with data (can be null)
  27888. * @returns The Array buffer containing the pixels data.
  27889. */
  27890. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27891. /**
  27892. * Release and destroy the underlying lower level texture aka internalTexture.
  27893. */
  27894. releaseInternalTexture(): void;
  27895. /**
  27896. * Get the polynomial representation of the texture data.
  27897. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27898. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27899. */
  27900. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27901. /** @hidden */
  27902. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27903. /** @hidden */
  27904. readonly _lodTextureMid: Nullable<BaseTexture>;
  27905. /** @hidden */
  27906. readonly _lodTextureLow: Nullable<BaseTexture>;
  27907. /**
  27908. * Dispose the texture and release its associated resources.
  27909. */
  27910. dispose(): void;
  27911. /**
  27912. * Serialize the texture into a JSON representation that can be parsed later on.
  27913. * @returns the JSON representation of the texture
  27914. */
  27915. serialize(): any;
  27916. /**
  27917. * Helper function to be called back once a list of texture contains only ready textures.
  27918. * @param textures Define the list of textures to wait for
  27919. * @param callback Define the callback triggered once the entire list will be ready
  27920. */
  27921. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27922. }
  27923. }
  27924. declare module BABYLON {
  27925. /**
  27926. * Class used to store data associated with WebGL texture data for the engine
  27927. * This class should not be used directly
  27928. */
  27929. export class InternalTexture {
  27930. /** @hidden */
  27931. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27932. /**
  27933. * The source of the texture data is unknown
  27934. */
  27935. static DATASOURCE_UNKNOWN: number;
  27936. /**
  27937. * Texture data comes from an URL
  27938. */
  27939. static DATASOURCE_URL: number;
  27940. /**
  27941. * Texture data is only used for temporary storage
  27942. */
  27943. static DATASOURCE_TEMP: number;
  27944. /**
  27945. * Texture data comes from raw data (ArrayBuffer)
  27946. */
  27947. static DATASOURCE_RAW: number;
  27948. /**
  27949. * Texture content is dynamic (video or dynamic texture)
  27950. */
  27951. static DATASOURCE_DYNAMIC: number;
  27952. /**
  27953. * Texture content is generated by rendering to it
  27954. */
  27955. static DATASOURCE_RENDERTARGET: number;
  27956. /**
  27957. * Texture content is part of a multi render target process
  27958. */
  27959. static DATASOURCE_MULTIRENDERTARGET: number;
  27960. /**
  27961. * Texture data comes from a cube data file
  27962. */
  27963. static DATASOURCE_CUBE: number;
  27964. /**
  27965. * Texture data comes from a raw cube data
  27966. */
  27967. static DATASOURCE_CUBERAW: number;
  27968. /**
  27969. * Texture data come from a prefiltered cube data file
  27970. */
  27971. static DATASOURCE_CUBEPREFILTERED: number;
  27972. /**
  27973. * Texture content is raw 3D data
  27974. */
  27975. static DATASOURCE_RAW3D: number;
  27976. /**
  27977. * Texture content is a depth texture
  27978. */
  27979. static DATASOURCE_DEPTHTEXTURE: number;
  27980. /**
  27981. * Texture data comes from a raw cube data encoded with RGBD
  27982. */
  27983. static DATASOURCE_CUBERAW_RGBD: number;
  27984. /**
  27985. * Defines if the texture is ready
  27986. */
  27987. isReady: boolean;
  27988. /**
  27989. * Defines if the texture is a cube texture
  27990. */
  27991. isCube: boolean;
  27992. /**
  27993. * Defines if the texture contains 3D data
  27994. */
  27995. is3D: boolean;
  27996. /**
  27997. * Defines if the texture contains multiview data
  27998. */
  27999. isMultiview: boolean;
  28000. /**
  28001. * Gets the URL used to load this texture
  28002. */
  28003. url: string;
  28004. /**
  28005. * Gets the sampling mode of the texture
  28006. */
  28007. samplingMode: number;
  28008. /**
  28009. * Gets a boolean indicating if the texture needs mipmaps generation
  28010. */
  28011. generateMipMaps: boolean;
  28012. /**
  28013. * Gets the number of samples used by the texture (WebGL2+ only)
  28014. */
  28015. samples: number;
  28016. /**
  28017. * Gets the type of the texture (int, float...)
  28018. */
  28019. type: number;
  28020. /**
  28021. * Gets the format of the texture (RGB, RGBA...)
  28022. */
  28023. format: number;
  28024. /**
  28025. * Observable called when the texture is loaded
  28026. */
  28027. onLoadedObservable: Observable<InternalTexture>;
  28028. /**
  28029. * Gets the width of the texture
  28030. */
  28031. width: number;
  28032. /**
  28033. * Gets the height of the texture
  28034. */
  28035. height: number;
  28036. /**
  28037. * Gets the depth of the texture
  28038. */
  28039. depth: number;
  28040. /**
  28041. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28042. */
  28043. baseWidth: number;
  28044. /**
  28045. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28046. */
  28047. baseHeight: number;
  28048. /**
  28049. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28050. */
  28051. baseDepth: number;
  28052. /**
  28053. * Gets a boolean indicating if the texture is inverted on Y axis
  28054. */
  28055. invertY: boolean;
  28056. /** @hidden */
  28057. _invertVScale: boolean;
  28058. /** @hidden */
  28059. _associatedChannel: number;
  28060. /** @hidden */
  28061. _dataSource: number;
  28062. /** @hidden */
  28063. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28064. /** @hidden */
  28065. _bufferView: Nullable<ArrayBufferView>;
  28066. /** @hidden */
  28067. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28068. /** @hidden */
  28069. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28070. /** @hidden */
  28071. _size: number;
  28072. /** @hidden */
  28073. _extension: string;
  28074. /** @hidden */
  28075. _files: Nullable<string[]>;
  28076. /** @hidden */
  28077. _workingCanvas: Nullable<HTMLCanvasElement>;
  28078. /** @hidden */
  28079. _workingContext: Nullable<CanvasRenderingContext2D>;
  28080. /** @hidden */
  28081. _framebuffer: Nullable<WebGLFramebuffer>;
  28082. /** @hidden */
  28083. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28084. /** @hidden */
  28085. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28086. /** @hidden */
  28087. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28088. /** @hidden */
  28089. _attachments: Nullable<number[]>;
  28090. /** @hidden */
  28091. _cachedCoordinatesMode: Nullable<number>;
  28092. /** @hidden */
  28093. _cachedWrapU: Nullable<number>;
  28094. /** @hidden */
  28095. _cachedWrapV: Nullable<number>;
  28096. /** @hidden */
  28097. _cachedWrapR: Nullable<number>;
  28098. /** @hidden */
  28099. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28100. /** @hidden */
  28101. _isDisabled: boolean;
  28102. /** @hidden */
  28103. _compression: Nullable<string>;
  28104. /** @hidden */
  28105. _generateStencilBuffer: boolean;
  28106. /** @hidden */
  28107. _generateDepthBuffer: boolean;
  28108. /** @hidden */
  28109. _comparisonFunction: number;
  28110. /** @hidden */
  28111. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28112. /** @hidden */
  28113. _lodGenerationScale: number;
  28114. /** @hidden */
  28115. _lodGenerationOffset: number;
  28116. /** @hidden */
  28117. _colorTextureArray: Nullable<WebGLTexture>;
  28118. /** @hidden */
  28119. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28120. /** @hidden */
  28121. _lodTextureHigh: Nullable<BaseTexture>;
  28122. /** @hidden */
  28123. _lodTextureMid: Nullable<BaseTexture>;
  28124. /** @hidden */
  28125. _lodTextureLow: Nullable<BaseTexture>;
  28126. /** @hidden */
  28127. _isRGBD: boolean;
  28128. /** @hidden */
  28129. _linearSpecularLOD: boolean;
  28130. /** @hidden */
  28131. _irradianceTexture: Nullable<BaseTexture>;
  28132. /** @hidden */
  28133. _webGLTexture: Nullable<WebGLTexture>;
  28134. /** @hidden */
  28135. _references: number;
  28136. private _engine;
  28137. /**
  28138. * Gets the Engine the texture belongs to.
  28139. * @returns The babylon engine
  28140. */
  28141. getEngine(): Engine;
  28142. /**
  28143. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28144. */
  28145. readonly dataSource: number;
  28146. /**
  28147. * Creates a new InternalTexture
  28148. * @param engine defines the engine to use
  28149. * @param dataSource defines the type of data that will be used
  28150. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28151. */
  28152. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28153. /**
  28154. * Increments the number of references (ie. the number of Texture that point to it)
  28155. */
  28156. incrementReferences(): void;
  28157. /**
  28158. * Change the size of the texture (not the size of the content)
  28159. * @param width defines the new width
  28160. * @param height defines the new height
  28161. * @param depth defines the new depth (1 by default)
  28162. */
  28163. updateSize(width: int, height: int, depth?: int): void;
  28164. /** @hidden */
  28165. _rebuild(): void;
  28166. /** @hidden */
  28167. _swapAndDie(target: InternalTexture): void;
  28168. /**
  28169. * Dispose the current allocated resources
  28170. */
  28171. dispose(): void;
  28172. }
  28173. }
  28174. declare module BABYLON {
  28175. /**
  28176. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28177. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28178. */
  28179. export class EffectFallbacks {
  28180. private _defines;
  28181. private _currentRank;
  28182. private _maxRank;
  28183. private _mesh;
  28184. /**
  28185. * Removes the fallback from the bound mesh.
  28186. */
  28187. unBindMesh(): void;
  28188. /**
  28189. * Adds a fallback on the specified property.
  28190. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28191. * @param define The name of the define in the shader
  28192. */
  28193. addFallback(rank: number, define: string): void;
  28194. /**
  28195. * Sets the mesh to use CPU skinning when needing to fallback.
  28196. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28197. * @param mesh The mesh to use the fallbacks.
  28198. */
  28199. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28200. /**
  28201. * Checks to see if more fallbacks are still availible.
  28202. */
  28203. readonly hasMoreFallbacks: boolean;
  28204. /**
  28205. * Removes the defines that should be removed when falling back.
  28206. * @param currentDefines defines the current define statements for the shader.
  28207. * @param effect defines the current effect we try to compile
  28208. * @returns The resulting defines with defines of the current rank removed.
  28209. */
  28210. reduce(currentDefines: string, effect: Effect): string;
  28211. }
  28212. /**
  28213. * Options to be used when creating an effect.
  28214. */
  28215. export class EffectCreationOptions {
  28216. /**
  28217. * Atrributes that will be used in the shader.
  28218. */
  28219. attributes: string[];
  28220. /**
  28221. * Uniform varible names that will be set in the shader.
  28222. */
  28223. uniformsNames: string[];
  28224. /**
  28225. * Uniform buffer varible names that will be set in the shader.
  28226. */
  28227. uniformBuffersNames: string[];
  28228. /**
  28229. * Sampler texture variable names that will be set in the shader.
  28230. */
  28231. samplers: string[];
  28232. /**
  28233. * Define statements that will be set in the shader.
  28234. */
  28235. defines: any;
  28236. /**
  28237. * Possible fallbacks for this effect to improve performance when needed.
  28238. */
  28239. fallbacks: Nullable<EffectFallbacks>;
  28240. /**
  28241. * Callback that will be called when the shader is compiled.
  28242. */
  28243. onCompiled: Nullable<(effect: Effect) => void>;
  28244. /**
  28245. * Callback that will be called if an error occurs during shader compilation.
  28246. */
  28247. onError: Nullable<(effect: Effect, errors: string) => void>;
  28248. /**
  28249. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28250. */
  28251. indexParameters: any;
  28252. /**
  28253. * Max number of lights that can be used in the shader.
  28254. */
  28255. maxSimultaneousLights: number;
  28256. /**
  28257. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28258. */
  28259. transformFeedbackVaryings: Nullable<string[]>;
  28260. }
  28261. /**
  28262. * Effect containing vertex and fragment shader that can be executed on an object.
  28263. */
  28264. export class Effect implements IDisposable {
  28265. /**
  28266. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28267. */
  28268. static ShadersRepository: string;
  28269. /**
  28270. * Name of the effect.
  28271. */
  28272. name: any;
  28273. /**
  28274. * String container all the define statements that should be set on the shader.
  28275. */
  28276. defines: string;
  28277. /**
  28278. * Callback that will be called when the shader is compiled.
  28279. */
  28280. onCompiled: Nullable<(effect: Effect) => void>;
  28281. /**
  28282. * Callback that will be called if an error occurs during shader compilation.
  28283. */
  28284. onError: Nullable<(effect: Effect, errors: string) => void>;
  28285. /**
  28286. * Callback that will be called when effect is bound.
  28287. */
  28288. onBind: Nullable<(effect: Effect) => void>;
  28289. /**
  28290. * Unique ID of the effect.
  28291. */
  28292. uniqueId: number;
  28293. /**
  28294. * Observable that will be called when the shader is compiled.
  28295. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28296. */
  28297. onCompileObservable: Observable<Effect>;
  28298. /**
  28299. * Observable that will be called if an error occurs during shader compilation.
  28300. */
  28301. onErrorObservable: Observable<Effect>;
  28302. /** @hidden */
  28303. _onBindObservable: Nullable<Observable<Effect>>;
  28304. /**
  28305. * Observable that will be called when effect is bound.
  28306. */
  28307. readonly onBindObservable: Observable<Effect>;
  28308. /** @hidden */
  28309. _bonesComputationForcedToCPU: boolean;
  28310. private static _uniqueIdSeed;
  28311. private _engine;
  28312. private _uniformBuffersNames;
  28313. private _uniformsNames;
  28314. private _samplerList;
  28315. private _samplers;
  28316. private _isReady;
  28317. private _compilationError;
  28318. private _attributesNames;
  28319. private _attributes;
  28320. private _uniforms;
  28321. /**
  28322. * Key for the effect.
  28323. * @hidden
  28324. */
  28325. _key: string;
  28326. private _indexParameters;
  28327. private _fallbacks;
  28328. private _vertexSourceCode;
  28329. private _fragmentSourceCode;
  28330. private _vertexSourceCodeOverride;
  28331. private _fragmentSourceCodeOverride;
  28332. private _transformFeedbackVaryings;
  28333. /**
  28334. * Compiled shader to webGL program.
  28335. * @hidden
  28336. */
  28337. _pipelineContext: Nullable<IPipelineContext>;
  28338. private _valueCache;
  28339. private static _baseCache;
  28340. /**
  28341. * Instantiates an effect.
  28342. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28343. * @param baseName Name of the effect.
  28344. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28345. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28346. * @param samplers List of sampler variables that will be passed to the shader.
  28347. * @param engine Engine to be used to render the effect
  28348. * @param defines Define statements to be added to the shader.
  28349. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28350. * @param onCompiled Callback that will be called when the shader is compiled.
  28351. * @param onError Callback that will be called if an error occurs during shader compilation.
  28352. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28353. */
  28354. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28355. private _useFinalCode;
  28356. /**
  28357. * Unique key for this effect
  28358. */
  28359. readonly key: string;
  28360. /**
  28361. * If the effect has been compiled and prepared.
  28362. * @returns if the effect is compiled and prepared.
  28363. */
  28364. isReady(): boolean;
  28365. private _isReadyInternal;
  28366. /**
  28367. * The engine the effect was initialized with.
  28368. * @returns the engine.
  28369. */
  28370. getEngine(): Engine;
  28371. /**
  28372. * The pipeline context for this effect
  28373. * @returns the associated pipeline context
  28374. */
  28375. getPipelineContext(): Nullable<IPipelineContext>;
  28376. /**
  28377. * The set of names of attribute variables for the shader.
  28378. * @returns An array of attribute names.
  28379. */
  28380. getAttributesNames(): string[];
  28381. /**
  28382. * Returns the attribute at the given index.
  28383. * @param index The index of the attribute.
  28384. * @returns The location of the attribute.
  28385. */
  28386. getAttributeLocation(index: number): number;
  28387. /**
  28388. * Returns the attribute based on the name of the variable.
  28389. * @param name of the attribute to look up.
  28390. * @returns the attribute location.
  28391. */
  28392. getAttributeLocationByName(name: string): number;
  28393. /**
  28394. * The number of attributes.
  28395. * @returns the numnber of attributes.
  28396. */
  28397. getAttributesCount(): number;
  28398. /**
  28399. * Gets the index of a uniform variable.
  28400. * @param uniformName of the uniform to look up.
  28401. * @returns the index.
  28402. */
  28403. getUniformIndex(uniformName: string): number;
  28404. /**
  28405. * Returns the attribute based on the name of the variable.
  28406. * @param uniformName of the uniform to look up.
  28407. * @returns the location of the uniform.
  28408. */
  28409. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28410. /**
  28411. * Returns an array of sampler variable names
  28412. * @returns The array of sampler variable neames.
  28413. */
  28414. getSamplers(): string[];
  28415. /**
  28416. * The error from the last compilation.
  28417. * @returns the error string.
  28418. */
  28419. getCompilationError(): string;
  28420. /**
  28421. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28422. * @param func The callback to be used.
  28423. */
  28424. executeWhenCompiled(func: (effect: Effect) => void): void;
  28425. private _checkIsReady;
  28426. /** @hidden */
  28427. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28428. /** @hidden */
  28429. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28430. /** @hidden */
  28431. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28432. /**
  28433. * Recompiles the webGL program
  28434. * @param vertexSourceCode The source code for the vertex shader.
  28435. * @param fragmentSourceCode The source code for the fragment shader.
  28436. * @param onCompiled Callback called when completed.
  28437. * @param onError Callback called on error.
  28438. * @hidden
  28439. */
  28440. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28441. /**
  28442. * Prepares the effect
  28443. * @hidden
  28444. */
  28445. _prepareEffect(): void;
  28446. private _processCompilationErrors;
  28447. /**
  28448. * Checks if the effect is supported. (Must be called after compilation)
  28449. */
  28450. readonly isSupported: boolean;
  28451. /**
  28452. * Binds a texture to the engine to be used as output of the shader.
  28453. * @param channel Name of the output variable.
  28454. * @param texture Texture to bind.
  28455. * @hidden
  28456. */
  28457. _bindTexture(channel: string, texture: InternalTexture): void;
  28458. /**
  28459. * Sets a texture on the engine to be used in the shader.
  28460. * @param channel Name of the sampler variable.
  28461. * @param texture Texture to set.
  28462. */
  28463. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28464. /**
  28465. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28466. * @param channel Name of the sampler variable.
  28467. * @param texture Texture to set.
  28468. */
  28469. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28470. /**
  28471. * Sets an array of textures on the engine to be used in the shader.
  28472. * @param channel Name of the variable.
  28473. * @param textures Textures to set.
  28474. */
  28475. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28476. /**
  28477. * 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)
  28478. * @param channel Name of the sampler variable.
  28479. * @param postProcess Post process to get the input texture from.
  28480. */
  28481. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28482. /**
  28483. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28484. * 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)
  28485. * @param channel Name of the sampler variable.
  28486. * @param postProcess Post process to get the output texture from.
  28487. */
  28488. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28489. /** @hidden */
  28490. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28491. /** @hidden */
  28492. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28493. /** @hidden */
  28494. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28495. /** @hidden */
  28496. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28497. /**
  28498. * Binds a buffer to a uniform.
  28499. * @param buffer Buffer to bind.
  28500. * @param name Name of the uniform variable to bind to.
  28501. */
  28502. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28503. /**
  28504. * Binds block to a uniform.
  28505. * @param blockName Name of the block to bind.
  28506. * @param index Index to bind.
  28507. */
  28508. bindUniformBlock(blockName: string, index: number): void;
  28509. /**
  28510. * Sets an interger value on a uniform variable.
  28511. * @param uniformName Name of the variable.
  28512. * @param value Value to be set.
  28513. * @returns this effect.
  28514. */
  28515. setInt(uniformName: string, value: number): Effect;
  28516. /**
  28517. * Sets an int array on a uniform variable.
  28518. * @param uniformName Name of the variable.
  28519. * @param array array to be set.
  28520. * @returns this effect.
  28521. */
  28522. setIntArray(uniformName: string, array: Int32Array): Effect;
  28523. /**
  28524. * 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)
  28525. * @param uniformName Name of the variable.
  28526. * @param array array to be set.
  28527. * @returns this effect.
  28528. */
  28529. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28530. /**
  28531. * 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)
  28532. * @param uniformName Name of the variable.
  28533. * @param array array to be set.
  28534. * @returns this effect.
  28535. */
  28536. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28537. /**
  28538. * 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)
  28539. * @param uniformName Name of the variable.
  28540. * @param array array to be set.
  28541. * @returns this effect.
  28542. */
  28543. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28544. /**
  28545. * Sets an float array on a uniform variable.
  28546. * @param uniformName Name of the variable.
  28547. * @param array array to be set.
  28548. * @returns this effect.
  28549. */
  28550. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28551. /**
  28552. * 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)
  28553. * @param uniformName Name of the variable.
  28554. * @param array array to be set.
  28555. * @returns this effect.
  28556. */
  28557. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28558. /**
  28559. * 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)
  28560. * @param uniformName Name of the variable.
  28561. * @param array array to be set.
  28562. * @returns this effect.
  28563. */
  28564. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28565. /**
  28566. * 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)
  28567. * @param uniformName Name of the variable.
  28568. * @param array array to be set.
  28569. * @returns this effect.
  28570. */
  28571. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28572. /**
  28573. * Sets an array on a uniform variable.
  28574. * @param uniformName Name of the variable.
  28575. * @param array array to be set.
  28576. * @returns this effect.
  28577. */
  28578. setArray(uniformName: string, array: number[]): Effect;
  28579. /**
  28580. * 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)
  28581. * @param uniformName Name of the variable.
  28582. * @param array array to be set.
  28583. * @returns this effect.
  28584. */
  28585. setArray2(uniformName: string, array: number[]): Effect;
  28586. /**
  28587. * 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)
  28588. * @param uniformName Name of the variable.
  28589. * @param array array to be set.
  28590. * @returns this effect.
  28591. */
  28592. setArray3(uniformName: string, array: number[]): Effect;
  28593. /**
  28594. * 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)
  28595. * @param uniformName Name of the variable.
  28596. * @param array array to be set.
  28597. * @returns this effect.
  28598. */
  28599. setArray4(uniformName: string, array: number[]): Effect;
  28600. /**
  28601. * Sets matrices on a uniform variable.
  28602. * @param uniformName Name of the variable.
  28603. * @param matrices matrices to be set.
  28604. * @returns this effect.
  28605. */
  28606. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28607. /**
  28608. * Sets matrix on a uniform variable.
  28609. * @param uniformName Name of the variable.
  28610. * @param matrix matrix to be set.
  28611. * @returns this effect.
  28612. */
  28613. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28614. /**
  28615. * 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)
  28616. * @param uniformName Name of the variable.
  28617. * @param matrix matrix to be set.
  28618. * @returns this effect.
  28619. */
  28620. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28621. /**
  28622. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28623. * @param uniformName Name of the variable.
  28624. * @param matrix matrix to be set.
  28625. * @returns this effect.
  28626. */
  28627. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28628. /**
  28629. * Sets a float on a uniform variable.
  28630. * @param uniformName Name of the variable.
  28631. * @param value value to be set.
  28632. * @returns this effect.
  28633. */
  28634. setFloat(uniformName: string, value: number): Effect;
  28635. /**
  28636. * Sets a boolean on a uniform variable.
  28637. * @param uniformName Name of the variable.
  28638. * @param bool value to be set.
  28639. * @returns this effect.
  28640. */
  28641. setBool(uniformName: string, bool: boolean): Effect;
  28642. /**
  28643. * Sets a Vector2 on a uniform variable.
  28644. * @param uniformName Name of the variable.
  28645. * @param vector2 vector2 to be set.
  28646. * @returns this effect.
  28647. */
  28648. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28649. /**
  28650. * Sets a float2 on a uniform variable.
  28651. * @param uniformName Name of the variable.
  28652. * @param x First float in float2.
  28653. * @param y Second float in float2.
  28654. * @returns this effect.
  28655. */
  28656. setFloat2(uniformName: string, x: number, y: number): Effect;
  28657. /**
  28658. * Sets a Vector3 on a uniform variable.
  28659. * @param uniformName Name of the variable.
  28660. * @param vector3 Value to be set.
  28661. * @returns this effect.
  28662. */
  28663. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28664. /**
  28665. * Sets a float3 on a uniform variable.
  28666. * @param uniformName Name of the variable.
  28667. * @param x First float in float3.
  28668. * @param y Second float in float3.
  28669. * @param z Third float in float3.
  28670. * @returns this effect.
  28671. */
  28672. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28673. /**
  28674. * Sets a Vector4 on a uniform variable.
  28675. * @param uniformName Name of the variable.
  28676. * @param vector4 Value to be set.
  28677. * @returns this effect.
  28678. */
  28679. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28680. /**
  28681. * Sets a float4 on a uniform variable.
  28682. * @param uniformName Name of the variable.
  28683. * @param x First float in float4.
  28684. * @param y Second float in float4.
  28685. * @param z Third float in float4.
  28686. * @param w Fourth float in float4.
  28687. * @returns this effect.
  28688. */
  28689. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28690. /**
  28691. * Sets a Color3 on a uniform variable.
  28692. * @param uniformName Name of the variable.
  28693. * @param color3 Value to be set.
  28694. * @returns this effect.
  28695. */
  28696. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28697. /**
  28698. * Sets a Color4 on a uniform variable.
  28699. * @param uniformName Name of the variable.
  28700. * @param color3 Value to be set.
  28701. * @param alpha Alpha value to be set.
  28702. * @returns this effect.
  28703. */
  28704. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28705. /**
  28706. * Sets a Color4 on a uniform variable
  28707. * @param uniformName defines the name of the variable
  28708. * @param color4 defines the value to be set
  28709. * @returns this effect.
  28710. */
  28711. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28712. /** Release all associated resources */
  28713. dispose(): void;
  28714. /**
  28715. * This function will add a new shader to the shader store
  28716. * @param name the name of the shader
  28717. * @param pixelShader optional pixel shader content
  28718. * @param vertexShader optional vertex shader content
  28719. */
  28720. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28721. /**
  28722. * Store of each shader (The can be looked up using effect.key)
  28723. */
  28724. static ShadersStore: {
  28725. [key: string]: string;
  28726. };
  28727. /**
  28728. * Store of each included file for a shader (The can be looked up using effect.key)
  28729. */
  28730. static IncludesShadersStore: {
  28731. [key: string]: string;
  28732. };
  28733. /**
  28734. * Resets the cache of effects.
  28735. */
  28736. static ResetCache(): void;
  28737. }
  28738. }
  28739. declare module BABYLON {
  28740. /**
  28741. * Uniform buffer objects.
  28742. *
  28743. * Handles blocks of uniform on the GPU.
  28744. *
  28745. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28746. *
  28747. * For more information, please refer to :
  28748. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28749. */
  28750. export class UniformBuffer {
  28751. private _engine;
  28752. private _buffer;
  28753. private _data;
  28754. private _bufferData;
  28755. private _dynamic?;
  28756. private _uniformLocations;
  28757. private _uniformSizes;
  28758. private _uniformLocationPointer;
  28759. private _needSync;
  28760. private _noUBO;
  28761. private _currentEffect;
  28762. private static _MAX_UNIFORM_SIZE;
  28763. private static _tempBuffer;
  28764. /**
  28765. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28766. * This is dynamic to allow compat with webgl 1 and 2.
  28767. * You will need to pass the name of the uniform as well as the value.
  28768. */
  28769. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28770. /**
  28771. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28772. * This is dynamic to allow compat with webgl 1 and 2.
  28773. * You will need to pass the name of the uniform as well as the value.
  28774. */
  28775. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28776. /**
  28777. * Lambda to Update a single float in a uniform buffer.
  28778. * This is dynamic to allow compat with webgl 1 and 2.
  28779. * You will need to pass the name of the uniform as well as the value.
  28780. */
  28781. updateFloat: (name: string, x: number) => void;
  28782. /**
  28783. * Lambda to Update a vec2 of float in a uniform buffer.
  28784. * This is dynamic to allow compat with webgl 1 and 2.
  28785. * You will need to pass the name of the uniform as well as the value.
  28786. */
  28787. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28788. /**
  28789. * Lambda to Update a vec3 of float in a uniform buffer.
  28790. * This is dynamic to allow compat with webgl 1 and 2.
  28791. * You will need to pass the name of the uniform as well as the value.
  28792. */
  28793. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28794. /**
  28795. * Lambda to Update a vec4 of float in a uniform buffer.
  28796. * This is dynamic to allow compat with webgl 1 and 2.
  28797. * You will need to pass the name of the uniform as well as the value.
  28798. */
  28799. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28800. /**
  28801. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28802. * This is dynamic to allow compat with webgl 1 and 2.
  28803. * You will need to pass the name of the uniform as well as the value.
  28804. */
  28805. updateMatrix: (name: string, mat: Matrix) => void;
  28806. /**
  28807. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28808. * This is dynamic to allow compat with webgl 1 and 2.
  28809. * You will need to pass the name of the uniform as well as the value.
  28810. */
  28811. updateVector3: (name: string, vector: Vector3) => void;
  28812. /**
  28813. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28814. * This is dynamic to allow compat with webgl 1 and 2.
  28815. * You will need to pass the name of the uniform as well as the value.
  28816. */
  28817. updateVector4: (name: string, vector: Vector4) => void;
  28818. /**
  28819. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28820. * This is dynamic to allow compat with webgl 1 and 2.
  28821. * You will need to pass the name of the uniform as well as the value.
  28822. */
  28823. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28824. /**
  28825. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28826. * This is dynamic to allow compat with webgl 1 and 2.
  28827. * You will need to pass the name of the uniform as well as the value.
  28828. */
  28829. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28830. /**
  28831. * Instantiates a new Uniform buffer objects.
  28832. *
  28833. * Handles blocks of uniform on the GPU.
  28834. *
  28835. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28836. *
  28837. * For more information, please refer to :
  28838. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28839. * @param engine Define the engine the buffer is associated with
  28840. * @param data Define the data contained in the buffer
  28841. * @param dynamic Define if the buffer is updatable
  28842. */
  28843. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28844. /**
  28845. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28846. * or just falling back on setUniformXXX calls.
  28847. */
  28848. readonly useUbo: boolean;
  28849. /**
  28850. * Indicates if the WebGL underlying uniform buffer is in sync
  28851. * with the javascript cache data.
  28852. */
  28853. readonly isSync: boolean;
  28854. /**
  28855. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28856. * Also, a dynamic UniformBuffer will disable cache verification and always
  28857. * update the underlying WebGL uniform buffer to the GPU.
  28858. * @returns if Dynamic, otherwise false
  28859. */
  28860. isDynamic(): boolean;
  28861. /**
  28862. * The data cache on JS side.
  28863. * @returns the underlying data as a float array
  28864. */
  28865. getData(): Float32Array;
  28866. /**
  28867. * The underlying WebGL Uniform buffer.
  28868. * @returns the webgl buffer
  28869. */
  28870. getBuffer(): Nullable<DataBuffer>;
  28871. /**
  28872. * std140 layout specifies how to align data within an UBO structure.
  28873. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28874. * for specs.
  28875. */
  28876. private _fillAlignment;
  28877. /**
  28878. * Adds an uniform in the buffer.
  28879. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28880. * for the layout to be correct !
  28881. * @param name Name of the uniform, as used in the uniform block in the shader.
  28882. * @param size Data size, or data directly.
  28883. */
  28884. addUniform(name: string, size: number | number[]): void;
  28885. /**
  28886. * Adds a Matrix 4x4 to the uniform buffer.
  28887. * @param name Name of the uniform, as used in the uniform block in the shader.
  28888. * @param mat A 4x4 matrix.
  28889. */
  28890. addMatrix(name: string, mat: Matrix): void;
  28891. /**
  28892. * Adds a vec2 to the uniform buffer.
  28893. * @param name Name of the uniform, as used in the uniform block in the shader.
  28894. * @param x Define the x component value of the vec2
  28895. * @param y Define the y component value of the vec2
  28896. */
  28897. addFloat2(name: string, x: number, y: number): void;
  28898. /**
  28899. * Adds a vec3 to the uniform buffer.
  28900. * @param name Name of the uniform, as used in the uniform block in the shader.
  28901. * @param x Define the x component value of the vec3
  28902. * @param y Define the y component value of the vec3
  28903. * @param z Define the z component value of the vec3
  28904. */
  28905. addFloat3(name: string, x: number, y: number, z: number): void;
  28906. /**
  28907. * Adds a vec3 to the uniform buffer.
  28908. * @param name Name of the uniform, as used in the uniform block in the shader.
  28909. * @param color Define the vec3 from a Color
  28910. */
  28911. addColor3(name: string, color: Color3): void;
  28912. /**
  28913. * Adds a vec4 to the uniform buffer.
  28914. * @param name Name of the uniform, as used in the uniform block in the shader.
  28915. * @param color Define the rgb components from a Color
  28916. * @param alpha Define the a component of the vec4
  28917. */
  28918. addColor4(name: string, color: Color3, alpha: number): void;
  28919. /**
  28920. * Adds a vec3 to the uniform buffer.
  28921. * @param name Name of the uniform, as used in the uniform block in the shader.
  28922. * @param vector Define the vec3 components from a Vector
  28923. */
  28924. addVector3(name: string, vector: Vector3): void;
  28925. /**
  28926. * Adds a Matrix 3x3 to the uniform buffer.
  28927. * @param name Name of the uniform, as used in the uniform block in the shader.
  28928. */
  28929. addMatrix3x3(name: string): void;
  28930. /**
  28931. * Adds a Matrix 2x2 to the uniform buffer.
  28932. * @param name Name of the uniform, as used in the uniform block in the shader.
  28933. */
  28934. addMatrix2x2(name: string): void;
  28935. /**
  28936. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28937. */
  28938. create(): void;
  28939. /** @hidden */
  28940. _rebuild(): void;
  28941. /**
  28942. * Updates the WebGL Uniform Buffer on the GPU.
  28943. * If the `dynamic` flag is set to true, no cache comparison is done.
  28944. * Otherwise, the buffer will be updated only if the cache differs.
  28945. */
  28946. update(): void;
  28947. /**
  28948. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28949. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28950. * @param data Define the flattened data
  28951. * @param size Define the size of the data.
  28952. */
  28953. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28954. private _valueCache;
  28955. private _cacheMatrix;
  28956. private _updateMatrix3x3ForUniform;
  28957. private _updateMatrix3x3ForEffect;
  28958. private _updateMatrix2x2ForEffect;
  28959. private _updateMatrix2x2ForUniform;
  28960. private _updateFloatForEffect;
  28961. private _updateFloatForUniform;
  28962. private _updateFloat2ForEffect;
  28963. private _updateFloat2ForUniform;
  28964. private _updateFloat3ForEffect;
  28965. private _updateFloat3ForUniform;
  28966. private _updateFloat4ForEffect;
  28967. private _updateFloat4ForUniform;
  28968. private _updateMatrixForEffect;
  28969. private _updateMatrixForUniform;
  28970. private _updateVector3ForEffect;
  28971. private _updateVector3ForUniform;
  28972. private _updateVector4ForEffect;
  28973. private _updateVector4ForUniform;
  28974. private _updateColor3ForEffect;
  28975. private _updateColor3ForUniform;
  28976. private _updateColor4ForEffect;
  28977. private _updateColor4ForUniform;
  28978. /**
  28979. * Sets a sampler uniform on the effect.
  28980. * @param name Define the name of the sampler.
  28981. * @param texture Define the texture to set in the sampler
  28982. */
  28983. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28984. /**
  28985. * Directly updates the value of the uniform in the cache AND on the GPU.
  28986. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28987. * @param data Define the flattened data
  28988. */
  28989. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28990. /**
  28991. * Binds this uniform buffer to an effect.
  28992. * @param effect Define the effect to bind the buffer to
  28993. * @param name Name of the uniform block in the shader.
  28994. */
  28995. bindToEffect(effect: Effect, name: string): void;
  28996. /**
  28997. * Disposes the uniform buffer.
  28998. */
  28999. dispose(): void;
  29000. }
  29001. }
  29002. declare module BABYLON {
  29003. /**
  29004. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29006. */
  29007. export class Analyser {
  29008. /**
  29009. * Gets or sets the smoothing
  29010. * @ignorenaming
  29011. */
  29012. SMOOTHING: number;
  29013. /**
  29014. * Gets or sets the FFT table size
  29015. * @ignorenaming
  29016. */
  29017. FFT_SIZE: number;
  29018. /**
  29019. * Gets or sets the bar graph amplitude
  29020. * @ignorenaming
  29021. */
  29022. BARGRAPHAMPLITUDE: number;
  29023. /**
  29024. * Gets or sets the position of the debug canvas
  29025. * @ignorenaming
  29026. */
  29027. DEBUGCANVASPOS: {
  29028. x: number;
  29029. y: number;
  29030. };
  29031. /**
  29032. * Gets or sets the debug canvas size
  29033. * @ignorenaming
  29034. */
  29035. DEBUGCANVASSIZE: {
  29036. width: number;
  29037. height: number;
  29038. };
  29039. private _byteFreqs;
  29040. private _byteTime;
  29041. private _floatFreqs;
  29042. private _webAudioAnalyser;
  29043. private _debugCanvas;
  29044. private _debugCanvasContext;
  29045. private _scene;
  29046. private _registerFunc;
  29047. private _audioEngine;
  29048. /**
  29049. * Creates a new analyser
  29050. * @param scene defines hosting scene
  29051. */
  29052. constructor(scene: Scene);
  29053. /**
  29054. * Get the number of data values you will have to play with for the visualization
  29055. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29056. * @returns a number
  29057. */
  29058. getFrequencyBinCount(): number;
  29059. /**
  29060. * Gets the current frequency data as a byte array
  29061. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29062. * @returns a Uint8Array
  29063. */
  29064. getByteFrequencyData(): Uint8Array;
  29065. /**
  29066. * Gets the current waveform as a byte array
  29067. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29068. * @returns a Uint8Array
  29069. */
  29070. getByteTimeDomainData(): Uint8Array;
  29071. /**
  29072. * Gets the current frequency data as a float array
  29073. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29074. * @returns a Float32Array
  29075. */
  29076. getFloatFrequencyData(): Float32Array;
  29077. /**
  29078. * Renders the debug canvas
  29079. */
  29080. drawDebugCanvas(): void;
  29081. /**
  29082. * Stops rendering the debug canvas and removes it
  29083. */
  29084. stopDebugCanvas(): void;
  29085. /**
  29086. * Connects two audio nodes
  29087. * @param inputAudioNode defines first node to connect
  29088. * @param outputAudioNode defines second node to connect
  29089. */
  29090. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29091. /**
  29092. * Releases all associated resources
  29093. */
  29094. dispose(): void;
  29095. }
  29096. }
  29097. declare module BABYLON {
  29098. /**
  29099. * This represents an audio engine and it is responsible
  29100. * to play, synchronize and analyse sounds throughout the application.
  29101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29102. */
  29103. export interface IAudioEngine extends IDisposable {
  29104. /**
  29105. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29106. */
  29107. readonly canUseWebAudio: boolean;
  29108. /**
  29109. * Gets the current AudioContext if available.
  29110. */
  29111. readonly audioContext: Nullable<AudioContext>;
  29112. /**
  29113. * The master gain node defines the global audio volume of your audio engine.
  29114. */
  29115. readonly masterGain: GainNode;
  29116. /**
  29117. * Gets whether or not mp3 are supported by your browser.
  29118. */
  29119. readonly isMP3supported: boolean;
  29120. /**
  29121. * Gets whether or not ogg are supported by your browser.
  29122. */
  29123. readonly isOGGsupported: boolean;
  29124. /**
  29125. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29126. * @ignoreNaming
  29127. */
  29128. WarnedWebAudioUnsupported: boolean;
  29129. /**
  29130. * Defines if the audio engine relies on a custom unlocked button.
  29131. * In this case, the embedded button will not be displayed.
  29132. */
  29133. useCustomUnlockedButton: boolean;
  29134. /**
  29135. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29136. */
  29137. readonly unlocked: boolean;
  29138. /**
  29139. * Event raised when audio has been unlocked on the browser.
  29140. */
  29141. onAudioUnlockedObservable: Observable<AudioEngine>;
  29142. /**
  29143. * Event raised when audio has been locked on the browser.
  29144. */
  29145. onAudioLockedObservable: Observable<AudioEngine>;
  29146. /**
  29147. * Flags the audio engine in Locked state.
  29148. * This happens due to new browser policies preventing audio to autoplay.
  29149. */
  29150. lock(): void;
  29151. /**
  29152. * Unlocks the audio engine once a user action has been done on the dom.
  29153. * This is helpful to resume play once browser policies have been satisfied.
  29154. */
  29155. unlock(): void;
  29156. }
  29157. /**
  29158. * This represents the default audio engine used in babylon.
  29159. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29161. */
  29162. export class AudioEngine implements IAudioEngine {
  29163. private _audioContext;
  29164. private _audioContextInitialized;
  29165. private _muteButton;
  29166. private _hostElement;
  29167. /**
  29168. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29169. */
  29170. canUseWebAudio: boolean;
  29171. /**
  29172. * The master gain node defines the global audio volume of your audio engine.
  29173. */
  29174. masterGain: GainNode;
  29175. /**
  29176. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29177. * @ignoreNaming
  29178. */
  29179. WarnedWebAudioUnsupported: boolean;
  29180. /**
  29181. * Gets whether or not mp3 are supported by your browser.
  29182. */
  29183. isMP3supported: boolean;
  29184. /**
  29185. * Gets whether or not ogg are supported by your browser.
  29186. */
  29187. isOGGsupported: boolean;
  29188. /**
  29189. * Gets whether audio has been unlocked on the device.
  29190. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29191. * a user interaction has happened.
  29192. */
  29193. unlocked: boolean;
  29194. /**
  29195. * Defines if the audio engine relies on a custom unlocked button.
  29196. * In this case, the embedded button will not be displayed.
  29197. */
  29198. useCustomUnlockedButton: boolean;
  29199. /**
  29200. * Event raised when audio has been unlocked on the browser.
  29201. */
  29202. onAudioUnlockedObservable: Observable<AudioEngine>;
  29203. /**
  29204. * Event raised when audio has been locked on the browser.
  29205. */
  29206. onAudioLockedObservable: Observable<AudioEngine>;
  29207. /**
  29208. * Gets the current AudioContext if available.
  29209. */
  29210. readonly audioContext: Nullable<AudioContext>;
  29211. private _connectedAnalyser;
  29212. /**
  29213. * Instantiates a new audio engine.
  29214. *
  29215. * There should be only one per page as some browsers restrict the number
  29216. * of audio contexts you can create.
  29217. * @param hostElement defines the host element where to display the mute icon if necessary
  29218. */
  29219. constructor(hostElement?: Nullable<HTMLElement>);
  29220. /**
  29221. * Flags the audio engine in Locked state.
  29222. * This happens due to new browser policies preventing audio to autoplay.
  29223. */
  29224. lock(): void;
  29225. /**
  29226. * Unlocks the audio engine once a user action has been done on the dom.
  29227. * This is helpful to resume play once browser policies have been satisfied.
  29228. */
  29229. unlock(): void;
  29230. private _resumeAudioContext;
  29231. private _initializeAudioContext;
  29232. private _tryToRun;
  29233. private _triggerRunningState;
  29234. private _triggerSuspendedState;
  29235. private _displayMuteButton;
  29236. private _moveButtonToTopLeft;
  29237. private _onResize;
  29238. private _hideMuteButton;
  29239. /**
  29240. * Destroy and release the resources associated with the audio ccontext.
  29241. */
  29242. dispose(): void;
  29243. /**
  29244. * Gets the global volume sets on the master gain.
  29245. * @returns the global volume if set or -1 otherwise
  29246. */
  29247. getGlobalVolume(): number;
  29248. /**
  29249. * Sets the global volume of your experience (sets on the master gain).
  29250. * @param newVolume Defines the new global volume of the application
  29251. */
  29252. setGlobalVolume(newVolume: number): void;
  29253. /**
  29254. * Connect the audio engine to an audio analyser allowing some amazing
  29255. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29257. * @param analyser The analyser to connect to the engine
  29258. */
  29259. connectToAnalyser(analyser: Analyser): void;
  29260. }
  29261. }
  29262. declare module BABYLON {
  29263. /**
  29264. * Interface used to present a loading screen while loading a scene
  29265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29266. */
  29267. export interface ILoadingScreen {
  29268. /**
  29269. * Function called to display the loading screen
  29270. */
  29271. displayLoadingUI: () => void;
  29272. /**
  29273. * Function called to hide the loading screen
  29274. */
  29275. hideLoadingUI: () => void;
  29276. /**
  29277. * Gets or sets the color to use for the background
  29278. */
  29279. loadingUIBackgroundColor: string;
  29280. /**
  29281. * Gets or sets the text to display while loading
  29282. */
  29283. loadingUIText: string;
  29284. }
  29285. /**
  29286. * Class used for the default loading screen
  29287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29288. */
  29289. export class DefaultLoadingScreen implements ILoadingScreen {
  29290. private _renderingCanvas;
  29291. private _loadingText;
  29292. private _loadingDivBackgroundColor;
  29293. private _loadingDiv;
  29294. private _loadingTextDiv;
  29295. /** Gets or sets the logo url to use for the default loading screen */
  29296. static DefaultLogoUrl: string;
  29297. /** Gets or sets the spinner url to use for the default loading screen */
  29298. static DefaultSpinnerUrl: string;
  29299. /**
  29300. * Creates a new default loading screen
  29301. * @param _renderingCanvas defines the canvas used to render the scene
  29302. * @param _loadingText defines the default text to display
  29303. * @param _loadingDivBackgroundColor defines the default background color
  29304. */
  29305. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29306. /**
  29307. * Function called to display the loading screen
  29308. */
  29309. displayLoadingUI(): void;
  29310. /**
  29311. * Function called to hide the loading screen
  29312. */
  29313. hideLoadingUI(): void;
  29314. /**
  29315. * Gets or sets the text to display while loading
  29316. */
  29317. loadingUIText: string;
  29318. /**
  29319. * Gets or sets the color to use for the background
  29320. */
  29321. loadingUIBackgroundColor: string;
  29322. private _resizeLoadingUI;
  29323. }
  29324. }
  29325. declare module BABYLON {
  29326. /** @hidden */
  29327. export class WebGLPipelineContext implements IPipelineContext {
  29328. engine: Engine;
  29329. program: Nullable<WebGLProgram>;
  29330. context?: WebGLRenderingContext;
  29331. vertexShader?: WebGLShader;
  29332. fragmentShader?: WebGLShader;
  29333. isParallelCompiled: boolean;
  29334. onCompiled?: () => void;
  29335. transformFeedback?: WebGLTransformFeedback | null;
  29336. readonly isAsync: boolean;
  29337. readonly isReady: boolean;
  29338. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29339. }
  29340. }
  29341. declare module BABYLON {
  29342. /** @hidden */
  29343. export class WebGLDataBuffer extends DataBuffer {
  29344. private _buffer;
  29345. constructor(resource: WebGLBuffer);
  29346. readonly underlyingResource: any;
  29347. }
  29348. }
  29349. declare module BABYLON {
  29350. /** @hidden */
  29351. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29352. attributeProcessor(attribute: string): string;
  29353. varyingProcessor(varying: string, isFragment: boolean): string;
  29354. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29355. }
  29356. }
  29357. declare module BABYLON {
  29358. /**
  29359. * This class is used to track a performance counter which is number based.
  29360. * The user has access to many properties which give statistics of different nature.
  29361. *
  29362. * The implementer can track two kinds of Performance Counter: time and count.
  29363. * 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.
  29364. * 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.
  29365. */
  29366. export class PerfCounter {
  29367. /**
  29368. * Gets or sets a global boolean to turn on and off all the counters
  29369. */
  29370. static Enabled: boolean;
  29371. /**
  29372. * Returns the smallest value ever
  29373. */
  29374. readonly min: number;
  29375. /**
  29376. * Returns the biggest value ever
  29377. */
  29378. readonly max: number;
  29379. /**
  29380. * Returns the average value since the performance counter is running
  29381. */
  29382. readonly average: number;
  29383. /**
  29384. * Returns the average value of the last second the counter was monitored
  29385. */
  29386. readonly lastSecAverage: number;
  29387. /**
  29388. * Returns the current value
  29389. */
  29390. readonly current: number;
  29391. /**
  29392. * Gets the accumulated total
  29393. */
  29394. readonly total: number;
  29395. /**
  29396. * Gets the total value count
  29397. */
  29398. readonly count: number;
  29399. /**
  29400. * Creates a new counter
  29401. */
  29402. constructor();
  29403. /**
  29404. * Call this method to start monitoring a new frame.
  29405. * 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.
  29406. */
  29407. fetchNewFrame(): void;
  29408. /**
  29409. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29410. * @param newCount the count value to add to the monitored count
  29411. * @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.
  29412. */
  29413. addCount(newCount: number, fetchResult: boolean): void;
  29414. /**
  29415. * Start monitoring this performance counter
  29416. */
  29417. beginMonitoring(): void;
  29418. /**
  29419. * Compute the time lapsed since the previous beginMonitoring() call.
  29420. * @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
  29421. */
  29422. endMonitoring(newFrame?: boolean): void;
  29423. private _fetchResult;
  29424. private _startMonitoringTime;
  29425. private _min;
  29426. private _max;
  29427. private _average;
  29428. private _current;
  29429. private _totalValueCount;
  29430. private _totalAccumulated;
  29431. private _lastSecAverage;
  29432. private _lastSecAccumulated;
  29433. private _lastSecTime;
  29434. private _lastSecValueCount;
  29435. }
  29436. }
  29437. declare module BABYLON {
  29438. /**
  29439. * Interface for any object that can request an animation frame
  29440. */
  29441. export interface ICustomAnimationFrameRequester {
  29442. /**
  29443. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29444. */
  29445. renderFunction?: Function;
  29446. /**
  29447. * Called to request the next frame to render to
  29448. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29449. */
  29450. requestAnimationFrame: Function;
  29451. /**
  29452. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29453. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29454. */
  29455. requestID?: number;
  29456. }
  29457. }
  29458. declare module BABYLON {
  29459. /**
  29460. * Settings for finer control over video usage
  29461. */
  29462. export interface VideoTextureSettings {
  29463. /**
  29464. * Applies `autoplay` to video, if specified
  29465. */
  29466. autoPlay?: boolean;
  29467. /**
  29468. * Applies `loop` to video, if specified
  29469. */
  29470. loop?: boolean;
  29471. /**
  29472. * Automatically updates internal texture from video at every frame in the render loop
  29473. */
  29474. autoUpdateTexture: boolean;
  29475. /**
  29476. * Image src displayed during the video loading or until the user interacts with the video.
  29477. */
  29478. poster?: string;
  29479. }
  29480. /**
  29481. * If you want to display a video in your scene, this is the special texture for that.
  29482. * This special texture works similar to other textures, with the exception of a few parameters.
  29483. * @see https://doc.babylonjs.com/how_to/video_texture
  29484. */
  29485. export class VideoTexture extends Texture {
  29486. /**
  29487. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29488. */
  29489. readonly autoUpdateTexture: boolean;
  29490. /**
  29491. * The video instance used by the texture internally
  29492. */
  29493. readonly video: HTMLVideoElement;
  29494. private _onUserActionRequestedObservable;
  29495. /**
  29496. * Event triggerd when a dom action is required by the user to play the video.
  29497. * This happens due to recent changes in browser policies preventing video to auto start.
  29498. */
  29499. readonly onUserActionRequestedObservable: Observable<Texture>;
  29500. private _generateMipMaps;
  29501. private _engine;
  29502. private _stillImageCaptured;
  29503. private _displayingPosterTexture;
  29504. private _settings;
  29505. private _createInternalTextureOnEvent;
  29506. private _frameId;
  29507. /**
  29508. * Creates a video texture.
  29509. * If you want to display a video in your scene, this is the special texture for that.
  29510. * This special texture works similar to other textures, with the exception of a few parameters.
  29511. * @see https://doc.babylonjs.com/how_to/video_texture
  29512. * @param name optional name, will detect from video source, if not defined
  29513. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29514. * @param scene is obviously the current scene.
  29515. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29516. * @param invertY is false by default but can be used to invert video on Y axis
  29517. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29518. * @param settings allows finer control over video usage
  29519. */
  29520. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29521. private _getName;
  29522. private _getVideo;
  29523. private _createInternalTexture;
  29524. private reset;
  29525. /**
  29526. * @hidden Internal method to initiate `update`.
  29527. */
  29528. _rebuild(): void;
  29529. /**
  29530. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29531. */
  29532. update(): void;
  29533. /**
  29534. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29535. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29536. */
  29537. updateTexture(isVisible: boolean): void;
  29538. protected _updateInternalTexture: () => void;
  29539. /**
  29540. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29541. * @param url New url.
  29542. */
  29543. updateURL(url: string): void;
  29544. /**
  29545. * Dispose the texture and release its associated resources.
  29546. */
  29547. dispose(): void;
  29548. /**
  29549. * Creates a video texture straight from a stream.
  29550. * @param scene Define the scene the texture should be created in
  29551. * @param stream Define the stream the texture should be created from
  29552. * @returns The created video texture as a promise
  29553. */
  29554. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29555. /**
  29556. * Creates a video texture straight from your WebCam video feed.
  29557. * @param scene Define the scene the texture should be created in
  29558. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29559. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29560. * @returns The created video texture as a promise
  29561. */
  29562. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29563. minWidth: number;
  29564. maxWidth: number;
  29565. minHeight: number;
  29566. maxHeight: number;
  29567. deviceId: string;
  29568. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29569. /**
  29570. * Creates a video texture straight from your WebCam video feed.
  29571. * @param scene Define the scene the texture should be created in
  29572. * @param onReady Define a callback to triggered once the texture will be ready
  29573. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29574. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29575. */
  29576. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29577. minWidth: number;
  29578. maxWidth: number;
  29579. minHeight: number;
  29580. maxHeight: number;
  29581. deviceId: string;
  29582. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29583. }
  29584. }
  29585. declare module BABYLON {
  29586. /**
  29587. * Defines the interface used by objects containing a viewport (like a camera)
  29588. */
  29589. interface IViewportOwnerLike {
  29590. /**
  29591. * Gets or sets the viewport
  29592. */
  29593. viewport: IViewportLike;
  29594. }
  29595. /**
  29596. * Interface for attribute information associated with buffer instanciation
  29597. */
  29598. export class InstancingAttributeInfo {
  29599. /**
  29600. * Index/offset of the attribute in the vertex shader
  29601. */
  29602. index: number;
  29603. /**
  29604. * size of the attribute, 1, 2, 3 or 4
  29605. */
  29606. attributeSize: number;
  29607. /**
  29608. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29609. * default is FLOAT
  29610. */
  29611. attribyteType: number;
  29612. /**
  29613. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29614. */
  29615. normalized: boolean;
  29616. /**
  29617. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29618. */
  29619. offset: number;
  29620. /**
  29621. * Name of the GLSL attribute, for debugging purpose only
  29622. */
  29623. attributeName: string;
  29624. }
  29625. /**
  29626. * Define options used to create a depth texture
  29627. */
  29628. export class DepthTextureCreationOptions {
  29629. /** Specifies whether or not a stencil should be allocated in the texture */
  29630. generateStencil?: boolean;
  29631. /** Specifies whether or not bilinear filtering is enable on the texture */
  29632. bilinearFiltering?: boolean;
  29633. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29634. comparisonFunction?: number;
  29635. /** Specifies if the created texture is a cube texture */
  29636. isCube?: boolean;
  29637. }
  29638. /**
  29639. * Class used to describe the capabilities of the engine relatively to the current browser
  29640. */
  29641. export class EngineCapabilities {
  29642. /** Maximum textures units per fragment shader */
  29643. maxTexturesImageUnits: number;
  29644. /** Maximum texture units per vertex shader */
  29645. maxVertexTextureImageUnits: number;
  29646. /** Maximum textures units in the entire pipeline */
  29647. maxCombinedTexturesImageUnits: number;
  29648. /** Maximum texture size */
  29649. maxTextureSize: number;
  29650. /** Maximum cube texture size */
  29651. maxCubemapTextureSize: number;
  29652. /** Maximum render texture size */
  29653. maxRenderTextureSize: number;
  29654. /** Maximum number of vertex attributes */
  29655. maxVertexAttribs: number;
  29656. /** Maximum number of varyings */
  29657. maxVaryingVectors: number;
  29658. /** Maximum number of uniforms per vertex shader */
  29659. maxVertexUniformVectors: number;
  29660. /** Maximum number of uniforms per fragment shader */
  29661. maxFragmentUniformVectors: number;
  29662. /** Defines if standard derivates (dx/dy) are supported */
  29663. standardDerivatives: boolean;
  29664. /** Defines if s3tc texture compression is supported */
  29665. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29666. /** Defines if pvrtc texture compression is supported */
  29667. pvrtc: any;
  29668. /** Defines if etc1 texture compression is supported */
  29669. etc1: any;
  29670. /** Defines if etc2 texture compression is supported */
  29671. etc2: any;
  29672. /** Defines if astc texture compression is supported */
  29673. astc: any;
  29674. /** Defines if float textures are supported */
  29675. textureFloat: boolean;
  29676. /** Defines if vertex array objects are supported */
  29677. vertexArrayObject: boolean;
  29678. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29679. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29680. /** Gets the maximum level of anisotropy supported */
  29681. maxAnisotropy: number;
  29682. /** Defines if instancing is supported */
  29683. instancedArrays: boolean;
  29684. /** Defines if 32 bits indices are supported */
  29685. uintIndices: boolean;
  29686. /** Defines if high precision shaders are supported */
  29687. highPrecisionShaderSupported: boolean;
  29688. /** Defines if depth reading in the fragment shader is supported */
  29689. fragmentDepthSupported: boolean;
  29690. /** Defines if float texture linear filtering is supported*/
  29691. textureFloatLinearFiltering: boolean;
  29692. /** Defines if rendering to float textures is supported */
  29693. textureFloatRender: boolean;
  29694. /** Defines if half float textures are supported*/
  29695. textureHalfFloat: boolean;
  29696. /** Defines if half float texture linear filtering is supported*/
  29697. textureHalfFloatLinearFiltering: boolean;
  29698. /** Defines if rendering to half float textures is supported */
  29699. textureHalfFloatRender: boolean;
  29700. /** Defines if textureLOD shader command is supported */
  29701. textureLOD: boolean;
  29702. /** Defines if draw buffers extension is supported */
  29703. drawBuffersExtension: boolean;
  29704. /** Defines if depth textures are supported */
  29705. depthTextureExtension: boolean;
  29706. /** Defines if float color buffer are supported */
  29707. colorBufferFloat: boolean;
  29708. /** Gets disjoint timer query extension (null if not supported) */
  29709. timerQuery: EXT_disjoint_timer_query;
  29710. /** Defines if timestamp can be used with timer query */
  29711. canUseTimestampForTimerQuery: boolean;
  29712. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29713. multiview: any;
  29714. /** Function used to let the system compiles shaders in background */
  29715. parallelShaderCompile: {
  29716. COMPLETION_STATUS_KHR: number;
  29717. };
  29718. /** Max number of texture samples for MSAA */
  29719. maxMSAASamples: number;
  29720. }
  29721. /** Interface defining initialization parameters for Engine class */
  29722. export interface EngineOptions extends WebGLContextAttributes {
  29723. /**
  29724. * Defines if the engine should no exceed a specified device ratio
  29725. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29726. */
  29727. limitDeviceRatio?: number;
  29728. /**
  29729. * Defines if webvr should be enabled automatically
  29730. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29731. */
  29732. autoEnableWebVR?: boolean;
  29733. /**
  29734. * Defines if webgl2 should be turned off even if supported
  29735. * @see http://doc.babylonjs.com/features/webgl2
  29736. */
  29737. disableWebGL2Support?: boolean;
  29738. /**
  29739. * Defines if webaudio should be initialized as well
  29740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29741. */
  29742. audioEngine?: boolean;
  29743. /**
  29744. * Defines if animations should run using a deterministic lock step
  29745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29746. */
  29747. deterministicLockstep?: boolean;
  29748. /** Defines the maximum steps to use with deterministic lock step mode */
  29749. lockstepMaxSteps?: number;
  29750. /**
  29751. * Defines that engine should ignore context lost events
  29752. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29753. */
  29754. doNotHandleContextLost?: boolean;
  29755. /**
  29756. * Defines that engine should ignore modifying touch action attribute and style
  29757. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29758. */
  29759. doNotHandleTouchAction?: boolean;
  29760. /**
  29761. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29762. */
  29763. useHighPrecisionFloats?: boolean;
  29764. }
  29765. /**
  29766. * Defines the interface used by display changed events
  29767. */
  29768. export interface IDisplayChangedEventArgs {
  29769. /** Gets the vrDisplay object (if any) */
  29770. vrDisplay: Nullable<any>;
  29771. /** Gets a boolean indicating if webVR is supported */
  29772. vrSupported: boolean;
  29773. }
  29774. /**
  29775. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29776. */
  29777. export class Engine {
  29778. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29779. static ExceptionList: ({
  29780. key: string;
  29781. capture: string;
  29782. captureConstraint: number;
  29783. targets: string[];
  29784. } | {
  29785. key: string;
  29786. capture: null;
  29787. captureConstraint: null;
  29788. targets: string[];
  29789. })[];
  29790. /** Gets the list of created engines */
  29791. static readonly Instances: Engine[];
  29792. /**
  29793. * Gets the latest created engine
  29794. */
  29795. static readonly LastCreatedEngine: Nullable<Engine>;
  29796. /**
  29797. * Gets the latest created scene
  29798. */
  29799. static readonly LastCreatedScene: Nullable<Scene>;
  29800. /**
  29801. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29802. * @param flag defines which part of the materials must be marked as dirty
  29803. * @param predicate defines a predicate used to filter which materials should be affected
  29804. */
  29805. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29806. /** @hidden */
  29807. static _TextureLoaders: IInternalTextureLoader[];
  29808. /** Defines that alpha blending is disabled */
  29809. static readonly ALPHA_DISABLE: number;
  29810. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29811. static readonly ALPHA_ADD: number;
  29812. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29813. static readonly ALPHA_COMBINE: number;
  29814. /** Defines that alpha blending to DEST - SRC * DEST */
  29815. static readonly ALPHA_SUBTRACT: number;
  29816. /** Defines that alpha blending to SRC * DEST */
  29817. static readonly ALPHA_MULTIPLY: number;
  29818. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29819. static readonly ALPHA_MAXIMIZED: number;
  29820. /** Defines that alpha blending to SRC + DEST */
  29821. static readonly ALPHA_ONEONE: number;
  29822. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29823. static readonly ALPHA_PREMULTIPLIED: number;
  29824. /**
  29825. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29826. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29827. */
  29828. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29829. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29830. static readonly ALPHA_INTERPOLATE: number;
  29831. /**
  29832. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29833. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29834. */
  29835. static readonly ALPHA_SCREENMODE: number;
  29836. /** Defines that the ressource is not delayed*/
  29837. static readonly DELAYLOADSTATE_NONE: number;
  29838. /** Defines that the ressource was successfully delay loaded */
  29839. static readonly DELAYLOADSTATE_LOADED: number;
  29840. /** Defines that the ressource is currently delay loading */
  29841. static readonly DELAYLOADSTATE_LOADING: number;
  29842. /** Defines that the ressource is delayed and has not started loading */
  29843. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29845. static readonly NEVER: number;
  29846. /** 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 */
  29847. static readonly ALWAYS: number;
  29848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29849. static readonly LESS: number;
  29850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29851. static readonly EQUAL: number;
  29852. /** 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 */
  29853. static readonly LEQUAL: number;
  29854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29855. static readonly GREATER: number;
  29856. /** 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 */
  29857. static readonly GEQUAL: number;
  29858. /** 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 */
  29859. static readonly NOTEQUAL: number;
  29860. /** Passed to stencilOperation to specify that stencil value must be kept */
  29861. static readonly KEEP: number;
  29862. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29863. static readonly REPLACE: number;
  29864. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29865. static readonly INCR: number;
  29866. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29867. static readonly DECR: number;
  29868. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29869. static readonly INVERT: number;
  29870. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29871. static readonly INCR_WRAP: number;
  29872. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29873. static readonly DECR_WRAP: number;
  29874. /** Texture is not repeating outside of 0..1 UVs */
  29875. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29876. /** Texture is repeating outside of 0..1 UVs */
  29877. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29878. /** Texture is repeating and mirrored */
  29879. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29880. /** ALPHA */
  29881. static readonly TEXTUREFORMAT_ALPHA: number;
  29882. /** LUMINANCE */
  29883. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29884. /** LUMINANCE_ALPHA */
  29885. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29886. /** RGB */
  29887. static readonly TEXTUREFORMAT_RGB: number;
  29888. /** RGBA */
  29889. static readonly TEXTUREFORMAT_RGBA: number;
  29890. /** RED */
  29891. static readonly TEXTUREFORMAT_RED: number;
  29892. /** RED (2nd reference) */
  29893. static readonly TEXTUREFORMAT_R: number;
  29894. /** RG */
  29895. static readonly TEXTUREFORMAT_RG: number;
  29896. /** RED_INTEGER */
  29897. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29898. /** RED_INTEGER (2nd reference) */
  29899. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29900. /** RG_INTEGER */
  29901. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29902. /** RGB_INTEGER */
  29903. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29904. /** RGBA_INTEGER */
  29905. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29906. /** UNSIGNED_BYTE */
  29907. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29908. /** UNSIGNED_BYTE (2nd reference) */
  29909. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29910. /** FLOAT */
  29911. static readonly TEXTURETYPE_FLOAT: number;
  29912. /** HALF_FLOAT */
  29913. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29914. /** BYTE */
  29915. static readonly TEXTURETYPE_BYTE: number;
  29916. /** SHORT */
  29917. static readonly TEXTURETYPE_SHORT: number;
  29918. /** UNSIGNED_SHORT */
  29919. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29920. /** INT */
  29921. static readonly TEXTURETYPE_INT: number;
  29922. /** UNSIGNED_INT */
  29923. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29924. /** UNSIGNED_SHORT_4_4_4_4 */
  29925. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29926. /** UNSIGNED_SHORT_5_5_5_1 */
  29927. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29928. /** UNSIGNED_SHORT_5_6_5 */
  29929. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29930. /** UNSIGNED_INT_2_10_10_10_REV */
  29931. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29932. /** UNSIGNED_INT_24_8 */
  29933. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29934. /** UNSIGNED_INT_10F_11F_11F_REV */
  29935. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29936. /** UNSIGNED_INT_5_9_9_9_REV */
  29937. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29938. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29939. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29940. /** nearest is mag = nearest and min = nearest and mip = linear */
  29941. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29943. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29944. /** Trilinear is mag = linear and min = linear and mip = linear */
  29945. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29946. /** nearest is mag = nearest and min = nearest and mip = linear */
  29947. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29948. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29949. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29950. /** Trilinear is mag = linear and min = linear and mip = linear */
  29951. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29952. /** mag = nearest and min = nearest and mip = nearest */
  29953. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29954. /** mag = nearest and min = linear and mip = nearest */
  29955. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29956. /** mag = nearest and min = linear and mip = linear */
  29957. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29958. /** mag = nearest and min = linear and mip = none */
  29959. static readonly TEXTURE_NEAREST_LINEAR: number;
  29960. /** mag = nearest and min = nearest and mip = none */
  29961. static readonly TEXTURE_NEAREST_NEAREST: number;
  29962. /** mag = linear and min = nearest and mip = nearest */
  29963. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29964. /** mag = linear and min = nearest and mip = linear */
  29965. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29966. /** mag = linear and min = linear and mip = none */
  29967. static readonly TEXTURE_LINEAR_LINEAR: number;
  29968. /** mag = linear and min = nearest and mip = none */
  29969. static readonly TEXTURE_LINEAR_NEAREST: number;
  29970. /** Explicit coordinates mode */
  29971. static readonly TEXTURE_EXPLICIT_MODE: number;
  29972. /** Spherical coordinates mode */
  29973. static readonly TEXTURE_SPHERICAL_MODE: number;
  29974. /** Planar coordinates mode */
  29975. static readonly TEXTURE_PLANAR_MODE: number;
  29976. /** Cubic coordinates mode */
  29977. static readonly TEXTURE_CUBIC_MODE: number;
  29978. /** Projection coordinates mode */
  29979. static readonly TEXTURE_PROJECTION_MODE: number;
  29980. /** Skybox coordinates mode */
  29981. static readonly TEXTURE_SKYBOX_MODE: number;
  29982. /** Inverse Cubic coordinates mode */
  29983. static readonly TEXTURE_INVCUBIC_MODE: number;
  29984. /** Equirectangular coordinates mode */
  29985. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29986. /** Equirectangular Fixed coordinates mode */
  29987. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29988. /** Equirectangular Fixed Mirrored coordinates mode */
  29989. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29990. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29991. static readonly SCALEMODE_FLOOR: number;
  29992. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29993. static readonly SCALEMODE_NEAREST: number;
  29994. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29995. static readonly SCALEMODE_CEILING: number;
  29996. /**
  29997. * Returns the current npm package of the sdk
  29998. */
  29999. static readonly NpmPackage: string;
  30000. /**
  30001. * Returns the current version of the framework
  30002. */
  30003. static readonly Version: string;
  30004. /**
  30005. * Returns a string describing the current engine
  30006. */
  30007. readonly description: string;
  30008. /**
  30009. * Gets or sets the epsilon value used by collision engine
  30010. */
  30011. static CollisionsEpsilon: number;
  30012. /**
  30013. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30014. */
  30015. static ShadersRepository: string;
  30016. /**
  30017. * Method called to create the default loading screen.
  30018. * This can be overriden in your own app.
  30019. * @param canvas The rendering canvas element
  30020. * @returns The loading screen
  30021. */
  30022. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30023. /**
  30024. * Method called to create the default rescale post process on each engine.
  30025. */
  30026. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30027. /** @hidden */
  30028. _shaderProcessor: IShaderProcessor;
  30029. /**
  30030. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30031. */
  30032. forcePOTTextures: boolean;
  30033. /**
  30034. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30035. */
  30036. isFullscreen: boolean;
  30037. /**
  30038. * Gets a boolean indicating if the pointer is currently locked
  30039. */
  30040. isPointerLock: boolean;
  30041. /**
  30042. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30043. */
  30044. cullBackFaces: boolean;
  30045. /**
  30046. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30047. */
  30048. renderEvenInBackground: boolean;
  30049. /**
  30050. * Gets or sets a boolean indicating that cache can be kept between frames
  30051. */
  30052. preventCacheWipeBetweenFrames: boolean;
  30053. /**
  30054. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30055. **/
  30056. enableOfflineSupport: boolean;
  30057. /**
  30058. * 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)
  30059. **/
  30060. disableManifestCheck: boolean;
  30061. /**
  30062. * Gets the list of created scenes
  30063. */
  30064. scenes: Scene[];
  30065. /**
  30066. * Event raised when a new scene is created
  30067. */
  30068. onNewSceneAddedObservable: Observable<Scene>;
  30069. /**
  30070. * Gets the list of created postprocesses
  30071. */
  30072. postProcesses: PostProcess[];
  30073. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30074. validateShaderPrograms: boolean;
  30075. /**
  30076. * Observable event triggered each time the rendering canvas is resized
  30077. */
  30078. onResizeObservable: Observable<Engine>;
  30079. /**
  30080. * Observable event triggered each time the canvas loses focus
  30081. */
  30082. onCanvasBlurObservable: Observable<Engine>;
  30083. /**
  30084. * Observable event triggered each time the canvas gains focus
  30085. */
  30086. onCanvasFocusObservable: Observable<Engine>;
  30087. /**
  30088. * Observable event triggered each time the canvas receives pointerout event
  30089. */
  30090. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30091. /**
  30092. * Observable event triggered before each texture is initialized
  30093. */
  30094. onBeforeTextureInitObservable: Observable<Texture>;
  30095. /**
  30096. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30097. */
  30098. disableUniformBuffers: boolean;
  30099. /** @hidden */
  30100. _uniformBuffers: UniformBuffer[];
  30101. /**
  30102. * Gets a boolean indicating that the engine supports uniform buffers
  30103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30104. */
  30105. readonly supportsUniformBuffers: boolean;
  30106. /**
  30107. * Observable raised when the engine begins a new frame
  30108. */
  30109. onBeginFrameObservable: Observable<Engine>;
  30110. /**
  30111. * If set, will be used to request the next animation frame for the render loop
  30112. */
  30113. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30114. /**
  30115. * Observable raised when the engine ends the current frame
  30116. */
  30117. onEndFrameObservable: Observable<Engine>;
  30118. /**
  30119. * Observable raised when the engine is about to compile a shader
  30120. */
  30121. onBeforeShaderCompilationObservable: Observable<Engine>;
  30122. /**
  30123. * Observable raised when the engine has jsut compiled a shader
  30124. */
  30125. onAfterShaderCompilationObservable: Observable<Engine>;
  30126. /** @hidden */
  30127. _gl: WebGLRenderingContext;
  30128. private _renderingCanvas;
  30129. private _windowIsBackground;
  30130. protected _webGLVersion: number;
  30131. protected _highPrecisionShadersAllowed: boolean;
  30132. /** @hidden */
  30133. readonly _shouldUseHighPrecisionShader: boolean;
  30134. /**
  30135. * Gets a boolean indicating that only power of 2 textures are supported
  30136. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30137. */
  30138. readonly needPOTTextures: boolean;
  30139. /** @hidden */
  30140. _badOS: boolean;
  30141. /** @hidden */
  30142. _badDesktopOS: boolean;
  30143. /**
  30144. * Gets the audio engine
  30145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30146. * @ignorenaming
  30147. */
  30148. static audioEngine: IAudioEngine;
  30149. /**
  30150. * Default AudioEngine factory responsible of creating the Audio Engine.
  30151. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30152. */
  30153. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30154. /**
  30155. * Default offline support factory responsible of creating a tool used to store data locally.
  30156. * By default, this will create a Database object if the workload has been embedded.
  30157. */
  30158. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30159. private _onFocus;
  30160. private _onBlur;
  30161. private _onCanvasPointerOut;
  30162. private _onCanvasBlur;
  30163. private _onCanvasFocus;
  30164. private _onFullscreenChange;
  30165. private _onPointerLockChange;
  30166. private _hardwareScalingLevel;
  30167. /** @hidden */
  30168. _caps: EngineCapabilities;
  30169. private _pointerLockRequested;
  30170. private _isStencilEnable;
  30171. protected _colorWrite: boolean;
  30172. private _loadingScreen;
  30173. /** @hidden */
  30174. _drawCalls: PerfCounter;
  30175. private _glVersion;
  30176. private _glRenderer;
  30177. private _glVendor;
  30178. private _videoTextureSupported;
  30179. private _renderingQueueLaunched;
  30180. private _activeRenderLoops;
  30181. private _deterministicLockstep;
  30182. private _lockstepMaxSteps;
  30183. /**
  30184. * Observable signaled when a context lost event is raised
  30185. */
  30186. onContextLostObservable: Observable<Engine>;
  30187. /**
  30188. * Observable signaled when a context restored event is raised
  30189. */
  30190. onContextRestoredObservable: Observable<Engine>;
  30191. private _onContextLost;
  30192. private _onContextRestored;
  30193. private _contextWasLost;
  30194. /** @hidden */
  30195. _doNotHandleContextLost: boolean;
  30196. /**
  30197. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30199. */
  30200. doNotHandleContextLost: boolean;
  30201. private _performanceMonitor;
  30202. private _fps;
  30203. private _deltaTime;
  30204. /**
  30205. * Turn this value on if you want to pause FPS computation when in background
  30206. */
  30207. disablePerformanceMonitorInBackground: boolean;
  30208. /**
  30209. * Gets the performance monitor attached to this engine
  30210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30211. */
  30212. readonly performanceMonitor: PerformanceMonitor;
  30213. /**
  30214. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30215. */
  30216. disableVertexArrayObjects: boolean;
  30217. /** @hidden */
  30218. protected _depthCullingState: _DepthCullingState;
  30219. /** @hidden */
  30220. protected _stencilState: _StencilState;
  30221. /** @hidden */
  30222. protected _alphaState: _AlphaState;
  30223. /** @hidden */
  30224. protected _alphaMode: number;
  30225. /** @hidden */
  30226. _internalTexturesCache: InternalTexture[];
  30227. /** @hidden */
  30228. protected _activeChannel: number;
  30229. private _currentTextureChannel;
  30230. /** @hidden */
  30231. protected _boundTexturesCache: {
  30232. [key: string]: Nullable<InternalTexture>;
  30233. };
  30234. /** @hidden */
  30235. protected _currentEffect: Nullable<Effect>;
  30236. /** @hidden */
  30237. protected _currentProgram: Nullable<WebGLProgram>;
  30238. private _compiledEffects;
  30239. private _vertexAttribArraysEnabled;
  30240. /** @hidden */
  30241. protected _cachedViewport: Nullable<IViewportLike>;
  30242. private _cachedVertexArrayObject;
  30243. /** @hidden */
  30244. protected _cachedVertexBuffers: any;
  30245. /** @hidden */
  30246. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30247. /** @hidden */
  30248. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30249. /** @hidden */
  30250. _currentRenderTarget: Nullable<InternalTexture>;
  30251. private _uintIndicesCurrentlySet;
  30252. private _currentBoundBuffer;
  30253. /** @hidden */
  30254. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30255. private _currentBufferPointers;
  30256. private _currentInstanceLocations;
  30257. private _currentInstanceBuffers;
  30258. private _textureUnits;
  30259. /** @hidden */
  30260. _workingCanvas: Nullable<HTMLCanvasElement>;
  30261. /** @hidden */
  30262. _workingContext: Nullable<CanvasRenderingContext2D>;
  30263. private _rescalePostProcess;
  30264. private _dummyFramebuffer;
  30265. private _externalData;
  30266. /** @hidden */
  30267. _bindedRenderFunction: any;
  30268. private _vaoRecordInProgress;
  30269. private _mustWipeVertexAttributes;
  30270. private _emptyTexture;
  30271. private _emptyCubeTexture;
  30272. private _emptyTexture3D;
  30273. /** @hidden */
  30274. _frameHandler: number;
  30275. private _nextFreeTextureSlots;
  30276. private _maxSimultaneousTextures;
  30277. private _activeRequests;
  30278. private _texturesSupported;
  30279. /** @hidden */
  30280. _textureFormatInUse: Nullable<string>;
  30281. /**
  30282. * Gets the list of texture formats supported
  30283. */
  30284. readonly texturesSupported: Array<string>;
  30285. /**
  30286. * Gets the list of texture formats in use
  30287. */
  30288. readonly textureFormatInUse: Nullable<string>;
  30289. /**
  30290. * Gets the current viewport
  30291. */
  30292. readonly currentViewport: Nullable<IViewportLike>;
  30293. /**
  30294. * Gets the default empty texture
  30295. */
  30296. readonly emptyTexture: InternalTexture;
  30297. /**
  30298. * Gets the default empty 3D texture
  30299. */
  30300. readonly emptyTexture3D: InternalTexture;
  30301. /**
  30302. * Gets the default empty cube texture
  30303. */
  30304. readonly emptyCubeTexture: InternalTexture;
  30305. /**
  30306. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30307. */
  30308. readonly premultipliedAlpha: boolean;
  30309. /**
  30310. * Creates a new engine
  30311. * @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
  30312. * @param antialias defines enable antialiasing (default: false)
  30313. * @param options defines further options to be sent to the getContext() function
  30314. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30315. */
  30316. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30317. /**
  30318. * Initializes a webVR display and starts listening to display change events
  30319. * The onVRDisplayChangedObservable will be notified upon these changes
  30320. * @returns The onVRDisplayChangedObservable
  30321. */
  30322. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30323. /** @hidden */
  30324. _prepareVRComponent(): void;
  30325. /** @hidden */
  30326. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30327. /** @hidden */
  30328. _submitVRFrame(): void;
  30329. /**
  30330. * Call this function to leave webVR mode
  30331. * Will do nothing if webVR is not supported or if there is no webVR device
  30332. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30333. */
  30334. disableVR(): void;
  30335. /**
  30336. * Gets a boolean indicating that the system is in VR mode and is presenting
  30337. * @returns true if VR mode is engaged
  30338. */
  30339. isVRPresenting(): boolean;
  30340. /** @hidden */
  30341. _requestVRFrame(): void;
  30342. private _disableTouchAction;
  30343. private _rebuildInternalTextures;
  30344. private _rebuildEffects;
  30345. /**
  30346. * Gets a boolean indicating if all created effects are ready
  30347. * @returns true if all effects are ready
  30348. */
  30349. areAllEffectsReady(): boolean;
  30350. private _rebuildBuffers;
  30351. private _initGLContext;
  30352. /**
  30353. * Gets version of the current webGL context
  30354. */
  30355. readonly webGLVersion: number;
  30356. /**
  30357. * Gets a string idenfifying the name of the class
  30358. * @returns "Engine" string
  30359. */
  30360. getClassName(): string;
  30361. /**
  30362. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30363. */
  30364. readonly isStencilEnable: boolean;
  30365. /** @hidden */
  30366. _prepareWorkingCanvas(): void;
  30367. /**
  30368. * Reset the texture cache to empty state
  30369. */
  30370. resetTextureCache(): void;
  30371. /**
  30372. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30374. * @returns true if engine is in deterministic lock step mode
  30375. */
  30376. isDeterministicLockStep(): boolean;
  30377. /**
  30378. * Gets the max steps when engine is running in deterministic lock step
  30379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30380. * @returns the max steps
  30381. */
  30382. getLockstepMaxSteps(): number;
  30383. /**
  30384. * Gets an object containing information about the current webGL context
  30385. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30386. */
  30387. getGlInfo(): {
  30388. vendor: string;
  30389. renderer: string;
  30390. version: string;
  30391. };
  30392. /**
  30393. * Gets current aspect ratio
  30394. * @param viewportOwner defines the camera to use to get the aspect ratio
  30395. * @param useScreen defines if screen size must be used (or the current render target if any)
  30396. * @returns a number defining the aspect ratio
  30397. */
  30398. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30399. /**
  30400. * Gets current screen aspect ratio
  30401. * @returns a number defining the aspect ratio
  30402. */
  30403. getScreenAspectRatio(): number;
  30404. /**
  30405. * Gets the current render width
  30406. * @param useScreen defines if screen size must be used (or the current render target if any)
  30407. * @returns a number defining the current render width
  30408. */
  30409. getRenderWidth(useScreen?: boolean): number;
  30410. /**
  30411. * Gets the current render height
  30412. * @param useScreen defines if screen size must be used (or the current render target if any)
  30413. * @returns a number defining the current render height
  30414. */
  30415. getRenderHeight(useScreen?: boolean): number;
  30416. /**
  30417. * Gets the HTML canvas attached with the current webGL context
  30418. * @returns a HTML canvas
  30419. */
  30420. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30421. /**
  30422. * Gets host window
  30423. * @returns the host window object
  30424. */
  30425. getHostWindow(): Window;
  30426. /**
  30427. * Gets host document
  30428. * @returns the host document object
  30429. */
  30430. getHostDocument(): Document;
  30431. /**
  30432. * Gets the client rect of the HTML canvas attached with the current webGL context
  30433. * @returns a client rectanglee
  30434. */
  30435. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30436. /**
  30437. * Defines the hardware scaling level.
  30438. * By default the hardware scaling level is computed from the window device ratio.
  30439. * 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.
  30440. * @param level defines the level to use
  30441. */
  30442. setHardwareScalingLevel(level: number): void;
  30443. /**
  30444. * Gets the current hardware scaling level.
  30445. * By default the hardware scaling level is computed from the window device ratio.
  30446. * 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.
  30447. * @returns a number indicating the current hardware scaling level
  30448. */
  30449. getHardwareScalingLevel(): number;
  30450. /**
  30451. * Gets the list of loaded textures
  30452. * @returns an array containing all loaded textures
  30453. */
  30454. getLoadedTexturesCache(): InternalTexture[];
  30455. /**
  30456. * Gets the object containing all engine capabilities
  30457. * @returns the EngineCapabilities object
  30458. */
  30459. getCaps(): EngineCapabilities;
  30460. /**
  30461. * Gets the current depth function
  30462. * @returns a number defining the depth function
  30463. */
  30464. getDepthFunction(): Nullable<number>;
  30465. /**
  30466. * Sets the current depth function
  30467. * @param depthFunc defines the function to use
  30468. */
  30469. setDepthFunction(depthFunc: number): void;
  30470. /**
  30471. * Sets the current depth function to GREATER
  30472. */
  30473. setDepthFunctionToGreater(): void;
  30474. /**
  30475. * Sets the current depth function to GEQUAL
  30476. */
  30477. setDepthFunctionToGreaterOrEqual(): void;
  30478. /**
  30479. * Sets the current depth function to LESS
  30480. */
  30481. setDepthFunctionToLess(): void;
  30482. private _cachedStencilBuffer;
  30483. private _cachedStencilFunction;
  30484. private _cachedStencilMask;
  30485. private _cachedStencilOperationPass;
  30486. private _cachedStencilOperationFail;
  30487. private _cachedStencilOperationDepthFail;
  30488. private _cachedStencilReference;
  30489. /**
  30490. * Caches the the state of the stencil buffer
  30491. */
  30492. cacheStencilState(): void;
  30493. /**
  30494. * Restores the state of the stencil buffer
  30495. */
  30496. restoreStencilState(): void;
  30497. /**
  30498. * Sets the current depth function to LEQUAL
  30499. */
  30500. setDepthFunctionToLessOrEqual(): void;
  30501. /**
  30502. * Gets a boolean indicating if stencil buffer is enabled
  30503. * @returns the current stencil buffer state
  30504. */
  30505. getStencilBuffer(): boolean;
  30506. /**
  30507. * Enable or disable the stencil buffer
  30508. * @param enable defines if the stencil buffer must be enabled or disabled
  30509. */
  30510. setStencilBuffer(enable: boolean): void;
  30511. /**
  30512. * Gets the current stencil mask
  30513. * @returns a number defining the new stencil mask to use
  30514. */
  30515. getStencilMask(): number;
  30516. /**
  30517. * Sets the current stencil mask
  30518. * @param mask defines the new stencil mask to use
  30519. */
  30520. setStencilMask(mask: number): void;
  30521. /**
  30522. * Gets the current stencil function
  30523. * @returns a number defining the stencil function to use
  30524. */
  30525. getStencilFunction(): number;
  30526. /**
  30527. * Gets the current stencil reference value
  30528. * @returns a number defining the stencil reference value to use
  30529. */
  30530. getStencilFunctionReference(): number;
  30531. /**
  30532. * Gets the current stencil mask
  30533. * @returns a number defining the stencil mask to use
  30534. */
  30535. getStencilFunctionMask(): number;
  30536. /**
  30537. * Sets the current stencil function
  30538. * @param stencilFunc defines the new stencil function to use
  30539. */
  30540. setStencilFunction(stencilFunc: number): void;
  30541. /**
  30542. * Sets the current stencil reference
  30543. * @param reference defines the new stencil reference to use
  30544. */
  30545. setStencilFunctionReference(reference: number): void;
  30546. /**
  30547. * Sets the current stencil mask
  30548. * @param mask defines the new stencil mask to use
  30549. */
  30550. setStencilFunctionMask(mask: number): void;
  30551. /**
  30552. * Gets the current stencil operation when stencil fails
  30553. * @returns a number defining stencil operation to use when stencil fails
  30554. */
  30555. getStencilOperationFail(): number;
  30556. /**
  30557. * Gets the current stencil operation when depth fails
  30558. * @returns a number defining stencil operation to use when depth fails
  30559. */
  30560. getStencilOperationDepthFail(): number;
  30561. /**
  30562. * Gets the current stencil operation when stencil passes
  30563. * @returns a number defining stencil operation to use when stencil passes
  30564. */
  30565. getStencilOperationPass(): number;
  30566. /**
  30567. * Sets the stencil operation to use when stencil fails
  30568. * @param operation defines the stencil operation to use when stencil fails
  30569. */
  30570. setStencilOperationFail(operation: number): void;
  30571. /**
  30572. * Sets the stencil operation to use when depth fails
  30573. * @param operation defines the stencil operation to use when depth fails
  30574. */
  30575. setStencilOperationDepthFail(operation: number): void;
  30576. /**
  30577. * Sets the stencil operation to use when stencil passes
  30578. * @param operation defines the stencil operation to use when stencil passes
  30579. */
  30580. setStencilOperationPass(operation: number): void;
  30581. /**
  30582. * Sets a boolean indicating if the dithering state is enabled or disabled
  30583. * @param value defines the dithering state
  30584. */
  30585. setDitheringState(value: boolean): void;
  30586. /**
  30587. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30588. * @param value defines the rasterizer state
  30589. */
  30590. setRasterizerState(value: boolean): void;
  30591. /**
  30592. * stop executing a render loop function and remove it from the execution array
  30593. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30594. */
  30595. stopRenderLoop(renderFunction?: () => void): void;
  30596. /** @hidden */
  30597. _renderLoop(): void;
  30598. /**
  30599. * Can be used to override the current requestAnimationFrame requester.
  30600. * @hidden
  30601. */
  30602. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30603. /**
  30604. * Register and execute a render loop. The engine can have more than one render function
  30605. * @param renderFunction defines the function to continuously execute
  30606. */
  30607. runRenderLoop(renderFunction: () => void): void;
  30608. /**
  30609. * Toggle full screen mode
  30610. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30611. */
  30612. switchFullscreen(requestPointerLock: boolean): void;
  30613. /**
  30614. * Enters full screen mode
  30615. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30616. */
  30617. enterFullscreen(requestPointerLock: boolean): void;
  30618. /**
  30619. * Exits full screen mode
  30620. */
  30621. exitFullscreen(): void;
  30622. /**
  30623. * Enters Pointerlock mode
  30624. */
  30625. enterPointerlock(): void;
  30626. /**
  30627. * Exits Pointerlock mode
  30628. */
  30629. exitPointerlock(): void;
  30630. /**
  30631. * Clear the current render buffer or the current render target (if any is set up)
  30632. * @param color defines the color to use
  30633. * @param backBuffer defines if the back buffer must be cleared
  30634. * @param depth defines if the depth buffer must be cleared
  30635. * @param stencil defines if the stencil buffer must be cleared
  30636. */
  30637. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30638. /**
  30639. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30640. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30641. * @param y defines the y-coordinate of the corner of the clear rectangle
  30642. * @param width defines the width of the clear rectangle
  30643. * @param height defines the height of the clear rectangle
  30644. * @param clearColor defines the clear color
  30645. */
  30646. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30647. /**
  30648. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30649. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30650. * @param y defines the y-coordinate of the corner of the clear rectangle
  30651. * @param width defines the width of the clear rectangle
  30652. * @param height defines the height of the clear rectangle
  30653. */
  30654. enableScissor(x: number, y: number, width: number, height: number): void;
  30655. /**
  30656. * Disable previously set scissor test rectangle
  30657. */
  30658. disableScissor(): void;
  30659. private _viewportCached;
  30660. /** @hidden */
  30661. _viewport(x: number, y: number, width: number, height: number): void;
  30662. /**
  30663. * Set the WebGL's viewport
  30664. * @param viewport defines the viewport element to be used
  30665. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30666. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30667. */
  30668. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30669. /**
  30670. * Directly set the WebGL Viewport
  30671. * @param x defines the x coordinate of the viewport (in screen space)
  30672. * @param y defines the y coordinate of the viewport (in screen space)
  30673. * @param width defines the width of the viewport (in screen space)
  30674. * @param height defines the height of the viewport (in screen space)
  30675. * @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
  30676. */
  30677. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30678. /**
  30679. * Begin a new frame
  30680. */
  30681. beginFrame(): void;
  30682. /**
  30683. * Enf the current frame
  30684. */
  30685. endFrame(): void;
  30686. /**
  30687. * Resize the view according to the canvas' size
  30688. */
  30689. resize(): void;
  30690. /**
  30691. * Force a specific size of the canvas
  30692. * @param width defines the new canvas' width
  30693. * @param height defines the new canvas' height
  30694. */
  30695. setSize(width: number, height: number): void;
  30696. /**
  30697. * Binds the frame buffer to the specified texture.
  30698. * @param texture The texture to render to or null for the default canvas
  30699. * @param faceIndex The face of the texture to render to in case of cube texture
  30700. * @param requiredWidth The width of the target to render to
  30701. * @param requiredHeight The height of the target to render to
  30702. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30703. * @param depthStencilTexture The depth stencil texture to use to render
  30704. * @param lodLevel defines le lod level to bind to the frame buffer
  30705. */
  30706. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30707. /** @hidden */
  30708. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30709. /**
  30710. * Unbind the current render target texture from the webGL context
  30711. * @param texture defines the render target texture to unbind
  30712. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30713. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30714. */
  30715. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30716. /**
  30717. * Force the mipmap generation for the given render target texture
  30718. * @param texture defines the render target texture to use
  30719. */
  30720. generateMipMapsForCubemap(texture: InternalTexture): void;
  30721. /**
  30722. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30723. */
  30724. flushFramebuffer(): void;
  30725. /**
  30726. * Unbind the current render target and bind the default framebuffer
  30727. */
  30728. restoreDefaultFramebuffer(): void;
  30729. /**
  30730. * Create an uniform buffer
  30731. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30732. * @param elements defines the content of the uniform buffer
  30733. * @returns the webGL uniform buffer
  30734. */
  30735. createUniformBuffer(elements: FloatArray): DataBuffer;
  30736. /**
  30737. * Create a dynamic uniform buffer
  30738. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30739. * @param elements defines the content of the uniform buffer
  30740. * @returns the webGL uniform buffer
  30741. */
  30742. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30743. /**
  30744. * Update an existing uniform buffer
  30745. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30746. * @param uniformBuffer defines the target uniform buffer
  30747. * @param elements defines the content to update
  30748. * @param offset defines the offset in the uniform buffer where update should start
  30749. * @param count defines the size of the data to update
  30750. */
  30751. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30752. private _resetVertexBufferBinding;
  30753. /**
  30754. * Creates a vertex buffer
  30755. * @param data the data for the vertex buffer
  30756. * @returns the new WebGL static buffer
  30757. */
  30758. createVertexBuffer(data: DataArray): DataBuffer;
  30759. /**
  30760. * Creates a dynamic vertex buffer
  30761. * @param data the data for the dynamic vertex buffer
  30762. * @returns the new WebGL dynamic buffer
  30763. */
  30764. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30765. /**
  30766. * Update a dynamic index buffer
  30767. * @param indexBuffer defines the target index buffer
  30768. * @param indices defines the data to update
  30769. * @param offset defines the offset in the target index buffer where update should start
  30770. */
  30771. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30772. /**
  30773. * Updates a dynamic vertex buffer.
  30774. * @param vertexBuffer the vertex buffer to update
  30775. * @param data the data used to update the vertex buffer
  30776. * @param byteOffset the byte offset of the data
  30777. * @param byteLength the byte length of the data
  30778. */
  30779. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30780. private _resetIndexBufferBinding;
  30781. /**
  30782. * Creates a new index buffer
  30783. * @param indices defines the content of the index buffer
  30784. * @param updatable defines if the index buffer must be updatable
  30785. * @returns a new webGL buffer
  30786. */
  30787. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30788. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30789. /**
  30790. * Bind a webGL buffer to the webGL context
  30791. * @param buffer defines the buffer to bind
  30792. */
  30793. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30794. /**
  30795. * Bind an uniform buffer to the current webGL context
  30796. * @param buffer defines the buffer to bind
  30797. */
  30798. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30799. /**
  30800. * Bind a buffer to the current webGL context at a given location
  30801. * @param buffer defines the buffer to bind
  30802. * @param location defines the index where to bind the buffer
  30803. */
  30804. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30805. /**
  30806. * Bind a specific block at a given index in a specific shader program
  30807. * @param pipelineContext defines the pipeline context to use
  30808. * @param blockName defines the block name
  30809. * @param index defines the index where to bind the block
  30810. */
  30811. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30812. private bindIndexBuffer;
  30813. private bindBuffer;
  30814. /**
  30815. * update the bound buffer with the given data
  30816. * @param data defines the data to update
  30817. */
  30818. updateArrayBuffer(data: Float32Array): void;
  30819. private _vertexAttribPointer;
  30820. private _bindIndexBufferWithCache;
  30821. private _bindVertexBuffersAttributes;
  30822. /**
  30823. * Records a vertex array object
  30824. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30825. * @param vertexBuffers defines the list of vertex buffers to store
  30826. * @param indexBuffer defines the index buffer to store
  30827. * @param effect defines the effect to store
  30828. * @returns the new vertex array object
  30829. */
  30830. recordVertexArrayObject(vertexBuffers: {
  30831. [key: string]: VertexBuffer;
  30832. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30833. /**
  30834. * Bind a specific vertex array object
  30835. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30836. * @param vertexArrayObject defines the vertex array object to bind
  30837. * @param indexBuffer defines the index buffer to bind
  30838. */
  30839. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30840. /**
  30841. * Bind webGl buffers directly to the webGL context
  30842. * @param vertexBuffer defines the vertex buffer to bind
  30843. * @param indexBuffer defines the index buffer to bind
  30844. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30845. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30846. * @param effect defines the effect associated with the vertex buffer
  30847. */
  30848. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30849. private _unbindVertexArrayObject;
  30850. /**
  30851. * Bind a list of vertex buffers to the webGL context
  30852. * @param vertexBuffers defines the list of vertex buffers to bind
  30853. * @param indexBuffer defines the index buffer to bind
  30854. * @param effect defines the effect associated with the vertex buffers
  30855. */
  30856. bindBuffers(vertexBuffers: {
  30857. [key: string]: Nullable<VertexBuffer>;
  30858. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30859. /**
  30860. * Unbind all instance attributes
  30861. */
  30862. unbindInstanceAttributes(): void;
  30863. /**
  30864. * Release and free the memory of a vertex array object
  30865. * @param vao defines the vertex array object to delete
  30866. */
  30867. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30868. /** @hidden */
  30869. _releaseBuffer(buffer: DataBuffer): boolean;
  30870. protected _deleteBuffer(buffer: DataBuffer): void;
  30871. /**
  30872. * Creates a webGL buffer to use with instanciation
  30873. * @param capacity defines the size of the buffer
  30874. * @returns the webGL buffer
  30875. */
  30876. createInstancesBuffer(capacity: number): DataBuffer;
  30877. /**
  30878. * Delete a webGL buffer used with instanciation
  30879. * @param buffer defines the webGL buffer to delete
  30880. */
  30881. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30882. /**
  30883. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30884. * @param instancesBuffer defines the webGL buffer to update and bind
  30885. * @param data defines the data to store in the buffer
  30886. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30887. */
  30888. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30889. /**
  30890. * Apply all cached states (depth, culling, stencil and alpha)
  30891. */
  30892. applyStates(): void;
  30893. /**
  30894. * Send a draw order
  30895. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30896. * @param indexStart defines the starting index
  30897. * @param indexCount defines the number of index to draw
  30898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30899. */
  30900. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30901. /**
  30902. * Draw a list of points
  30903. * @param verticesStart defines the index of first vertex to draw
  30904. * @param verticesCount defines the count of vertices to draw
  30905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30906. */
  30907. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30908. /**
  30909. * Draw a list of unindexed primitives
  30910. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30911. * @param verticesStart defines the index of first vertex to draw
  30912. * @param verticesCount defines the count of vertices to draw
  30913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30914. */
  30915. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30916. /**
  30917. * Draw a list of indexed primitives
  30918. * @param fillMode defines the primitive to use
  30919. * @param indexStart defines the starting index
  30920. * @param indexCount defines the number of index to draw
  30921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30922. */
  30923. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30924. /**
  30925. * Draw a list of unindexed primitives
  30926. * @param fillMode defines the primitive to use
  30927. * @param verticesStart defines the index of first vertex to draw
  30928. * @param verticesCount defines the count of vertices to draw
  30929. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30930. */
  30931. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30932. private _drawMode;
  30933. /** @hidden */
  30934. _releaseEffect(effect: Effect): void;
  30935. /** @hidden */
  30936. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30937. /**
  30938. * Create a new effect (used to store vertex/fragment shaders)
  30939. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30940. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30941. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30942. * @param samplers defines an array of string used to represent textures
  30943. * @param defines defines the string containing the defines to use to compile the shaders
  30944. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30945. * @param onCompiled defines a function to call when the effect creation is successful
  30946. * @param onError defines a function to call when the effect creation has failed
  30947. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30948. * @returns the new Effect
  30949. */
  30950. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30951. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30952. private _compileShader;
  30953. private _compileRawShader;
  30954. /**
  30955. * Directly creates a webGL program
  30956. * @param pipelineContext defines the pipeline context to attach to
  30957. * @param vertexCode defines the vertex shader code to use
  30958. * @param fragmentCode defines the fragment shader code to use
  30959. * @param context defines the webGL context to use (if not set, the current one will be used)
  30960. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30961. * @returns the new webGL program
  30962. */
  30963. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30964. /**
  30965. * Creates a webGL program
  30966. * @param pipelineContext defines the pipeline context to attach to
  30967. * @param vertexCode defines the vertex shader code to use
  30968. * @param fragmentCode defines the fragment shader code to use
  30969. * @param defines defines the string containing the defines to use to compile the shaders
  30970. * @param context defines the webGL context to use (if not set, the current one will be used)
  30971. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30972. * @returns the new webGL program
  30973. */
  30974. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30975. /**
  30976. * Creates a new pipeline context
  30977. * @returns the new pipeline
  30978. */
  30979. createPipelineContext(): IPipelineContext;
  30980. private _createShaderProgram;
  30981. private _finalizePipelineContext;
  30982. /** @hidden */
  30983. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30984. /** @hidden */
  30985. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30986. /** @hidden */
  30987. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30988. /**
  30989. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30990. * @param pipelineContext defines the pipeline context to use
  30991. * @param uniformsNames defines the list of uniform names
  30992. * @returns an array of webGL uniform locations
  30993. */
  30994. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30995. /**
  30996. * Gets the lsit of active attributes for a given webGL program
  30997. * @param pipelineContext defines the pipeline context to use
  30998. * @param attributesNames defines the list of attribute names to get
  30999. * @returns an array of indices indicating the offset of each attribute
  31000. */
  31001. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31002. /**
  31003. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31004. * @param effect defines the effect to activate
  31005. */
  31006. enableEffect(effect: Nullable<Effect>): void;
  31007. /**
  31008. * Set the value of an uniform to an array of int32
  31009. * @param uniform defines the webGL uniform location where to store the value
  31010. * @param array defines the array of int32 to store
  31011. */
  31012. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31013. /**
  31014. * Set the value of an uniform to an array of int32 (stored as vec2)
  31015. * @param uniform defines the webGL uniform location where to store the value
  31016. * @param array defines the array of int32 to store
  31017. */
  31018. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31019. /**
  31020. * Set the value of an uniform to an array of int32 (stored as vec3)
  31021. * @param uniform defines the webGL uniform location where to store the value
  31022. * @param array defines the array of int32 to store
  31023. */
  31024. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31025. /**
  31026. * Set the value of an uniform to an array of int32 (stored as vec4)
  31027. * @param uniform defines the webGL uniform location where to store the value
  31028. * @param array defines the array of int32 to store
  31029. */
  31030. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31031. /**
  31032. * Set the value of an uniform to an array of float32
  31033. * @param uniform defines the webGL uniform location where to store the value
  31034. * @param array defines the array of float32 to store
  31035. */
  31036. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31037. /**
  31038. * Set the value of an uniform to an array of float32 (stored as vec2)
  31039. * @param uniform defines the webGL uniform location where to store the value
  31040. * @param array defines the array of float32 to store
  31041. */
  31042. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31043. /**
  31044. * Set the value of an uniform to an array of float32 (stored as vec3)
  31045. * @param uniform defines the webGL uniform location where to store the value
  31046. * @param array defines the array of float32 to store
  31047. */
  31048. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31049. /**
  31050. * Set the value of an uniform to an array of float32 (stored as vec4)
  31051. * @param uniform defines the webGL uniform location where to store the value
  31052. * @param array defines the array of float32 to store
  31053. */
  31054. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31055. /**
  31056. * Set the value of an uniform to an array of number
  31057. * @param uniform defines the webGL uniform location where to store the value
  31058. * @param array defines the array of number to store
  31059. */
  31060. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31061. /**
  31062. * Set the value of an uniform to an array of number (stored as vec2)
  31063. * @param uniform defines the webGL uniform location where to store the value
  31064. * @param array defines the array of number to store
  31065. */
  31066. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31067. /**
  31068. * Set the value of an uniform to an array of number (stored as vec3)
  31069. * @param uniform defines the webGL uniform location where to store the value
  31070. * @param array defines the array of number to store
  31071. */
  31072. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31073. /**
  31074. * Set the value of an uniform to an array of number (stored as vec4)
  31075. * @param uniform defines the webGL uniform location where to store the value
  31076. * @param array defines the array of number to store
  31077. */
  31078. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31079. /**
  31080. * Set the value of an uniform to an array of float32 (stored as matrices)
  31081. * @param uniform defines the webGL uniform location where to store the value
  31082. * @param matrices defines the array of float32 to store
  31083. */
  31084. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31085. /**
  31086. * Set the value of an uniform to a matrix (3x3)
  31087. * @param uniform defines the webGL uniform location where to store the value
  31088. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31089. */
  31090. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31091. /**
  31092. * Set the value of an uniform to a matrix (2x2)
  31093. * @param uniform defines the webGL uniform location where to store the value
  31094. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31095. */
  31096. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31097. /**
  31098. * Set the value of an uniform to a number (int)
  31099. * @param uniform defines the webGL uniform location where to store the value
  31100. * @param value defines the int number to store
  31101. */
  31102. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31103. /**
  31104. * Set the value of an uniform to a number (float)
  31105. * @param uniform defines the webGL uniform location where to store the value
  31106. * @param value defines the float number to store
  31107. */
  31108. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31109. /**
  31110. * Set the value of an uniform to a vec2
  31111. * @param uniform defines the webGL uniform location where to store the value
  31112. * @param x defines the 1st component of the value
  31113. * @param y defines the 2nd component of the value
  31114. */
  31115. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31116. /**
  31117. * Set the value of an uniform to a vec3
  31118. * @param uniform defines the webGL uniform location where to store the value
  31119. * @param x defines the 1st component of the value
  31120. * @param y defines the 2nd component of the value
  31121. * @param z defines the 3rd component of the value
  31122. */
  31123. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31124. /**
  31125. * Set the value of an uniform to a boolean
  31126. * @param uniform defines the webGL uniform location where to store the value
  31127. * @param bool defines the boolean to store
  31128. */
  31129. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31130. /**
  31131. * Set the value of an uniform to a vec4
  31132. * @param uniform defines the webGL uniform location where to store the value
  31133. * @param x defines the 1st component of the value
  31134. * @param y defines the 2nd component of the value
  31135. * @param z defines the 3rd component of the value
  31136. * @param w defines the 4th component of the value
  31137. */
  31138. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31139. /**
  31140. * Sets a Color4 on a uniform variable
  31141. * @param uniform defines the uniform location
  31142. * @param color4 defines the value to be set
  31143. */
  31144. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31145. /**
  31146. * Set various states to the webGL context
  31147. * @param culling defines backface culling state
  31148. * @param zOffset defines the value to apply to zOffset (0 by default)
  31149. * @param force defines if states must be applied even if cache is up to date
  31150. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31151. */
  31152. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31153. /**
  31154. * Set the z offset to apply to current rendering
  31155. * @param value defines the offset to apply
  31156. */
  31157. setZOffset(value: number): void;
  31158. /**
  31159. * Gets the current value of the zOffset
  31160. * @returns the current zOffset state
  31161. */
  31162. getZOffset(): number;
  31163. /**
  31164. * Enable or disable depth buffering
  31165. * @param enable defines the state to set
  31166. */
  31167. setDepthBuffer(enable: boolean): void;
  31168. /**
  31169. * Gets a boolean indicating if depth writing is enabled
  31170. * @returns the current depth writing state
  31171. */
  31172. getDepthWrite(): boolean;
  31173. /**
  31174. * Enable or disable depth writing
  31175. * @param enable defines the state to set
  31176. */
  31177. setDepthWrite(enable: boolean): void;
  31178. /**
  31179. * Enable or disable color writing
  31180. * @param enable defines the state to set
  31181. */
  31182. setColorWrite(enable: boolean): void;
  31183. /**
  31184. * Gets a boolean indicating if color writing is enabled
  31185. * @returns the current color writing state
  31186. */
  31187. getColorWrite(): boolean;
  31188. /**
  31189. * Sets alpha constants used by some alpha blending modes
  31190. * @param r defines the red component
  31191. * @param g defines the green component
  31192. * @param b defines the blue component
  31193. * @param a defines the alpha component
  31194. */
  31195. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31196. /**
  31197. * Sets the current alpha mode
  31198. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31199. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31200. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31201. */
  31202. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31203. /**
  31204. * Gets the current alpha mode
  31205. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31206. * @returns the current alpha mode
  31207. */
  31208. getAlphaMode(): number;
  31209. /**
  31210. * Clears the list of texture accessible through engine.
  31211. * This can help preventing texture load conflict due to name collision.
  31212. */
  31213. clearInternalTexturesCache(): void;
  31214. /**
  31215. * Force the entire cache to be cleared
  31216. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31217. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31218. */
  31219. wipeCaches(bruteForce?: boolean): void;
  31220. /**
  31221. * Set the compressed texture format to use, based on the formats you have, and the formats
  31222. * supported by the hardware / browser.
  31223. *
  31224. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31225. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31226. * to API arguments needed to compressed textures. This puts the burden on the container
  31227. * generator to house the arcane code for determining these for current & future formats.
  31228. *
  31229. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31230. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31231. *
  31232. * Note: The result of this call is not taken into account when a texture is base64.
  31233. *
  31234. * @param formatsAvailable defines the list of those format families you have created
  31235. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31236. *
  31237. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31238. * @returns The extension selected.
  31239. */
  31240. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31241. /** @hidden */
  31242. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31243. min: number;
  31244. mag: number;
  31245. };
  31246. /** @hidden */
  31247. _createTexture(): WebGLTexture;
  31248. /**
  31249. * Usually called from Texture.ts.
  31250. * Passed information to create a WebGLTexture
  31251. * @param urlArg defines a value which contains one of the following:
  31252. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31253. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31254. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31255. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31256. * @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)
  31257. * @param scene needed for loading to the correct scene
  31258. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31259. * @param onLoad optional callback to be called upon successful completion
  31260. * @param onError optional callback to be called upon failure
  31261. * @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
  31262. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31263. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31264. * @param forcedExtension defines the extension to use to pick the right loader
  31265. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31266. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31267. */
  31268. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31269. /**
  31270. * @hidden
  31271. * Rescales a texture
  31272. * @param source input texutre
  31273. * @param destination destination texture
  31274. * @param scene scene to use to render the resize
  31275. * @param internalFormat format to use when resizing
  31276. * @param onComplete callback to be called when resize has completed
  31277. */
  31278. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31279. private _unpackFlipYCached;
  31280. /**
  31281. * In case you are sharing the context with other applications, it might
  31282. * be interested to not cache the unpack flip y state to ensure a consistent
  31283. * value would be set.
  31284. */
  31285. enableUnpackFlipYCached: boolean;
  31286. /** @hidden */
  31287. _unpackFlipY(value: boolean): void;
  31288. /** @hidden */
  31289. _getUnpackAlignement(): number;
  31290. /**
  31291. * Creates a dynamic texture
  31292. * @param width defines the width of the texture
  31293. * @param height defines the height of the texture
  31294. * @param generateMipMaps defines if the engine should generate the mip levels
  31295. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31296. * @returns the dynamic texture inside an InternalTexture
  31297. */
  31298. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31299. /**
  31300. * Update the sampling mode of a given texture
  31301. * @param samplingMode defines the required sampling mode
  31302. * @param texture defines the texture to update
  31303. */
  31304. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31305. /**
  31306. * Update the content of a dynamic texture
  31307. * @param texture defines the texture to update
  31308. * @param canvas defines the canvas containing the source
  31309. * @param invertY defines if data must be stored with Y axis inverted
  31310. * @param premulAlpha defines if alpha is stored as premultiplied
  31311. * @param format defines the format of the data
  31312. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31313. */
  31314. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31315. /**
  31316. * Update a video texture
  31317. * @param texture defines the texture to update
  31318. * @param video defines the video element to use
  31319. * @param invertY defines if data must be stored with Y axis inverted
  31320. */
  31321. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31322. /**
  31323. * Updates a depth texture Comparison Mode and Function.
  31324. * If the comparison Function is equal to 0, the mode will be set to none.
  31325. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31326. * @param texture The texture to set the comparison function for
  31327. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31328. */
  31329. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31330. /** @hidden */
  31331. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31332. width: number;
  31333. height: number;
  31334. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31335. /**
  31336. * Creates a depth stencil texture.
  31337. * This is only available in WebGL 2 or with the depth texture extension available.
  31338. * @param size The size of face edge in the texture.
  31339. * @param options The options defining the texture.
  31340. * @returns The texture
  31341. */
  31342. createDepthStencilTexture(size: number | {
  31343. width: number;
  31344. height: number;
  31345. }, options: DepthTextureCreationOptions): InternalTexture;
  31346. /**
  31347. * Creates a depth stencil texture.
  31348. * This is only available in WebGL 2 or with the depth texture extension available.
  31349. * @param size The size of face edge in the texture.
  31350. * @param options The options defining the texture.
  31351. * @returns The texture
  31352. */
  31353. private _createDepthStencilTexture;
  31354. /**
  31355. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31356. * @param renderTarget The render target to set the frame buffer for
  31357. */
  31358. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31359. /**
  31360. * Creates a new render target texture
  31361. * @param size defines the size of the texture
  31362. * @param options defines the options used to create the texture
  31363. * @returns a new render target texture stored in an InternalTexture
  31364. */
  31365. createRenderTargetTexture(size: number | {
  31366. width: number;
  31367. height: number;
  31368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31369. /** @hidden */
  31370. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31371. /**
  31372. * Updates the sample count of a render target texture
  31373. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31374. * @param texture defines the texture to update
  31375. * @param samples defines the sample count to set
  31376. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31377. */
  31378. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31379. /** @hidden */
  31380. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31381. /** @hidden */
  31382. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31383. /** @hidden */
  31384. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31385. /** @hidden */
  31386. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31387. /**
  31388. * @hidden
  31389. */
  31390. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31391. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31392. private _prepareWebGLTexture;
  31393. /** @hidden */
  31394. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31395. /** @hidden */
  31396. _releaseFramebufferObjects(texture: InternalTexture): void;
  31397. /** @hidden */
  31398. _releaseTexture(texture: InternalTexture): void;
  31399. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31400. protected _setProgram(program: WebGLProgram): void;
  31401. protected _boundUniforms: {
  31402. [key: number]: WebGLUniformLocation;
  31403. };
  31404. /**
  31405. * Binds an effect to the webGL context
  31406. * @param effect defines the effect to bind
  31407. */
  31408. bindSamplers(effect: Effect): void;
  31409. private _activateCurrentTexture;
  31410. /** @hidden */
  31411. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31412. /** @hidden */
  31413. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31414. /**
  31415. * Sets a texture to the webGL context from a postprocess
  31416. * @param channel defines the channel to use
  31417. * @param postProcess defines the source postprocess
  31418. */
  31419. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31420. /**
  31421. * Binds the output of the passed in post process to the texture channel specified
  31422. * @param channel The channel the texture should be bound to
  31423. * @param postProcess The post process which's output should be bound
  31424. */
  31425. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31426. /**
  31427. * Unbind all textures from the webGL context
  31428. */
  31429. unbindAllTextures(): void;
  31430. /**
  31431. * Sets a texture to the according uniform.
  31432. * @param channel The texture channel
  31433. * @param uniform The uniform to set
  31434. * @param texture The texture to apply
  31435. */
  31436. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31437. /**
  31438. * Sets a depth stencil texture from a render target to the according uniform.
  31439. * @param channel The texture channel
  31440. * @param uniform The uniform to set
  31441. * @param texture The render target texture containing the depth stencil texture to apply
  31442. */
  31443. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31444. private _bindSamplerUniformToChannel;
  31445. private _getTextureWrapMode;
  31446. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31447. /**
  31448. * Sets an array of texture to the webGL context
  31449. * @param channel defines the channel where the texture array must be set
  31450. * @param uniform defines the associated uniform location
  31451. * @param textures defines the array of textures to bind
  31452. */
  31453. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31454. /** @hidden */
  31455. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31456. private _setTextureParameterFloat;
  31457. private _setTextureParameterInteger;
  31458. /**
  31459. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31460. * @param x defines the x coordinate of the rectangle where pixels must be read
  31461. * @param y defines the y coordinate of the rectangle where pixels must be read
  31462. * @param width defines the width of the rectangle where pixels must be read
  31463. * @param height defines the height of the rectangle where pixels must be read
  31464. * @returns a Uint8Array containing RGBA colors
  31465. */
  31466. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31467. /**
  31468. * Add an externaly attached data from its key.
  31469. * This method call will fail and return false, if such key already exists.
  31470. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31471. * @param key the unique key that identifies the data
  31472. * @param data the data object to associate to the key for this Engine instance
  31473. * @return true if no such key were already present and the data was added successfully, false otherwise
  31474. */
  31475. addExternalData<T>(key: string, data: T): boolean;
  31476. /**
  31477. * Get an externaly attached data from its key
  31478. * @param key the unique key that identifies the data
  31479. * @return the associated data, if present (can be null), or undefined if not present
  31480. */
  31481. getExternalData<T>(key: string): T;
  31482. /**
  31483. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31484. * @param key the unique key that identifies the data
  31485. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31486. * @return the associated data, can be null if the factory returned null.
  31487. */
  31488. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31489. /**
  31490. * Remove an externaly attached data from the Engine instance
  31491. * @param key the unique key that identifies the data
  31492. * @return true if the data was successfully removed, false if it doesn't exist
  31493. */
  31494. removeExternalData(key: string): boolean;
  31495. /**
  31496. * Unbind all vertex attributes from the webGL context
  31497. */
  31498. unbindAllAttributes(): void;
  31499. /**
  31500. * 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
  31501. */
  31502. releaseEffects(): void;
  31503. /**
  31504. * Dispose and release all associated resources
  31505. */
  31506. dispose(): void;
  31507. /**
  31508. * Display the loading screen
  31509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31510. */
  31511. displayLoadingUI(): void;
  31512. /**
  31513. * Hide the loading screen
  31514. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31515. */
  31516. hideLoadingUI(): void;
  31517. /**
  31518. * Gets the current loading screen object
  31519. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31520. */
  31521. /**
  31522. * Sets the current loading screen object
  31523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31524. */
  31525. loadingScreen: ILoadingScreen;
  31526. /**
  31527. * Sets the current loading screen text
  31528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31529. */
  31530. loadingUIText: string;
  31531. /**
  31532. * Sets the current loading screen background color
  31533. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31534. */
  31535. loadingUIBackgroundColor: string;
  31536. /**
  31537. * Attach a new callback raised when context lost event is fired
  31538. * @param callback defines the callback to call
  31539. */
  31540. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31541. /**
  31542. * Attach a new callback raised when context restored event is fired
  31543. * @param callback defines the callback to call
  31544. */
  31545. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31546. /**
  31547. * Gets the source code of the vertex shader associated with a specific webGL program
  31548. * @param program defines the program to use
  31549. * @returns a string containing the source code of the vertex shader associated with the program
  31550. */
  31551. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31552. /**
  31553. * Gets the source code of the fragment shader associated with a specific webGL program
  31554. * @param program defines the program to use
  31555. * @returns a string containing the source code of the fragment shader associated with the program
  31556. */
  31557. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31558. /**
  31559. * Get the current error code of the webGL context
  31560. * @returns the error code
  31561. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31562. */
  31563. getError(): number;
  31564. /**
  31565. * Gets the current framerate
  31566. * @returns a number representing the framerate
  31567. */
  31568. getFps(): number;
  31569. /**
  31570. * Gets the time spent between current and previous frame
  31571. * @returns a number representing the delta time in ms
  31572. */
  31573. getDeltaTime(): number;
  31574. private _measureFps;
  31575. /** @hidden */
  31576. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31577. private _canRenderToFloatFramebuffer;
  31578. private _canRenderToHalfFloatFramebuffer;
  31579. private _canRenderToFramebuffer;
  31580. /** @hidden */
  31581. _getWebGLTextureType(type: number): number;
  31582. /** @hidden */
  31583. _getInternalFormat(format: number): number;
  31584. /** @hidden */
  31585. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31586. /** @hidden */
  31587. _getRGBAMultiSampleBufferFormat(type: number): number;
  31588. /** @hidden */
  31589. _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;
  31590. /** @hidden */
  31591. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31592. /**
  31593. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31594. * @returns true if the engine can be created
  31595. * @ignorenaming
  31596. */
  31597. static isSupported(): boolean;
  31598. /**
  31599. * Find the next highest power of two.
  31600. * @param x Number to start search from.
  31601. * @return Next highest power of two.
  31602. */
  31603. static CeilingPOT(x: number): number;
  31604. /**
  31605. * Find the next lowest power of two.
  31606. * @param x Number to start search from.
  31607. * @return Next lowest power of two.
  31608. */
  31609. static FloorPOT(x: number): number;
  31610. /**
  31611. * Find the nearest power of two.
  31612. * @param x Number to start search from.
  31613. * @return Next nearest power of two.
  31614. */
  31615. static NearestPOT(x: number): number;
  31616. /**
  31617. * Get the closest exponent of two
  31618. * @param value defines the value to approximate
  31619. * @param max defines the maximum value to return
  31620. * @param mode defines how to define the closest value
  31621. * @returns closest exponent of two of the given value
  31622. */
  31623. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31624. /**
  31625. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31626. * @param func - the function to be called
  31627. * @param requester - the object that will request the next frame. Falls back to window.
  31628. * @returns frame number
  31629. */
  31630. static QueueNewFrame(func: () => void, requester?: any): number;
  31631. /**
  31632. * Ask the browser to promote the current element to pointerlock mode
  31633. * @param element defines the DOM element to promote
  31634. */
  31635. static _RequestPointerlock(element: HTMLElement): void;
  31636. /**
  31637. * Asks the browser to exit pointerlock mode
  31638. */
  31639. static _ExitPointerlock(): void;
  31640. /**
  31641. * Ask the browser to promote the current element to fullscreen rendering mode
  31642. * @param element defines the DOM element to promote
  31643. */
  31644. static _RequestFullscreen(element: HTMLElement): void;
  31645. /**
  31646. * Asks the browser to exit fullscreen mode
  31647. */
  31648. static _ExitFullscreen(): void;
  31649. }
  31650. }
  31651. declare module BABYLON {
  31652. /**
  31653. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31654. * during the life time of the application.
  31655. */
  31656. export class EngineStore {
  31657. /** Gets the list of created engines */
  31658. static Instances: Engine[];
  31659. /** @hidden */
  31660. static _LastCreatedScene: Nullable<Scene>;
  31661. /**
  31662. * Gets the latest created engine
  31663. */
  31664. static readonly LastCreatedEngine: Nullable<Engine>;
  31665. /**
  31666. * Gets the latest created scene
  31667. */
  31668. static readonly LastCreatedScene: Nullable<Scene>;
  31669. /**
  31670. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31671. * @ignorenaming
  31672. */
  31673. static UseFallbackTexture: boolean;
  31674. /**
  31675. * Texture content used if a texture cannot loaded
  31676. * @ignorenaming
  31677. */
  31678. static FallbackTexture: string;
  31679. }
  31680. }
  31681. declare module BABYLON {
  31682. /**
  31683. * Helper class that provides a small promise polyfill
  31684. */
  31685. export class PromisePolyfill {
  31686. /**
  31687. * Static function used to check if the polyfill is required
  31688. * If this is the case then the function will inject the polyfill to window.Promise
  31689. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31690. */
  31691. static Apply(force?: boolean): void;
  31692. }
  31693. }
  31694. declare module BABYLON {
  31695. /**
  31696. * Interface for screenshot methods with describe argument called `size` as object with options
  31697. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31698. */
  31699. export interface IScreenshotSize {
  31700. /**
  31701. * number in pixels for canvas height
  31702. */
  31703. height?: number;
  31704. /**
  31705. * multiplier allowing render at a higher or lower resolution
  31706. * If value is defined then height and width will be ignored and taken from camera
  31707. */
  31708. precision?: number;
  31709. /**
  31710. * number in pixels for canvas width
  31711. */
  31712. width?: number;
  31713. }
  31714. }
  31715. declare module BABYLON {
  31716. interface IColor4Like {
  31717. r: float;
  31718. g: float;
  31719. b: float;
  31720. a: float;
  31721. }
  31722. /**
  31723. * Class containing a set of static utilities functions
  31724. */
  31725. export class Tools {
  31726. /**
  31727. * Gets or sets the base URL to use to load assets
  31728. */
  31729. static BaseUrl: string;
  31730. /**
  31731. * Enable/Disable Custom HTTP Request Headers globally.
  31732. * default = false
  31733. * @see CustomRequestHeaders
  31734. */
  31735. static UseCustomRequestHeaders: boolean;
  31736. /**
  31737. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31738. * i.e. when loading files, where the server/service expects an Authorization header
  31739. */
  31740. static CustomRequestHeaders: {
  31741. [key: string]: string;
  31742. };
  31743. /**
  31744. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31745. */
  31746. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31747. /**
  31748. * Default behaviour for cors in the application.
  31749. * It can be a string if the expected behavior is identical in the entire app.
  31750. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31751. */
  31752. static CorsBehavior: string | ((url: string | string[]) => string);
  31753. /**
  31754. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31755. * @ignorenaming
  31756. */
  31757. static UseFallbackTexture: boolean;
  31758. /**
  31759. * Use this object to register external classes like custom textures or material
  31760. * to allow the laoders to instantiate them
  31761. */
  31762. static RegisteredExternalClasses: {
  31763. [key: string]: Object;
  31764. };
  31765. /**
  31766. * Texture content used if a texture cannot loaded
  31767. * @ignorenaming
  31768. */
  31769. static fallbackTexture: string;
  31770. /**
  31771. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31772. * @param u defines the coordinate on X axis
  31773. * @param v defines the coordinate on Y axis
  31774. * @param width defines the width of the source data
  31775. * @param height defines the height of the source data
  31776. * @param pixels defines the source byte array
  31777. * @param color defines the output color
  31778. */
  31779. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31780. /**
  31781. * Interpolates between a and b via alpha
  31782. * @param a The lower value (returned when alpha = 0)
  31783. * @param b The upper value (returned when alpha = 1)
  31784. * @param alpha The interpolation-factor
  31785. * @return The mixed value
  31786. */
  31787. static Mix(a: number, b: number, alpha: number): number;
  31788. /**
  31789. * Tries to instantiate a new object from a given class name
  31790. * @param className defines the class name to instantiate
  31791. * @returns the new object or null if the system was not able to do the instantiation
  31792. */
  31793. static Instantiate(className: string): any;
  31794. /**
  31795. * Provides a slice function that will work even on IE
  31796. * @param data defines the array to slice
  31797. * @param start defines the start of the data (optional)
  31798. * @param end defines the end of the data (optional)
  31799. * @returns the new sliced array
  31800. */
  31801. static Slice<T>(data: T, start?: number, end?: number): T;
  31802. /**
  31803. * Polyfill for setImmediate
  31804. * @param action defines the action to execute after the current execution block
  31805. */
  31806. static SetImmediate(action: () => void): void;
  31807. /**
  31808. * Function indicating if a number is an exponent of 2
  31809. * @param value defines the value to test
  31810. * @returns true if the value is an exponent of 2
  31811. */
  31812. static IsExponentOfTwo(value: number): boolean;
  31813. private static _tmpFloatArray;
  31814. /**
  31815. * Returns the nearest 32-bit single precision float representation of a Number
  31816. * @param value A Number. If the parameter is of a different type, it will get converted
  31817. * to a number or to NaN if it cannot be converted
  31818. * @returns number
  31819. */
  31820. static FloatRound(value: number): number;
  31821. /**
  31822. * Extracts the filename from a path
  31823. * @param path defines the path to use
  31824. * @returns the filename
  31825. */
  31826. static GetFilename(path: string): string;
  31827. /**
  31828. * Extracts the "folder" part of a path (everything before the filename).
  31829. * @param uri The URI to extract the info from
  31830. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31831. * @returns The "folder" part of the path
  31832. */
  31833. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31834. /**
  31835. * Extracts text content from a DOM element hierarchy
  31836. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31837. */
  31838. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31839. /**
  31840. * Convert an angle in radians to degrees
  31841. * @param angle defines the angle to convert
  31842. * @returns the angle in degrees
  31843. */
  31844. static ToDegrees(angle: number): number;
  31845. /**
  31846. * Convert an angle in degrees to radians
  31847. * @param angle defines the angle to convert
  31848. * @returns the angle in radians
  31849. */
  31850. static ToRadians(angle: number): number;
  31851. /**
  31852. * Encode a buffer to a base64 string
  31853. * @param buffer defines the buffer to encode
  31854. * @returns the encoded string
  31855. */
  31856. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31857. /**
  31858. * Returns an array if obj is not an array
  31859. * @param obj defines the object to evaluate as an array
  31860. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31861. * @returns either obj directly if obj is an array or a new array containing obj
  31862. */
  31863. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31864. /**
  31865. * Gets the pointer prefix to use
  31866. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31867. */
  31868. static GetPointerPrefix(): string;
  31869. /**
  31870. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31871. * @param url define the url we are trying
  31872. * @param element define the dom element where to configure the cors policy
  31873. */
  31874. static SetCorsBehavior(url: string | string[], element: {
  31875. crossOrigin: string | null;
  31876. }): void;
  31877. /**
  31878. * Removes unwanted characters from an url
  31879. * @param url defines the url to clean
  31880. * @returns the cleaned url
  31881. */
  31882. static CleanUrl(url: string): string;
  31883. /**
  31884. * Gets or sets a function used to pre-process url before using them to load assets
  31885. */
  31886. static PreprocessUrl: (url: string) => string;
  31887. /**
  31888. * Loads an image as an HTMLImageElement.
  31889. * @param input url string, ArrayBuffer, or Blob to load
  31890. * @param onLoad callback called when the image successfully loads
  31891. * @param onError callback called when the image fails to load
  31892. * @param offlineProvider offline provider for caching
  31893. * @returns the HTMLImageElement of the loaded image
  31894. */
  31895. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31896. /**
  31897. * Loads a file
  31898. * @param url url string, ArrayBuffer, or Blob to load
  31899. * @param onSuccess callback called when the file successfully loads
  31900. * @param onProgress callback called while file is loading (if the server supports this mode)
  31901. * @param offlineProvider defines the offline provider for caching
  31902. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31903. * @param onError callback called when the file fails to load
  31904. * @returns a file request object
  31905. */
  31906. 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;
  31907. /**
  31908. * Loads a file from a url
  31909. * @param url the file url to load
  31910. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31911. */
  31912. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31913. /**
  31914. * Load a script (identified by an url). When the url returns, the
  31915. * content of this file is added into a new script element, attached to the DOM (body element)
  31916. * @param scriptUrl defines the url of the script to laod
  31917. * @param onSuccess defines the callback called when the script is loaded
  31918. * @param onError defines the callback to call if an error occurs
  31919. * @param scriptId defines the id of the script element
  31920. */
  31921. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31922. /**
  31923. * Load an asynchronous script (identified by an url). When the url returns, the
  31924. * content of this file is added into a new script element, attached to the DOM (body element)
  31925. * @param scriptUrl defines the url of the script to laod
  31926. * @param scriptId defines the id of the script element
  31927. * @returns a promise request object
  31928. */
  31929. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31930. /**
  31931. * Loads a file from a blob
  31932. * @param fileToLoad defines the blob to use
  31933. * @param callback defines the callback to call when data is loaded
  31934. * @param progressCallback defines the callback to call during loading process
  31935. * @returns a file request object
  31936. */
  31937. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31938. /**
  31939. * Loads a file
  31940. * @param fileToLoad defines the file to load
  31941. * @param callback defines the callback to call when data is loaded
  31942. * @param progressCallBack defines the callback to call during loading process
  31943. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31944. * @returns a file request object
  31945. */
  31946. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31947. /**
  31948. * Creates a data url from a given string content
  31949. * @param content defines the content to convert
  31950. * @returns the new data url link
  31951. */
  31952. static FileAsURL(content: string): string;
  31953. /**
  31954. * Format the given number to a specific decimal format
  31955. * @param value defines the number to format
  31956. * @param decimals defines the number of decimals to use
  31957. * @returns the formatted string
  31958. */
  31959. static Format(value: number, decimals?: number): string;
  31960. /**
  31961. * Tries to copy an object by duplicating every property
  31962. * @param source defines the source object
  31963. * @param destination defines the target object
  31964. * @param doNotCopyList defines a list of properties to avoid
  31965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31966. */
  31967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31968. /**
  31969. * Gets a boolean indicating if the given object has no own property
  31970. * @param obj defines the object to test
  31971. * @returns true if object has no own property
  31972. */
  31973. static IsEmpty(obj: any): boolean;
  31974. /**
  31975. * Function used to register events at window level
  31976. * @param windowElement defines the Window object to use
  31977. * @param events defines the events to register
  31978. */
  31979. static RegisterTopRootEvents(windowElement: Window, events: {
  31980. name: string;
  31981. handler: Nullable<(e: FocusEvent) => any>;
  31982. }[]): void;
  31983. /**
  31984. * Function used to unregister events from window level
  31985. * @param windowElement defines the Window object to use
  31986. * @param events defines the events to unregister
  31987. */
  31988. static UnregisterTopRootEvents(windowElement: Window, events: {
  31989. name: string;
  31990. handler: Nullable<(e: FocusEvent) => any>;
  31991. }[]): void;
  31992. /**
  31993. * @ignore
  31994. */
  31995. static _ScreenshotCanvas: HTMLCanvasElement;
  31996. /**
  31997. * Dumps the current bound framebuffer
  31998. * @param width defines the rendering width
  31999. * @param height defines the rendering height
  32000. * @param engine defines the hosting engine
  32001. * @param successCallback defines the callback triggered once the data are available
  32002. * @param mimeType defines the mime type of the result
  32003. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32004. */
  32005. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32006. /**
  32007. * Converts the canvas data to blob.
  32008. * This acts as a polyfill for browsers not supporting the to blob function.
  32009. * @param canvas Defines the canvas to extract the data from
  32010. * @param successCallback Defines the callback triggered once the data are available
  32011. * @param mimeType Defines the mime type of the result
  32012. */
  32013. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32014. /**
  32015. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32016. * @param successCallback defines the callback triggered once the data are available
  32017. * @param mimeType defines the mime type of the result
  32018. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32019. */
  32020. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32021. /**
  32022. * Downloads a blob in the browser
  32023. * @param blob defines the blob to download
  32024. * @param fileName defines the name of the downloaded file
  32025. */
  32026. static Download(blob: Blob, fileName: string): void;
  32027. /**
  32028. * Captures a screenshot of the current rendering
  32029. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32030. * @param engine defines the rendering engine
  32031. * @param camera defines the source camera
  32032. * @param size This parameter can be set to a single number or to an object with the
  32033. * following (optional) properties: precision, width, height. If a single number is passed,
  32034. * it will be used for both width and height. If an object is passed, the screenshot size
  32035. * will be derived from the parameters. The precision property is a multiplier allowing
  32036. * rendering at a higher or lower resolution
  32037. * @param successCallback defines the callback receives a single parameter which contains the
  32038. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32039. * src parameter of an <img> to display it
  32040. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32041. * Check your browser for supported MIME types
  32042. */
  32043. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32044. /**
  32045. * Captures a screenshot of the current rendering
  32046. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32047. * @param engine defines the rendering engine
  32048. * @param camera defines the source camera
  32049. * @param size This parameter can be set to a single number or to an object with the
  32050. * following (optional) properties: precision, width, height. If a single number is passed,
  32051. * it will be used for both width and height. If an object is passed, the screenshot size
  32052. * will be derived from the parameters. The precision property is a multiplier allowing
  32053. * rendering at a higher or lower resolution
  32054. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32055. * Check your browser for supported MIME types
  32056. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32057. * to the src parameter of an <img> to display it
  32058. */
  32059. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32060. /**
  32061. * Generates an image screenshot from the specified camera.
  32062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32063. * @param engine The engine to use for rendering
  32064. * @param camera The camera to use for rendering
  32065. * @param size This parameter can be set to a single number or to an object with the
  32066. * following (optional) properties: precision, width, height. If a single number is passed,
  32067. * it will be used for both width and height. If an object is passed, the screenshot size
  32068. * will be derived from the parameters. The precision property is a multiplier allowing
  32069. * rendering at a higher or lower resolution
  32070. * @param successCallback The callback receives a single parameter which contains the
  32071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32072. * src parameter of an <img> to display it
  32073. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32074. * Check your browser for supported MIME types
  32075. * @param samples Texture samples (default: 1)
  32076. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32077. * @param fileName A name for for the downloaded file.
  32078. */
  32079. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32080. /**
  32081. * Generates an image screenshot from the specified camera.
  32082. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32083. * @param engine The engine to use for rendering
  32084. * @param camera The camera to use for rendering
  32085. * @param size This parameter can be set to a single number or to an object with the
  32086. * following (optional) properties: precision, width, height. If a single number is passed,
  32087. * it will be used for both width and height. If an object is passed, the screenshot size
  32088. * will be derived from the parameters. The precision property is a multiplier allowing
  32089. * rendering at a higher or lower resolution
  32090. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32091. * Check your browser for supported MIME types
  32092. * @param samples Texture samples (default: 1)
  32093. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32094. * @param fileName A name for for the downloaded file.
  32095. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32096. * to the src parameter of an <img> to display it
  32097. */
  32098. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32099. /**
  32100. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32101. * Be aware Math.random() could cause collisions, but:
  32102. * "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"
  32103. * @returns a pseudo random id
  32104. */
  32105. static RandomId(): string;
  32106. /**
  32107. * Test if the given uri is a base64 string
  32108. * @param uri The uri to test
  32109. * @return True if the uri is a base64 string or false otherwise
  32110. */
  32111. static IsBase64(uri: string): boolean;
  32112. /**
  32113. * Decode the given base64 uri.
  32114. * @param uri The uri to decode
  32115. * @return The decoded base64 data.
  32116. */
  32117. static DecodeBase64(uri: string): ArrayBuffer;
  32118. /**
  32119. * Gets the absolute url.
  32120. * @param url the input url
  32121. * @return the absolute url
  32122. */
  32123. static GetAbsoluteUrl(url: string): string;
  32124. /**
  32125. * No log
  32126. */
  32127. static readonly NoneLogLevel: number;
  32128. /**
  32129. * Only message logs
  32130. */
  32131. static readonly MessageLogLevel: number;
  32132. /**
  32133. * Only warning logs
  32134. */
  32135. static readonly WarningLogLevel: number;
  32136. /**
  32137. * Only error logs
  32138. */
  32139. static readonly ErrorLogLevel: number;
  32140. /**
  32141. * All logs
  32142. */
  32143. static readonly AllLogLevel: number;
  32144. /**
  32145. * Gets a value indicating the number of loading errors
  32146. * @ignorenaming
  32147. */
  32148. static readonly errorsCount: number;
  32149. /**
  32150. * Callback called when a new log is added
  32151. */
  32152. static OnNewCacheEntry: (entry: string) => void;
  32153. /**
  32154. * Log a message to the console
  32155. * @param message defines the message to log
  32156. */
  32157. static Log(message: string): void;
  32158. /**
  32159. * Write a warning message to the console
  32160. * @param message defines the message to log
  32161. */
  32162. static Warn(message: string): void;
  32163. /**
  32164. * Write an error message to the console
  32165. * @param message defines the message to log
  32166. */
  32167. static Error(message: string): void;
  32168. /**
  32169. * Gets current log cache (list of logs)
  32170. */
  32171. static readonly LogCache: string;
  32172. /**
  32173. * Clears the log cache
  32174. */
  32175. static ClearLogCache(): void;
  32176. /**
  32177. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32178. */
  32179. static LogLevels: number;
  32180. /**
  32181. * Checks if the window object exists
  32182. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32183. */
  32184. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32185. /**
  32186. * No performance log
  32187. */
  32188. static readonly PerformanceNoneLogLevel: number;
  32189. /**
  32190. * Use user marks to log performance
  32191. */
  32192. static readonly PerformanceUserMarkLogLevel: number;
  32193. /**
  32194. * Log performance to the console
  32195. */
  32196. static readonly PerformanceConsoleLogLevel: number;
  32197. private static _performance;
  32198. /**
  32199. * Sets the current performance log level
  32200. */
  32201. static PerformanceLogLevel: number;
  32202. private static _StartPerformanceCounterDisabled;
  32203. private static _EndPerformanceCounterDisabled;
  32204. private static _StartUserMark;
  32205. private static _EndUserMark;
  32206. private static _StartPerformanceConsole;
  32207. private static _EndPerformanceConsole;
  32208. /**
  32209. * Starts a performance counter
  32210. */
  32211. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32212. /**
  32213. * Ends a specific performance coutner
  32214. */
  32215. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32216. /**
  32217. * Gets either window.performance.now() if supported or Date.now() else
  32218. */
  32219. static readonly Now: number;
  32220. /**
  32221. * This method will return the name of the class used to create the instance of the given object.
  32222. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32223. * @param object the object to get the class name from
  32224. * @param isType defines if the object is actually a type
  32225. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32226. */
  32227. static GetClassName(object: any, isType?: boolean): string;
  32228. /**
  32229. * Gets the first element of an array satisfying a given predicate
  32230. * @param array defines the array to browse
  32231. * @param predicate defines the predicate to use
  32232. * @returns null if not found or the element
  32233. */
  32234. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32235. /**
  32236. * This method will return the name of the full name of the class, including its owning module (if any).
  32237. * 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).
  32238. * @param object the object to get the class name from
  32239. * @param isType defines if the object is actually a type
  32240. * @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.
  32241. * @ignorenaming
  32242. */
  32243. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32244. /**
  32245. * Returns a promise that resolves after the given amount of time.
  32246. * @param delay Number of milliseconds to delay
  32247. * @returns Promise that resolves after the given amount of time
  32248. */
  32249. static DelayAsync(delay: number): Promise<void>;
  32250. }
  32251. /**
  32252. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32253. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32254. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32255. * @param name The name of the class, case should be preserved
  32256. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32257. */
  32258. export function className(name: string, module?: string): (target: Object) => void;
  32259. /**
  32260. * An implementation of a loop for asynchronous functions.
  32261. */
  32262. export class AsyncLoop {
  32263. /**
  32264. * Defines the number of iterations for the loop
  32265. */
  32266. iterations: number;
  32267. /**
  32268. * Defines the current index of the loop.
  32269. */
  32270. index: number;
  32271. private _done;
  32272. private _fn;
  32273. private _successCallback;
  32274. /**
  32275. * Constructor.
  32276. * @param iterations the number of iterations.
  32277. * @param func the function to run each iteration
  32278. * @param successCallback the callback that will be called upon succesful execution
  32279. * @param offset starting offset.
  32280. */
  32281. constructor(
  32282. /**
  32283. * Defines the number of iterations for the loop
  32284. */
  32285. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32286. /**
  32287. * Execute the next iteration. Must be called after the last iteration was finished.
  32288. */
  32289. executeNext(): void;
  32290. /**
  32291. * Break the loop and run the success callback.
  32292. */
  32293. breakLoop(): void;
  32294. /**
  32295. * Create and run an async loop.
  32296. * @param iterations the number of iterations.
  32297. * @param fn the function to run each iteration
  32298. * @param successCallback the callback that will be called upon succesful execution
  32299. * @param offset starting offset.
  32300. * @returns the created async loop object
  32301. */
  32302. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32303. /**
  32304. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32305. * @param iterations total number of iterations
  32306. * @param syncedIterations number of synchronous iterations in each async iteration.
  32307. * @param fn the function to call each iteration.
  32308. * @param callback a success call back that will be called when iterating stops.
  32309. * @param breakFunction a break condition (optional)
  32310. * @param timeout timeout settings for the setTimeout function. default - 0.
  32311. * @returns the created async loop object
  32312. */
  32313. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32314. }
  32315. }
  32316. declare module BABYLON {
  32317. /** @hidden */
  32318. export interface ICollisionCoordinator {
  32319. createCollider(): Collider;
  32320. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32321. init(scene: Scene): void;
  32322. }
  32323. /** @hidden */
  32324. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32325. private _scene;
  32326. private _scaledPosition;
  32327. private _scaledVelocity;
  32328. private _finalPosition;
  32329. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32330. createCollider(): Collider;
  32331. init(scene: Scene): void;
  32332. private _collideWithWorld;
  32333. }
  32334. }
  32335. declare module BABYLON {
  32336. /**
  32337. * Class used to manage all inputs for the scene.
  32338. */
  32339. export class InputManager {
  32340. /** The distance in pixel that you have to move to prevent some events */
  32341. static DragMovementThreshold: number;
  32342. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32343. static LongPressDelay: number;
  32344. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32345. static DoubleClickDelay: number;
  32346. /** If you need to check double click without raising a single click at first click, enable this flag */
  32347. static ExclusiveDoubleClickMode: boolean;
  32348. private _wheelEventName;
  32349. private _onPointerMove;
  32350. private _onPointerDown;
  32351. private _onPointerUp;
  32352. private _initClickEvent;
  32353. private _initActionManager;
  32354. private _delayedSimpleClick;
  32355. private _delayedSimpleClickTimeout;
  32356. private _previousDelayedSimpleClickTimeout;
  32357. private _meshPickProceed;
  32358. private _previousButtonPressed;
  32359. private _currentPickResult;
  32360. private _previousPickResult;
  32361. private _totalPointersPressed;
  32362. private _doubleClickOccured;
  32363. private _pointerOverMesh;
  32364. private _pickedDownMesh;
  32365. private _pickedUpMesh;
  32366. private _pointerX;
  32367. private _pointerY;
  32368. private _unTranslatedPointerX;
  32369. private _unTranslatedPointerY;
  32370. private _startingPointerPosition;
  32371. private _previousStartingPointerPosition;
  32372. private _startingPointerTime;
  32373. private _previousStartingPointerTime;
  32374. private _pointerCaptures;
  32375. private _onKeyDown;
  32376. private _onKeyUp;
  32377. private _onCanvasFocusObserver;
  32378. private _onCanvasBlurObserver;
  32379. private _scene;
  32380. /**
  32381. * Creates a new InputManager
  32382. * @param scene defines the hosting scene
  32383. */
  32384. constructor(scene: Scene);
  32385. /**
  32386. * Gets the mesh that is currently under the pointer
  32387. */
  32388. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32389. /**
  32390. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32391. */
  32392. readonly unTranslatedPointer: Vector2;
  32393. /**
  32394. * Gets or sets the current on-screen X position of the pointer
  32395. */
  32396. pointerX: number;
  32397. /**
  32398. * Gets or sets the current on-screen Y position of the pointer
  32399. */
  32400. pointerY: number;
  32401. private _updatePointerPosition;
  32402. private _processPointerMove;
  32403. private _setRayOnPointerInfo;
  32404. private _checkPrePointerObservable;
  32405. /**
  32406. * Use this method to simulate a pointer move on a mesh
  32407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32410. */
  32411. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32412. /**
  32413. * Use this method to simulate a pointer down on a mesh
  32414. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32415. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32416. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32417. */
  32418. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32419. private _processPointerDown;
  32420. /** @hidden */
  32421. _isPointerSwiping(): boolean;
  32422. /**
  32423. * Use this method to simulate a pointer up on a mesh
  32424. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32425. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32426. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32427. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32428. */
  32429. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32430. private _processPointerUp;
  32431. /**
  32432. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32433. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32434. * @returns true if the pointer was captured
  32435. */
  32436. isPointerCaptured(pointerId?: number): boolean;
  32437. /**
  32438. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32439. * @param attachUp defines if you want to attach events to pointerup
  32440. * @param attachDown defines if you want to attach events to pointerdown
  32441. * @param attachMove defines if you want to attach events to pointermove
  32442. */
  32443. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32444. /**
  32445. * Detaches all event handlers
  32446. */
  32447. detachControl(): void;
  32448. /**
  32449. * Force the value of meshUnderPointer
  32450. * @param mesh defines the mesh to use
  32451. */
  32452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32453. /**
  32454. * Gets the mesh under the pointer
  32455. * @returns a Mesh or null if no mesh is under the pointer
  32456. */
  32457. getPointerOverMesh(): Nullable<AbstractMesh>;
  32458. }
  32459. }
  32460. declare module BABYLON {
  32461. /**
  32462. * Helper class used to generate session unique ID
  32463. */
  32464. export class UniqueIdGenerator {
  32465. private static _UniqueIdCounter;
  32466. /**
  32467. * Gets an unique (relatively to the current scene) Id
  32468. */
  32469. static readonly UniqueId: number;
  32470. }
  32471. }
  32472. declare module BABYLON {
  32473. /**
  32474. * This class defines the direct association between an animation and a target
  32475. */
  32476. export class TargetedAnimation {
  32477. /**
  32478. * Animation to perform
  32479. */
  32480. animation: Animation;
  32481. /**
  32482. * Target to animate
  32483. */
  32484. target: any;
  32485. /**
  32486. * Serialize the object
  32487. * @returns the JSON object representing the current entity
  32488. */
  32489. serialize(): any;
  32490. }
  32491. /**
  32492. * Use this class to create coordinated animations on multiple targets
  32493. */
  32494. export class AnimationGroup implements IDisposable {
  32495. /** The name of the animation group */
  32496. name: string;
  32497. private _scene;
  32498. private _targetedAnimations;
  32499. private _animatables;
  32500. private _from;
  32501. private _to;
  32502. private _isStarted;
  32503. private _isPaused;
  32504. private _speedRatio;
  32505. private _loopAnimation;
  32506. /**
  32507. * Gets or sets the unique id of the node
  32508. */
  32509. uniqueId: number;
  32510. /**
  32511. * This observable will notify when one animation have ended
  32512. */
  32513. onAnimationEndObservable: Observable<TargetedAnimation>;
  32514. /**
  32515. * Observer raised when one animation loops
  32516. */
  32517. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32518. /**
  32519. * This observable will notify when all animations have ended.
  32520. */
  32521. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32522. /**
  32523. * This observable will notify when all animations have paused.
  32524. */
  32525. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32526. /**
  32527. * This observable will notify when all animations are playing.
  32528. */
  32529. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32530. /**
  32531. * Gets the first frame
  32532. */
  32533. readonly from: number;
  32534. /**
  32535. * Gets the last frame
  32536. */
  32537. readonly to: number;
  32538. /**
  32539. * Define if the animations are started
  32540. */
  32541. readonly isStarted: boolean;
  32542. /**
  32543. * Gets a value indicating that the current group is playing
  32544. */
  32545. readonly isPlaying: boolean;
  32546. /**
  32547. * Gets or sets the speed ratio to use for all animations
  32548. */
  32549. /**
  32550. * Gets or sets the speed ratio to use for all animations
  32551. */
  32552. speedRatio: number;
  32553. /**
  32554. * Gets or sets if all animations should loop or not
  32555. */
  32556. loopAnimation: boolean;
  32557. /**
  32558. * Gets the targeted animations for this animation group
  32559. */
  32560. readonly targetedAnimations: Array<TargetedAnimation>;
  32561. /**
  32562. * returning the list of animatables controlled by this animation group.
  32563. */
  32564. readonly animatables: Array<Animatable>;
  32565. /**
  32566. * Instantiates a new Animation Group.
  32567. * This helps managing several animations at once.
  32568. * @see http://doc.babylonjs.com/how_to/group
  32569. * @param name Defines the name of the group
  32570. * @param scene Defines the scene the group belongs to
  32571. */
  32572. constructor(
  32573. /** The name of the animation group */
  32574. name: string, scene?: Nullable<Scene>);
  32575. /**
  32576. * Add an animation (with its target) in the group
  32577. * @param animation defines the animation we want to add
  32578. * @param target defines the target of the animation
  32579. * @returns the TargetedAnimation object
  32580. */
  32581. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32582. /**
  32583. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32584. * It can add constant keys at begin or end
  32585. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32586. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32587. * @returns the animation group
  32588. */
  32589. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32590. /**
  32591. * Start all animations on given targets
  32592. * @param loop defines if animations must loop
  32593. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32594. * @param from defines the from key (optional)
  32595. * @param to defines the to key (optional)
  32596. * @returns the current animation group
  32597. */
  32598. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32599. /**
  32600. * Pause all animations
  32601. * @returns the animation group
  32602. */
  32603. pause(): AnimationGroup;
  32604. /**
  32605. * Play all animations to initial state
  32606. * This function will start() the animations if they were not started or will restart() them if they were paused
  32607. * @param loop defines if animations must loop
  32608. * @returns the animation group
  32609. */
  32610. play(loop?: boolean): AnimationGroup;
  32611. /**
  32612. * Reset all animations to initial state
  32613. * @returns the animation group
  32614. */
  32615. reset(): AnimationGroup;
  32616. /**
  32617. * Restart animations from key 0
  32618. * @returns the animation group
  32619. */
  32620. restart(): AnimationGroup;
  32621. /**
  32622. * Stop all animations
  32623. * @returns the animation group
  32624. */
  32625. stop(): AnimationGroup;
  32626. /**
  32627. * Set animation weight for all animatables
  32628. * @param weight defines the weight to use
  32629. * @return the animationGroup
  32630. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32631. */
  32632. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32633. /**
  32634. * Synchronize and normalize all animatables with a source animatable
  32635. * @param root defines the root animatable to synchronize with
  32636. * @return the animationGroup
  32637. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32638. */
  32639. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32640. /**
  32641. * Goes to a specific frame in this animation group
  32642. * @param frame the frame number to go to
  32643. * @return the animationGroup
  32644. */
  32645. goToFrame(frame: number): AnimationGroup;
  32646. /**
  32647. * Dispose all associated resources
  32648. */
  32649. dispose(): void;
  32650. private _checkAnimationGroupEnded;
  32651. /**
  32652. * Clone the current animation group and returns a copy
  32653. * @param newName defines the name of the new group
  32654. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32655. * @returns the new aniamtion group
  32656. */
  32657. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32658. /**
  32659. * Serializes the animationGroup to an object
  32660. * @returns Serialized object
  32661. */
  32662. serialize(): any;
  32663. /**
  32664. * Returns a new AnimationGroup object parsed from the source provided.
  32665. * @param parsedAnimationGroup defines the source
  32666. * @param scene defines the scene that will receive the animationGroup
  32667. * @returns a new AnimationGroup
  32668. */
  32669. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32670. /**
  32671. * Returns the string "AnimationGroup"
  32672. * @returns "AnimationGroup"
  32673. */
  32674. getClassName(): string;
  32675. /**
  32676. * Creates a detailled string about the object
  32677. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32678. * @returns a string representing the object
  32679. */
  32680. toString(fullDetails?: boolean): string;
  32681. }
  32682. }
  32683. declare module BABYLON {
  32684. /**
  32685. * Define an interface for all classes that will hold resources
  32686. */
  32687. export interface IDisposable {
  32688. /**
  32689. * Releases all held resources
  32690. */
  32691. dispose(): void;
  32692. }
  32693. /** Interface defining initialization parameters for Scene class */
  32694. export interface SceneOptions {
  32695. /**
  32696. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32697. * It will improve performance when the number of geometries becomes important.
  32698. */
  32699. useGeometryUniqueIdsMap?: boolean;
  32700. /**
  32701. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32702. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32703. */
  32704. useMaterialMeshMap?: boolean;
  32705. /**
  32706. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32707. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32708. */
  32709. useClonedMeshhMap?: boolean;
  32710. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32711. virtual?: boolean;
  32712. }
  32713. /**
  32714. * Represents a scene to be rendered by the engine.
  32715. * @see http://doc.babylonjs.com/features/scene
  32716. */
  32717. export class Scene extends AbstractScene implements IAnimatable {
  32718. /** The fog is deactivated */
  32719. static readonly FOGMODE_NONE: number;
  32720. /** The fog density is following an exponential function */
  32721. static readonly FOGMODE_EXP: number;
  32722. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32723. static readonly FOGMODE_EXP2: number;
  32724. /** The fog density is following a linear function. */
  32725. static readonly FOGMODE_LINEAR: number;
  32726. /**
  32727. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32728. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32729. */
  32730. static MinDeltaTime: number;
  32731. /**
  32732. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32734. */
  32735. static MaxDeltaTime: number;
  32736. /**
  32737. * Factory used to create the default material.
  32738. * @param name The name of the material to create
  32739. * @param scene The scene to create the material for
  32740. * @returns The default material
  32741. */
  32742. static DefaultMaterialFactory(scene: Scene): Material;
  32743. /**
  32744. * Factory used to create the a collision coordinator.
  32745. * @returns The collision coordinator
  32746. */
  32747. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32748. /** @hidden */
  32749. _inputManager: InputManager;
  32750. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32751. cameraToUseForPointers: Nullable<Camera>;
  32752. /** @hidden */
  32753. readonly _isScene: boolean;
  32754. /**
  32755. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32756. */
  32757. autoClear: boolean;
  32758. /**
  32759. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32760. */
  32761. autoClearDepthAndStencil: boolean;
  32762. /**
  32763. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32764. */
  32765. clearColor: Color4;
  32766. /**
  32767. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32768. */
  32769. ambientColor: Color3;
  32770. /**
  32771. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32772. * It should only be one of the following (if not the default embedded one):
  32773. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32774. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32775. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32776. * The material properties need to be setup according to the type of texture in use.
  32777. */
  32778. environmentBRDFTexture: BaseTexture;
  32779. /** @hidden */
  32780. protected _environmentTexture: Nullable<BaseTexture>;
  32781. /**
  32782. * Texture used in all pbr material as the reflection texture.
  32783. * As in the majority of the scene they are the same (exception for multi room and so on),
  32784. * this is easier to reference from here than from all the materials.
  32785. */
  32786. /**
  32787. * Texture used in all pbr material as the reflection texture.
  32788. * As in the majority of the scene they are the same (exception for multi room and so on),
  32789. * this is easier to set here than in all the materials.
  32790. */
  32791. environmentTexture: Nullable<BaseTexture>;
  32792. /** @hidden */
  32793. protected _environmentIntensity: number;
  32794. /**
  32795. * Intensity of the environment in all pbr material.
  32796. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32797. * As in the majority of the scene they are the same (exception for multi room and so on),
  32798. * this is easier to reference from here than from all the materials.
  32799. */
  32800. /**
  32801. * Intensity of the environment in all pbr material.
  32802. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32803. * As in the majority of the scene they are the same (exception for multi room and so on),
  32804. * this is easier to set here than in all the materials.
  32805. */
  32806. environmentIntensity: number;
  32807. /** @hidden */
  32808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32809. /**
  32810. * Default image processing configuration used either in the rendering
  32811. * Forward main pass or through the imageProcessingPostProcess if present.
  32812. * As in the majority of the scene they are the same (exception for multi camera),
  32813. * this is easier to reference from here than from all the materials and post process.
  32814. *
  32815. * No setter as we it is a shared configuration, you can set the values instead.
  32816. */
  32817. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32818. private _forceWireframe;
  32819. /**
  32820. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32821. */
  32822. forceWireframe: boolean;
  32823. private _forcePointsCloud;
  32824. /**
  32825. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32826. */
  32827. forcePointsCloud: boolean;
  32828. /**
  32829. * Gets or sets the active clipplane 1
  32830. */
  32831. clipPlane: Nullable<Plane>;
  32832. /**
  32833. * Gets or sets the active clipplane 2
  32834. */
  32835. clipPlane2: Nullable<Plane>;
  32836. /**
  32837. * Gets or sets the active clipplane 3
  32838. */
  32839. clipPlane3: Nullable<Plane>;
  32840. /**
  32841. * Gets or sets the active clipplane 4
  32842. */
  32843. clipPlane4: Nullable<Plane>;
  32844. /**
  32845. * Gets or sets a boolean indicating if animations are enabled
  32846. */
  32847. animationsEnabled: boolean;
  32848. private _animationPropertiesOverride;
  32849. /**
  32850. * Gets or sets the animation properties override
  32851. */
  32852. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32853. /**
  32854. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32855. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32856. */
  32857. useConstantAnimationDeltaTime: boolean;
  32858. /**
  32859. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32860. * Please note that it requires to run a ray cast through the scene on every frame
  32861. */
  32862. constantlyUpdateMeshUnderPointer: boolean;
  32863. /**
  32864. * Defines the HTML cursor to use when hovering over interactive elements
  32865. */
  32866. hoverCursor: string;
  32867. /**
  32868. * Defines the HTML default cursor to use (empty by default)
  32869. */
  32870. defaultCursor: string;
  32871. /**
  32872. * This is used to call preventDefault() on pointer down
  32873. * in order to block unwanted artifacts like system double clicks
  32874. */
  32875. preventDefaultOnPointerDown: boolean;
  32876. /**
  32877. * This is used to call preventDefault() on pointer up
  32878. * in order to block unwanted artifacts like system double clicks
  32879. */
  32880. preventDefaultOnPointerUp: boolean;
  32881. /**
  32882. * Gets or sets user defined metadata
  32883. */
  32884. metadata: any;
  32885. /**
  32886. * For internal use only. Please do not use.
  32887. */
  32888. reservedDataStore: any;
  32889. /**
  32890. * Gets the name of the plugin used to load this scene (null by default)
  32891. */
  32892. loadingPluginName: string;
  32893. /**
  32894. * Use this array to add regular expressions used to disable offline support for specific urls
  32895. */
  32896. disableOfflineSupportExceptionRules: RegExp[];
  32897. /**
  32898. * An event triggered when the scene is disposed.
  32899. */
  32900. onDisposeObservable: Observable<Scene>;
  32901. private _onDisposeObserver;
  32902. /** Sets a function to be executed when this scene is disposed. */
  32903. onDispose: () => void;
  32904. /**
  32905. * An event triggered before rendering the scene (right after animations and physics)
  32906. */
  32907. onBeforeRenderObservable: Observable<Scene>;
  32908. private _onBeforeRenderObserver;
  32909. /** Sets a function to be executed before rendering this scene */
  32910. beforeRender: Nullable<() => void>;
  32911. /**
  32912. * An event triggered after rendering the scene
  32913. */
  32914. onAfterRenderObservable: Observable<Scene>;
  32915. /**
  32916. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32917. */
  32918. onAfterRenderCameraObservable: Observable<Camera>;
  32919. private _onAfterRenderObserver;
  32920. /** Sets a function to be executed after rendering this scene */
  32921. afterRender: Nullable<() => void>;
  32922. /**
  32923. * An event triggered before animating the scene
  32924. */
  32925. onBeforeAnimationsObservable: Observable<Scene>;
  32926. /**
  32927. * An event triggered after animations processing
  32928. */
  32929. onAfterAnimationsObservable: Observable<Scene>;
  32930. /**
  32931. * An event triggered before draw calls are ready to be sent
  32932. */
  32933. onBeforeDrawPhaseObservable: Observable<Scene>;
  32934. /**
  32935. * An event triggered after draw calls have been sent
  32936. */
  32937. onAfterDrawPhaseObservable: Observable<Scene>;
  32938. /**
  32939. * An event triggered when the scene is ready
  32940. */
  32941. onReadyObservable: Observable<Scene>;
  32942. /**
  32943. * An event triggered before rendering a camera
  32944. */
  32945. onBeforeCameraRenderObservable: Observable<Camera>;
  32946. private _onBeforeCameraRenderObserver;
  32947. /** Sets a function to be executed before rendering a camera*/
  32948. beforeCameraRender: () => void;
  32949. /**
  32950. * An event triggered after rendering a camera
  32951. */
  32952. onAfterCameraRenderObservable: Observable<Camera>;
  32953. private _onAfterCameraRenderObserver;
  32954. /** Sets a function to be executed after rendering a camera*/
  32955. afterCameraRender: () => void;
  32956. /**
  32957. * An event triggered when active meshes evaluation is about to start
  32958. */
  32959. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32960. /**
  32961. * An event triggered when active meshes evaluation is done
  32962. */
  32963. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32964. /**
  32965. * An event triggered when particles rendering is about to start
  32966. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32967. */
  32968. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32969. /**
  32970. * An event triggered when particles rendering is done
  32971. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32972. */
  32973. onAfterParticlesRenderingObservable: Observable<Scene>;
  32974. /**
  32975. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32976. */
  32977. onDataLoadedObservable: Observable<Scene>;
  32978. /**
  32979. * An event triggered when a camera is created
  32980. */
  32981. onNewCameraAddedObservable: Observable<Camera>;
  32982. /**
  32983. * An event triggered when a camera is removed
  32984. */
  32985. onCameraRemovedObservable: Observable<Camera>;
  32986. /**
  32987. * An event triggered when a light is created
  32988. */
  32989. onNewLightAddedObservable: Observable<Light>;
  32990. /**
  32991. * An event triggered when a light is removed
  32992. */
  32993. onLightRemovedObservable: Observable<Light>;
  32994. /**
  32995. * An event triggered when a geometry is created
  32996. */
  32997. onNewGeometryAddedObservable: Observable<Geometry>;
  32998. /**
  32999. * An event triggered when a geometry is removed
  33000. */
  33001. onGeometryRemovedObservable: Observable<Geometry>;
  33002. /**
  33003. * An event triggered when a transform node is created
  33004. */
  33005. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33006. /**
  33007. * An event triggered when a transform node is removed
  33008. */
  33009. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33010. /**
  33011. * An event triggered when a mesh is created
  33012. */
  33013. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33014. /**
  33015. * An event triggered when a mesh is removed
  33016. */
  33017. onMeshRemovedObservable: Observable<AbstractMesh>;
  33018. /**
  33019. * An event triggered when a skeleton is created
  33020. */
  33021. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33022. /**
  33023. * An event triggered when a skeleton is removed
  33024. */
  33025. onSkeletonRemovedObservable: Observable<Skeleton>;
  33026. /**
  33027. * An event triggered when a material is created
  33028. */
  33029. onNewMaterialAddedObservable: Observable<Material>;
  33030. /**
  33031. * An event triggered when a material is removed
  33032. */
  33033. onMaterialRemovedObservable: Observable<Material>;
  33034. /**
  33035. * An event triggered when a texture is created
  33036. */
  33037. onNewTextureAddedObservable: Observable<BaseTexture>;
  33038. /**
  33039. * An event triggered when a texture is removed
  33040. */
  33041. onTextureRemovedObservable: Observable<BaseTexture>;
  33042. /**
  33043. * An event triggered when render targets are about to be rendered
  33044. * Can happen multiple times per frame.
  33045. */
  33046. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33047. /**
  33048. * An event triggered when render targets were rendered.
  33049. * Can happen multiple times per frame.
  33050. */
  33051. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33052. /**
  33053. * An event triggered before calculating deterministic simulation step
  33054. */
  33055. onBeforeStepObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered after calculating deterministic simulation step
  33058. */
  33059. onAfterStepObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered when the activeCamera property is updated
  33062. */
  33063. onActiveCameraChanged: Observable<Scene>;
  33064. /**
  33065. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33066. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33067. * 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)
  33068. */
  33069. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33070. /**
  33071. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33072. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33073. * 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)
  33074. */
  33075. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33076. /**
  33077. * This Observable will when a mesh has been imported into the scene.
  33078. */
  33079. onMeshImportedObservable: Observable<AbstractMesh>;
  33080. /**
  33081. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33082. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33083. */
  33084. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33085. /** @hidden */
  33086. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33087. /**
  33088. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33089. */
  33090. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33091. /**
  33092. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33093. */
  33094. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33095. /**
  33096. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33097. */
  33098. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33099. /** Callback called when a pointer move is detected */
  33100. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33101. /** Callback called when a pointer down is detected */
  33102. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33103. /** Callback called when a pointer up is detected */
  33104. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33105. /** Callback called when a pointer pick is detected */
  33106. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33107. /**
  33108. * 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).
  33109. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33110. */
  33111. onPrePointerObservable: Observable<PointerInfoPre>;
  33112. /**
  33113. * Observable event triggered each time an input event is received from the rendering canvas
  33114. */
  33115. onPointerObservable: Observable<PointerInfo>;
  33116. /**
  33117. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33118. */
  33119. readonly unTranslatedPointer: Vector2;
  33120. /**
  33121. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33122. */
  33123. static DragMovementThreshold: number;
  33124. /**
  33125. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33126. */
  33127. static LongPressDelay: number;
  33128. /**
  33129. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33130. */
  33131. static DoubleClickDelay: number;
  33132. /** If you need to check double click without raising a single click at first click, enable this flag */
  33133. static ExclusiveDoubleClickMode: boolean;
  33134. /** @hidden */
  33135. _mirroredCameraPosition: Nullable<Vector3>;
  33136. /**
  33137. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33138. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33139. */
  33140. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33141. /**
  33142. * Observable event triggered each time an keyboard event is received from the hosting window
  33143. */
  33144. onKeyboardObservable: Observable<KeyboardInfo>;
  33145. private _useRightHandedSystem;
  33146. /**
  33147. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33148. */
  33149. useRightHandedSystem: boolean;
  33150. private _timeAccumulator;
  33151. private _currentStepId;
  33152. private _currentInternalStep;
  33153. /**
  33154. * Sets the step Id used by deterministic lock step
  33155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33156. * @param newStepId defines the step Id
  33157. */
  33158. setStepId(newStepId: number): void;
  33159. /**
  33160. * Gets the step Id used by deterministic lock step
  33161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33162. * @returns the step Id
  33163. */
  33164. getStepId(): number;
  33165. /**
  33166. * Gets the internal step used by deterministic lock step
  33167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33168. * @returns the internal step
  33169. */
  33170. getInternalStep(): number;
  33171. private _fogEnabled;
  33172. /**
  33173. * Gets or sets a boolean indicating if fog is enabled on this scene
  33174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33175. * (Default is true)
  33176. */
  33177. fogEnabled: boolean;
  33178. private _fogMode;
  33179. /**
  33180. * Gets or sets the fog mode to use
  33181. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33182. * | mode | value |
  33183. * | --- | --- |
  33184. * | FOGMODE_NONE | 0 |
  33185. * | FOGMODE_EXP | 1 |
  33186. * | FOGMODE_EXP2 | 2 |
  33187. * | FOGMODE_LINEAR | 3 |
  33188. */
  33189. fogMode: number;
  33190. /**
  33191. * Gets or sets the fog color to use
  33192. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33193. * (Default is Color3(0.2, 0.2, 0.3))
  33194. */
  33195. fogColor: Color3;
  33196. /**
  33197. * Gets or sets the fog density to use
  33198. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33199. * (Default is 0.1)
  33200. */
  33201. fogDensity: number;
  33202. /**
  33203. * Gets or sets the fog start distance to use
  33204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33205. * (Default is 0)
  33206. */
  33207. fogStart: number;
  33208. /**
  33209. * Gets or sets the fog end distance to use
  33210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33211. * (Default is 1000)
  33212. */
  33213. fogEnd: number;
  33214. private _shadowsEnabled;
  33215. /**
  33216. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33217. */
  33218. shadowsEnabled: boolean;
  33219. private _lightsEnabled;
  33220. /**
  33221. * Gets or sets a boolean indicating if lights are enabled on this scene
  33222. */
  33223. lightsEnabled: boolean;
  33224. /** All of the active cameras added to this scene. */
  33225. activeCameras: Camera[];
  33226. /** @hidden */
  33227. _activeCamera: Nullable<Camera>;
  33228. /** Gets or sets the current active camera */
  33229. activeCamera: Nullable<Camera>;
  33230. private _defaultMaterial;
  33231. /** The default material used on meshes when no material is affected */
  33232. /** The default material used on meshes when no material is affected */
  33233. defaultMaterial: Material;
  33234. private _texturesEnabled;
  33235. /**
  33236. * Gets or sets a boolean indicating if textures are enabled on this scene
  33237. */
  33238. texturesEnabled: boolean;
  33239. /**
  33240. * Gets or sets a boolean indicating if particles are enabled on this scene
  33241. */
  33242. particlesEnabled: boolean;
  33243. /**
  33244. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33245. */
  33246. spritesEnabled: boolean;
  33247. private _skeletonsEnabled;
  33248. /**
  33249. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33250. */
  33251. skeletonsEnabled: boolean;
  33252. /**
  33253. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33254. */
  33255. lensFlaresEnabled: boolean;
  33256. /**
  33257. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33258. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33259. */
  33260. collisionsEnabled: boolean;
  33261. private _collisionCoordinator;
  33262. /** @hidden */
  33263. readonly collisionCoordinator: ICollisionCoordinator;
  33264. /**
  33265. * Defines the gravity applied to this scene (used only for collisions)
  33266. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33267. */
  33268. gravity: Vector3;
  33269. /**
  33270. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33271. */
  33272. postProcessesEnabled: boolean;
  33273. /**
  33274. * The list of postprocesses added to the scene
  33275. */
  33276. postProcesses: PostProcess[];
  33277. /**
  33278. * Gets the current postprocess manager
  33279. */
  33280. postProcessManager: PostProcessManager;
  33281. /**
  33282. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33283. */
  33284. renderTargetsEnabled: boolean;
  33285. /**
  33286. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33287. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33288. */
  33289. dumpNextRenderTargets: boolean;
  33290. /**
  33291. * The list of user defined render targets added to the scene
  33292. */
  33293. customRenderTargets: RenderTargetTexture[];
  33294. /**
  33295. * Defines if texture loading must be delayed
  33296. * If true, textures will only be loaded when they need to be rendered
  33297. */
  33298. useDelayedTextureLoading: boolean;
  33299. /**
  33300. * Gets the list of meshes imported to the scene through SceneLoader
  33301. */
  33302. importedMeshesFiles: String[];
  33303. /**
  33304. * Gets or sets a boolean indicating if probes are enabled on this scene
  33305. */
  33306. probesEnabled: boolean;
  33307. /**
  33308. * Gets or sets the current offline provider to use to store scene data
  33309. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33310. */
  33311. offlineProvider: IOfflineProvider;
  33312. /**
  33313. * Gets or sets the action manager associated with the scene
  33314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33315. */
  33316. actionManager: AbstractActionManager;
  33317. private _meshesForIntersections;
  33318. /**
  33319. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33320. */
  33321. proceduralTexturesEnabled: boolean;
  33322. private _engine;
  33323. private _totalVertices;
  33324. /** @hidden */
  33325. _activeIndices: PerfCounter;
  33326. /** @hidden */
  33327. _activeParticles: PerfCounter;
  33328. /** @hidden */
  33329. _activeBones: PerfCounter;
  33330. private _animationRatio;
  33331. /** @hidden */
  33332. _animationTimeLast: number;
  33333. /** @hidden */
  33334. _animationTime: number;
  33335. /**
  33336. * Gets or sets a general scale for animation speed
  33337. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33338. */
  33339. animationTimeScale: number;
  33340. /** @hidden */
  33341. _cachedMaterial: Nullable<Material>;
  33342. /** @hidden */
  33343. _cachedEffect: Nullable<Effect>;
  33344. /** @hidden */
  33345. _cachedVisibility: Nullable<number>;
  33346. private _renderId;
  33347. private _frameId;
  33348. private _executeWhenReadyTimeoutId;
  33349. private _intermediateRendering;
  33350. private _viewUpdateFlag;
  33351. private _projectionUpdateFlag;
  33352. /** @hidden */
  33353. _toBeDisposed: Nullable<IDisposable>[];
  33354. private _activeRequests;
  33355. /** @hidden */
  33356. _pendingData: any[];
  33357. private _isDisposed;
  33358. /**
  33359. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33360. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33361. */
  33362. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33363. private _activeMeshes;
  33364. private _processedMaterials;
  33365. private _renderTargets;
  33366. /** @hidden */
  33367. _activeParticleSystems: SmartArray<IParticleSystem>;
  33368. private _activeSkeletons;
  33369. private _softwareSkinnedMeshes;
  33370. private _renderingManager;
  33371. /** @hidden */
  33372. _activeAnimatables: Animatable[];
  33373. private _transformMatrix;
  33374. private _sceneUbo;
  33375. /** @hidden */
  33376. _viewMatrix: Matrix;
  33377. private _projectionMatrix;
  33378. /** @hidden */
  33379. _forcedViewPosition: Nullable<Vector3>;
  33380. /** @hidden */
  33381. _frustumPlanes: Plane[];
  33382. /**
  33383. * Gets the list of frustum planes (built from the active camera)
  33384. */
  33385. readonly frustumPlanes: Plane[];
  33386. /**
  33387. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33388. * This is useful if there are more lights that the maximum simulteanous authorized
  33389. */
  33390. requireLightSorting: boolean;
  33391. /** @hidden */
  33392. readonly useMaterialMeshMap: boolean;
  33393. /** @hidden */
  33394. readonly useClonedMeshhMap: boolean;
  33395. private _externalData;
  33396. private _uid;
  33397. /**
  33398. * @hidden
  33399. * Backing store of defined scene components.
  33400. */
  33401. _components: ISceneComponent[];
  33402. /**
  33403. * @hidden
  33404. * Backing store of defined scene components.
  33405. */
  33406. _serializableComponents: ISceneSerializableComponent[];
  33407. /**
  33408. * List of components to register on the next registration step.
  33409. */
  33410. private _transientComponents;
  33411. /**
  33412. * Registers the transient components if needed.
  33413. */
  33414. private _registerTransientComponents;
  33415. /**
  33416. * @hidden
  33417. * Add a component to the scene.
  33418. * Note that the ccomponent could be registered on th next frame if this is called after
  33419. * the register component stage.
  33420. * @param component Defines the component to add to the scene
  33421. */
  33422. _addComponent(component: ISceneComponent): void;
  33423. /**
  33424. * @hidden
  33425. * Gets a component from the scene.
  33426. * @param name defines the name of the component to retrieve
  33427. * @returns the component or null if not present
  33428. */
  33429. _getComponent(name: string): Nullable<ISceneComponent>;
  33430. /**
  33431. * @hidden
  33432. * Defines the actions happening before camera updates.
  33433. */
  33434. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33435. /**
  33436. * @hidden
  33437. * Defines the actions happening before clear the canvas.
  33438. */
  33439. _beforeClearStage: Stage<SimpleStageAction>;
  33440. /**
  33441. * @hidden
  33442. * Defines the actions when collecting render targets for the frame.
  33443. */
  33444. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33445. /**
  33446. * @hidden
  33447. * Defines the actions happening for one camera in the frame.
  33448. */
  33449. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33450. /**
  33451. * @hidden
  33452. * Defines the actions happening during the per mesh ready checks.
  33453. */
  33454. _isReadyForMeshStage: Stage<MeshStageAction>;
  33455. /**
  33456. * @hidden
  33457. * Defines the actions happening before evaluate active mesh checks.
  33458. */
  33459. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33460. /**
  33461. * @hidden
  33462. * Defines the actions happening during the evaluate sub mesh checks.
  33463. */
  33464. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33465. /**
  33466. * @hidden
  33467. * Defines the actions happening during the active mesh stage.
  33468. */
  33469. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33470. /**
  33471. * @hidden
  33472. * Defines the actions happening during the per camera render target step.
  33473. */
  33474. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33475. /**
  33476. * @hidden
  33477. * Defines the actions happening just before the active camera is drawing.
  33478. */
  33479. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33480. /**
  33481. * @hidden
  33482. * Defines the actions happening just before a render target is drawing.
  33483. */
  33484. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33485. /**
  33486. * @hidden
  33487. * Defines the actions happening just before a rendering group is drawing.
  33488. */
  33489. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33490. /**
  33491. * @hidden
  33492. * Defines the actions happening just before a mesh is drawing.
  33493. */
  33494. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33495. /**
  33496. * @hidden
  33497. * Defines the actions happening just after a mesh has been drawn.
  33498. */
  33499. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33500. /**
  33501. * @hidden
  33502. * Defines the actions happening just after a rendering group has been drawn.
  33503. */
  33504. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33505. /**
  33506. * @hidden
  33507. * Defines the actions happening just after the active camera has been drawn.
  33508. */
  33509. _afterCameraDrawStage: Stage<CameraStageAction>;
  33510. /**
  33511. * @hidden
  33512. * Defines the actions happening just after a render target has been drawn.
  33513. */
  33514. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33515. /**
  33516. * @hidden
  33517. * Defines the actions happening just after rendering all cameras and computing intersections.
  33518. */
  33519. _afterRenderStage: Stage<SimpleStageAction>;
  33520. /**
  33521. * @hidden
  33522. * Defines the actions happening when a pointer move event happens.
  33523. */
  33524. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33525. /**
  33526. * @hidden
  33527. * Defines the actions happening when a pointer down event happens.
  33528. */
  33529. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33530. /**
  33531. * @hidden
  33532. * Defines the actions happening when a pointer up event happens.
  33533. */
  33534. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33535. /**
  33536. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33537. */
  33538. private geometriesByUniqueId;
  33539. /**
  33540. * Creates a new Scene
  33541. * @param engine defines the engine to use to render this scene
  33542. * @param options defines the scene options
  33543. */
  33544. constructor(engine: Engine, options?: SceneOptions);
  33545. /**
  33546. * Gets a string idenfifying the name of the class
  33547. * @returns "Scene" string
  33548. */
  33549. getClassName(): string;
  33550. private _defaultMeshCandidates;
  33551. /**
  33552. * @hidden
  33553. */
  33554. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33555. private _defaultSubMeshCandidates;
  33556. /**
  33557. * @hidden
  33558. */
  33559. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33560. /**
  33561. * Sets the default candidate providers for the scene.
  33562. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33563. * and getCollidingSubMeshCandidates to their default function
  33564. */
  33565. setDefaultCandidateProviders(): void;
  33566. /**
  33567. * Gets the mesh that is currently under the pointer
  33568. */
  33569. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33570. /**
  33571. * Gets or sets the current on-screen X position of the pointer
  33572. */
  33573. pointerX: number;
  33574. /**
  33575. * Gets or sets the current on-screen Y position of the pointer
  33576. */
  33577. pointerY: number;
  33578. /**
  33579. * Gets the cached material (ie. the latest rendered one)
  33580. * @returns the cached material
  33581. */
  33582. getCachedMaterial(): Nullable<Material>;
  33583. /**
  33584. * Gets the cached effect (ie. the latest rendered one)
  33585. * @returns the cached effect
  33586. */
  33587. getCachedEffect(): Nullable<Effect>;
  33588. /**
  33589. * Gets the cached visibility state (ie. the latest rendered one)
  33590. * @returns the cached visibility state
  33591. */
  33592. getCachedVisibility(): Nullable<number>;
  33593. /**
  33594. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33595. * @param material defines the current material
  33596. * @param effect defines the current effect
  33597. * @param visibility defines the current visibility state
  33598. * @returns true if one parameter is not cached
  33599. */
  33600. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33601. /**
  33602. * Gets the engine associated with the scene
  33603. * @returns an Engine
  33604. */
  33605. getEngine(): Engine;
  33606. /**
  33607. * Gets the total number of vertices rendered per frame
  33608. * @returns the total number of vertices rendered per frame
  33609. */
  33610. getTotalVertices(): number;
  33611. /**
  33612. * Gets the performance counter for total vertices
  33613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33614. */
  33615. readonly totalVerticesPerfCounter: PerfCounter;
  33616. /**
  33617. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33618. * @returns the total number of active indices rendered per frame
  33619. */
  33620. getActiveIndices(): number;
  33621. /**
  33622. * Gets the performance counter for active indices
  33623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33624. */
  33625. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33626. /**
  33627. * Gets the total number of active particles rendered per frame
  33628. * @returns the total number of active particles rendered per frame
  33629. */
  33630. getActiveParticles(): number;
  33631. /**
  33632. * Gets the performance counter for active particles
  33633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33634. */
  33635. readonly activeParticlesPerfCounter: PerfCounter;
  33636. /**
  33637. * Gets the total number of active bones rendered per frame
  33638. * @returns the total number of active bones rendered per frame
  33639. */
  33640. getActiveBones(): number;
  33641. /**
  33642. * Gets the performance counter for active bones
  33643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33644. */
  33645. readonly activeBonesPerfCounter: PerfCounter;
  33646. /**
  33647. * Gets the array of active meshes
  33648. * @returns an array of AbstractMesh
  33649. */
  33650. getActiveMeshes(): SmartArray<AbstractMesh>;
  33651. /**
  33652. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33653. * @returns a number
  33654. */
  33655. getAnimationRatio(): number;
  33656. /**
  33657. * Gets an unique Id for the current render phase
  33658. * @returns a number
  33659. */
  33660. getRenderId(): number;
  33661. /**
  33662. * Gets an unique Id for the current frame
  33663. * @returns a number
  33664. */
  33665. getFrameId(): number;
  33666. /** Call this function if you want to manually increment the render Id*/
  33667. incrementRenderId(): void;
  33668. private _createUbo;
  33669. /**
  33670. * Use this method to simulate a pointer move on a mesh
  33671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33674. * @returns the current scene
  33675. */
  33676. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33677. /**
  33678. * Use this method to simulate a pointer down on a mesh
  33679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33682. * @returns the current scene
  33683. */
  33684. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33685. /**
  33686. * Use this method to simulate a pointer up on a mesh
  33687. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33688. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33689. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33690. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33691. * @returns the current scene
  33692. */
  33693. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33694. /**
  33695. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33696. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33697. * @returns true if the pointer was captured
  33698. */
  33699. isPointerCaptured(pointerId?: number): boolean;
  33700. /**
  33701. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33702. * @param attachUp defines if you want to attach events to pointerup
  33703. * @param attachDown defines if you want to attach events to pointerdown
  33704. * @param attachMove defines if you want to attach events to pointermove
  33705. */
  33706. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33707. /** Detaches all event handlers*/
  33708. detachControl(): void;
  33709. /**
  33710. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33711. * Delay loaded resources are not taking in account
  33712. * @return true if all required resources are ready
  33713. */
  33714. isReady(): boolean;
  33715. /** Resets all cached information relative to material (including effect and visibility) */
  33716. resetCachedMaterial(): void;
  33717. /**
  33718. * Registers a function to be called before every frame render
  33719. * @param func defines the function to register
  33720. */
  33721. registerBeforeRender(func: () => void): void;
  33722. /**
  33723. * Unregisters a function called before every frame render
  33724. * @param func defines the function to unregister
  33725. */
  33726. unregisterBeforeRender(func: () => void): void;
  33727. /**
  33728. * Registers a function to be called after every frame render
  33729. * @param func defines the function to register
  33730. */
  33731. registerAfterRender(func: () => void): void;
  33732. /**
  33733. * Unregisters a function called after every frame render
  33734. * @param func defines the function to unregister
  33735. */
  33736. unregisterAfterRender(func: () => void): void;
  33737. private _executeOnceBeforeRender;
  33738. /**
  33739. * The provided function will run before render once and will be disposed afterwards.
  33740. * A timeout delay can be provided so that the function will be executed in N ms.
  33741. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33742. * @param func The function to be executed.
  33743. * @param timeout optional delay in ms
  33744. */
  33745. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33746. /** @hidden */
  33747. _addPendingData(data: any): void;
  33748. /** @hidden */
  33749. _removePendingData(data: any): void;
  33750. /**
  33751. * Returns the number of items waiting to be loaded
  33752. * @returns the number of items waiting to be loaded
  33753. */
  33754. getWaitingItemsCount(): number;
  33755. /**
  33756. * Returns a boolean indicating if the scene is still loading data
  33757. */
  33758. readonly isLoading: boolean;
  33759. /**
  33760. * Registers a function to be executed when the scene is ready
  33761. * @param {Function} func - the function to be executed
  33762. */
  33763. executeWhenReady(func: () => void): void;
  33764. /**
  33765. * Returns a promise that resolves when the scene is ready
  33766. * @returns A promise that resolves when the scene is ready
  33767. */
  33768. whenReadyAsync(): Promise<void>;
  33769. /** @hidden */
  33770. _checkIsReady(): void;
  33771. /**
  33772. * Gets all animatable attached to the scene
  33773. */
  33774. readonly animatables: Animatable[];
  33775. /**
  33776. * Resets the last animation time frame.
  33777. * Useful to override when animations start running when loading a scene for the first time.
  33778. */
  33779. resetLastAnimationTimeFrame(): void;
  33780. /**
  33781. * Gets the current view matrix
  33782. * @returns a Matrix
  33783. */
  33784. getViewMatrix(): Matrix;
  33785. /**
  33786. * Gets the current projection matrix
  33787. * @returns a Matrix
  33788. */
  33789. getProjectionMatrix(): Matrix;
  33790. /**
  33791. * Gets the current transform matrix
  33792. * @returns a Matrix made of View * Projection
  33793. */
  33794. getTransformMatrix(): Matrix;
  33795. /**
  33796. * Sets the current transform matrix
  33797. * @param viewL defines the View matrix to use
  33798. * @param projectionL defines the Projection matrix to use
  33799. * @param viewR defines the right View matrix to use (if provided)
  33800. * @param projectionR defines the right Projection matrix to use (if provided)
  33801. */
  33802. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33803. /**
  33804. * Gets the uniform buffer used to store scene data
  33805. * @returns a UniformBuffer
  33806. */
  33807. getSceneUniformBuffer(): UniformBuffer;
  33808. /**
  33809. * Gets an unique (relatively to the current scene) Id
  33810. * @returns an unique number for the scene
  33811. */
  33812. getUniqueId(): number;
  33813. /**
  33814. * Add a mesh to the list of scene's meshes
  33815. * @param newMesh defines the mesh to add
  33816. * @param recursive if all child meshes should also be added to the scene
  33817. */
  33818. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33819. /**
  33820. * Remove a mesh for the list of scene's meshes
  33821. * @param toRemove defines the mesh to remove
  33822. * @param recursive if all child meshes should also be removed from the scene
  33823. * @returns the index where the mesh was in the mesh list
  33824. */
  33825. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33826. /**
  33827. * Add a transform node to the list of scene's transform nodes
  33828. * @param newTransformNode defines the transform node to add
  33829. */
  33830. addTransformNode(newTransformNode: TransformNode): void;
  33831. /**
  33832. * Remove a transform node for the list of scene's transform nodes
  33833. * @param toRemove defines the transform node to remove
  33834. * @returns the index where the transform node was in the transform node list
  33835. */
  33836. removeTransformNode(toRemove: TransformNode): number;
  33837. /**
  33838. * Remove a skeleton for the list of scene's skeletons
  33839. * @param toRemove defines the skeleton to remove
  33840. * @returns the index where the skeleton was in the skeleton list
  33841. */
  33842. removeSkeleton(toRemove: Skeleton): number;
  33843. /**
  33844. * Remove a morph target for the list of scene's morph targets
  33845. * @param toRemove defines the morph target to remove
  33846. * @returns the index where the morph target was in the morph target list
  33847. */
  33848. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33849. /**
  33850. * Remove a light for the list of scene's lights
  33851. * @param toRemove defines the light to remove
  33852. * @returns the index where the light was in the light list
  33853. */
  33854. removeLight(toRemove: Light): number;
  33855. /**
  33856. * Remove a camera for the list of scene's cameras
  33857. * @param toRemove defines the camera to remove
  33858. * @returns the index where the camera was in the camera list
  33859. */
  33860. removeCamera(toRemove: Camera): number;
  33861. /**
  33862. * Remove a particle system for the list of scene's particle systems
  33863. * @param toRemove defines the particle system to remove
  33864. * @returns the index where the particle system was in the particle system list
  33865. */
  33866. removeParticleSystem(toRemove: IParticleSystem): number;
  33867. /**
  33868. * Remove a animation for the list of scene's animations
  33869. * @param toRemove defines the animation to remove
  33870. * @returns the index where the animation was in the animation list
  33871. */
  33872. removeAnimation(toRemove: Animation): number;
  33873. /**
  33874. * Will stop the animation of the given target
  33875. * @param target - the target
  33876. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33877. * @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)
  33878. */
  33879. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33880. /**
  33881. * Removes the given animation group from this scene.
  33882. * @param toRemove The animation group to remove
  33883. * @returns The index of the removed animation group
  33884. */
  33885. removeAnimationGroup(toRemove: AnimationGroup): number;
  33886. /**
  33887. * Removes the given multi-material from this scene.
  33888. * @param toRemove The multi-material to remove
  33889. * @returns The index of the removed multi-material
  33890. */
  33891. removeMultiMaterial(toRemove: MultiMaterial): number;
  33892. /**
  33893. * Removes the given material from this scene.
  33894. * @param toRemove The material to remove
  33895. * @returns The index of the removed material
  33896. */
  33897. removeMaterial(toRemove: Material): number;
  33898. /**
  33899. * Removes the given action manager from this scene.
  33900. * @param toRemove The action manager to remove
  33901. * @returns The index of the removed action manager
  33902. */
  33903. removeActionManager(toRemove: AbstractActionManager): number;
  33904. /**
  33905. * Removes the given texture from this scene.
  33906. * @param toRemove The texture to remove
  33907. * @returns The index of the removed texture
  33908. */
  33909. removeTexture(toRemove: BaseTexture): number;
  33910. /**
  33911. * Adds the given light to this scene
  33912. * @param newLight The light to add
  33913. */
  33914. addLight(newLight: Light): void;
  33915. /**
  33916. * Sorts the list list based on light priorities
  33917. */
  33918. sortLightsByPriority(): void;
  33919. /**
  33920. * Adds the given camera to this scene
  33921. * @param newCamera The camera to add
  33922. */
  33923. addCamera(newCamera: Camera): void;
  33924. /**
  33925. * Adds the given skeleton to this scene
  33926. * @param newSkeleton The skeleton to add
  33927. */
  33928. addSkeleton(newSkeleton: Skeleton): void;
  33929. /**
  33930. * Adds the given particle system to this scene
  33931. * @param newParticleSystem The particle system to add
  33932. */
  33933. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33934. /**
  33935. * Adds the given animation to this scene
  33936. * @param newAnimation The animation to add
  33937. */
  33938. addAnimation(newAnimation: Animation): void;
  33939. /**
  33940. * Adds the given animation group to this scene.
  33941. * @param newAnimationGroup The animation group to add
  33942. */
  33943. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33944. /**
  33945. * Adds the given multi-material to this scene
  33946. * @param newMultiMaterial The multi-material to add
  33947. */
  33948. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33949. /**
  33950. * Adds the given material to this scene
  33951. * @param newMaterial The material to add
  33952. */
  33953. addMaterial(newMaterial: Material): void;
  33954. /**
  33955. * Adds the given morph target to this scene
  33956. * @param newMorphTargetManager The morph target to add
  33957. */
  33958. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33959. /**
  33960. * Adds the given geometry to this scene
  33961. * @param newGeometry The geometry to add
  33962. */
  33963. addGeometry(newGeometry: Geometry): void;
  33964. /**
  33965. * Adds the given action manager to this scene
  33966. * @param newActionManager The action manager to add
  33967. */
  33968. addActionManager(newActionManager: AbstractActionManager): void;
  33969. /**
  33970. * Adds the given texture to this scene.
  33971. * @param newTexture The texture to add
  33972. */
  33973. addTexture(newTexture: BaseTexture): void;
  33974. /**
  33975. * Switch active camera
  33976. * @param newCamera defines the new active camera
  33977. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33978. */
  33979. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33980. /**
  33981. * sets the active camera of the scene using its ID
  33982. * @param id defines the camera's ID
  33983. * @return the new active camera or null if none found.
  33984. */
  33985. setActiveCameraByID(id: string): Nullable<Camera>;
  33986. /**
  33987. * sets the active camera of the scene using its name
  33988. * @param name defines the camera's name
  33989. * @returns the new active camera or null if none found.
  33990. */
  33991. setActiveCameraByName(name: string): Nullable<Camera>;
  33992. /**
  33993. * get an animation group using its name
  33994. * @param name defines the material's name
  33995. * @return the animation group or null if none found.
  33996. */
  33997. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33998. /**
  33999. * Get a material using its unique id
  34000. * @param uniqueId defines the material's unique id
  34001. * @return the material or null if none found.
  34002. */
  34003. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34004. /**
  34005. * get a material using its id
  34006. * @param id defines the material's ID
  34007. * @return the material or null if none found.
  34008. */
  34009. getMaterialByID(id: string): Nullable<Material>;
  34010. /**
  34011. * Gets a the last added material using a given id
  34012. * @param id defines the material's ID
  34013. * @return the last material with the given id or null if none found.
  34014. */
  34015. getLastMaterialByID(id: string): Nullable<Material>;
  34016. /**
  34017. * Gets a material using its name
  34018. * @param name defines the material's name
  34019. * @return the material or null if none found.
  34020. */
  34021. getMaterialByName(name: string): Nullable<Material>;
  34022. /**
  34023. * Get a texture using its unique id
  34024. * @param uniqueId defines the texture's unique id
  34025. * @return the texture or null if none found.
  34026. */
  34027. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34028. /**
  34029. * Gets a camera using its id
  34030. * @param id defines the id to look for
  34031. * @returns the camera or null if not found
  34032. */
  34033. getCameraByID(id: string): Nullable<Camera>;
  34034. /**
  34035. * Gets a camera using its unique id
  34036. * @param uniqueId defines the unique id to look for
  34037. * @returns the camera or null if not found
  34038. */
  34039. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34040. /**
  34041. * Gets a camera using its name
  34042. * @param name defines the camera's name
  34043. * @return the camera or null if none found.
  34044. */
  34045. getCameraByName(name: string): Nullable<Camera>;
  34046. /**
  34047. * Gets a bone using its id
  34048. * @param id defines the bone's id
  34049. * @return the bone or null if not found
  34050. */
  34051. getBoneByID(id: string): Nullable<Bone>;
  34052. /**
  34053. * Gets a bone using its id
  34054. * @param name defines the bone's name
  34055. * @return the bone or null if not found
  34056. */
  34057. getBoneByName(name: string): Nullable<Bone>;
  34058. /**
  34059. * Gets a light node using its name
  34060. * @param name defines the the light's name
  34061. * @return the light or null if none found.
  34062. */
  34063. getLightByName(name: string): Nullable<Light>;
  34064. /**
  34065. * Gets a light node using its id
  34066. * @param id defines the light's id
  34067. * @return the light or null if none found.
  34068. */
  34069. getLightByID(id: string): Nullable<Light>;
  34070. /**
  34071. * Gets a light node using its scene-generated unique ID
  34072. * @param uniqueId defines the light's unique id
  34073. * @return the light or null if none found.
  34074. */
  34075. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34076. /**
  34077. * Gets a particle system by id
  34078. * @param id defines the particle system id
  34079. * @return the corresponding system or null if none found
  34080. */
  34081. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34082. /**
  34083. * Gets a geometry using its ID
  34084. * @param id defines the geometry's id
  34085. * @return the geometry or null if none found.
  34086. */
  34087. getGeometryByID(id: string): Nullable<Geometry>;
  34088. private _getGeometryByUniqueID;
  34089. /**
  34090. * Add a new geometry to this scene
  34091. * @param geometry defines the geometry to be added to the scene.
  34092. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34093. * @return a boolean defining if the geometry was added or not
  34094. */
  34095. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34096. /**
  34097. * Removes an existing geometry
  34098. * @param geometry defines the geometry to be removed from the scene
  34099. * @return a boolean defining if the geometry was removed or not
  34100. */
  34101. removeGeometry(geometry: Geometry): boolean;
  34102. /**
  34103. * Gets the list of geometries attached to the scene
  34104. * @returns an array of Geometry
  34105. */
  34106. getGeometries(): Geometry[];
  34107. /**
  34108. * Gets the first added mesh found of a given ID
  34109. * @param id defines the id to search for
  34110. * @return the mesh found or null if not found at all
  34111. */
  34112. getMeshByID(id: string): Nullable<AbstractMesh>;
  34113. /**
  34114. * Gets a list of meshes using their id
  34115. * @param id defines the id to search for
  34116. * @returns a list of meshes
  34117. */
  34118. getMeshesByID(id: string): Array<AbstractMesh>;
  34119. /**
  34120. * Gets the first added transform node found of a given ID
  34121. * @param id defines the id to search for
  34122. * @return the found transform node or null if not found at all.
  34123. */
  34124. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34125. /**
  34126. * Gets a transform node with its auto-generated unique id
  34127. * @param uniqueId efines the unique id to search for
  34128. * @return the found transform node or null if not found at all.
  34129. */
  34130. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34131. /**
  34132. * Gets a list of transform nodes using their id
  34133. * @param id defines the id to search for
  34134. * @returns a list of transform nodes
  34135. */
  34136. getTransformNodesByID(id: string): Array<TransformNode>;
  34137. /**
  34138. * Gets a mesh with its auto-generated unique id
  34139. * @param uniqueId defines the unique id to search for
  34140. * @return the found mesh or null if not found at all.
  34141. */
  34142. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34143. /**
  34144. * Gets a the last added mesh using a given id
  34145. * @param id defines the id to search for
  34146. * @return the found mesh or null if not found at all.
  34147. */
  34148. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34149. /**
  34150. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34151. * @param id defines the id to search for
  34152. * @return the found node or null if not found at all
  34153. */
  34154. getLastEntryByID(id: string): Nullable<Node>;
  34155. /**
  34156. * Gets a node (Mesh, Camera, Light) using a given id
  34157. * @param id defines the id to search for
  34158. * @return the found node or null if not found at all
  34159. */
  34160. getNodeByID(id: string): Nullable<Node>;
  34161. /**
  34162. * Gets a node (Mesh, Camera, Light) using a given name
  34163. * @param name defines the name to search for
  34164. * @return the found node or null if not found at all.
  34165. */
  34166. getNodeByName(name: string): Nullable<Node>;
  34167. /**
  34168. * Gets a mesh using a given name
  34169. * @param name defines the name to search for
  34170. * @return the found mesh or null if not found at all.
  34171. */
  34172. getMeshByName(name: string): Nullable<AbstractMesh>;
  34173. /**
  34174. * Gets a transform node using a given name
  34175. * @param name defines the name to search for
  34176. * @return the found transform node or null if not found at all.
  34177. */
  34178. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34179. /**
  34180. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34181. * @param id defines the id to search for
  34182. * @return the found skeleton or null if not found at all.
  34183. */
  34184. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34185. /**
  34186. * Gets a skeleton using a given auto generated unique id
  34187. * @param uniqueId defines the unique id to search for
  34188. * @return the found skeleton or null if not found at all.
  34189. */
  34190. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34191. /**
  34192. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34193. * @param id defines the id to search for
  34194. * @return the found skeleton or null if not found at all.
  34195. */
  34196. getSkeletonById(id: string): Nullable<Skeleton>;
  34197. /**
  34198. * Gets a skeleton using a given name
  34199. * @param name defines the name to search for
  34200. * @return the found skeleton or null if not found at all.
  34201. */
  34202. getSkeletonByName(name: string): Nullable<Skeleton>;
  34203. /**
  34204. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34205. * @param id defines the id to search for
  34206. * @return the found morph target manager or null if not found at all.
  34207. */
  34208. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34209. /**
  34210. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34211. * @param id defines the id to search for
  34212. * @return the found morph target or null if not found at all.
  34213. */
  34214. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34215. /**
  34216. * Gets a boolean indicating if the given mesh is active
  34217. * @param mesh defines the mesh to look for
  34218. * @returns true if the mesh is in the active list
  34219. */
  34220. isActiveMesh(mesh: AbstractMesh): boolean;
  34221. /**
  34222. * Return a unique id as a string which can serve as an identifier for the scene
  34223. */
  34224. readonly uid: string;
  34225. /**
  34226. * Add an externaly attached data from its key.
  34227. * This method call will fail and return false, if such key already exists.
  34228. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34229. * @param key the unique key that identifies the data
  34230. * @param data the data object to associate to the key for this Engine instance
  34231. * @return true if no such key were already present and the data was added successfully, false otherwise
  34232. */
  34233. addExternalData<T>(key: string, data: T): boolean;
  34234. /**
  34235. * Get an externaly attached data from its key
  34236. * @param key the unique key that identifies the data
  34237. * @return the associated data, if present (can be null), or undefined if not present
  34238. */
  34239. getExternalData<T>(key: string): Nullable<T>;
  34240. /**
  34241. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34242. * @param key the unique key that identifies the data
  34243. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34244. * @return the associated data, can be null if the factory returned null.
  34245. */
  34246. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34247. /**
  34248. * Remove an externaly attached data from the Engine instance
  34249. * @param key the unique key that identifies the data
  34250. * @return true if the data was successfully removed, false if it doesn't exist
  34251. */
  34252. removeExternalData(key: string): boolean;
  34253. private _evaluateSubMesh;
  34254. /**
  34255. * Clear the processed materials smart array preventing retention point in material dispose.
  34256. */
  34257. freeProcessedMaterials(): void;
  34258. private _preventFreeActiveMeshesAndRenderingGroups;
  34259. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34260. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34261. * when disposing several meshes in a row or a hierarchy of meshes.
  34262. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34263. */
  34264. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34265. /**
  34266. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34267. */
  34268. freeActiveMeshes(): void;
  34269. /**
  34270. * Clear the info related to rendering groups preventing retention points during dispose.
  34271. */
  34272. freeRenderingGroups(): void;
  34273. /** @hidden */
  34274. _isInIntermediateRendering(): boolean;
  34275. /**
  34276. * Lambda returning the list of potentially active meshes.
  34277. */
  34278. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34279. /**
  34280. * Lambda returning the list of potentially active sub meshes.
  34281. */
  34282. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34283. /**
  34284. * Lambda returning the list of potentially intersecting sub meshes.
  34285. */
  34286. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34287. /**
  34288. * Lambda returning the list of potentially colliding sub meshes.
  34289. */
  34290. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34291. private _activeMeshesFrozen;
  34292. /**
  34293. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34294. * @returns the current scene
  34295. */
  34296. freezeActiveMeshes(): Scene;
  34297. /**
  34298. * Use this function to restart evaluating active meshes on every frame
  34299. * @returns the current scene
  34300. */
  34301. unfreezeActiveMeshes(): Scene;
  34302. private _evaluateActiveMeshes;
  34303. private _activeMesh;
  34304. /**
  34305. * Update the transform matrix to update from the current active camera
  34306. * @param force defines a boolean used to force the update even if cache is up to date
  34307. */
  34308. updateTransformMatrix(force?: boolean): void;
  34309. private _bindFrameBuffer;
  34310. /** @hidden */
  34311. _allowPostProcessClearColor: boolean;
  34312. /** @hidden */
  34313. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34314. private _processSubCameras;
  34315. private _checkIntersections;
  34316. /** @hidden */
  34317. _advancePhysicsEngineStep(step: number): void;
  34318. /**
  34319. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34320. */
  34321. getDeterministicFrameTime: () => number;
  34322. /** @hidden */
  34323. _animate(): void;
  34324. /** Execute all animations (for a frame) */
  34325. animate(): void;
  34326. /**
  34327. * Render the scene
  34328. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34329. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34330. */
  34331. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34332. /**
  34333. * Freeze all materials
  34334. * A frozen material will not be updatable but should be faster to render
  34335. */
  34336. freezeMaterials(): void;
  34337. /**
  34338. * Unfreeze all materials
  34339. * A frozen material will not be updatable but should be faster to render
  34340. */
  34341. unfreezeMaterials(): void;
  34342. /**
  34343. * Releases all held ressources
  34344. */
  34345. dispose(): void;
  34346. /**
  34347. * Gets if the scene is already disposed
  34348. */
  34349. readonly isDisposed: boolean;
  34350. /**
  34351. * Call this function to reduce memory footprint of the scene.
  34352. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34353. */
  34354. clearCachedVertexData(): void;
  34355. /**
  34356. * This function will remove the local cached buffer data from texture.
  34357. * It will save memory but will prevent the texture from being rebuilt
  34358. */
  34359. cleanCachedTextureBuffer(): void;
  34360. /**
  34361. * Get the world extend vectors with an optional filter
  34362. *
  34363. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34364. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34365. */
  34366. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34367. min: Vector3;
  34368. max: Vector3;
  34369. };
  34370. /**
  34371. * Creates a ray that can be used to pick in the scene
  34372. * @param x defines the x coordinate of the origin (on-screen)
  34373. * @param y defines the y coordinate of the origin (on-screen)
  34374. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34375. * @param camera defines the camera to use for the picking
  34376. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34377. * @returns a Ray
  34378. */
  34379. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34380. /**
  34381. * Creates a ray that can be used to pick in the scene
  34382. * @param x defines the x coordinate of the origin (on-screen)
  34383. * @param y defines the y coordinate of the origin (on-screen)
  34384. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34385. * @param result defines the ray where to store the picking ray
  34386. * @param camera defines the camera to use for the picking
  34387. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34388. * @returns the current scene
  34389. */
  34390. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34391. /**
  34392. * Creates a ray that can be used to pick in the scene
  34393. * @param x defines the x coordinate of the origin (on-screen)
  34394. * @param y defines the y coordinate of the origin (on-screen)
  34395. * @param camera defines the camera to use for the picking
  34396. * @returns a Ray
  34397. */
  34398. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34399. /**
  34400. * Creates a ray that can be used to pick in the scene
  34401. * @param x defines the x coordinate of the origin (on-screen)
  34402. * @param y defines the y coordinate of the origin (on-screen)
  34403. * @param result defines the ray where to store the picking ray
  34404. * @param camera defines the camera to use for the picking
  34405. * @returns the current scene
  34406. */
  34407. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34408. /** Launch a ray to try to pick a mesh in the scene
  34409. * @param x position on screen
  34410. * @param y position on screen
  34411. * @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
  34412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34413. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34414. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34415. * @returns a PickingInfo
  34416. */
  34417. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34418. /** Use the given ray to pick a mesh in the scene
  34419. * @param ray The ray to use to pick meshes
  34420. * @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
  34421. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34422. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34423. * @returns a PickingInfo
  34424. */
  34425. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34426. /**
  34427. * Launch a ray to try to pick a mesh in the scene
  34428. * @param x X position on screen
  34429. * @param y Y position on screen
  34430. * @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
  34431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34432. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34433. * @returns an array of PickingInfo
  34434. */
  34435. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34436. /**
  34437. * Launch a ray to try to pick a mesh in the scene
  34438. * @param ray Ray to use
  34439. * @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
  34440. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34441. * @returns an array of PickingInfo
  34442. */
  34443. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34444. /**
  34445. * Force the value of meshUnderPointer
  34446. * @param mesh defines the mesh to use
  34447. */
  34448. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34449. /**
  34450. * Gets the mesh under the pointer
  34451. * @returns a Mesh or null if no mesh is under the pointer
  34452. */
  34453. getPointerOverMesh(): Nullable<AbstractMesh>;
  34454. /** @hidden */
  34455. _rebuildGeometries(): void;
  34456. /** @hidden */
  34457. _rebuildTextures(): void;
  34458. private _getByTags;
  34459. /**
  34460. * Get a list of meshes by tags
  34461. * @param tagsQuery defines the tags query to use
  34462. * @param forEach defines a predicate used to filter results
  34463. * @returns an array of Mesh
  34464. */
  34465. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34466. /**
  34467. * Get a list of cameras by tags
  34468. * @param tagsQuery defines the tags query to use
  34469. * @param forEach defines a predicate used to filter results
  34470. * @returns an array of Camera
  34471. */
  34472. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34473. /**
  34474. * Get a list of lights by tags
  34475. * @param tagsQuery defines the tags query to use
  34476. * @param forEach defines a predicate used to filter results
  34477. * @returns an array of Light
  34478. */
  34479. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34480. /**
  34481. * Get a list of materials by tags
  34482. * @param tagsQuery defines the tags query to use
  34483. * @param forEach defines a predicate used to filter results
  34484. * @returns an array of Material
  34485. */
  34486. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34487. /**
  34488. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34489. * This allowed control for front to back rendering or reversly depending of the special needs.
  34490. *
  34491. * @param renderingGroupId The rendering group id corresponding to its index
  34492. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34493. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34494. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34495. */
  34496. 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;
  34497. /**
  34498. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34499. *
  34500. * @param renderingGroupId The rendering group id corresponding to its index
  34501. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34502. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34503. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34504. */
  34505. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34506. /**
  34507. * Gets the current auto clear configuration for one rendering group of the rendering
  34508. * manager.
  34509. * @param index the rendering group index to get the information for
  34510. * @returns The auto clear setup for the requested rendering group
  34511. */
  34512. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34513. private _blockMaterialDirtyMechanism;
  34514. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34515. blockMaterialDirtyMechanism: boolean;
  34516. /**
  34517. * Will flag all materials as dirty to trigger new shader compilation
  34518. * @param flag defines the flag used to specify which material part must be marked as dirty
  34519. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34520. */
  34521. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34522. /** @hidden */
  34523. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34524. /** @hidden */
  34525. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34526. }
  34527. }
  34528. declare module BABYLON {
  34529. /**
  34530. * Set of assets to keep when moving a scene into an asset container.
  34531. */
  34532. export class KeepAssets extends AbstractScene {
  34533. }
  34534. /**
  34535. * Container with a set of assets that can be added or removed from a scene.
  34536. */
  34537. export class AssetContainer extends AbstractScene {
  34538. /**
  34539. * The scene the AssetContainer belongs to.
  34540. */
  34541. scene: Scene;
  34542. /**
  34543. * Instantiates an AssetContainer.
  34544. * @param scene The scene the AssetContainer belongs to.
  34545. */
  34546. constructor(scene: Scene);
  34547. /**
  34548. * Adds all the assets from the container to the scene.
  34549. */
  34550. addAllToScene(): void;
  34551. /**
  34552. * Removes all the assets in the container from the scene
  34553. */
  34554. removeAllFromScene(): void;
  34555. /**
  34556. * Disposes all the assets in the container
  34557. */
  34558. dispose(): void;
  34559. private _moveAssets;
  34560. /**
  34561. * Removes all the assets contained in the scene and adds them to the container.
  34562. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34563. */
  34564. moveAllFromScene(keepAssets?: KeepAssets): void;
  34565. /**
  34566. * 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.
  34567. * @returns the root mesh
  34568. */
  34569. createRootMesh(): Mesh;
  34570. }
  34571. }
  34572. declare module BABYLON {
  34573. /**
  34574. * Defines how the parser contract is defined.
  34575. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34576. */
  34577. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34578. /**
  34579. * Defines how the individual parser contract is defined.
  34580. * These parser can parse an individual asset
  34581. */
  34582. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34583. /**
  34584. * Base class of the scene acting as a container for the different elements composing a scene.
  34585. * This class is dynamically extended by the different components of the scene increasing
  34586. * flexibility and reducing coupling
  34587. */
  34588. export abstract class AbstractScene {
  34589. /**
  34590. * Stores the list of available parsers in the application.
  34591. */
  34592. private static _BabylonFileParsers;
  34593. /**
  34594. * Stores the list of available individual parsers in the application.
  34595. */
  34596. private static _IndividualBabylonFileParsers;
  34597. /**
  34598. * Adds a parser in the list of available ones
  34599. * @param name Defines the name of the parser
  34600. * @param parser Defines the parser to add
  34601. */
  34602. static AddParser(name: string, parser: BabylonFileParser): void;
  34603. /**
  34604. * Gets a general parser from the list of avaialble ones
  34605. * @param name Defines the name of the parser
  34606. * @returns the requested parser or null
  34607. */
  34608. static GetParser(name: string): Nullable<BabylonFileParser>;
  34609. /**
  34610. * Adds n individual parser in the list of available ones
  34611. * @param name Defines the name of the parser
  34612. * @param parser Defines the parser to add
  34613. */
  34614. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34615. /**
  34616. * Gets an individual parser from the list of avaialble ones
  34617. * @param name Defines the name of the parser
  34618. * @returns the requested parser or null
  34619. */
  34620. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34621. /**
  34622. * Parser json data and populate both a scene and its associated container object
  34623. * @param jsonData Defines the data to parse
  34624. * @param scene Defines the scene to parse the data for
  34625. * @param container Defines the container attached to the parsing sequence
  34626. * @param rootUrl Defines the root url of the data
  34627. */
  34628. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34629. /**
  34630. * Gets the list of root nodes (ie. nodes with no parent)
  34631. */
  34632. rootNodes: Node[];
  34633. /** All of the cameras added to this scene
  34634. * @see http://doc.babylonjs.com/babylon101/cameras
  34635. */
  34636. cameras: Camera[];
  34637. /**
  34638. * All of the lights added to this scene
  34639. * @see http://doc.babylonjs.com/babylon101/lights
  34640. */
  34641. lights: Light[];
  34642. /**
  34643. * All of the (abstract) meshes added to this scene
  34644. */
  34645. meshes: AbstractMesh[];
  34646. /**
  34647. * The list of skeletons added to the scene
  34648. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34649. */
  34650. skeletons: Skeleton[];
  34651. /**
  34652. * All of the particle systems added to this scene
  34653. * @see http://doc.babylonjs.com/babylon101/particles
  34654. */
  34655. particleSystems: IParticleSystem[];
  34656. /**
  34657. * Gets a list of Animations associated with the scene
  34658. */
  34659. animations: Animation[];
  34660. /**
  34661. * All of the animation groups added to this scene
  34662. * @see http://doc.babylonjs.com/how_to/group
  34663. */
  34664. animationGroups: AnimationGroup[];
  34665. /**
  34666. * All of the multi-materials added to this scene
  34667. * @see http://doc.babylonjs.com/how_to/multi_materials
  34668. */
  34669. multiMaterials: MultiMaterial[];
  34670. /**
  34671. * All of the materials added to this scene
  34672. * In the context of a Scene, it is not supposed to be modified manually.
  34673. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34674. * Note also that the order of the Material wihin the array is not significant and might change.
  34675. * @see http://doc.babylonjs.com/babylon101/materials
  34676. */
  34677. materials: Material[];
  34678. /**
  34679. * The list of morph target managers added to the scene
  34680. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34681. */
  34682. morphTargetManagers: MorphTargetManager[];
  34683. /**
  34684. * The list of geometries used in the scene.
  34685. */
  34686. geometries: Geometry[];
  34687. /**
  34688. * All of the tranform nodes added to this scene
  34689. * In the context of a Scene, it is not supposed to be modified manually.
  34690. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34691. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34692. * @see http://doc.babylonjs.com/how_to/transformnode
  34693. */
  34694. transformNodes: TransformNode[];
  34695. /**
  34696. * ActionManagers available on the scene.
  34697. */
  34698. actionManagers: AbstractActionManager[];
  34699. /**
  34700. * Textures to keep.
  34701. */
  34702. textures: BaseTexture[];
  34703. /**
  34704. * Environment texture for the scene
  34705. */
  34706. environmentTexture: Nullable<BaseTexture>;
  34707. }
  34708. }
  34709. declare module BABYLON {
  34710. /**
  34711. * Interface used to define options for Sound class
  34712. */
  34713. export interface ISoundOptions {
  34714. /**
  34715. * Does the sound autoplay once loaded.
  34716. */
  34717. autoplay?: boolean;
  34718. /**
  34719. * Does the sound loop after it finishes playing once.
  34720. */
  34721. loop?: boolean;
  34722. /**
  34723. * Sound's volume
  34724. */
  34725. volume?: number;
  34726. /**
  34727. * Is it a spatial sound?
  34728. */
  34729. spatialSound?: boolean;
  34730. /**
  34731. * Maximum distance to hear that sound
  34732. */
  34733. maxDistance?: number;
  34734. /**
  34735. * Uses user defined attenuation function
  34736. */
  34737. useCustomAttenuation?: boolean;
  34738. /**
  34739. * Define the roll off factor of spatial sounds.
  34740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34741. */
  34742. rolloffFactor?: number;
  34743. /**
  34744. * Define the reference distance the sound should be heard perfectly.
  34745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34746. */
  34747. refDistance?: number;
  34748. /**
  34749. * Define the distance attenuation model the sound will follow.
  34750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34751. */
  34752. distanceModel?: string;
  34753. /**
  34754. * Defines the playback speed (1 by default)
  34755. */
  34756. playbackRate?: number;
  34757. /**
  34758. * Defines if the sound is from a streaming source
  34759. */
  34760. streaming?: boolean;
  34761. /**
  34762. * Defines an optional length (in seconds) inside the sound file
  34763. */
  34764. length?: number;
  34765. /**
  34766. * Defines an optional offset (in seconds) inside the sound file
  34767. */
  34768. offset?: number;
  34769. /**
  34770. * If true, URLs will not be required to state the audio file codec to use.
  34771. */
  34772. skipCodecCheck?: boolean;
  34773. }
  34774. /**
  34775. * Defines a sound that can be played in the application.
  34776. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34778. */
  34779. export class Sound {
  34780. /**
  34781. * The name of the sound in the scene.
  34782. */
  34783. name: string;
  34784. /**
  34785. * Does the sound autoplay once loaded.
  34786. */
  34787. autoplay: boolean;
  34788. /**
  34789. * Does the sound loop after it finishes playing once.
  34790. */
  34791. loop: boolean;
  34792. /**
  34793. * Does the sound use a custom attenuation curve to simulate the falloff
  34794. * happening when the source gets further away from the camera.
  34795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34796. */
  34797. useCustomAttenuation: boolean;
  34798. /**
  34799. * The sound track id this sound belongs to.
  34800. */
  34801. soundTrackId: number;
  34802. /**
  34803. * Is this sound currently played.
  34804. */
  34805. isPlaying: boolean;
  34806. /**
  34807. * Is this sound currently paused.
  34808. */
  34809. isPaused: boolean;
  34810. /**
  34811. * Does this sound enables spatial sound.
  34812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34813. */
  34814. spatialSound: boolean;
  34815. /**
  34816. * Define the reference distance the sound should be heard perfectly.
  34817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34818. */
  34819. refDistance: number;
  34820. /**
  34821. * Define the roll off factor of spatial sounds.
  34822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34823. */
  34824. rolloffFactor: number;
  34825. /**
  34826. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34828. */
  34829. maxDistance: number;
  34830. /**
  34831. * Define the distance attenuation model the sound will follow.
  34832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34833. */
  34834. distanceModel: string;
  34835. /**
  34836. * @hidden
  34837. * Back Compat
  34838. **/
  34839. onended: () => any;
  34840. /**
  34841. * Observable event when the current playing sound finishes.
  34842. */
  34843. onEndedObservable: Observable<Sound>;
  34844. private _panningModel;
  34845. private _playbackRate;
  34846. private _streaming;
  34847. private _startTime;
  34848. private _startOffset;
  34849. private _position;
  34850. /** @hidden */
  34851. _positionInEmitterSpace: boolean;
  34852. private _localDirection;
  34853. private _volume;
  34854. private _isReadyToPlay;
  34855. private _isDirectional;
  34856. private _readyToPlayCallback;
  34857. private _audioBuffer;
  34858. private _soundSource;
  34859. private _streamingSource;
  34860. private _soundPanner;
  34861. private _soundGain;
  34862. private _inputAudioNode;
  34863. private _outputAudioNode;
  34864. private _coneInnerAngle;
  34865. private _coneOuterAngle;
  34866. private _coneOuterGain;
  34867. private _scene;
  34868. private _connectedTransformNode;
  34869. private _customAttenuationFunction;
  34870. private _registerFunc;
  34871. private _isOutputConnected;
  34872. private _htmlAudioElement;
  34873. private _urlType;
  34874. private _length?;
  34875. private _offset?;
  34876. /** @hidden */
  34877. static _SceneComponentInitialization: (scene: Scene) => void;
  34878. /**
  34879. * Create a sound and attach it to a scene
  34880. * @param name Name of your sound
  34881. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34882. * @param scene defines the scene the sound belongs to
  34883. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34884. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34885. */
  34886. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34887. /**
  34888. * Release the sound and its associated resources
  34889. */
  34890. dispose(): void;
  34891. /**
  34892. * Gets if the sounds is ready to be played or not.
  34893. * @returns true if ready, otherwise false
  34894. */
  34895. isReady(): boolean;
  34896. private _soundLoaded;
  34897. /**
  34898. * Sets the data of the sound from an audiobuffer
  34899. * @param audioBuffer The audioBuffer containing the data
  34900. */
  34901. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34902. /**
  34903. * Updates the current sounds options such as maxdistance, loop...
  34904. * @param options A JSON object containing values named as the object properties
  34905. */
  34906. updateOptions(options: ISoundOptions): void;
  34907. private _createSpatialParameters;
  34908. private _updateSpatialParameters;
  34909. /**
  34910. * Switch the panning model to HRTF:
  34911. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34913. */
  34914. switchPanningModelToHRTF(): void;
  34915. /**
  34916. * Switch the panning model to Equal Power:
  34917. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34919. */
  34920. switchPanningModelToEqualPower(): void;
  34921. private _switchPanningModel;
  34922. /**
  34923. * Connect this sound to a sound track audio node like gain...
  34924. * @param soundTrackAudioNode the sound track audio node to connect to
  34925. */
  34926. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34927. /**
  34928. * Transform this sound into a directional source
  34929. * @param coneInnerAngle Size of the inner cone in degree
  34930. * @param coneOuterAngle Size of the outer cone in degree
  34931. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34932. */
  34933. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34934. /**
  34935. * Gets or sets the inner angle for the directional cone.
  34936. */
  34937. /**
  34938. * Gets or sets the inner angle for the directional cone.
  34939. */
  34940. directionalConeInnerAngle: number;
  34941. /**
  34942. * Gets or sets the outer angle for the directional cone.
  34943. */
  34944. /**
  34945. * Gets or sets the outer angle for the directional cone.
  34946. */
  34947. directionalConeOuterAngle: number;
  34948. /**
  34949. * Sets the position of the emitter if spatial sound is enabled
  34950. * @param newPosition Defines the new posisiton
  34951. */
  34952. setPosition(newPosition: Vector3): void;
  34953. /**
  34954. * Sets the local direction of the emitter if spatial sound is enabled
  34955. * @param newLocalDirection Defines the new local direction
  34956. */
  34957. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34958. private _updateDirection;
  34959. /** @hidden */
  34960. updateDistanceFromListener(): void;
  34961. /**
  34962. * Sets a new custom attenuation function for the sound.
  34963. * @param callback Defines the function used for the attenuation
  34964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34965. */
  34966. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34967. /**
  34968. * Play the sound
  34969. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34970. * @param offset (optional) Start the sound at a specific time in seconds
  34971. * @param length (optional) Sound duration (in seconds)
  34972. */
  34973. play(time?: number, offset?: number, length?: number): void;
  34974. private _onended;
  34975. /**
  34976. * Stop the sound
  34977. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34978. */
  34979. stop(time?: number): void;
  34980. /**
  34981. * Put the sound in pause
  34982. */
  34983. pause(): void;
  34984. /**
  34985. * Sets a dedicated volume for this sounds
  34986. * @param newVolume Define the new volume of the sound
  34987. * @param time Define time for gradual change to new volume
  34988. */
  34989. setVolume(newVolume: number, time?: number): void;
  34990. /**
  34991. * Set the sound play back rate
  34992. * @param newPlaybackRate Define the playback rate the sound should be played at
  34993. */
  34994. setPlaybackRate(newPlaybackRate: number): void;
  34995. /**
  34996. * Gets the volume of the sound.
  34997. * @returns the volume of the sound
  34998. */
  34999. getVolume(): number;
  35000. /**
  35001. * Attach the sound to a dedicated mesh
  35002. * @param transformNode The transform node to connect the sound with
  35003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35004. */
  35005. attachToMesh(transformNode: TransformNode): void;
  35006. /**
  35007. * Detach the sound from the previously attached mesh
  35008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35009. */
  35010. detachFromMesh(): void;
  35011. private _onRegisterAfterWorldMatrixUpdate;
  35012. /**
  35013. * Clone the current sound in the scene.
  35014. * @returns the new sound clone
  35015. */
  35016. clone(): Nullable<Sound>;
  35017. /**
  35018. * Gets the current underlying audio buffer containing the data
  35019. * @returns the audio buffer
  35020. */
  35021. getAudioBuffer(): Nullable<AudioBuffer>;
  35022. /**
  35023. * Serializes the Sound in a JSON representation
  35024. * @returns the JSON representation of the sound
  35025. */
  35026. serialize(): any;
  35027. /**
  35028. * Parse a JSON representation of a sound to innstantiate in a given scene
  35029. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35030. * @param scene Define the scene the new parsed sound should be created in
  35031. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35032. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35033. * @returns the newly parsed sound
  35034. */
  35035. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35036. }
  35037. }
  35038. declare module BABYLON {
  35039. /**
  35040. * This defines an action helpful to play a defined sound on a triggered action.
  35041. */
  35042. export class PlaySoundAction extends Action {
  35043. private _sound;
  35044. /**
  35045. * Instantiate the action
  35046. * @param triggerOptions defines the trigger options
  35047. * @param sound defines the sound to play
  35048. * @param condition defines the trigger related conditions
  35049. */
  35050. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35051. /** @hidden */
  35052. _prepare(): void;
  35053. /**
  35054. * Execute the action and play the sound.
  35055. */
  35056. execute(): void;
  35057. /**
  35058. * Serializes the actions and its related information.
  35059. * @param parent defines the object to serialize in
  35060. * @returns the serialized object
  35061. */
  35062. serialize(parent: any): any;
  35063. }
  35064. /**
  35065. * This defines an action helpful to stop a defined sound on a triggered action.
  35066. */
  35067. export class StopSoundAction extends Action {
  35068. private _sound;
  35069. /**
  35070. * Instantiate the action
  35071. * @param triggerOptions defines the trigger options
  35072. * @param sound defines the sound to stop
  35073. * @param condition defines the trigger related conditions
  35074. */
  35075. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35076. /** @hidden */
  35077. _prepare(): void;
  35078. /**
  35079. * Execute the action and stop the sound.
  35080. */
  35081. execute(): void;
  35082. /**
  35083. * Serializes the actions and its related information.
  35084. * @param parent defines the object to serialize in
  35085. * @returns the serialized object
  35086. */
  35087. serialize(parent: any): any;
  35088. }
  35089. }
  35090. declare module BABYLON {
  35091. /**
  35092. * This defines an action responsible to change the value of a property
  35093. * by interpolating between its current value and the newly set one once triggered.
  35094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35095. */
  35096. export class InterpolateValueAction extends Action {
  35097. /**
  35098. * Defines the path of the property where the value should be interpolated
  35099. */
  35100. propertyPath: string;
  35101. /**
  35102. * Defines the target value at the end of the interpolation.
  35103. */
  35104. value: any;
  35105. /**
  35106. * Defines the time it will take for the property to interpolate to the value.
  35107. */
  35108. duration: number;
  35109. /**
  35110. * Defines if the other scene animations should be stopped when the action has been triggered
  35111. */
  35112. stopOtherAnimations?: boolean;
  35113. /**
  35114. * Defines a callback raised once the interpolation animation has been done.
  35115. */
  35116. onInterpolationDone?: () => void;
  35117. /**
  35118. * Observable triggered once the interpolation animation has been done.
  35119. */
  35120. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35121. private _target;
  35122. private _effectiveTarget;
  35123. private _property;
  35124. /**
  35125. * Instantiate the action
  35126. * @param triggerOptions defines the trigger options
  35127. * @param target defines the object containing the value to interpolate
  35128. * @param propertyPath defines the path to the property in the target object
  35129. * @param value defines the target value at the end of the interpolation
  35130. * @param duration deines the time it will take for the property to interpolate to the value.
  35131. * @param condition defines the trigger related conditions
  35132. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35133. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35134. */
  35135. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35136. /** @hidden */
  35137. _prepare(): void;
  35138. /**
  35139. * Execute the action starts the value interpolation.
  35140. */
  35141. execute(): void;
  35142. /**
  35143. * Serializes the actions and its related information.
  35144. * @param parent defines the object to serialize in
  35145. * @returns the serialized object
  35146. */
  35147. serialize(parent: any): any;
  35148. }
  35149. }
  35150. declare module BABYLON {
  35151. /**
  35152. * Options allowed during the creation of a sound track.
  35153. */
  35154. export interface ISoundTrackOptions {
  35155. /**
  35156. * The volume the sound track should take during creation
  35157. */
  35158. volume?: number;
  35159. /**
  35160. * Define if the sound track is the main sound track of the scene
  35161. */
  35162. mainTrack?: boolean;
  35163. }
  35164. /**
  35165. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35166. * It will be also used in a future release to apply effects on a specific track.
  35167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35168. */
  35169. export class SoundTrack {
  35170. /**
  35171. * The unique identifier of the sound track in the scene.
  35172. */
  35173. id: number;
  35174. /**
  35175. * The list of sounds included in the sound track.
  35176. */
  35177. soundCollection: Array<Sound>;
  35178. private _outputAudioNode;
  35179. private _scene;
  35180. private _isMainTrack;
  35181. private _connectedAnalyser;
  35182. private _options;
  35183. private _isInitialized;
  35184. /**
  35185. * Creates a new sound track.
  35186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35187. * @param scene Define the scene the sound track belongs to
  35188. * @param options
  35189. */
  35190. constructor(scene: Scene, options?: ISoundTrackOptions);
  35191. private _initializeSoundTrackAudioGraph;
  35192. /**
  35193. * Release the sound track and its associated resources
  35194. */
  35195. dispose(): void;
  35196. /**
  35197. * Adds a sound to this sound track
  35198. * @param sound define the cound to add
  35199. * @ignoreNaming
  35200. */
  35201. AddSound(sound: Sound): void;
  35202. /**
  35203. * Removes a sound to this sound track
  35204. * @param sound define the cound to remove
  35205. * @ignoreNaming
  35206. */
  35207. RemoveSound(sound: Sound): void;
  35208. /**
  35209. * Set a global volume for the full sound track.
  35210. * @param newVolume Define the new volume of the sound track
  35211. */
  35212. setVolume(newVolume: number): void;
  35213. /**
  35214. * Switch the panning model to HRTF:
  35215. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35217. */
  35218. switchPanningModelToHRTF(): void;
  35219. /**
  35220. * Switch the panning model to Equal Power:
  35221. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35223. */
  35224. switchPanningModelToEqualPower(): void;
  35225. /**
  35226. * Connect the sound track to an audio analyser allowing some amazing
  35227. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35229. * @param analyser The analyser to connect to the engine
  35230. */
  35231. connectToAnalyser(analyser: Analyser): void;
  35232. }
  35233. }
  35234. declare module BABYLON {
  35235. interface AbstractScene {
  35236. /**
  35237. * The list of sounds used in the scene.
  35238. */
  35239. sounds: Nullable<Array<Sound>>;
  35240. }
  35241. interface Scene {
  35242. /**
  35243. * @hidden
  35244. * Backing field
  35245. */
  35246. _mainSoundTrack: SoundTrack;
  35247. /**
  35248. * The main sound track played by the scene.
  35249. * It cotains your primary collection of sounds.
  35250. */
  35251. mainSoundTrack: SoundTrack;
  35252. /**
  35253. * The list of sound tracks added to the scene
  35254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35255. */
  35256. soundTracks: Nullable<Array<SoundTrack>>;
  35257. /**
  35258. * Gets a sound using a given name
  35259. * @param name defines the name to search for
  35260. * @return the found sound or null if not found at all.
  35261. */
  35262. getSoundByName(name: string): Nullable<Sound>;
  35263. /**
  35264. * Gets or sets if audio support is enabled
  35265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35266. */
  35267. audioEnabled: boolean;
  35268. /**
  35269. * Gets or sets if audio will be output to headphones
  35270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35271. */
  35272. headphone: boolean;
  35273. /**
  35274. * Gets or sets custom audio listener position provider
  35275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35276. */
  35277. audioListenerPositionProvider: Nullable<() => Vector3>;
  35278. }
  35279. /**
  35280. * Defines the sound scene component responsible to manage any sounds
  35281. * in a given scene.
  35282. */
  35283. export class AudioSceneComponent implements ISceneSerializableComponent {
  35284. /**
  35285. * The component name helpfull to identify the component in the list of scene components.
  35286. */
  35287. readonly name: string;
  35288. /**
  35289. * The scene the component belongs to.
  35290. */
  35291. scene: Scene;
  35292. private _audioEnabled;
  35293. /**
  35294. * Gets whether audio is enabled or not.
  35295. * Please use related enable/disable method to switch state.
  35296. */
  35297. readonly audioEnabled: boolean;
  35298. private _headphone;
  35299. /**
  35300. * Gets whether audio is outputing to headphone or not.
  35301. * Please use the according Switch methods to change output.
  35302. */
  35303. readonly headphone: boolean;
  35304. private _audioListenerPositionProvider;
  35305. /**
  35306. * Gets the current audio listener position provider
  35307. */
  35308. /**
  35309. * Sets a custom listener position for all sounds in the scene
  35310. * By default, this is the position of the first active camera
  35311. */
  35312. audioListenerPositionProvider: Nullable<() => Vector3>;
  35313. /**
  35314. * Creates a new instance of the component for the given scene
  35315. * @param scene Defines the scene to register the component in
  35316. */
  35317. constructor(scene: Scene);
  35318. /**
  35319. * Registers the component in a given scene
  35320. */
  35321. register(): void;
  35322. /**
  35323. * Rebuilds the elements related to this component in case of
  35324. * context lost for instance.
  35325. */
  35326. rebuild(): void;
  35327. /**
  35328. * Serializes the component data to the specified json object
  35329. * @param serializationObject The object to serialize to
  35330. */
  35331. serialize(serializationObject: any): void;
  35332. /**
  35333. * Adds all the elements from the container to the scene
  35334. * @param container the container holding the elements
  35335. */
  35336. addFromContainer(container: AbstractScene): void;
  35337. /**
  35338. * Removes all the elements in the container from the scene
  35339. * @param container contains the elements to remove
  35340. * @param dispose if the removed element should be disposed (default: false)
  35341. */
  35342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35343. /**
  35344. * Disposes the component and the associated ressources.
  35345. */
  35346. dispose(): void;
  35347. /**
  35348. * Disables audio in the associated scene.
  35349. */
  35350. disableAudio(): void;
  35351. /**
  35352. * Enables audio in the associated scene.
  35353. */
  35354. enableAudio(): void;
  35355. /**
  35356. * Switch audio to headphone output.
  35357. */
  35358. switchAudioModeForHeadphones(): void;
  35359. /**
  35360. * Switch audio to normal speakers.
  35361. */
  35362. switchAudioModeForNormalSpeakers(): void;
  35363. private _afterRender;
  35364. }
  35365. }
  35366. declare module BABYLON {
  35367. /**
  35368. * Wraps one or more Sound objects and selects one with random weight for playback.
  35369. */
  35370. export class WeightedSound {
  35371. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35372. loop: boolean;
  35373. private _coneInnerAngle;
  35374. private _coneOuterAngle;
  35375. private _volume;
  35376. /** A Sound is currently playing. */
  35377. isPlaying: boolean;
  35378. /** A Sound is currently paused. */
  35379. isPaused: boolean;
  35380. private _sounds;
  35381. private _weights;
  35382. private _currentIndex?;
  35383. /**
  35384. * Creates a new WeightedSound from the list of sounds given.
  35385. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35386. * @param sounds Array of Sounds that will be selected from.
  35387. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35388. */
  35389. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35390. /**
  35391. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35392. */
  35393. /**
  35394. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35395. */
  35396. directionalConeInnerAngle: number;
  35397. /**
  35398. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35399. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35400. */
  35401. /**
  35402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35404. */
  35405. directionalConeOuterAngle: number;
  35406. /**
  35407. * Playback volume.
  35408. */
  35409. /**
  35410. * Playback volume.
  35411. */
  35412. volume: number;
  35413. private _onended;
  35414. /**
  35415. * Suspend playback
  35416. */
  35417. pause(): void;
  35418. /**
  35419. * Stop playback
  35420. */
  35421. stop(): void;
  35422. /**
  35423. * Start playback.
  35424. * @param startOffset Position the clip head at a specific time in seconds.
  35425. */
  35426. play(startOffset?: number): void;
  35427. }
  35428. }
  35429. declare module BABYLON {
  35430. /**
  35431. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35433. */
  35434. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35435. /**
  35436. * Gets the name of the behavior.
  35437. */
  35438. readonly name: string;
  35439. /**
  35440. * The easing function used by animations
  35441. */
  35442. static EasingFunction: BackEase;
  35443. /**
  35444. * The easing mode used by animations
  35445. */
  35446. static EasingMode: number;
  35447. /**
  35448. * The duration of the animation, in milliseconds
  35449. */
  35450. transitionDuration: number;
  35451. /**
  35452. * Length of the distance animated by the transition when lower radius is reached
  35453. */
  35454. lowerRadiusTransitionRange: number;
  35455. /**
  35456. * Length of the distance animated by the transition when upper radius is reached
  35457. */
  35458. upperRadiusTransitionRange: number;
  35459. private _autoTransitionRange;
  35460. /**
  35461. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35462. */
  35463. /**
  35464. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35465. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35466. */
  35467. autoTransitionRange: boolean;
  35468. private _attachedCamera;
  35469. private _onAfterCheckInputsObserver;
  35470. private _onMeshTargetChangedObserver;
  35471. /**
  35472. * Initializes the behavior.
  35473. */
  35474. init(): void;
  35475. /**
  35476. * Attaches the behavior to its arc rotate camera.
  35477. * @param camera Defines the camera to attach the behavior to
  35478. */
  35479. attach(camera: ArcRotateCamera): void;
  35480. /**
  35481. * Detaches the behavior from its current arc rotate camera.
  35482. */
  35483. detach(): void;
  35484. private _radiusIsAnimating;
  35485. private _radiusBounceTransition;
  35486. private _animatables;
  35487. private _cachedWheelPrecision;
  35488. /**
  35489. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35490. * @param radiusLimit The limit to check against.
  35491. * @return Bool to indicate if at limit.
  35492. */
  35493. private _isRadiusAtLimit;
  35494. /**
  35495. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35496. * @param radiusDelta The delta by which to animate to. Can be negative.
  35497. */
  35498. private _applyBoundRadiusAnimation;
  35499. /**
  35500. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35501. */
  35502. protected _clearAnimationLocks(): void;
  35503. /**
  35504. * Stops and removes all animations that have been applied to the camera
  35505. */
  35506. stopAllAnimations(): void;
  35507. }
  35508. }
  35509. declare module BABYLON {
  35510. /**
  35511. * 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.
  35512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35513. */
  35514. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35515. /**
  35516. * Gets the name of the behavior.
  35517. */
  35518. readonly name: string;
  35519. private _mode;
  35520. private _radiusScale;
  35521. private _positionScale;
  35522. private _defaultElevation;
  35523. private _elevationReturnTime;
  35524. private _elevationReturnWaitTime;
  35525. private _zoomStopsAnimation;
  35526. private _framingTime;
  35527. /**
  35528. * The easing function used by animations
  35529. */
  35530. static EasingFunction: ExponentialEase;
  35531. /**
  35532. * The easing mode used by animations
  35533. */
  35534. static EasingMode: number;
  35535. /**
  35536. * Sets the current mode used by the behavior
  35537. */
  35538. /**
  35539. * Gets current mode used by the behavior.
  35540. */
  35541. mode: number;
  35542. /**
  35543. * Sets the scale applied to the radius (1 by default)
  35544. */
  35545. /**
  35546. * Gets the scale applied to the radius
  35547. */
  35548. radiusScale: number;
  35549. /**
  35550. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35551. */
  35552. /**
  35553. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35554. */
  35555. positionScale: number;
  35556. /**
  35557. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35558. * behaviour is triggered, in radians.
  35559. */
  35560. /**
  35561. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35562. * behaviour is triggered, in radians.
  35563. */
  35564. defaultElevation: number;
  35565. /**
  35566. * Sets the time (in milliseconds) taken to return to the default beta position.
  35567. * Negative value indicates camera should not return to default.
  35568. */
  35569. /**
  35570. * Gets the time (in milliseconds) taken to return to the default beta position.
  35571. * Negative value indicates camera should not return to default.
  35572. */
  35573. elevationReturnTime: number;
  35574. /**
  35575. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35576. */
  35577. /**
  35578. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35579. */
  35580. elevationReturnWaitTime: number;
  35581. /**
  35582. * Sets the flag that indicates if user zooming should stop animation.
  35583. */
  35584. /**
  35585. * Gets the flag that indicates if user zooming should stop animation.
  35586. */
  35587. zoomStopsAnimation: boolean;
  35588. /**
  35589. * Sets the transition time when framing the mesh, in milliseconds
  35590. */
  35591. /**
  35592. * Gets the transition time when framing the mesh, in milliseconds
  35593. */
  35594. framingTime: number;
  35595. /**
  35596. * Define if the behavior should automatically change the configured
  35597. * camera limits and sensibilities.
  35598. */
  35599. autoCorrectCameraLimitsAndSensibility: boolean;
  35600. private _onPrePointerObservableObserver;
  35601. private _onAfterCheckInputsObserver;
  35602. private _onMeshTargetChangedObserver;
  35603. private _attachedCamera;
  35604. private _isPointerDown;
  35605. private _lastInteractionTime;
  35606. /**
  35607. * Initializes the behavior.
  35608. */
  35609. init(): void;
  35610. /**
  35611. * Attaches the behavior to its arc rotate camera.
  35612. * @param camera Defines the camera to attach the behavior to
  35613. */
  35614. attach(camera: ArcRotateCamera): void;
  35615. /**
  35616. * Detaches the behavior from its current arc rotate camera.
  35617. */
  35618. detach(): void;
  35619. private _animatables;
  35620. private _betaIsAnimating;
  35621. private _betaTransition;
  35622. private _radiusTransition;
  35623. private _vectorTransition;
  35624. /**
  35625. * Targets the given mesh and updates zoom level accordingly.
  35626. * @param mesh The mesh to target.
  35627. * @param radius Optional. If a cached radius position already exists, overrides default.
  35628. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35631. */
  35632. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35633. /**
  35634. * Targets the given mesh with its children and updates zoom level accordingly.
  35635. * @param mesh The mesh to target.
  35636. * @param radius Optional. If a cached radius position already exists, overrides default.
  35637. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35638. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35639. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35640. */
  35641. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35642. /**
  35643. * Targets the given meshes with their children and updates zoom level accordingly.
  35644. * @param meshes The mesh to target.
  35645. * @param radius Optional. If a cached radius position already exists, overrides default.
  35646. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35649. */
  35650. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35651. /**
  35652. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35653. * @param minimumWorld Determines the smaller position of the bounding box extend
  35654. * @param maximumWorld Determines the bigger position of the bounding box extend
  35655. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35656. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35657. */
  35658. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35659. /**
  35660. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35661. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35662. * frustum width.
  35663. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35664. * to fully enclose the mesh in the viewing frustum.
  35665. */
  35666. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35667. /**
  35668. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35669. * is automatically returned to its default position (expected to be above ground plane).
  35670. */
  35671. private _maintainCameraAboveGround;
  35672. /**
  35673. * Returns the frustum slope based on the canvas ratio and camera FOV
  35674. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35675. */
  35676. private _getFrustumSlope;
  35677. /**
  35678. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35679. */
  35680. private _clearAnimationLocks;
  35681. /**
  35682. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35683. */
  35684. private _applyUserInteraction;
  35685. /**
  35686. * Stops and removes all animations that have been applied to the camera
  35687. */
  35688. stopAllAnimations(): void;
  35689. /**
  35690. * Gets a value indicating if the user is moving the camera
  35691. */
  35692. readonly isUserIsMoving: boolean;
  35693. /**
  35694. * The camera can move all the way towards the mesh.
  35695. */
  35696. static IgnoreBoundsSizeMode: number;
  35697. /**
  35698. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35699. */
  35700. static FitFrustumSidesMode: number;
  35701. }
  35702. }
  35703. declare module BABYLON {
  35704. /**
  35705. * Base class for Camera Pointer Inputs.
  35706. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35707. * for example usage.
  35708. */
  35709. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35710. /**
  35711. * Defines the camera the input is attached to.
  35712. */
  35713. abstract camera: Camera;
  35714. /**
  35715. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35716. */
  35717. protected _altKey: boolean;
  35718. protected _ctrlKey: boolean;
  35719. protected _metaKey: boolean;
  35720. protected _shiftKey: boolean;
  35721. /**
  35722. * Which mouse buttons were pressed at time of last mouse event.
  35723. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35724. */
  35725. protected _buttonsPressed: number;
  35726. /**
  35727. * Defines the buttons associated with the input to handle camera move.
  35728. */
  35729. buttons: number[];
  35730. /**
  35731. * Attach the input controls to a specific dom element to get the input from.
  35732. * @param element Defines the element the controls should be listened from
  35733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35734. */
  35735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35736. /**
  35737. * Detach the current controls from the specified dom element.
  35738. * @param element Defines the element to stop listening the inputs from
  35739. */
  35740. detachControl(element: Nullable<HTMLElement>): void;
  35741. /**
  35742. * Gets the class name of the current input.
  35743. * @returns the class name
  35744. */
  35745. getClassName(): string;
  35746. /**
  35747. * Get the friendly name associated with the input class.
  35748. * @returns the input friendly name
  35749. */
  35750. getSimpleName(): string;
  35751. /**
  35752. * Called on pointer POINTERDOUBLETAP event.
  35753. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35754. */
  35755. protected onDoubleTap(type: string): void;
  35756. /**
  35757. * Called on pointer POINTERMOVE event if only a single touch is active.
  35758. * Override this method to provide functionality.
  35759. */
  35760. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35761. /**
  35762. * Called on pointer POINTERMOVE event if multiple touches are active.
  35763. * Override this method to provide functionality.
  35764. */
  35765. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35766. /**
  35767. * Called on JS contextmenu event.
  35768. * Override this method to provide functionality.
  35769. */
  35770. protected onContextMenu(evt: PointerEvent): void;
  35771. /**
  35772. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35773. * press.
  35774. * Override this method to provide functionality.
  35775. */
  35776. protected onButtonDown(evt: PointerEvent): void;
  35777. /**
  35778. * Called each time a new POINTERUP event occurs. Ie, for each button
  35779. * release.
  35780. * Override this method to provide functionality.
  35781. */
  35782. protected onButtonUp(evt: PointerEvent): void;
  35783. /**
  35784. * Called when window becomes inactive.
  35785. * Override this method to provide functionality.
  35786. */
  35787. protected onLostFocus(): void;
  35788. private _pointerInput;
  35789. private _observer;
  35790. private _onLostFocus;
  35791. private pointA;
  35792. private pointB;
  35793. }
  35794. }
  35795. declare module BABYLON {
  35796. /**
  35797. * Manage the pointers inputs to control an arc rotate camera.
  35798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35799. */
  35800. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35801. /**
  35802. * Defines the camera the input is attached to.
  35803. */
  35804. camera: ArcRotateCamera;
  35805. /**
  35806. * Gets the class name of the current input.
  35807. * @returns the class name
  35808. */
  35809. getClassName(): string;
  35810. /**
  35811. * Defines the buttons associated with the input to handle camera move.
  35812. */
  35813. buttons: number[];
  35814. /**
  35815. * Defines the pointer angular sensibility along the X axis or how fast is
  35816. * the camera rotating.
  35817. */
  35818. angularSensibilityX: number;
  35819. /**
  35820. * Defines the pointer angular sensibility along the Y axis or how fast is
  35821. * the camera rotating.
  35822. */
  35823. angularSensibilityY: number;
  35824. /**
  35825. * Defines the pointer pinch precision or how fast is the camera zooming.
  35826. */
  35827. pinchPrecision: number;
  35828. /**
  35829. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35830. * from 0.
  35831. * It defines the percentage of current camera.radius to use as delta when
  35832. * pinch zoom is used.
  35833. */
  35834. pinchDeltaPercentage: number;
  35835. /**
  35836. * Defines the pointer panning sensibility or how fast is the camera moving.
  35837. */
  35838. panningSensibility: number;
  35839. /**
  35840. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35841. */
  35842. multiTouchPanning: boolean;
  35843. /**
  35844. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35845. * zoom (pinch) through multitouch.
  35846. */
  35847. multiTouchPanAndZoom: boolean;
  35848. /**
  35849. * Revers pinch action direction.
  35850. */
  35851. pinchInwards: boolean;
  35852. private _isPanClick;
  35853. private _twoFingerActivityCount;
  35854. private _isPinching;
  35855. /**
  35856. * Called on pointer POINTERMOVE event if only a single touch is active.
  35857. */
  35858. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35859. /**
  35860. * Called on pointer POINTERDOUBLETAP event.
  35861. */
  35862. protected onDoubleTap(type: string): void;
  35863. /**
  35864. * Called on pointer POINTERMOVE event if multiple touches are active.
  35865. */
  35866. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35867. /**
  35868. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35869. * press.
  35870. */
  35871. protected onButtonDown(evt: PointerEvent): void;
  35872. /**
  35873. * Called each time a new POINTERUP event occurs. Ie, for each button
  35874. * release.
  35875. */
  35876. protected onButtonUp(evt: PointerEvent): void;
  35877. /**
  35878. * Called when window becomes inactive.
  35879. */
  35880. protected onLostFocus(): void;
  35881. }
  35882. }
  35883. declare module BABYLON {
  35884. /**
  35885. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35887. */
  35888. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35889. /**
  35890. * Defines the camera the input is attached to.
  35891. */
  35892. camera: ArcRotateCamera;
  35893. /**
  35894. * Defines the list of key codes associated with the up action (increase alpha)
  35895. */
  35896. keysUp: number[];
  35897. /**
  35898. * Defines the list of key codes associated with the down action (decrease alpha)
  35899. */
  35900. keysDown: number[];
  35901. /**
  35902. * Defines the list of key codes associated with the left action (increase beta)
  35903. */
  35904. keysLeft: number[];
  35905. /**
  35906. * Defines the list of key codes associated with the right action (decrease beta)
  35907. */
  35908. keysRight: number[];
  35909. /**
  35910. * Defines the list of key codes associated with the reset action.
  35911. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35912. */
  35913. keysReset: number[];
  35914. /**
  35915. * Defines the panning sensibility of the inputs.
  35916. * (How fast is the camera paning)
  35917. */
  35918. panningSensibility: number;
  35919. /**
  35920. * Defines the zooming sensibility of the inputs.
  35921. * (How fast is the camera zooming)
  35922. */
  35923. zoomingSensibility: number;
  35924. /**
  35925. * Defines wether maintaining the alt key down switch the movement mode from
  35926. * orientation to zoom.
  35927. */
  35928. useAltToZoom: boolean;
  35929. /**
  35930. * Rotation speed of the camera
  35931. */
  35932. angularSpeed: number;
  35933. private _keys;
  35934. private _ctrlPressed;
  35935. private _altPressed;
  35936. private _onCanvasBlurObserver;
  35937. private _onKeyboardObserver;
  35938. private _engine;
  35939. private _scene;
  35940. /**
  35941. * Attach the input controls to a specific dom element to get the input from.
  35942. * @param element Defines the element the controls should be listened from
  35943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35944. */
  35945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35946. /**
  35947. * Detach the current controls from the specified dom element.
  35948. * @param element Defines the element to stop listening the inputs from
  35949. */
  35950. detachControl(element: Nullable<HTMLElement>): void;
  35951. /**
  35952. * Update the current camera state depending on the inputs that have been used this frame.
  35953. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35954. */
  35955. checkInputs(): void;
  35956. /**
  35957. * Gets the class name of the current intput.
  35958. * @returns the class name
  35959. */
  35960. getClassName(): string;
  35961. /**
  35962. * Get the friendly name associated with the input class.
  35963. * @returns the input friendly name
  35964. */
  35965. getSimpleName(): string;
  35966. }
  35967. }
  35968. declare module BABYLON {
  35969. /**
  35970. * Manage the mouse wheel inputs to control an arc rotate camera.
  35971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35972. */
  35973. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35974. /**
  35975. * Defines the camera the input is attached to.
  35976. */
  35977. camera: ArcRotateCamera;
  35978. /**
  35979. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35980. */
  35981. wheelPrecision: number;
  35982. /**
  35983. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35984. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35985. */
  35986. wheelDeltaPercentage: number;
  35987. private _wheel;
  35988. private _observer;
  35989. private computeDeltaFromMouseWheelLegacyEvent;
  35990. /**
  35991. * Attach the input controls to a specific dom element to get the input from.
  35992. * @param element Defines the element the controls should be listened from
  35993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35994. */
  35995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35996. /**
  35997. * Detach the current controls from the specified dom element.
  35998. * @param element Defines the element to stop listening the inputs from
  35999. */
  36000. detachControl(element: Nullable<HTMLElement>): void;
  36001. /**
  36002. * Gets the class name of the current intput.
  36003. * @returns the class name
  36004. */
  36005. getClassName(): string;
  36006. /**
  36007. * Get the friendly name associated with the input class.
  36008. * @returns the input friendly name
  36009. */
  36010. getSimpleName(): string;
  36011. }
  36012. }
  36013. declare module BABYLON {
  36014. /**
  36015. * Default Inputs manager for the ArcRotateCamera.
  36016. * It groups all the default supported inputs for ease of use.
  36017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36018. */
  36019. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36020. /**
  36021. * Instantiates a new ArcRotateCameraInputsManager.
  36022. * @param camera Defines the camera the inputs belong to
  36023. */
  36024. constructor(camera: ArcRotateCamera);
  36025. /**
  36026. * Add mouse wheel input support to the input manager.
  36027. * @returns the current input manager
  36028. */
  36029. addMouseWheel(): ArcRotateCameraInputsManager;
  36030. /**
  36031. * Add pointers input support to the input manager.
  36032. * @returns the current input manager
  36033. */
  36034. addPointers(): ArcRotateCameraInputsManager;
  36035. /**
  36036. * Add keyboard input support to the input manager.
  36037. * @returns the current input manager
  36038. */
  36039. addKeyboard(): ArcRotateCameraInputsManager;
  36040. }
  36041. }
  36042. declare module BABYLON {
  36043. /**
  36044. * This represents an orbital type of camera.
  36045. *
  36046. * 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.
  36047. * 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.
  36048. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36049. */
  36050. export class ArcRotateCamera extends TargetCamera {
  36051. /**
  36052. * Defines the rotation angle of the camera along the longitudinal axis.
  36053. */
  36054. alpha: number;
  36055. /**
  36056. * Defines the rotation angle of the camera along the latitudinal axis.
  36057. */
  36058. beta: number;
  36059. /**
  36060. * Defines the radius of the camera from it s target point.
  36061. */
  36062. radius: number;
  36063. protected _target: Vector3;
  36064. protected _targetHost: Nullable<AbstractMesh>;
  36065. /**
  36066. * Defines the target point of the camera.
  36067. * The camera looks towards it form the radius distance.
  36068. */
  36069. target: Vector3;
  36070. /**
  36071. * Define the current local position of the camera in the scene
  36072. */
  36073. position: Vector3;
  36074. protected _upVector: Vector3;
  36075. protected _upToYMatrix: Matrix;
  36076. protected _YToUpMatrix: Matrix;
  36077. /**
  36078. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36079. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36080. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36081. */
  36082. upVector: Vector3;
  36083. /**
  36084. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36085. */
  36086. setMatUp(): void;
  36087. /**
  36088. * Current inertia value on the longitudinal axis.
  36089. * The bigger this number the longer it will take for the camera to stop.
  36090. */
  36091. inertialAlphaOffset: number;
  36092. /**
  36093. * Current inertia value on the latitudinal axis.
  36094. * The bigger this number the longer it will take for the camera to stop.
  36095. */
  36096. inertialBetaOffset: number;
  36097. /**
  36098. * Current inertia value on the radius axis.
  36099. * The bigger this number the longer it will take for the camera to stop.
  36100. */
  36101. inertialRadiusOffset: number;
  36102. /**
  36103. * Minimum allowed angle on the longitudinal axis.
  36104. * This can help limiting how the Camera is able to move in the scene.
  36105. */
  36106. lowerAlphaLimit: Nullable<number>;
  36107. /**
  36108. * Maximum allowed angle on the longitudinal axis.
  36109. * This can help limiting how the Camera is able to move in the scene.
  36110. */
  36111. upperAlphaLimit: Nullable<number>;
  36112. /**
  36113. * Minimum allowed angle on the latitudinal axis.
  36114. * This can help limiting how the Camera is able to move in the scene.
  36115. */
  36116. lowerBetaLimit: number;
  36117. /**
  36118. * Maximum allowed angle on the latitudinal axis.
  36119. * This can help limiting how the Camera is able to move in the scene.
  36120. */
  36121. upperBetaLimit: number;
  36122. /**
  36123. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36124. * This can help limiting how the Camera is able to move in the scene.
  36125. */
  36126. lowerRadiusLimit: Nullable<number>;
  36127. /**
  36128. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36129. * This can help limiting how the Camera is able to move in the scene.
  36130. */
  36131. upperRadiusLimit: Nullable<number>;
  36132. /**
  36133. * Defines the current inertia value used during panning of the camera along the X axis.
  36134. */
  36135. inertialPanningX: number;
  36136. /**
  36137. * Defines the current inertia value used during panning of the camera along the Y axis.
  36138. */
  36139. inertialPanningY: number;
  36140. /**
  36141. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36142. * Basically if your fingers moves away from more than this distance you will be considered
  36143. * in pinch mode.
  36144. */
  36145. pinchToPanMaxDistance: number;
  36146. /**
  36147. * Defines the maximum distance the camera can pan.
  36148. * This could help keeping the cammera always in your scene.
  36149. */
  36150. panningDistanceLimit: Nullable<number>;
  36151. /**
  36152. * Defines the target of the camera before paning.
  36153. */
  36154. panningOriginTarget: Vector3;
  36155. /**
  36156. * Defines the value of the inertia used during panning.
  36157. * 0 would mean stop inertia and one would mean no decelleration at all.
  36158. */
  36159. panningInertia: number;
  36160. /**
  36161. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36162. */
  36163. angularSensibilityX: number;
  36164. /**
  36165. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36166. */
  36167. angularSensibilityY: number;
  36168. /**
  36169. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36170. */
  36171. pinchPrecision: number;
  36172. /**
  36173. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36174. * It will be used instead of pinchDeltaPrecision if different from 0.
  36175. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36176. */
  36177. pinchDeltaPercentage: number;
  36178. /**
  36179. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36180. */
  36181. panningSensibility: number;
  36182. /**
  36183. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36184. */
  36185. keysUp: number[];
  36186. /**
  36187. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36188. */
  36189. keysDown: number[];
  36190. /**
  36191. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36192. */
  36193. keysLeft: number[];
  36194. /**
  36195. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36196. */
  36197. keysRight: number[];
  36198. /**
  36199. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36200. */
  36201. wheelPrecision: number;
  36202. /**
  36203. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36204. * It will be used instead of pinchDeltaPrecision if different from 0.
  36205. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36206. */
  36207. wheelDeltaPercentage: number;
  36208. /**
  36209. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36210. */
  36211. zoomOnFactor: number;
  36212. /**
  36213. * Defines a screen offset for the camera position.
  36214. */
  36215. targetScreenOffset: Vector2;
  36216. /**
  36217. * Allows the camera to be completely reversed.
  36218. * If false the camera can not arrive upside down.
  36219. */
  36220. allowUpsideDown: boolean;
  36221. /**
  36222. * Define if double tap/click is used to restore the previously saved state of the camera.
  36223. */
  36224. useInputToRestoreState: boolean;
  36225. /** @hidden */
  36226. _viewMatrix: Matrix;
  36227. /** @hidden */
  36228. _useCtrlForPanning: boolean;
  36229. /** @hidden */
  36230. _panningMouseButton: number;
  36231. /**
  36232. * Defines the input associated to the camera.
  36233. */
  36234. inputs: ArcRotateCameraInputsManager;
  36235. /** @hidden */
  36236. _reset: () => void;
  36237. /**
  36238. * Defines the allowed panning axis.
  36239. */
  36240. panningAxis: Vector3;
  36241. protected _localDirection: Vector3;
  36242. protected _transformedDirection: Vector3;
  36243. private _bouncingBehavior;
  36244. /**
  36245. * Gets the bouncing behavior of the camera if it has been enabled.
  36246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36247. */
  36248. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36249. /**
  36250. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36252. */
  36253. useBouncingBehavior: boolean;
  36254. private _framingBehavior;
  36255. /**
  36256. * Gets the framing behavior of the camera if it has been enabled.
  36257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36258. */
  36259. readonly framingBehavior: Nullable<FramingBehavior>;
  36260. /**
  36261. * Defines if the framing behavior of the camera is enabled on the camera.
  36262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36263. */
  36264. useFramingBehavior: boolean;
  36265. private _autoRotationBehavior;
  36266. /**
  36267. * Gets the auto rotation behavior of the camera if it has been enabled.
  36268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36269. */
  36270. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36271. /**
  36272. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36274. */
  36275. useAutoRotationBehavior: boolean;
  36276. /**
  36277. * Observable triggered when the mesh target has been changed on the camera.
  36278. */
  36279. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36280. /**
  36281. * Event raised when the camera is colliding with a mesh.
  36282. */
  36283. onCollide: (collidedMesh: AbstractMesh) => void;
  36284. /**
  36285. * Defines whether the camera should check collision with the objects oh the scene.
  36286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36287. */
  36288. checkCollisions: boolean;
  36289. /**
  36290. * Defines the collision radius of the camera.
  36291. * This simulates a sphere around the camera.
  36292. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36293. */
  36294. collisionRadius: Vector3;
  36295. protected _collider: Collider;
  36296. protected _previousPosition: Vector3;
  36297. protected _collisionVelocity: Vector3;
  36298. protected _newPosition: Vector3;
  36299. protected _previousAlpha: number;
  36300. protected _previousBeta: number;
  36301. protected _previousRadius: number;
  36302. protected _collisionTriggered: boolean;
  36303. protected _targetBoundingCenter: Nullable<Vector3>;
  36304. private _computationVector;
  36305. /**
  36306. * Instantiates a new ArcRotateCamera in a given scene
  36307. * @param name Defines the name of the camera
  36308. * @param alpha Defines the camera rotation along the logitudinal axis
  36309. * @param beta Defines the camera rotation along the latitudinal axis
  36310. * @param radius Defines the camera distance from its target
  36311. * @param target Defines the camera target
  36312. * @param scene Defines the scene the camera belongs to
  36313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36314. */
  36315. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36316. /** @hidden */
  36317. _initCache(): void;
  36318. /** @hidden */
  36319. _updateCache(ignoreParentClass?: boolean): void;
  36320. protected _getTargetPosition(): Vector3;
  36321. private _storedAlpha;
  36322. private _storedBeta;
  36323. private _storedRadius;
  36324. private _storedTarget;
  36325. private _storedTargetScreenOffset;
  36326. /**
  36327. * Stores the current state of the camera (alpha, beta, radius and target)
  36328. * @returns the camera itself
  36329. */
  36330. storeState(): Camera;
  36331. /**
  36332. * @hidden
  36333. * Restored camera state. You must call storeState() first
  36334. */
  36335. _restoreStateValues(): boolean;
  36336. /** @hidden */
  36337. _isSynchronizedViewMatrix(): boolean;
  36338. /**
  36339. * Attached controls to the current camera.
  36340. * @param element Defines the element the controls should be listened from
  36341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36342. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36343. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36344. */
  36345. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36346. /**
  36347. * Detach the current controls from the camera.
  36348. * The camera will stop reacting to inputs.
  36349. * @param element Defines the element to stop listening the inputs from
  36350. */
  36351. detachControl(element: HTMLElement): void;
  36352. /** @hidden */
  36353. _checkInputs(): void;
  36354. protected _checkLimits(): void;
  36355. /**
  36356. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36357. */
  36358. rebuildAnglesAndRadius(): void;
  36359. /**
  36360. * Use a position to define the current camera related information like aplha, beta and radius
  36361. * @param position Defines the position to set the camera at
  36362. */
  36363. setPosition(position: Vector3): void;
  36364. /**
  36365. * Defines the target the camera should look at.
  36366. * This will automatically adapt alpha beta and radius to fit within the new target.
  36367. * @param target Defines the new target as a Vector or a mesh
  36368. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36369. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36370. */
  36371. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36372. /** @hidden */
  36373. _getViewMatrix(): Matrix;
  36374. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36375. /**
  36376. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36377. * @param meshes Defines the mesh to zoom on
  36378. * @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)
  36379. */
  36380. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36381. /**
  36382. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36383. * The target will be changed but the radius
  36384. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36385. * @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)
  36386. */
  36387. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36388. min: Vector3;
  36389. max: Vector3;
  36390. distance: number;
  36391. }, doNotUpdateMaxZ?: boolean): void;
  36392. /**
  36393. * @override
  36394. * Override Camera.createRigCamera
  36395. */
  36396. createRigCamera(name: string, cameraIndex: number): Camera;
  36397. /**
  36398. * @hidden
  36399. * @override
  36400. * Override Camera._updateRigCameras
  36401. */
  36402. _updateRigCameras(): void;
  36403. /**
  36404. * Destroy the camera and release the current resources hold by it.
  36405. */
  36406. dispose(): void;
  36407. /**
  36408. * Gets the current object class name.
  36409. * @return the class name
  36410. */
  36411. getClassName(): string;
  36412. }
  36413. }
  36414. declare module BABYLON {
  36415. /**
  36416. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36418. */
  36419. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36420. /**
  36421. * Gets the name of the behavior.
  36422. */
  36423. readonly name: string;
  36424. private _zoomStopsAnimation;
  36425. private _idleRotationSpeed;
  36426. private _idleRotationWaitTime;
  36427. private _idleRotationSpinupTime;
  36428. /**
  36429. * Sets the flag that indicates if user zooming should stop animation.
  36430. */
  36431. /**
  36432. * Gets the flag that indicates if user zooming should stop animation.
  36433. */
  36434. zoomStopsAnimation: boolean;
  36435. /**
  36436. * Sets the default speed at which the camera rotates around the model.
  36437. */
  36438. /**
  36439. * Gets the default speed at which the camera rotates around the model.
  36440. */
  36441. idleRotationSpeed: number;
  36442. /**
  36443. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36444. */
  36445. /**
  36446. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36447. */
  36448. idleRotationWaitTime: number;
  36449. /**
  36450. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36451. */
  36452. /**
  36453. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36454. */
  36455. idleRotationSpinupTime: number;
  36456. /**
  36457. * Gets a value indicating if the camera is currently rotating because of this behavior
  36458. */
  36459. readonly rotationInProgress: boolean;
  36460. private _onPrePointerObservableObserver;
  36461. private _onAfterCheckInputsObserver;
  36462. private _attachedCamera;
  36463. private _isPointerDown;
  36464. private _lastFrameTime;
  36465. private _lastInteractionTime;
  36466. private _cameraRotationSpeed;
  36467. /**
  36468. * Initializes the behavior.
  36469. */
  36470. init(): void;
  36471. /**
  36472. * Attaches the behavior to its arc rotate camera.
  36473. * @param camera Defines the camera to attach the behavior to
  36474. */
  36475. attach(camera: ArcRotateCamera): void;
  36476. /**
  36477. * Detaches the behavior from its current arc rotate camera.
  36478. */
  36479. detach(): void;
  36480. /**
  36481. * Returns true if user is scrolling.
  36482. * @return true if user is scrolling.
  36483. */
  36484. private _userIsZooming;
  36485. private _lastFrameRadius;
  36486. private _shouldAnimationStopForInteraction;
  36487. /**
  36488. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36489. */
  36490. private _applyUserInteraction;
  36491. private _userIsMoving;
  36492. }
  36493. }
  36494. declare module BABYLON {
  36495. /**
  36496. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36497. */
  36498. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36499. private ui;
  36500. /**
  36501. * The name of the behavior
  36502. */
  36503. name: string;
  36504. /**
  36505. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36506. */
  36507. distanceAwayFromFace: number;
  36508. /**
  36509. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36510. */
  36511. distanceAwayFromBottomOfFace: number;
  36512. private _faceVectors;
  36513. private _target;
  36514. private _scene;
  36515. private _onRenderObserver;
  36516. private _tmpMatrix;
  36517. private _tmpVector;
  36518. /**
  36519. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36520. * @param ui The transform node that should be attched to the mesh
  36521. */
  36522. constructor(ui: TransformNode);
  36523. /**
  36524. * Initializes the behavior
  36525. */
  36526. init(): void;
  36527. private _closestFace;
  36528. private _zeroVector;
  36529. private _lookAtTmpMatrix;
  36530. private _lookAtToRef;
  36531. /**
  36532. * Attaches the AttachToBoxBehavior to the passed in mesh
  36533. * @param target The mesh that the specified node will be attached to
  36534. */
  36535. attach(target: Mesh): void;
  36536. /**
  36537. * Detaches the behavior from the mesh
  36538. */
  36539. detach(): void;
  36540. }
  36541. }
  36542. declare module BABYLON {
  36543. /**
  36544. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36545. */
  36546. export class FadeInOutBehavior implements Behavior<Mesh> {
  36547. /**
  36548. * Time in milliseconds to delay before fading in (Default: 0)
  36549. */
  36550. delay: number;
  36551. /**
  36552. * Time in milliseconds for the mesh to fade in (Default: 300)
  36553. */
  36554. fadeInTime: number;
  36555. private _millisecondsPerFrame;
  36556. private _hovered;
  36557. private _hoverValue;
  36558. private _ownerNode;
  36559. /**
  36560. * Instatiates the FadeInOutBehavior
  36561. */
  36562. constructor();
  36563. /**
  36564. * The name of the behavior
  36565. */
  36566. readonly name: string;
  36567. /**
  36568. * Initializes the behavior
  36569. */
  36570. init(): void;
  36571. /**
  36572. * Attaches the fade behavior on the passed in mesh
  36573. * @param ownerNode The mesh that will be faded in/out once attached
  36574. */
  36575. attach(ownerNode: Mesh): void;
  36576. /**
  36577. * Detaches the behavior from the mesh
  36578. */
  36579. detach(): void;
  36580. /**
  36581. * Triggers the mesh to begin fading in or out
  36582. * @param value if the object should fade in or out (true to fade in)
  36583. */
  36584. fadeIn(value: boolean): void;
  36585. private _update;
  36586. private _setAllVisibility;
  36587. }
  36588. }
  36589. declare module BABYLON {
  36590. /**
  36591. * Class containing a set of static utilities functions for managing Pivots
  36592. * @hidden
  36593. */
  36594. export class PivotTools {
  36595. private static _PivotCached;
  36596. private static _OldPivotPoint;
  36597. private static _PivotTranslation;
  36598. private static _PivotTmpVector;
  36599. /** @hidden */
  36600. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36601. /** @hidden */
  36602. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36603. }
  36604. }
  36605. declare module BABYLON {
  36606. /**
  36607. * Class containing static functions to help procedurally build meshes
  36608. */
  36609. export class PlaneBuilder {
  36610. /**
  36611. * Creates a plane mesh
  36612. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36613. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36614. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36616. * * 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
  36617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36618. * @param name defines the name of the mesh
  36619. * @param options defines the options used to create the mesh
  36620. * @param scene defines the hosting scene
  36621. * @returns the plane mesh
  36622. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36623. */
  36624. static CreatePlane(name: string, options: {
  36625. size?: number;
  36626. width?: number;
  36627. height?: number;
  36628. sideOrientation?: number;
  36629. frontUVs?: Vector4;
  36630. backUVs?: Vector4;
  36631. updatable?: boolean;
  36632. sourcePlane?: Plane;
  36633. }, scene?: Nullable<Scene>): Mesh;
  36634. }
  36635. }
  36636. declare module BABYLON {
  36637. /**
  36638. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36639. */
  36640. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36641. private static _AnyMouseID;
  36642. /**
  36643. * Abstract mesh the behavior is set on
  36644. */
  36645. attachedNode: AbstractMesh;
  36646. private _dragPlane;
  36647. private _scene;
  36648. private _pointerObserver;
  36649. private _beforeRenderObserver;
  36650. private static _planeScene;
  36651. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36652. /**
  36653. * 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)
  36654. */
  36655. maxDragAngle: number;
  36656. /**
  36657. * @hidden
  36658. */
  36659. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36660. /**
  36661. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36662. */
  36663. currentDraggingPointerID: number;
  36664. /**
  36665. * The last position where the pointer hit the drag plane in world space
  36666. */
  36667. lastDragPosition: Vector3;
  36668. /**
  36669. * If the behavior is currently in a dragging state
  36670. */
  36671. dragging: boolean;
  36672. /**
  36673. * 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)
  36674. */
  36675. dragDeltaRatio: number;
  36676. /**
  36677. * If the drag plane orientation should be updated during the dragging (Default: true)
  36678. */
  36679. updateDragPlane: boolean;
  36680. private _debugMode;
  36681. private _moving;
  36682. /**
  36683. * Fires each time the attached mesh is dragged with the pointer
  36684. * * delta between last drag position and current drag position in world space
  36685. * * dragDistance along the drag axis
  36686. * * dragPlaneNormal normal of the current drag plane used during the drag
  36687. * * dragPlanePoint in world space where the drag intersects the drag plane
  36688. */
  36689. onDragObservable: Observable<{
  36690. delta: Vector3;
  36691. dragPlanePoint: Vector3;
  36692. dragPlaneNormal: Vector3;
  36693. dragDistance: number;
  36694. pointerId: number;
  36695. }>;
  36696. /**
  36697. * Fires each time a drag begins (eg. mouse down on mesh)
  36698. */
  36699. onDragStartObservable: Observable<{
  36700. dragPlanePoint: Vector3;
  36701. pointerId: number;
  36702. }>;
  36703. /**
  36704. * Fires each time a drag ends (eg. mouse release after drag)
  36705. */
  36706. onDragEndObservable: Observable<{
  36707. dragPlanePoint: Vector3;
  36708. pointerId: number;
  36709. }>;
  36710. /**
  36711. * If the attached mesh should be moved when dragged
  36712. */
  36713. moveAttached: boolean;
  36714. /**
  36715. * If the drag behavior will react to drag events (Default: true)
  36716. */
  36717. enabled: boolean;
  36718. /**
  36719. * If pointer events should start and release the drag (Default: true)
  36720. */
  36721. startAndReleaseDragOnPointerEvents: boolean;
  36722. /**
  36723. * If camera controls should be detached during the drag
  36724. */
  36725. detachCameraControls: boolean;
  36726. /**
  36727. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36728. */
  36729. useObjectOrienationForDragging: boolean;
  36730. private _options;
  36731. /**
  36732. * Creates a pointer drag behavior that can be attached to a mesh
  36733. * @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)
  36734. */
  36735. constructor(options?: {
  36736. dragAxis?: Vector3;
  36737. dragPlaneNormal?: Vector3;
  36738. });
  36739. /**
  36740. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36741. */
  36742. validateDrag: (targetPosition: Vector3) => boolean;
  36743. /**
  36744. * The name of the behavior
  36745. */
  36746. readonly name: string;
  36747. /**
  36748. * Initializes the behavior
  36749. */
  36750. init(): void;
  36751. private _tmpVector;
  36752. private _alternatePickedPoint;
  36753. private _worldDragAxis;
  36754. private _targetPosition;
  36755. private _attachedElement;
  36756. /**
  36757. * Attaches the drag behavior the passed in mesh
  36758. * @param ownerNode The mesh that will be dragged around once attached
  36759. * @param predicate Predicate to use for pick filtering
  36760. */
  36761. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36762. /**
  36763. * Force relase the drag action by code.
  36764. */
  36765. releaseDrag(): void;
  36766. private _startDragRay;
  36767. private _lastPointerRay;
  36768. /**
  36769. * Simulates the start of a pointer drag event on the behavior
  36770. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36771. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36772. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36773. */
  36774. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36775. private _startDrag;
  36776. private _dragDelta;
  36777. private _moveDrag;
  36778. private _pickWithRayOnDragPlane;
  36779. private _pointA;
  36780. private _pointB;
  36781. private _pointC;
  36782. private _lineA;
  36783. private _lineB;
  36784. private _localAxis;
  36785. private _lookAt;
  36786. private _updateDragPlanePosition;
  36787. /**
  36788. * Detaches the behavior from the mesh
  36789. */
  36790. detach(): void;
  36791. }
  36792. }
  36793. declare module BABYLON {
  36794. /**
  36795. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36796. */
  36797. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36798. private _dragBehaviorA;
  36799. private _dragBehaviorB;
  36800. private _startDistance;
  36801. private _initialScale;
  36802. private _targetScale;
  36803. private _ownerNode;
  36804. private _sceneRenderObserver;
  36805. /**
  36806. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36807. */
  36808. constructor();
  36809. /**
  36810. * The name of the behavior
  36811. */
  36812. readonly name: string;
  36813. /**
  36814. * Initializes the behavior
  36815. */
  36816. init(): void;
  36817. private _getCurrentDistance;
  36818. /**
  36819. * Attaches the scale behavior the passed in mesh
  36820. * @param ownerNode The mesh that will be scaled around once attached
  36821. */
  36822. attach(ownerNode: Mesh): void;
  36823. /**
  36824. * Detaches the behavior from the mesh
  36825. */
  36826. detach(): void;
  36827. }
  36828. }
  36829. declare module BABYLON {
  36830. /**
  36831. * 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
  36832. */
  36833. export class SixDofDragBehavior implements Behavior<Mesh> {
  36834. private static _virtualScene;
  36835. private _ownerNode;
  36836. private _sceneRenderObserver;
  36837. private _scene;
  36838. private _targetPosition;
  36839. private _virtualOriginMesh;
  36840. private _virtualDragMesh;
  36841. private _pointerObserver;
  36842. private _moving;
  36843. private _startingOrientation;
  36844. /**
  36845. * 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)
  36846. */
  36847. private zDragFactor;
  36848. /**
  36849. * If the object should rotate to face the drag origin
  36850. */
  36851. rotateDraggedObject: boolean;
  36852. /**
  36853. * If the behavior is currently in a dragging state
  36854. */
  36855. dragging: boolean;
  36856. /**
  36857. * 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)
  36858. */
  36859. dragDeltaRatio: number;
  36860. /**
  36861. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36862. */
  36863. currentDraggingPointerID: number;
  36864. /**
  36865. * If camera controls should be detached during the drag
  36866. */
  36867. detachCameraControls: boolean;
  36868. /**
  36869. * Fires each time a drag starts
  36870. */
  36871. onDragStartObservable: Observable<{}>;
  36872. /**
  36873. * Fires each time a drag ends (eg. mouse release after drag)
  36874. */
  36875. onDragEndObservable: Observable<{}>;
  36876. /**
  36877. * 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
  36878. */
  36879. constructor();
  36880. /**
  36881. * The name of the behavior
  36882. */
  36883. readonly name: string;
  36884. /**
  36885. * Initializes the behavior
  36886. */
  36887. init(): void;
  36888. /**
  36889. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36890. */
  36891. private readonly _pointerCamera;
  36892. /**
  36893. * Attaches the scale behavior the passed in mesh
  36894. * @param ownerNode The mesh that will be scaled around once attached
  36895. */
  36896. attach(ownerNode: Mesh): void;
  36897. /**
  36898. * Detaches the behavior from the mesh
  36899. */
  36900. detach(): void;
  36901. }
  36902. }
  36903. declare module BABYLON {
  36904. /**
  36905. * Class used to apply inverse kinematics to bones
  36906. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36907. */
  36908. export class BoneIKController {
  36909. private static _tmpVecs;
  36910. private static _tmpQuat;
  36911. private static _tmpMats;
  36912. /**
  36913. * Gets or sets the target mesh
  36914. */
  36915. targetMesh: AbstractMesh;
  36916. /** Gets or sets the mesh used as pole */
  36917. poleTargetMesh: AbstractMesh;
  36918. /**
  36919. * Gets or sets the bone used as pole
  36920. */
  36921. poleTargetBone: Nullable<Bone>;
  36922. /**
  36923. * Gets or sets the target position
  36924. */
  36925. targetPosition: Vector3;
  36926. /**
  36927. * Gets or sets the pole target position
  36928. */
  36929. poleTargetPosition: Vector3;
  36930. /**
  36931. * Gets or sets the pole target local offset
  36932. */
  36933. poleTargetLocalOffset: Vector3;
  36934. /**
  36935. * Gets or sets the pole angle
  36936. */
  36937. poleAngle: number;
  36938. /**
  36939. * Gets or sets the mesh associated with the controller
  36940. */
  36941. mesh: AbstractMesh;
  36942. /**
  36943. * 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)
  36944. */
  36945. slerpAmount: number;
  36946. private _bone1Quat;
  36947. private _bone1Mat;
  36948. private _bone2Ang;
  36949. private _bone1;
  36950. private _bone2;
  36951. private _bone1Length;
  36952. private _bone2Length;
  36953. private _maxAngle;
  36954. private _maxReach;
  36955. private _rightHandedSystem;
  36956. private _bendAxis;
  36957. private _slerping;
  36958. private _adjustRoll;
  36959. /**
  36960. * Gets or sets maximum allowed angle
  36961. */
  36962. maxAngle: number;
  36963. /**
  36964. * Creates a new BoneIKController
  36965. * @param mesh defines the mesh to control
  36966. * @param bone defines the bone to control
  36967. * @param options defines options to set up the controller
  36968. */
  36969. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36970. targetMesh?: AbstractMesh;
  36971. poleTargetMesh?: AbstractMesh;
  36972. poleTargetBone?: Bone;
  36973. poleTargetLocalOffset?: Vector3;
  36974. poleAngle?: number;
  36975. bendAxis?: Vector3;
  36976. maxAngle?: number;
  36977. slerpAmount?: number;
  36978. });
  36979. private _setMaxAngle;
  36980. /**
  36981. * Force the controller to update the bones
  36982. */
  36983. update(): void;
  36984. }
  36985. }
  36986. declare module BABYLON {
  36987. /**
  36988. * Class used to make a bone look toward a point in space
  36989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36990. */
  36991. export class BoneLookController {
  36992. private static _tmpVecs;
  36993. private static _tmpQuat;
  36994. private static _tmpMats;
  36995. /**
  36996. * The target Vector3 that the bone will look at
  36997. */
  36998. target: Vector3;
  36999. /**
  37000. * The mesh that the bone is attached to
  37001. */
  37002. mesh: AbstractMesh;
  37003. /**
  37004. * The bone that will be looking to the target
  37005. */
  37006. bone: Bone;
  37007. /**
  37008. * The up axis of the coordinate system that is used when the bone is rotated
  37009. */
  37010. upAxis: Vector3;
  37011. /**
  37012. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37013. */
  37014. upAxisSpace: Space;
  37015. /**
  37016. * Used to make an adjustment to the yaw of the bone
  37017. */
  37018. adjustYaw: number;
  37019. /**
  37020. * Used to make an adjustment to the pitch of the bone
  37021. */
  37022. adjustPitch: number;
  37023. /**
  37024. * Used to make an adjustment to the roll of the bone
  37025. */
  37026. adjustRoll: number;
  37027. /**
  37028. * 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)
  37029. */
  37030. slerpAmount: number;
  37031. private _minYaw;
  37032. private _maxYaw;
  37033. private _minPitch;
  37034. private _maxPitch;
  37035. private _minYawSin;
  37036. private _minYawCos;
  37037. private _maxYawSin;
  37038. private _maxYawCos;
  37039. private _midYawConstraint;
  37040. private _minPitchTan;
  37041. private _maxPitchTan;
  37042. private _boneQuat;
  37043. private _slerping;
  37044. private _transformYawPitch;
  37045. private _transformYawPitchInv;
  37046. private _firstFrameSkipped;
  37047. private _yawRange;
  37048. private _fowardAxis;
  37049. /**
  37050. * Gets or sets the minimum yaw angle that the bone can look to
  37051. */
  37052. minYaw: number;
  37053. /**
  37054. * Gets or sets the maximum yaw angle that the bone can look to
  37055. */
  37056. maxYaw: number;
  37057. /**
  37058. * Gets or sets the minimum pitch angle that the bone can look to
  37059. */
  37060. minPitch: number;
  37061. /**
  37062. * Gets or sets the maximum pitch angle that the bone can look to
  37063. */
  37064. maxPitch: number;
  37065. /**
  37066. * Create a BoneLookController
  37067. * @param mesh the mesh that the bone belongs to
  37068. * @param bone the bone that will be looking to the target
  37069. * @param target the target Vector3 to look at
  37070. * @param options optional settings:
  37071. * * maxYaw: the maximum angle the bone will yaw to
  37072. * * minYaw: the minimum angle the bone will yaw to
  37073. * * maxPitch: the maximum angle the bone will pitch to
  37074. * * minPitch: the minimum angle the bone will yaw to
  37075. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37076. * * upAxis: the up axis of the coordinate system
  37077. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37078. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37079. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37080. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37081. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37082. * * adjustRoll: used to make an adjustment to the roll of the bone
  37083. **/
  37084. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37085. maxYaw?: number;
  37086. minYaw?: number;
  37087. maxPitch?: number;
  37088. minPitch?: number;
  37089. slerpAmount?: number;
  37090. upAxis?: Vector3;
  37091. upAxisSpace?: Space;
  37092. yawAxis?: Vector3;
  37093. pitchAxis?: Vector3;
  37094. adjustYaw?: number;
  37095. adjustPitch?: number;
  37096. adjustRoll?: number;
  37097. });
  37098. /**
  37099. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37100. */
  37101. update(): void;
  37102. private _getAngleDiff;
  37103. private _getAngleBetween;
  37104. private _isAngleBetween;
  37105. }
  37106. }
  37107. declare module BABYLON {
  37108. /**
  37109. * Manage the gamepad inputs to control an arc rotate camera.
  37110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37111. */
  37112. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37113. /**
  37114. * Defines the camera the input is attached to.
  37115. */
  37116. camera: ArcRotateCamera;
  37117. /**
  37118. * Defines the gamepad the input is gathering event from.
  37119. */
  37120. gamepad: Nullable<Gamepad>;
  37121. /**
  37122. * Defines the gamepad rotation sensiblity.
  37123. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37124. */
  37125. gamepadRotationSensibility: number;
  37126. /**
  37127. * Defines the gamepad move sensiblity.
  37128. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37129. */
  37130. gamepadMoveSensibility: number;
  37131. private _onGamepadConnectedObserver;
  37132. private _onGamepadDisconnectedObserver;
  37133. /**
  37134. * Attach the input controls to a specific dom element to get the input from.
  37135. * @param element Defines the element the controls should be listened from
  37136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37137. */
  37138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37139. /**
  37140. * Detach the current controls from the specified dom element.
  37141. * @param element Defines the element to stop listening the inputs from
  37142. */
  37143. detachControl(element: Nullable<HTMLElement>): void;
  37144. /**
  37145. * Update the current camera state depending on the inputs that have been used this frame.
  37146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37147. */
  37148. checkInputs(): void;
  37149. /**
  37150. * Gets the class name of the current intput.
  37151. * @returns the class name
  37152. */
  37153. getClassName(): string;
  37154. /**
  37155. * Get the friendly name associated with the input class.
  37156. * @returns the input friendly name
  37157. */
  37158. getSimpleName(): string;
  37159. }
  37160. }
  37161. declare module BABYLON {
  37162. interface ArcRotateCameraInputsManager {
  37163. /**
  37164. * Add orientation input support to the input manager.
  37165. * @returns the current input manager
  37166. */
  37167. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37168. }
  37169. /**
  37170. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37172. */
  37173. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37174. /**
  37175. * Defines the camera the input is attached to.
  37176. */
  37177. camera: ArcRotateCamera;
  37178. /**
  37179. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37180. */
  37181. alphaCorrection: number;
  37182. /**
  37183. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37184. */
  37185. gammaCorrection: number;
  37186. private _alpha;
  37187. private _gamma;
  37188. private _dirty;
  37189. private _deviceOrientationHandler;
  37190. /**
  37191. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37192. */
  37193. constructor();
  37194. /**
  37195. * Attach the input controls to a specific dom element to get the input from.
  37196. * @param element Defines the element the controls should be listened from
  37197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37198. */
  37199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37200. /** @hidden */
  37201. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37202. /**
  37203. * Update the current camera state depending on the inputs that have been used this frame.
  37204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37205. */
  37206. checkInputs(): void;
  37207. /**
  37208. * Detach the current controls from the specified dom element.
  37209. * @param element Defines the element to stop listening the inputs from
  37210. */
  37211. detachControl(element: Nullable<HTMLElement>): void;
  37212. /**
  37213. * Gets the class name of the current intput.
  37214. * @returns the class name
  37215. */
  37216. getClassName(): string;
  37217. /**
  37218. * Get the friendly name associated with the input class.
  37219. * @returns the input friendly name
  37220. */
  37221. getSimpleName(): string;
  37222. }
  37223. }
  37224. declare module BABYLON {
  37225. /**
  37226. * Listen to mouse events to control the camera.
  37227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37228. */
  37229. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37230. /**
  37231. * Defines the camera the input is attached to.
  37232. */
  37233. camera: FlyCamera;
  37234. /**
  37235. * Defines if touch is enabled. (Default is true.)
  37236. */
  37237. touchEnabled: boolean;
  37238. /**
  37239. * Defines the buttons associated with the input to handle camera rotation.
  37240. */
  37241. buttons: number[];
  37242. /**
  37243. * Assign buttons for Yaw control.
  37244. */
  37245. buttonsYaw: number[];
  37246. /**
  37247. * Assign buttons for Pitch control.
  37248. */
  37249. buttonsPitch: number[];
  37250. /**
  37251. * Assign buttons for Roll control.
  37252. */
  37253. buttonsRoll: number[];
  37254. /**
  37255. * Detect if any button is being pressed while mouse is moved.
  37256. * -1 = Mouse locked.
  37257. * 0 = Left button.
  37258. * 1 = Middle Button.
  37259. * 2 = Right Button.
  37260. */
  37261. activeButton: number;
  37262. /**
  37263. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37264. * Higher values reduce its sensitivity.
  37265. */
  37266. angularSensibility: number;
  37267. private _mousemoveCallback;
  37268. private _observer;
  37269. private _rollObserver;
  37270. private previousPosition;
  37271. private noPreventDefault;
  37272. private element;
  37273. /**
  37274. * Listen to mouse events to control the camera.
  37275. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37277. */
  37278. constructor(touchEnabled?: boolean);
  37279. /**
  37280. * Attach the mouse control to the HTML DOM element.
  37281. * @param element Defines the element that listens to the input events.
  37282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37283. */
  37284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37285. /**
  37286. * Detach the current controls from the specified dom element.
  37287. * @param element Defines the element to stop listening the inputs from
  37288. */
  37289. detachControl(element: Nullable<HTMLElement>): void;
  37290. /**
  37291. * Gets the class name of the current input.
  37292. * @returns the class name.
  37293. */
  37294. getClassName(): string;
  37295. /**
  37296. * Get the friendly name associated with the input class.
  37297. * @returns the input's friendly name.
  37298. */
  37299. getSimpleName(): string;
  37300. private _pointerInput;
  37301. private _onMouseMove;
  37302. /**
  37303. * Rotate camera by mouse offset.
  37304. */
  37305. private rotateCamera;
  37306. }
  37307. }
  37308. declare module BABYLON {
  37309. /**
  37310. * Default Inputs manager for the FlyCamera.
  37311. * It groups all the default supported inputs for ease of use.
  37312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37313. */
  37314. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37315. /**
  37316. * Instantiates a new FlyCameraInputsManager.
  37317. * @param camera Defines the camera the inputs belong to.
  37318. */
  37319. constructor(camera: FlyCamera);
  37320. /**
  37321. * Add keyboard input support to the input manager.
  37322. * @returns the new FlyCameraKeyboardMoveInput().
  37323. */
  37324. addKeyboard(): FlyCameraInputsManager;
  37325. /**
  37326. * Add mouse input support to the input manager.
  37327. * @param touchEnabled Enable touch screen support.
  37328. * @returns the new FlyCameraMouseInput().
  37329. */
  37330. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37331. }
  37332. }
  37333. declare module BABYLON {
  37334. /**
  37335. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37336. * such as in a 3D Space Shooter or a Flight Simulator.
  37337. */
  37338. export class FlyCamera extends TargetCamera {
  37339. /**
  37340. * Define the collision ellipsoid of the camera.
  37341. * This is helpful for simulating a camera body, like a player's body.
  37342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37343. */
  37344. ellipsoid: Vector3;
  37345. /**
  37346. * Define an offset for the position of the ellipsoid around the camera.
  37347. * This can be helpful if the camera is attached away from the player's body center,
  37348. * such as at its head.
  37349. */
  37350. ellipsoidOffset: Vector3;
  37351. /**
  37352. * Enable or disable collisions of the camera with the rest of the scene objects.
  37353. */
  37354. checkCollisions: boolean;
  37355. /**
  37356. * Enable or disable gravity on the camera.
  37357. */
  37358. applyGravity: boolean;
  37359. /**
  37360. * Define the current direction the camera is moving to.
  37361. */
  37362. cameraDirection: Vector3;
  37363. /**
  37364. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37365. * This overrides and empties cameraRotation.
  37366. */
  37367. rotationQuaternion: Quaternion;
  37368. /**
  37369. * Track Roll to maintain the wanted Rolling when looking around.
  37370. */
  37371. _trackRoll: number;
  37372. /**
  37373. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37374. */
  37375. rollCorrect: number;
  37376. /**
  37377. * Mimic a banked turn, Rolling the camera when Yawing.
  37378. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37379. */
  37380. bankedTurn: boolean;
  37381. /**
  37382. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37383. */
  37384. bankedTurnLimit: number;
  37385. /**
  37386. * Value of 0 disables the banked Roll.
  37387. * Value of 1 is equal to the Yaw angle in radians.
  37388. */
  37389. bankedTurnMultiplier: number;
  37390. /**
  37391. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37392. */
  37393. inputs: FlyCameraInputsManager;
  37394. /**
  37395. * Gets the input sensibility for mouse input.
  37396. * Higher values reduce sensitivity.
  37397. */
  37398. /**
  37399. * Sets the input sensibility for a mouse input.
  37400. * Higher values reduce sensitivity.
  37401. */
  37402. angularSensibility: number;
  37403. /**
  37404. * Get the keys for camera movement forward.
  37405. */
  37406. /**
  37407. * Set the keys for camera movement forward.
  37408. */
  37409. keysForward: number[];
  37410. /**
  37411. * Get the keys for camera movement backward.
  37412. */
  37413. keysBackward: number[];
  37414. /**
  37415. * Get the keys for camera movement up.
  37416. */
  37417. /**
  37418. * Set the keys for camera movement up.
  37419. */
  37420. keysUp: number[];
  37421. /**
  37422. * Get the keys for camera movement down.
  37423. */
  37424. /**
  37425. * Set the keys for camera movement down.
  37426. */
  37427. keysDown: number[];
  37428. /**
  37429. * Get the keys for camera movement left.
  37430. */
  37431. /**
  37432. * Set the keys for camera movement left.
  37433. */
  37434. keysLeft: number[];
  37435. /**
  37436. * Set the keys for camera movement right.
  37437. */
  37438. /**
  37439. * Set the keys for camera movement right.
  37440. */
  37441. keysRight: number[];
  37442. /**
  37443. * Event raised when the camera collides with a mesh in the scene.
  37444. */
  37445. onCollide: (collidedMesh: AbstractMesh) => void;
  37446. private _collider;
  37447. private _needMoveForGravity;
  37448. private _oldPosition;
  37449. private _diffPosition;
  37450. private _newPosition;
  37451. /** @hidden */
  37452. _localDirection: Vector3;
  37453. /** @hidden */
  37454. _transformedDirection: Vector3;
  37455. /**
  37456. * Instantiates a FlyCamera.
  37457. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37458. * such as in a 3D Space Shooter or a Flight Simulator.
  37459. * @param name Define the name of the camera in the scene.
  37460. * @param position Define the starting position of the camera in the scene.
  37461. * @param scene Define the scene the camera belongs to.
  37462. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37463. */
  37464. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37465. /**
  37466. * Attach a control to the HTML DOM element.
  37467. * @param element Defines the element that listens to the input events.
  37468. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37469. */
  37470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37471. /**
  37472. * Detach a control from the HTML DOM element.
  37473. * The camera will stop reacting to that input.
  37474. * @param element Defines the element that listens to the input events.
  37475. */
  37476. detachControl(element: HTMLElement): void;
  37477. private _collisionMask;
  37478. /**
  37479. * Get the mask that the camera ignores in collision events.
  37480. */
  37481. /**
  37482. * Set the mask that the camera ignores in collision events.
  37483. */
  37484. collisionMask: number;
  37485. /** @hidden */
  37486. _collideWithWorld(displacement: Vector3): void;
  37487. /** @hidden */
  37488. private _onCollisionPositionChange;
  37489. /** @hidden */
  37490. _checkInputs(): void;
  37491. /** @hidden */
  37492. _decideIfNeedsToMove(): boolean;
  37493. /** @hidden */
  37494. _updatePosition(): void;
  37495. /**
  37496. * Restore the Roll to its target value at the rate specified.
  37497. * @param rate - Higher means slower restoring.
  37498. * @hidden
  37499. */
  37500. restoreRoll(rate: number): void;
  37501. /**
  37502. * Destroy the camera and release the current resources held by it.
  37503. */
  37504. dispose(): void;
  37505. /**
  37506. * Get the current object class name.
  37507. * @returns the class name.
  37508. */
  37509. getClassName(): string;
  37510. }
  37511. }
  37512. declare module BABYLON {
  37513. /**
  37514. * Listen to keyboard events to control the camera.
  37515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37516. */
  37517. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37518. /**
  37519. * Defines the camera the input is attached to.
  37520. */
  37521. camera: FlyCamera;
  37522. /**
  37523. * The list of keyboard keys used to control the forward move of the camera.
  37524. */
  37525. keysForward: number[];
  37526. /**
  37527. * The list of keyboard keys used to control the backward move of the camera.
  37528. */
  37529. keysBackward: number[];
  37530. /**
  37531. * The list of keyboard keys used to control the forward move of the camera.
  37532. */
  37533. keysUp: number[];
  37534. /**
  37535. * The list of keyboard keys used to control the backward move of the camera.
  37536. */
  37537. keysDown: number[];
  37538. /**
  37539. * The list of keyboard keys used to control the right strafe move of the camera.
  37540. */
  37541. keysRight: number[];
  37542. /**
  37543. * The list of keyboard keys used to control the left strafe move of the camera.
  37544. */
  37545. keysLeft: number[];
  37546. private _keys;
  37547. private _onCanvasBlurObserver;
  37548. private _onKeyboardObserver;
  37549. private _engine;
  37550. private _scene;
  37551. /**
  37552. * Attach the input controls to a specific dom element to get the input from.
  37553. * @param element Defines the element the controls should be listened from
  37554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37555. */
  37556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37557. /**
  37558. * Detach the current controls from the specified dom element.
  37559. * @param element Defines the element to stop listening the inputs from
  37560. */
  37561. detachControl(element: Nullable<HTMLElement>): void;
  37562. /**
  37563. * Gets the class name of the current intput.
  37564. * @returns the class name
  37565. */
  37566. getClassName(): string;
  37567. /** @hidden */
  37568. _onLostFocus(e: FocusEvent): void;
  37569. /**
  37570. * Get the friendly name associated with the input class.
  37571. * @returns the input friendly name
  37572. */
  37573. getSimpleName(): string;
  37574. /**
  37575. * Update the current camera state depending on the inputs that have been used this frame.
  37576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37577. */
  37578. checkInputs(): void;
  37579. }
  37580. }
  37581. declare module BABYLON {
  37582. /**
  37583. * Manage the mouse wheel inputs to control a follow camera.
  37584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37585. */
  37586. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37587. /**
  37588. * Defines the camera the input is attached to.
  37589. */
  37590. camera: FollowCamera;
  37591. /**
  37592. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37593. */
  37594. axisControlRadius: boolean;
  37595. /**
  37596. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37597. */
  37598. axisControlHeight: boolean;
  37599. /**
  37600. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37601. */
  37602. axisControlRotation: boolean;
  37603. /**
  37604. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37605. * relation to mouseWheel events.
  37606. */
  37607. wheelPrecision: number;
  37608. /**
  37609. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37610. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37611. */
  37612. wheelDeltaPercentage: number;
  37613. private _wheel;
  37614. private _observer;
  37615. /**
  37616. * Attach the input controls to a specific dom element to get the input from.
  37617. * @param element Defines the element the controls should be listened from
  37618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37619. */
  37620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37621. /**
  37622. * Detach the current controls from the specified dom element.
  37623. * @param element Defines the element to stop listening the inputs from
  37624. */
  37625. detachControl(element: Nullable<HTMLElement>): void;
  37626. /**
  37627. * Gets the class name of the current intput.
  37628. * @returns the class name
  37629. */
  37630. getClassName(): string;
  37631. /**
  37632. * Get the friendly name associated with the input class.
  37633. * @returns the input friendly name
  37634. */
  37635. getSimpleName(): string;
  37636. }
  37637. }
  37638. declare module BABYLON {
  37639. /**
  37640. * Manage the pointers inputs to control an follow camera.
  37641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37642. */
  37643. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37644. /**
  37645. * Defines the camera the input is attached to.
  37646. */
  37647. camera: FollowCamera;
  37648. /**
  37649. * Gets the class name of the current input.
  37650. * @returns the class name
  37651. */
  37652. getClassName(): string;
  37653. /**
  37654. * Defines the pointer angular sensibility along the X axis or how fast is
  37655. * the camera rotating.
  37656. * A negative number will reverse the axis direction.
  37657. */
  37658. angularSensibilityX: number;
  37659. /**
  37660. * Defines the pointer angular sensibility along the Y axis or how fast is
  37661. * the camera rotating.
  37662. * A negative number will reverse the axis direction.
  37663. */
  37664. angularSensibilityY: number;
  37665. /**
  37666. * Defines the pointer pinch precision or how fast is the camera zooming.
  37667. * A negative number will reverse the axis direction.
  37668. */
  37669. pinchPrecision: number;
  37670. /**
  37671. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37672. * from 0.
  37673. * It defines the percentage of current camera.radius to use as delta when
  37674. * pinch zoom is used.
  37675. */
  37676. pinchDeltaPercentage: number;
  37677. /**
  37678. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37679. */
  37680. axisXControlRadius: boolean;
  37681. /**
  37682. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37683. */
  37684. axisXControlHeight: boolean;
  37685. /**
  37686. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37687. */
  37688. axisXControlRotation: boolean;
  37689. /**
  37690. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37691. */
  37692. axisYControlRadius: boolean;
  37693. /**
  37694. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37695. */
  37696. axisYControlHeight: boolean;
  37697. /**
  37698. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37699. */
  37700. axisYControlRotation: boolean;
  37701. /**
  37702. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37703. */
  37704. axisPinchControlRadius: boolean;
  37705. /**
  37706. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37707. */
  37708. axisPinchControlHeight: boolean;
  37709. /**
  37710. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37711. */
  37712. axisPinchControlRotation: boolean;
  37713. /**
  37714. * Log error messages if basic misconfiguration has occurred.
  37715. */
  37716. warningEnable: boolean;
  37717. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37718. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37719. private _warningCounter;
  37720. private _warning;
  37721. }
  37722. }
  37723. declare module BABYLON {
  37724. /**
  37725. * Default Inputs manager for the FollowCamera.
  37726. * It groups all the default supported inputs for ease of use.
  37727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37728. */
  37729. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37730. /**
  37731. * Instantiates a new FollowCameraInputsManager.
  37732. * @param camera Defines the camera the inputs belong to
  37733. */
  37734. constructor(camera: FollowCamera);
  37735. /**
  37736. * Add keyboard input support to the input manager.
  37737. * @returns the current input manager
  37738. */
  37739. addKeyboard(): FollowCameraInputsManager;
  37740. /**
  37741. * Add mouse wheel input support to the input manager.
  37742. * @returns the current input manager
  37743. */
  37744. addMouseWheel(): FollowCameraInputsManager;
  37745. /**
  37746. * Add pointers input support to the input manager.
  37747. * @returns the current input manager
  37748. */
  37749. addPointers(): FollowCameraInputsManager;
  37750. /**
  37751. * Add orientation input support to the input manager.
  37752. * @returns the current input manager
  37753. */
  37754. addVRDeviceOrientation(): FollowCameraInputsManager;
  37755. }
  37756. }
  37757. declare module BABYLON {
  37758. /**
  37759. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37760. * an arc rotate version arcFollowCamera are available.
  37761. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37762. */
  37763. export class FollowCamera extends TargetCamera {
  37764. /**
  37765. * Distance the follow camera should follow an object at
  37766. */
  37767. radius: number;
  37768. /**
  37769. * Minimum allowed distance of the camera to the axis of rotation
  37770. * (The camera can not get closer).
  37771. * This can help limiting how the Camera is able to move in the scene.
  37772. */
  37773. lowerRadiusLimit: Nullable<number>;
  37774. /**
  37775. * Maximum allowed distance of the camera to the axis of rotation
  37776. * (The camera can not get further).
  37777. * This can help limiting how the Camera is able to move in the scene.
  37778. */
  37779. upperRadiusLimit: Nullable<number>;
  37780. /**
  37781. * Define a rotation offset between the camera and the object it follows
  37782. */
  37783. rotationOffset: number;
  37784. /**
  37785. * Minimum allowed angle to camera position relative to target object.
  37786. * This can help limiting how the Camera is able to move in the scene.
  37787. */
  37788. lowerRotationOffsetLimit: Nullable<number>;
  37789. /**
  37790. * Maximum allowed angle to camera position relative to target object.
  37791. * This can help limiting how the Camera is able to move in the scene.
  37792. */
  37793. upperRotationOffsetLimit: Nullable<number>;
  37794. /**
  37795. * Define a height offset between the camera and the object it follows.
  37796. * It can help following an object from the top (like a car chaing a plane)
  37797. */
  37798. heightOffset: number;
  37799. /**
  37800. * Minimum allowed height of camera position relative to target object.
  37801. * This can help limiting how the Camera is able to move in the scene.
  37802. */
  37803. lowerHeightOffsetLimit: Nullable<number>;
  37804. /**
  37805. * Maximum allowed height of camera position relative to target object.
  37806. * This can help limiting how the Camera is able to move in the scene.
  37807. */
  37808. upperHeightOffsetLimit: Nullable<number>;
  37809. /**
  37810. * Define how fast the camera can accelerate to follow it s target.
  37811. */
  37812. cameraAcceleration: number;
  37813. /**
  37814. * Define the speed limit of the camera following an object.
  37815. */
  37816. maxCameraSpeed: number;
  37817. /**
  37818. * Define the target of the camera.
  37819. */
  37820. lockedTarget: Nullable<AbstractMesh>;
  37821. /**
  37822. * Defines the input associated with the camera.
  37823. */
  37824. inputs: FollowCameraInputsManager;
  37825. /**
  37826. * Instantiates the follow camera.
  37827. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37828. * @param name Define the name of the camera in the scene
  37829. * @param position Define the position of the camera
  37830. * @param scene Define the scene the camera belong to
  37831. * @param lockedTarget Define the target of the camera
  37832. */
  37833. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37834. private _follow;
  37835. /**
  37836. * Attached controls to the current camera.
  37837. * @param element Defines the element the controls should be listened from
  37838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37839. */
  37840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37841. /**
  37842. * Detach the current controls from the camera.
  37843. * The camera will stop reacting to inputs.
  37844. * @param element Defines the element to stop listening the inputs from
  37845. */
  37846. detachControl(element: HTMLElement): void;
  37847. /** @hidden */
  37848. _checkInputs(): void;
  37849. private _checkLimits;
  37850. /**
  37851. * Gets the camera class name.
  37852. * @returns the class name
  37853. */
  37854. getClassName(): string;
  37855. }
  37856. /**
  37857. * Arc Rotate version of the follow camera.
  37858. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37859. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37860. */
  37861. export class ArcFollowCamera extends TargetCamera {
  37862. /** The longitudinal angle of the camera */
  37863. alpha: number;
  37864. /** The latitudinal angle of the camera */
  37865. beta: number;
  37866. /** The radius of the camera from its target */
  37867. radius: number;
  37868. /** Define the camera target (the messh it should follow) */
  37869. target: Nullable<AbstractMesh>;
  37870. private _cartesianCoordinates;
  37871. /**
  37872. * Instantiates a new ArcFollowCamera
  37873. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37874. * @param name Define the name of the camera
  37875. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37876. * @param beta Define the rotation angle of the camera around the elevation axis
  37877. * @param radius Define the radius of the camera from its target point
  37878. * @param target Define the target of the camera
  37879. * @param scene Define the scene the camera belongs to
  37880. */
  37881. constructor(name: string,
  37882. /** The longitudinal angle of the camera */
  37883. alpha: number,
  37884. /** The latitudinal angle of the camera */
  37885. beta: number,
  37886. /** The radius of the camera from its target */
  37887. radius: number,
  37888. /** Define the camera target (the messh it should follow) */
  37889. target: Nullable<AbstractMesh>, scene: Scene);
  37890. private _follow;
  37891. /** @hidden */
  37892. _checkInputs(): void;
  37893. /**
  37894. * Returns the class name of the object.
  37895. * It is mostly used internally for serialization purposes.
  37896. */
  37897. getClassName(): string;
  37898. }
  37899. }
  37900. declare module BABYLON {
  37901. /**
  37902. * Manage the keyboard inputs to control the movement of a follow camera.
  37903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37904. */
  37905. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37906. /**
  37907. * Defines the camera the input is attached to.
  37908. */
  37909. camera: FollowCamera;
  37910. /**
  37911. * Defines the list of key codes associated with the up action (increase heightOffset)
  37912. */
  37913. keysHeightOffsetIncr: number[];
  37914. /**
  37915. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37916. */
  37917. keysHeightOffsetDecr: number[];
  37918. /**
  37919. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37920. */
  37921. keysHeightOffsetModifierAlt: boolean;
  37922. /**
  37923. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37924. */
  37925. keysHeightOffsetModifierCtrl: boolean;
  37926. /**
  37927. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37928. */
  37929. keysHeightOffsetModifierShift: boolean;
  37930. /**
  37931. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37932. */
  37933. keysRotationOffsetIncr: number[];
  37934. /**
  37935. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37936. */
  37937. keysRotationOffsetDecr: number[];
  37938. /**
  37939. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37940. */
  37941. keysRotationOffsetModifierAlt: boolean;
  37942. /**
  37943. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37944. */
  37945. keysRotationOffsetModifierCtrl: boolean;
  37946. /**
  37947. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37948. */
  37949. keysRotationOffsetModifierShift: boolean;
  37950. /**
  37951. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37952. */
  37953. keysRadiusIncr: number[];
  37954. /**
  37955. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37956. */
  37957. keysRadiusDecr: number[];
  37958. /**
  37959. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37960. */
  37961. keysRadiusModifierAlt: boolean;
  37962. /**
  37963. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37964. */
  37965. keysRadiusModifierCtrl: boolean;
  37966. /**
  37967. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37968. */
  37969. keysRadiusModifierShift: boolean;
  37970. /**
  37971. * Defines the rate of change of heightOffset.
  37972. */
  37973. heightSensibility: number;
  37974. /**
  37975. * Defines the rate of change of rotationOffset.
  37976. */
  37977. rotationSensibility: number;
  37978. /**
  37979. * Defines the rate of change of radius.
  37980. */
  37981. radiusSensibility: number;
  37982. private _keys;
  37983. private _ctrlPressed;
  37984. private _altPressed;
  37985. private _shiftPressed;
  37986. private _onCanvasBlurObserver;
  37987. private _onKeyboardObserver;
  37988. private _engine;
  37989. private _scene;
  37990. /**
  37991. * Attach the input controls to a specific dom element to get the input from.
  37992. * @param element Defines the element the controls should be listened from
  37993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37994. */
  37995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37996. /**
  37997. * Detach the current controls from the specified dom element.
  37998. * @param element Defines the element to stop listening the inputs from
  37999. */
  38000. detachControl(element: Nullable<HTMLElement>): void;
  38001. /**
  38002. * Update the current camera state depending on the inputs that have been used this frame.
  38003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38004. */
  38005. checkInputs(): void;
  38006. /**
  38007. * Gets the class name of the current input.
  38008. * @returns the class name
  38009. */
  38010. getClassName(): string;
  38011. /**
  38012. * Get the friendly name associated with the input class.
  38013. * @returns the input friendly name
  38014. */
  38015. getSimpleName(): string;
  38016. /**
  38017. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38018. * allow modification of the heightOffset value.
  38019. */
  38020. private _modifierHeightOffset;
  38021. /**
  38022. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38023. * allow modification of the rotationOffset value.
  38024. */
  38025. private _modifierRotationOffset;
  38026. /**
  38027. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38028. * allow modification of the radius value.
  38029. */
  38030. private _modifierRadius;
  38031. }
  38032. }
  38033. declare module BABYLON {
  38034. interface FreeCameraInputsManager {
  38035. /**
  38036. * @hidden
  38037. */
  38038. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38039. /**
  38040. * Add orientation input support to the input manager.
  38041. * @returns the current input manager
  38042. */
  38043. addDeviceOrientation(): FreeCameraInputsManager;
  38044. }
  38045. /**
  38046. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38047. * Screen rotation is taken into account.
  38048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38049. */
  38050. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38051. private _camera;
  38052. private _screenOrientationAngle;
  38053. private _constantTranform;
  38054. private _screenQuaternion;
  38055. private _alpha;
  38056. private _beta;
  38057. private _gamma;
  38058. /**
  38059. * Can be used to detect if a device orientation sensor is availible on a device
  38060. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38061. * @returns a promise that will resolve on orientation change
  38062. */
  38063. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38064. /**
  38065. * @hidden
  38066. */
  38067. _onDeviceOrientationChangedObservable: Observable<void>;
  38068. /**
  38069. * Instantiates a new input
  38070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38071. */
  38072. constructor();
  38073. /**
  38074. * Define the camera controlled by the input.
  38075. */
  38076. camera: FreeCamera;
  38077. /**
  38078. * Attach the input controls to a specific dom element to get the input from.
  38079. * @param element Defines the element the controls should be listened from
  38080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38081. */
  38082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38083. private _orientationChanged;
  38084. private _deviceOrientation;
  38085. /**
  38086. * Detach the current controls from the specified dom element.
  38087. * @param element Defines the element to stop listening the inputs from
  38088. */
  38089. detachControl(element: Nullable<HTMLElement>): void;
  38090. /**
  38091. * Update the current camera state depending on the inputs that have been used this frame.
  38092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38093. */
  38094. checkInputs(): void;
  38095. /**
  38096. * Gets the class name of the current intput.
  38097. * @returns the class name
  38098. */
  38099. getClassName(): string;
  38100. /**
  38101. * Get the friendly name associated with the input class.
  38102. * @returns the input friendly name
  38103. */
  38104. getSimpleName(): string;
  38105. }
  38106. }
  38107. declare module BABYLON {
  38108. /**
  38109. * Manage the gamepad inputs to control a free camera.
  38110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38111. */
  38112. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38113. /**
  38114. * Define the camera the input is attached to.
  38115. */
  38116. camera: FreeCamera;
  38117. /**
  38118. * Define the Gamepad controlling the input
  38119. */
  38120. gamepad: Nullable<Gamepad>;
  38121. /**
  38122. * Defines the gamepad rotation sensiblity.
  38123. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38124. */
  38125. gamepadAngularSensibility: number;
  38126. /**
  38127. * Defines the gamepad move sensiblity.
  38128. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38129. */
  38130. gamepadMoveSensibility: number;
  38131. private _onGamepadConnectedObserver;
  38132. private _onGamepadDisconnectedObserver;
  38133. private _cameraTransform;
  38134. private _deltaTransform;
  38135. private _vector3;
  38136. private _vector2;
  38137. /**
  38138. * Attach the input controls to a specific dom element to get the input from.
  38139. * @param element Defines the element the controls should be listened from
  38140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38141. */
  38142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38143. /**
  38144. * Detach the current controls from the specified dom element.
  38145. * @param element Defines the element to stop listening the inputs from
  38146. */
  38147. detachControl(element: Nullable<HTMLElement>): void;
  38148. /**
  38149. * Update the current camera state depending on the inputs that have been used this frame.
  38150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38151. */
  38152. checkInputs(): void;
  38153. /**
  38154. * Gets the class name of the current intput.
  38155. * @returns the class name
  38156. */
  38157. getClassName(): string;
  38158. /**
  38159. * Get the friendly name associated with the input class.
  38160. * @returns the input friendly name
  38161. */
  38162. getSimpleName(): string;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * Defines the potential axis of a Joystick
  38168. */
  38169. export enum JoystickAxis {
  38170. /** X axis */
  38171. X = 0,
  38172. /** Y axis */
  38173. Y = 1,
  38174. /** Z axis */
  38175. Z = 2
  38176. }
  38177. /**
  38178. * Class used to define virtual joystick (used in touch mode)
  38179. */
  38180. export class VirtualJoystick {
  38181. /**
  38182. * Gets or sets a boolean indicating that left and right values must be inverted
  38183. */
  38184. reverseLeftRight: boolean;
  38185. /**
  38186. * Gets or sets a boolean indicating that up and down values must be inverted
  38187. */
  38188. reverseUpDown: boolean;
  38189. /**
  38190. * Gets the offset value for the position (ie. the change of the position value)
  38191. */
  38192. deltaPosition: Vector3;
  38193. /**
  38194. * Gets a boolean indicating if the virtual joystick was pressed
  38195. */
  38196. pressed: boolean;
  38197. /**
  38198. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38199. */
  38200. static Canvas: Nullable<HTMLCanvasElement>;
  38201. private static _globalJoystickIndex;
  38202. private static vjCanvasContext;
  38203. private static vjCanvasWidth;
  38204. private static vjCanvasHeight;
  38205. private static halfWidth;
  38206. private _action;
  38207. private _axisTargetedByLeftAndRight;
  38208. private _axisTargetedByUpAndDown;
  38209. private _joystickSensibility;
  38210. private _inversedSensibility;
  38211. private _joystickPointerID;
  38212. private _joystickColor;
  38213. private _joystickPointerPos;
  38214. private _joystickPreviousPointerPos;
  38215. private _joystickPointerStartPos;
  38216. private _deltaJoystickVector;
  38217. private _leftJoystick;
  38218. private _touches;
  38219. private _onPointerDownHandlerRef;
  38220. private _onPointerMoveHandlerRef;
  38221. private _onPointerUpHandlerRef;
  38222. private _onResize;
  38223. /**
  38224. * Creates a new virtual joystick
  38225. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38226. */
  38227. constructor(leftJoystick?: boolean);
  38228. /**
  38229. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38230. * @param newJoystickSensibility defines the new sensibility
  38231. */
  38232. setJoystickSensibility(newJoystickSensibility: number): void;
  38233. private _onPointerDown;
  38234. private _onPointerMove;
  38235. private _onPointerUp;
  38236. /**
  38237. * Change the color of the virtual joystick
  38238. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38239. */
  38240. setJoystickColor(newColor: string): void;
  38241. /**
  38242. * Defines a callback to call when the joystick is touched
  38243. * @param action defines the callback
  38244. */
  38245. setActionOnTouch(action: () => any): void;
  38246. /**
  38247. * Defines which axis you'd like to control for left & right
  38248. * @param axis defines the axis to use
  38249. */
  38250. setAxisForLeftRight(axis: JoystickAxis): void;
  38251. /**
  38252. * Defines which axis you'd like to control for up & down
  38253. * @param axis defines the axis to use
  38254. */
  38255. setAxisForUpDown(axis: JoystickAxis): void;
  38256. private _drawVirtualJoystick;
  38257. /**
  38258. * Release internal HTML canvas
  38259. */
  38260. releaseCanvas(): void;
  38261. }
  38262. }
  38263. declare module BABYLON {
  38264. interface FreeCameraInputsManager {
  38265. /**
  38266. * Add virtual joystick input support to the input manager.
  38267. * @returns the current input manager
  38268. */
  38269. addVirtualJoystick(): FreeCameraInputsManager;
  38270. }
  38271. /**
  38272. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38274. */
  38275. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38276. /**
  38277. * Defines the camera the input is attached to.
  38278. */
  38279. camera: FreeCamera;
  38280. private _leftjoystick;
  38281. private _rightjoystick;
  38282. /**
  38283. * Gets the left stick of the virtual joystick.
  38284. * @returns The virtual Joystick
  38285. */
  38286. getLeftJoystick(): VirtualJoystick;
  38287. /**
  38288. * Gets the right stick of the virtual joystick.
  38289. * @returns The virtual Joystick
  38290. */
  38291. getRightJoystick(): VirtualJoystick;
  38292. /**
  38293. * Update the current camera state depending on the inputs that have been used this frame.
  38294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38295. */
  38296. checkInputs(): void;
  38297. /**
  38298. * Attach the input controls to a specific dom element to get the input from.
  38299. * @param element Defines the element the controls should be listened from
  38300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38301. */
  38302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38303. /**
  38304. * Detach the current controls from the specified dom element.
  38305. * @param element Defines the element to stop listening the inputs from
  38306. */
  38307. detachControl(element: Nullable<HTMLElement>): void;
  38308. /**
  38309. * Gets the class name of the current intput.
  38310. * @returns the class name
  38311. */
  38312. getClassName(): string;
  38313. /**
  38314. * Get the friendly name associated with the input class.
  38315. * @returns the input friendly name
  38316. */
  38317. getSimpleName(): string;
  38318. }
  38319. }
  38320. declare module BABYLON {
  38321. /**
  38322. * This represents a FPS type of camera controlled by touch.
  38323. * This is like a universal camera minus the Gamepad controls.
  38324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38325. */
  38326. export class TouchCamera extends FreeCamera {
  38327. /**
  38328. * Defines the touch sensibility for rotation.
  38329. * The higher the faster.
  38330. */
  38331. touchAngularSensibility: number;
  38332. /**
  38333. * Defines the touch sensibility for move.
  38334. * The higher the faster.
  38335. */
  38336. touchMoveSensibility: number;
  38337. /**
  38338. * Instantiates a new touch camera.
  38339. * This represents a FPS type of camera controlled by touch.
  38340. * This is like a universal camera minus the Gamepad controls.
  38341. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38342. * @param name Define the name of the camera in the scene
  38343. * @param position Define the start position of the camera in the scene
  38344. * @param scene Define the scene the camera belongs to
  38345. */
  38346. constructor(name: string, position: Vector3, scene: Scene);
  38347. /**
  38348. * Gets the current object class name.
  38349. * @return the class name
  38350. */
  38351. getClassName(): string;
  38352. /** @hidden */
  38353. _setupInputs(): void;
  38354. }
  38355. }
  38356. declare module BABYLON {
  38357. /**
  38358. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38359. * being tilted forward or back and left or right.
  38360. */
  38361. export class DeviceOrientationCamera extends FreeCamera {
  38362. private _initialQuaternion;
  38363. private _quaternionCache;
  38364. private _tmpDragQuaternion;
  38365. private _disablePointerInputWhenUsingDeviceOrientation;
  38366. /**
  38367. * Creates a new device orientation camera
  38368. * @param name The name of the camera
  38369. * @param position The start position camera
  38370. * @param scene The scene the camera belongs to
  38371. */
  38372. constructor(name: string, position: Vector3, scene: Scene);
  38373. /**
  38374. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38375. */
  38376. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38377. private _dragFactor;
  38378. /**
  38379. * Enabled turning on the y axis when the orientation sensor is active
  38380. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38381. */
  38382. enableHorizontalDragging(dragFactor?: number): void;
  38383. /**
  38384. * Gets the current instance class name ("DeviceOrientationCamera").
  38385. * This helps avoiding instanceof at run time.
  38386. * @returns the class name
  38387. */
  38388. getClassName(): string;
  38389. /**
  38390. * @hidden
  38391. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38392. */
  38393. _checkInputs(): void;
  38394. /**
  38395. * Reset the camera to its default orientation on the specified axis only.
  38396. * @param axis The axis to reset
  38397. */
  38398. resetToCurrentRotation(axis?: Axis): void;
  38399. }
  38400. }
  38401. declare module BABYLON {
  38402. /**
  38403. * Defines supported buttons for XBox360 compatible gamepads
  38404. */
  38405. export enum Xbox360Button {
  38406. /** A */
  38407. A = 0,
  38408. /** B */
  38409. B = 1,
  38410. /** X */
  38411. X = 2,
  38412. /** Y */
  38413. Y = 3,
  38414. /** Start */
  38415. Start = 4,
  38416. /** Back */
  38417. Back = 5,
  38418. /** Left button */
  38419. LB = 6,
  38420. /** Right button */
  38421. RB = 7,
  38422. /** Left stick */
  38423. LeftStick = 8,
  38424. /** Right stick */
  38425. RightStick = 9
  38426. }
  38427. /** Defines values for XBox360 DPad */
  38428. export enum Xbox360Dpad {
  38429. /** Up */
  38430. Up = 0,
  38431. /** Down */
  38432. Down = 1,
  38433. /** Left */
  38434. Left = 2,
  38435. /** Right */
  38436. Right = 3
  38437. }
  38438. /**
  38439. * Defines a XBox360 gamepad
  38440. */
  38441. export class Xbox360Pad extends Gamepad {
  38442. private _leftTrigger;
  38443. private _rightTrigger;
  38444. private _onlefttriggerchanged;
  38445. private _onrighttriggerchanged;
  38446. private _onbuttondown;
  38447. private _onbuttonup;
  38448. private _ondpaddown;
  38449. private _ondpadup;
  38450. /** Observable raised when a button is pressed */
  38451. onButtonDownObservable: Observable<Xbox360Button>;
  38452. /** Observable raised when a button is released */
  38453. onButtonUpObservable: Observable<Xbox360Button>;
  38454. /** Observable raised when a pad is pressed */
  38455. onPadDownObservable: Observable<Xbox360Dpad>;
  38456. /** Observable raised when a pad is released */
  38457. onPadUpObservable: Observable<Xbox360Dpad>;
  38458. private _buttonA;
  38459. private _buttonB;
  38460. private _buttonX;
  38461. private _buttonY;
  38462. private _buttonBack;
  38463. private _buttonStart;
  38464. private _buttonLB;
  38465. private _buttonRB;
  38466. private _buttonLeftStick;
  38467. private _buttonRightStick;
  38468. private _dPadUp;
  38469. private _dPadDown;
  38470. private _dPadLeft;
  38471. private _dPadRight;
  38472. private _isXboxOnePad;
  38473. /**
  38474. * Creates a new XBox360 gamepad object
  38475. * @param id defines the id of this gamepad
  38476. * @param index defines its index
  38477. * @param gamepad defines the internal HTML gamepad object
  38478. * @param xboxOne defines if it is a XBox One gamepad
  38479. */
  38480. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38481. /**
  38482. * Defines the callback to call when left trigger is pressed
  38483. * @param callback defines the callback to use
  38484. */
  38485. onlefttriggerchanged(callback: (value: number) => void): void;
  38486. /**
  38487. * Defines the callback to call when right trigger is pressed
  38488. * @param callback defines the callback to use
  38489. */
  38490. onrighttriggerchanged(callback: (value: number) => void): void;
  38491. /**
  38492. * Gets the left trigger value
  38493. */
  38494. /**
  38495. * Sets the left trigger value
  38496. */
  38497. leftTrigger: number;
  38498. /**
  38499. * Gets the right trigger value
  38500. */
  38501. /**
  38502. * Sets the right trigger value
  38503. */
  38504. rightTrigger: number;
  38505. /**
  38506. * Defines the callback to call when a button is pressed
  38507. * @param callback defines the callback to use
  38508. */
  38509. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38510. /**
  38511. * Defines the callback to call when a button is released
  38512. * @param callback defines the callback to use
  38513. */
  38514. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38515. /**
  38516. * Defines the callback to call when a pad is pressed
  38517. * @param callback defines the callback to use
  38518. */
  38519. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38520. /**
  38521. * Defines the callback to call when a pad is released
  38522. * @param callback defines the callback to use
  38523. */
  38524. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38525. private _setButtonValue;
  38526. private _setDPadValue;
  38527. /**
  38528. * Gets the value of the `A` button
  38529. */
  38530. /**
  38531. * Sets the value of the `A` button
  38532. */
  38533. buttonA: number;
  38534. /**
  38535. * Gets the value of the `B` button
  38536. */
  38537. /**
  38538. * Sets the value of the `B` button
  38539. */
  38540. buttonB: number;
  38541. /**
  38542. * Gets the value of the `X` button
  38543. */
  38544. /**
  38545. * Sets the value of the `X` button
  38546. */
  38547. buttonX: number;
  38548. /**
  38549. * Gets the value of the `Y` button
  38550. */
  38551. /**
  38552. * Sets the value of the `Y` button
  38553. */
  38554. buttonY: number;
  38555. /**
  38556. * Gets the value of the `Start` button
  38557. */
  38558. /**
  38559. * Sets the value of the `Start` button
  38560. */
  38561. buttonStart: number;
  38562. /**
  38563. * Gets the value of the `Back` button
  38564. */
  38565. /**
  38566. * Sets the value of the `Back` button
  38567. */
  38568. buttonBack: number;
  38569. /**
  38570. * Gets the value of the `Left` button
  38571. */
  38572. /**
  38573. * Sets the value of the `Left` button
  38574. */
  38575. buttonLB: number;
  38576. /**
  38577. * Gets the value of the `Right` button
  38578. */
  38579. /**
  38580. * Sets the value of the `Right` button
  38581. */
  38582. buttonRB: number;
  38583. /**
  38584. * Gets the value of the Left joystick
  38585. */
  38586. /**
  38587. * Sets the value of the Left joystick
  38588. */
  38589. buttonLeftStick: number;
  38590. /**
  38591. * Gets the value of the Right joystick
  38592. */
  38593. /**
  38594. * Sets the value of the Right joystick
  38595. */
  38596. buttonRightStick: number;
  38597. /**
  38598. * Gets the value of D-pad up
  38599. */
  38600. /**
  38601. * Sets the value of D-pad up
  38602. */
  38603. dPadUp: number;
  38604. /**
  38605. * Gets the value of D-pad down
  38606. */
  38607. /**
  38608. * Sets the value of D-pad down
  38609. */
  38610. dPadDown: number;
  38611. /**
  38612. * Gets the value of D-pad left
  38613. */
  38614. /**
  38615. * Sets the value of D-pad left
  38616. */
  38617. dPadLeft: number;
  38618. /**
  38619. * Gets the value of D-pad right
  38620. */
  38621. /**
  38622. * Sets the value of D-pad right
  38623. */
  38624. dPadRight: number;
  38625. /**
  38626. * Force the gamepad to synchronize with device values
  38627. */
  38628. update(): void;
  38629. /**
  38630. * Disposes the gamepad
  38631. */
  38632. dispose(): void;
  38633. }
  38634. }
  38635. declare module BABYLON {
  38636. /**
  38637. * Defines supported buttons for DualShock compatible gamepads
  38638. */
  38639. export enum DualShockButton {
  38640. /** Cross */
  38641. Cross = 0,
  38642. /** Circle */
  38643. Circle = 1,
  38644. /** Square */
  38645. Square = 2,
  38646. /** Triangle */
  38647. Triangle = 3,
  38648. /** Options */
  38649. Options = 4,
  38650. /** Share */
  38651. Share = 5,
  38652. /** L1 */
  38653. L1 = 6,
  38654. /** R1 */
  38655. R1 = 7,
  38656. /** Left stick */
  38657. LeftStick = 8,
  38658. /** Right stick */
  38659. RightStick = 9
  38660. }
  38661. /** Defines values for DualShock DPad */
  38662. export enum DualShockDpad {
  38663. /** Up */
  38664. Up = 0,
  38665. /** Down */
  38666. Down = 1,
  38667. /** Left */
  38668. Left = 2,
  38669. /** Right */
  38670. Right = 3
  38671. }
  38672. /**
  38673. * Defines a DualShock gamepad
  38674. */
  38675. export class DualShockPad extends Gamepad {
  38676. private _leftTrigger;
  38677. private _rightTrigger;
  38678. private _onlefttriggerchanged;
  38679. private _onrighttriggerchanged;
  38680. private _onbuttondown;
  38681. private _onbuttonup;
  38682. private _ondpaddown;
  38683. private _ondpadup;
  38684. /** Observable raised when a button is pressed */
  38685. onButtonDownObservable: Observable<DualShockButton>;
  38686. /** Observable raised when a button is released */
  38687. onButtonUpObservable: Observable<DualShockButton>;
  38688. /** Observable raised when a pad is pressed */
  38689. onPadDownObservable: Observable<DualShockDpad>;
  38690. /** Observable raised when a pad is released */
  38691. onPadUpObservable: Observable<DualShockDpad>;
  38692. private _buttonCross;
  38693. private _buttonCircle;
  38694. private _buttonSquare;
  38695. private _buttonTriangle;
  38696. private _buttonShare;
  38697. private _buttonOptions;
  38698. private _buttonL1;
  38699. private _buttonR1;
  38700. private _buttonLeftStick;
  38701. private _buttonRightStick;
  38702. private _dPadUp;
  38703. private _dPadDown;
  38704. private _dPadLeft;
  38705. private _dPadRight;
  38706. /**
  38707. * Creates a new DualShock gamepad object
  38708. * @param id defines the id of this gamepad
  38709. * @param index defines its index
  38710. * @param gamepad defines the internal HTML gamepad object
  38711. */
  38712. constructor(id: string, index: number, gamepad: any);
  38713. /**
  38714. * Defines the callback to call when left trigger is pressed
  38715. * @param callback defines the callback to use
  38716. */
  38717. onlefttriggerchanged(callback: (value: number) => void): void;
  38718. /**
  38719. * Defines the callback to call when right trigger is pressed
  38720. * @param callback defines the callback to use
  38721. */
  38722. onrighttriggerchanged(callback: (value: number) => void): void;
  38723. /**
  38724. * Gets the left trigger value
  38725. */
  38726. /**
  38727. * Sets the left trigger value
  38728. */
  38729. leftTrigger: number;
  38730. /**
  38731. * Gets the right trigger value
  38732. */
  38733. /**
  38734. * Sets the right trigger value
  38735. */
  38736. rightTrigger: number;
  38737. /**
  38738. * Defines the callback to call when a button is pressed
  38739. * @param callback defines the callback to use
  38740. */
  38741. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38742. /**
  38743. * Defines the callback to call when a button is released
  38744. * @param callback defines the callback to use
  38745. */
  38746. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38747. /**
  38748. * Defines the callback to call when a pad is pressed
  38749. * @param callback defines the callback to use
  38750. */
  38751. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38752. /**
  38753. * Defines the callback to call when a pad is released
  38754. * @param callback defines the callback to use
  38755. */
  38756. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38757. private _setButtonValue;
  38758. private _setDPadValue;
  38759. /**
  38760. * Gets the value of the `Cross` button
  38761. */
  38762. /**
  38763. * Sets the value of the `Cross` button
  38764. */
  38765. buttonCross: number;
  38766. /**
  38767. * Gets the value of the `Circle` button
  38768. */
  38769. /**
  38770. * Sets the value of the `Circle` button
  38771. */
  38772. buttonCircle: number;
  38773. /**
  38774. * Gets the value of the `Square` button
  38775. */
  38776. /**
  38777. * Sets the value of the `Square` button
  38778. */
  38779. buttonSquare: number;
  38780. /**
  38781. * Gets the value of the `Triangle` button
  38782. */
  38783. /**
  38784. * Sets the value of the `Triangle` button
  38785. */
  38786. buttonTriangle: number;
  38787. /**
  38788. * Gets the value of the `Options` button
  38789. */
  38790. /**
  38791. * Sets the value of the `Options` button
  38792. */
  38793. buttonOptions: number;
  38794. /**
  38795. * Gets the value of the `Share` button
  38796. */
  38797. /**
  38798. * Sets the value of the `Share` button
  38799. */
  38800. buttonShare: number;
  38801. /**
  38802. * Gets the value of the `L1` button
  38803. */
  38804. /**
  38805. * Sets the value of the `L1` button
  38806. */
  38807. buttonL1: number;
  38808. /**
  38809. * Gets the value of the `R1` button
  38810. */
  38811. /**
  38812. * Sets the value of the `R1` button
  38813. */
  38814. buttonR1: number;
  38815. /**
  38816. * Gets the value of the Left joystick
  38817. */
  38818. /**
  38819. * Sets the value of the Left joystick
  38820. */
  38821. buttonLeftStick: number;
  38822. /**
  38823. * Gets the value of the Right joystick
  38824. */
  38825. /**
  38826. * Sets the value of the Right joystick
  38827. */
  38828. buttonRightStick: number;
  38829. /**
  38830. * Gets the value of D-pad up
  38831. */
  38832. /**
  38833. * Sets the value of D-pad up
  38834. */
  38835. dPadUp: number;
  38836. /**
  38837. * Gets the value of D-pad down
  38838. */
  38839. /**
  38840. * Sets the value of D-pad down
  38841. */
  38842. dPadDown: number;
  38843. /**
  38844. * Gets the value of D-pad left
  38845. */
  38846. /**
  38847. * Sets the value of D-pad left
  38848. */
  38849. dPadLeft: number;
  38850. /**
  38851. * Gets the value of D-pad right
  38852. */
  38853. /**
  38854. * Sets the value of D-pad right
  38855. */
  38856. dPadRight: number;
  38857. /**
  38858. * Force the gamepad to synchronize with device values
  38859. */
  38860. update(): void;
  38861. /**
  38862. * Disposes the gamepad
  38863. */
  38864. dispose(): void;
  38865. }
  38866. }
  38867. declare module BABYLON {
  38868. /**
  38869. * Manager for handling gamepads
  38870. */
  38871. export class GamepadManager {
  38872. private _scene?;
  38873. private _babylonGamepads;
  38874. private _oneGamepadConnected;
  38875. /** @hidden */
  38876. _isMonitoring: boolean;
  38877. private _gamepadEventSupported;
  38878. private _gamepadSupport;
  38879. /**
  38880. * observable to be triggered when the gamepad controller has been connected
  38881. */
  38882. onGamepadConnectedObservable: Observable<Gamepad>;
  38883. /**
  38884. * observable to be triggered when the gamepad controller has been disconnected
  38885. */
  38886. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38887. private _onGamepadConnectedEvent;
  38888. private _onGamepadDisconnectedEvent;
  38889. /**
  38890. * Initializes the gamepad manager
  38891. * @param _scene BabylonJS scene
  38892. */
  38893. constructor(_scene?: Scene | undefined);
  38894. /**
  38895. * The gamepads in the game pad manager
  38896. */
  38897. readonly gamepads: Gamepad[];
  38898. /**
  38899. * Get the gamepad controllers based on type
  38900. * @param type The type of gamepad controller
  38901. * @returns Nullable gamepad
  38902. */
  38903. getGamepadByType(type?: number): Nullable<Gamepad>;
  38904. /**
  38905. * Disposes the gamepad manager
  38906. */
  38907. dispose(): void;
  38908. private _addNewGamepad;
  38909. private _startMonitoringGamepads;
  38910. private _stopMonitoringGamepads;
  38911. /** @hidden */
  38912. _checkGamepadsStatus(): void;
  38913. private _updateGamepadObjects;
  38914. }
  38915. }
  38916. declare module BABYLON {
  38917. interface Scene {
  38918. /** @hidden */
  38919. _gamepadManager: Nullable<GamepadManager>;
  38920. /**
  38921. * Gets the gamepad manager associated with the scene
  38922. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38923. */
  38924. gamepadManager: GamepadManager;
  38925. }
  38926. /**
  38927. * Interface representing a free camera inputs manager
  38928. */
  38929. interface FreeCameraInputsManager {
  38930. /**
  38931. * Adds gamepad input support to the FreeCameraInputsManager.
  38932. * @returns the FreeCameraInputsManager
  38933. */
  38934. addGamepad(): FreeCameraInputsManager;
  38935. }
  38936. /**
  38937. * Interface representing an arc rotate camera inputs manager
  38938. */
  38939. interface ArcRotateCameraInputsManager {
  38940. /**
  38941. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38942. * @returns the camera inputs manager
  38943. */
  38944. addGamepad(): ArcRotateCameraInputsManager;
  38945. }
  38946. /**
  38947. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38948. */
  38949. export class GamepadSystemSceneComponent implements ISceneComponent {
  38950. /**
  38951. * The component name helpfull to identify the component in the list of scene components.
  38952. */
  38953. readonly name: string;
  38954. /**
  38955. * The scene the component belongs to.
  38956. */
  38957. scene: Scene;
  38958. /**
  38959. * Creates a new instance of the component for the given scene
  38960. * @param scene Defines the scene to register the component in
  38961. */
  38962. constructor(scene: Scene);
  38963. /**
  38964. * Registers the component in a given scene
  38965. */
  38966. register(): void;
  38967. /**
  38968. * Rebuilds the elements related to this component in case of
  38969. * context lost for instance.
  38970. */
  38971. rebuild(): void;
  38972. /**
  38973. * Disposes the component and the associated ressources
  38974. */
  38975. dispose(): void;
  38976. private _beforeCameraUpdate;
  38977. }
  38978. }
  38979. declare module BABYLON {
  38980. /**
  38981. * 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,
  38982. * which still works and will still be found in many Playgrounds.
  38983. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38984. */
  38985. export class UniversalCamera extends TouchCamera {
  38986. /**
  38987. * Defines the gamepad rotation sensiblity.
  38988. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38989. */
  38990. gamepadAngularSensibility: number;
  38991. /**
  38992. * Defines the gamepad move sensiblity.
  38993. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38994. */
  38995. gamepadMoveSensibility: number;
  38996. /**
  38997. * 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,
  38998. * which still works and will still be found in many Playgrounds.
  38999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39000. * @param name Define the name of the camera in the scene
  39001. * @param position Define the start position of the camera in the scene
  39002. * @param scene Define the scene the camera belongs to
  39003. */
  39004. constructor(name: string, position: Vector3, scene: Scene);
  39005. /**
  39006. * Gets the current object class name.
  39007. * @return the class name
  39008. */
  39009. getClassName(): string;
  39010. }
  39011. }
  39012. declare module BABYLON {
  39013. /**
  39014. * This represents a FPS type of camera. This is only here for back compat purpose.
  39015. * Please use the UniversalCamera instead as both are identical.
  39016. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39017. */
  39018. export class GamepadCamera extends UniversalCamera {
  39019. /**
  39020. * Instantiates a new Gamepad Camera
  39021. * This represents a FPS type of camera. This is only here for back compat purpose.
  39022. * Please use the UniversalCamera instead as both are identical.
  39023. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39024. * @param name Define the name of the camera in the scene
  39025. * @param position Define the start position of the camera in the scene
  39026. * @param scene Define the scene the camera belongs to
  39027. */
  39028. constructor(name: string, position: Vector3, scene: Scene);
  39029. /**
  39030. * Gets the current object class name.
  39031. * @return the class name
  39032. */
  39033. getClassName(): string;
  39034. }
  39035. }
  39036. declare module BABYLON {
  39037. /** @hidden */
  39038. export var passPixelShader: {
  39039. name: string;
  39040. shader: string;
  39041. };
  39042. }
  39043. declare module BABYLON {
  39044. /** @hidden */
  39045. export var passCubePixelShader: {
  39046. name: string;
  39047. shader: string;
  39048. };
  39049. }
  39050. declare module BABYLON {
  39051. /**
  39052. * PassPostProcess which produces an output the same as it's input
  39053. */
  39054. export class PassPostProcess extends PostProcess {
  39055. /**
  39056. * Creates the PassPostProcess
  39057. * @param name The name of the effect.
  39058. * @param options The required width/height ratio to downsize to before computing the render pass.
  39059. * @param camera The camera to apply the render pass to.
  39060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39061. * @param engine The engine which the post process will be applied. (default: current engine)
  39062. * @param reusable If the post process can be reused on the same frame. (default: false)
  39063. * @param textureType The type of texture to be used when performing the post processing.
  39064. * @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)
  39065. */
  39066. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39067. }
  39068. /**
  39069. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39070. */
  39071. export class PassCubePostProcess extends PostProcess {
  39072. private _face;
  39073. /**
  39074. * Gets or sets the cube face to display.
  39075. * * 0 is +X
  39076. * * 1 is -X
  39077. * * 2 is +Y
  39078. * * 3 is -Y
  39079. * * 4 is +Z
  39080. * * 5 is -Z
  39081. */
  39082. face: number;
  39083. /**
  39084. * Creates the PassCubePostProcess
  39085. * @param name The name of the effect.
  39086. * @param options The required width/height ratio to downsize to before computing the render pass.
  39087. * @param camera The camera to apply the render pass to.
  39088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39089. * @param engine The engine which the post process will be applied. (default: current engine)
  39090. * @param reusable If the post process can be reused on the same frame. (default: false)
  39091. * @param textureType The type of texture to be used when performing the post processing.
  39092. * @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)
  39093. */
  39094. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /** @hidden */
  39099. export var anaglyphPixelShader: {
  39100. name: string;
  39101. shader: string;
  39102. };
  39103. }
  39104. declare module BABYLON {
  39105. /**
  39106. * Postprocess used to generate anaglyphic rendering
  39107. */
  39108. export class AnaglyphPostProcess extends PostProcess {
  39109. private _passedProcess;
  39110. /**
  39111. * Creates a new AnaglyphPostProcess
  39112. * @param name defines postprocess name
  39113. * @param options defines creation options or target ratio scale
  39114. * @param rigCameras defines cameras using this postprocess
  39115. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39116. * @param engine defines hosting engine
  39117. * @param reusable defines if the postprocess will be reused multiple times per frame
  39118. */
  39119. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39120. }
  39121. }
  39122. declare module BABYLON {
  39123. /**
  39124. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39125. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39126. */
  39127. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39128. /**
  39129. * Creates a new AnaglyphArcRotateCamera
  39130. * @param name defines camera name
  39131. * @param alpha defines alpha angle (in radians)
  39132. * @param beta defines beta angle (in radians)
  39133. * @param radius defines radius
  39134. * @param target defines camera target
  39135. * @param interaxialDistance defines distance between each color axis
  39136. * @param scene defines the hosting scene
  39137. */
  39138. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39139. /**
  39140. * Gets camera class name
  39141. * @returns AnaglyphArcRotateCamera
  39142. */
  39143. getClassName(): string;
  39144. }
  39145. }
  39146. declare module BABYLON {
  39147. /**
  39148. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39149. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39150. */
  39151. export class AnaglyphFreeCamera extends FreeCamera {
  39152. /**
  39153. * Creates a new AnaglyphFreeCamera
  39154. * @param name defines camera name
  39155. * @param position defines initial position
  39156. * @param interaxialDistance defines distance between each color axis
  39157. * @param scene defines the hosting scene
  39158. */
  39159. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39160. /**
  39161. * Gets camera class name
  39162. * @returns AnaglyphFreeCamera
  39163. */
  39164. getClassName(): string;
  39165. }
  39166. }
  39167. declare module BABYLON {
  39168. /**
  39169. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39170. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39171. */
  39172. export class AnaglyphGamepadCamera extends GamepadCamera {
  39173. /**
  39174. * Creates a new AnaglyphGamepadCamera
  39175. * @param name defines camera name
  39176. * @param position defines initial position
  39177. * @param interaxialDistance defines distance between each color axis
  39178. * @param scene defines the hosting scene
  39179. */
  39180. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39181. /**
  39182. * Gets camera class name
  39183. * @returns AnaglyphGamepadCamera
  39184. */
  39185. getClassName(): string;
  39186. }
  39187. }
  39188. declare module BABYLON {
  39189. /**
  39190. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39191. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39192. */
  39193. export class AnaglyphUniversalCamera extends UniversalCamera {
  39194. /**
  39195. * Creates a new AnaglyphUniversalCamera
  39196. * @param name defines camera name
  39197. * @param position defines initial position
  39198. * @param interaxialDistance defines distance between each color axis
  39199. * @param scene defines the hosting scene
  39200. */
  39201. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39202. /**
  39203. * Gets camera class name
  39204. * @returns AnaglyphUniversalCamera
  39205. */
  39206. getClassName(): string;
  39207. }
  39208. }
  39209. declare module BABYLON {
  39210. /** @hidden */
  39211. export var stereoscopicInterlacePixelShader: {
  39212. name: string;
  39213. shader: string;
  39214. };
  39215. }
  39216. declare module BABYLON {
  39217. /**
  39218. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39219. */
  39220. export class StereoscopicInterlacePostProcess extends PostProcess {
  39221. private _stepSize;
  39222. private _passedProcess;
  39223. /**
  39224. * Initializes a StereoscopicInterlacePostProcess
  39225. * @param name The name of the effect.
  39226. * @param rigCameras The rig cameras to be appled to the post process
  39227. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39229. * @param engine The engine which the post process will be applied. (default: current engine)
  39230. * @param reusable If the post process can be reused on the same frame. (default: false)
  39231. */
  39232. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39233. }
  39234. }
  39235. declare module BABYLON {
  39236. /**
  39237. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39238. * @see http://doc.babylonjs.com/features/cameras
  39239. */
  39240. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39241. /**
  39242. * Creates a new StereoscopicArcRotateCamera
  39243. * @param name defines camera name
  39244. * @param alpha defines alpha angle (in radians)
  39245. * @param beta defines beta angle (in radians)
  39246. * @param radius defines radius
  39247. * @param target defines camera target
  39248. * @param interaxialDistance defines distance between each color axis
  39249. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39250. * @param scene defines the hosting scene
  39251. */
  39252. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39253. /**
  39254. * Gets camera class name
  39255. * @returns StereoscopicArcRotateCamera
  39256. */
  39257. getClassName(): string;
  39258. }
  39259. }
  39260. declare module BABYLON {
  39261. /**
  39262. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39263. * @see http://doc.babylonjs.com/features/cameras
  39264. */
  39265. export class StereoscopicFreeCamera extends FreeCamera {
  39266. /**
  39267. * Creates a new StereoscopicFreeCamera
  39268. * @param name defines camera name
  39269. * @param position defines initial position
  39270. * @param interaxialDistance defines distance between each color axis
  39271. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39272. * @param scene defines the hosting scene
  39273. */
  39274. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39275. /**
  39276. * Gets camera class name
  39277. * @returns StereoscopicFreeCamera
  39278. */
  39279. getClassName(): string;
  39280. }
  39281. }
  39282. declare module BABYLON {
  39283. /**
  39284. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39285. * @see http://doc.babylonjs.com/features/cameras
  39286. */
  39287. export class StereoscopicGamepadCamera extends GamepadCamera {
  39288. /**
  39289. * Creates a new StereoscopicGamepadCamera
  39290. * @param name defines camera name
  39291. * @param position defines initial position
  39292. * @param interaxialDistance defines distance between each color axis
  39293. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39294. * @param scene defines the hosting scene
  39295. */
  39296. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39297. /**
  39298. * Gets camera class name
  39299. * @returns StereoscopicGamepadCamera
  39300. */
  39301. getClassName(): string;
  39302. }
  39303. }
  39304. declare module BABYLON {
  39305. /**
  39306. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39307. * @see http://doc.babylonjs.com/features/cameras
  39308. */
  39309. export class StereoscopicUniversalCamera extends UniversalCamera {
  39310. /**
  39311. * Creates a new StereoscopicUniversalCamera
  39312. * @param name defines camera name
  39313. * @param position defines initial position
  39314. * @param interaxialDistance defines distance between each color axis
  39315. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39316. * @param scene defines the hosting scene
  39317. */
  39318. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39319. /**
  39320. * Gets camera class name
  39321. * @returns StereoscopicUniversalCamera
  39322. */
  39323. getClassName(): string;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. /**
  39328. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39329. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39330. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39331. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39332. */
  39333. export class VirtualJoysticksCamera extends FreeCamera {
  39334. /**
  39335. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39336. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39337. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39338. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39339. * @param name Define the name of the camera in the scene
  39340. * @param position Define the start position of the camera in the scene
  39341. * @param scene Define the scene the camera belongs to
  39342. */
  39343. constructor(name: string, position: Vector3, scene: Scene);
  39344. /**
  39345. * Gets the current object class name.
  39346. * @return the class name
  39347. */
  39348. getClassName(): string;
  39349. }
  39350. }
  39351. declare module BABYLON {
  39352. /**
  39353. * This represents all the required metrics to create a VR camera.
  39354. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39355. */
  39356. export class VRCameraMetrics {
  39357. /**
  39358. * Define the horizontal resolution off the screen.
  39359. */
  39360. hResolution: number;
  39361. /**
  39362. * Define the vertical resolution off the screen.
  39363. */
  39364. vResolution: number;
  39365. /**
  39366. * Define the horizontal screen size.
  39367. */
  39368. hScreenSize: number;
  39369. /**
  39370. * Define the vertical screen size.
  39371. */
  39372. vScreenSize: number;
  39373. /**
  39374. * Define the vertical screen center position.
  39375. */
  39376. vScreenCenter: number;
  39377. /**
  39378. * Define the distance of the eyes to the screen.
  39379. */
  39380. eyeToScreenDistance: number;
  39381. /**
  39382. * Define the distance between both lenses
  39383. */
  39384. lensSeparationDistance: number;
  39385. /**
  39386. * Define the distance between both viewer's eyes.
  39387. */
  39388. interpupillaryDistance: number;
  39389. /**
  39390. * Define the distortion factor of the VR postprocess.
  39391. * Please, touch with care.
  39392. */
  39393. distortionK: number[];
  39394. /**
  39395. * Define the chromatic aberration correction factors for the VR post process.
  39396. */
  39397. chromaAbCorrection: number[];
  39398. /**
  39399. * Define the scale factor of the post process.
  39400. * The smaller the better but the slower.
  39401. */
  39402. postProcessScaleFactor: number;
  39403. /**
  39404. * Define an offset for the lens center.
  39405. */
  39406. lensCenterOffset: number;
  39407. /**
  39408. * Define if the current vr camera should compensate the distortion of the lense or not.
  39409. */
  39410. compensateDistortion: boolean;
  39411. /**
  39412. * Defines if multiview should be enabled when rendering (Default: false)
  39413. */
  39414. multiviewEnabled: boolean;
  39415. /**
  39416. * Gets the rendering aspect ratio based on the provided resolutions.
  39417. */
  39418. readonly aspectRatio: number;
  39419. /**
  39420. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39421. */
  39422. readonly aspectRatioFov: number;
  39423. /**
  39424. * @hidden
  39425. */
  39426. readonly leftHMatrix: Matrix;
  39427. /**
  39428. * @hidden
  39429. */
  39430. readonly rightHMatrix: Matrix;
  39431. /**
  39432. * @hidden
  39433. */
  39434. readonly leftPreViewMatrix: Matrix;
  39435. /**
  39436. * @hidden
  39437. */
  39438. readonly rightPreViewMatrix: Matrix;
  39439. /**
  39440. * Get the default VRMetrics based on the most generic setup.
  39441. * @returns the default vr metrics
  39442. */
  39443. static GetDefault(): VRCameraMetrics;
  39444. }
  39445. }
  39446. declare module BABYLON {
  39447. /** @hidden */
  39448. export var vrDistortionCorrectionPixelShader: {
  39449. name: string;
  39450. shader: string;
  39451. };
  39452. }
  39453. declare module BABYLON {
  39454. /**
  39455. * VRDistortionCorrectionPostProcess used for mobile VR
  39456. */
  39457. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39458. private _isRightEye;
  39459. private _distortionFactors;
  39460. private _postProcessScaleFactor;
  39461. private _lensCenterOffset;
  39462. private _scaleIn;
  39463. private _scaleFactor;
  39464. private _lensCenter;
  39465. /**
  39466. * Initializes the VRDistortionCorrectionPostProcess
  39467. * @param name The name of the effect.
  39468. * @param camera The camera to apply the render pass to.
  39469. * @param isRightEye If this is for the right eye distortion
  39470. * @param vrMetrics All the required metrics for the VR camera
  39471. */
  39472. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. /**
  39477. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39478. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39479. */
  39480. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39481. /**
  39482. * Creates a new VRDeviceOrientationArcRotateCamera
  39483. * @param name defines camera name
  39484. * @param alpha defines the camera rotation along the logitudinal axis
  39485. * @param beta defines the camera rotation along the latitudinal axis
  39486. * @param radius defines the camera distance from its target
  39487. * @param target defines the camera target
  39488. * @param scene defines the scene the camera belongs to
  39489. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39490. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39491. */
  39492. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39493. /**
  39494. * Gets camera class name
  39495. * @returns VRDeviceOrientationArcRotateCamera
  39496. */
  39497. getClassName(): string;
  39498. }
  39499. }
  39500. declare module BABYLON {
  39501. /**
  39502. * Camera used to simulate VR rendering (based on FreeCamera)
  39503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39504. */
  39505. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39506. /**
  39507. * Creates a new VRDeviceOrientationFreeCamera
  39508. * @param name defines camera name
  39509. * @param position defines the start position of the camera
  39510. * @param scene defines the scene the camera belongs to
  39511. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39512. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39513. */
  39514. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39515. /**
  39516. * Gets camera class name
  39517. * @returns VRDeviceOrientationFreeCamera
  39518. */
  39519. getClassName(): string;
  39520. }
  39521. }
  39522. declare module BABYLON {
  39523. /**
  39524. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39525. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39526. */
  39527. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39528. /**
  39529. * Creates a new VRDeviceOrientationGamepadCamera
  39530. * @param name defines camera name
  39531. * @param position defines the start position of the camera
  39532. * @param scene defines the scene the camera belongs to
  39533. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39534. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39535. */
  39536. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39537. /**
  39538. * Gets camera class name
  39539. * @returns VRDeviceOrientationGamepadCamera
  39540. */
  39541. getClassName(): string;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /**
  39546. * Base class of materials working in push mode in babylon JS
  39547. * @hidden
  39548. */
  39549. export class PushMaterial extends Material {
  39550. protected _activeEffect: Effect;
  39551. protected _normalMatrix: Matrix;
  39552. /**
  39553. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39554. * This means that the material can keep using a previous shader while a new one is being compiled.
  39555. * This is mostly used when shader parallel compilation is supported (true by default)
  39556. */
  39557. allowShaderHotSwapping: boolean;
  39558. constructor(name: string, scene: Scene);
  39559. getEffect(): Effect;
  39560. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39561. /**
  39562. * Binds the given world matrix to the active effect
  39563. *
  39564. * @param world the matrix to bind
  39565. */
  39566. bindOnlyWorldMatrix(world: Matrix): void;
  39567. /**
  39568. * Binds the given normal matrix to the active effect
  39569. *
  39570. * @param normalMatrix the matrix to bind
  39571. */
  39572. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39573. bind(world: Matrix, mesh?: Mesh): void;
  39574. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39575. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39576. }
  39577. }
  39578. declare module BABYLON {
  39579. /**
  39580. * This groups all the flags used to control the materials channel.
  39581. */
  39582. export class MaterialFlags {
  39583. private static _DiffuseTextureEnabled;
  39584. /**
  39585. * Are diffuse textures enabled in the application.
  39586. */
  39587. static DiffuseTextureEnabled: boolean;
  39588. private static _AmbientTextureEnabled;
  39589. /**
  39590. * Are ambient textures enabled in the application.
  39591. */
  39592. static AmbientTextureEnabled: boolean;
  39593. private static _OpacityTextureEnabled;
  39594. /**
  39595. * Are opacity textures enabled in the application.
  39596. */
  39597. static OpacityTextureEnabled: boolean;
  39598. private static _ReflectionTextureEnabled;
  39599. /**
  39600. * Are reflection textures enabled in the application.
  39601. */
  39602. static ReflectionTextureEnabled: boolean;
  39603. private static _EmissiveTextureEnabled;
  39604. /**
  39605. * Are emissive textures enabled in the application.
  39606. */
  39607. static EmissiveTextureEnabled: boolean;
  39608. private static _SpecularTextureEnabled;
  39609. /**
  39610. * Are specular textures enabled in the application.
  39611. */
  39612. static SpecularTextureEnabled: boolean;
  39613. private static _BumpTextureEnabled;
  39614. /**
  39615. * Are bump textures enabled in the application.
  39616. */
  39617. static BumpTextureEnabled: boolean;
  39618. private static _LightmapTextureEnabled;
  39619. /**
  39620. * Are lightmap textures enabled in the application.
  39621. */
  39622. static LightmapTextureEnabled: boolean;
  39623. private static _RefractionTextureEnabled;
  39624. /**
  39625. * Are refraction textures enabled in the application.
  39626. */
  39627. static RefractionTextureEnabled: boolean;
  39628. private static _ColorGradingTextureEnabled;
  39629. /**
  39630. * Are color grading textures enabled in the application.
  39631. */
  39632. static ColorGradingTextureEnabled: boolean;
  39633. private static _FresnelEnabled;
  39634. /**
  39635. * Are fresnels enabled in the application.
  39636. */
  39637. static FresnelEnabled: boolean;
  39638. private static _ClearCoatTextureEnabled;
  39639. /**
  39640. * Are clear coat textures enabled in the application.
  39641. */
  39642. static ClearCoatTextureEnabled: boolean;
  39643. private static _ClearCoatBumpTextureEnabled;
  39644. /**
  39645. * Are clear coat bump textures enabled in the application.
  39646. */
  39647. static ClearCoatBumpTextureEnabled: boolean;
  39648. private static _ClearCoatTintTextureEnabled;
  39649. /**
  39650. * Are clear coat tint textures enabled in the application.
  39651. */
  39652. static ClearCoatTintTextureEnabled: boolean;
  39653. private static _SheenTextureEnabled;
  39654. /**
  39655. * Are sheen textures enabled in the application.
  39656. */
  39657. static SheenTextureEnabled: boolean;
  39658. private static _AnisotropicTextureEnabled;
  39659. /**
  39660. * Are anisotropic textures enabled in the application.
  39661. */
  39662. static AnisotropicTextureEnabled: boolean;
  39663. private static _ThicknessTextureEnabled;
  39664. /**
  39665. * Are thickness textures enabled in the application.
  39666. */
  39667. static ThicknessTextureEnabled: boolean;
  39668. }
  39669. }
  39670. declare module BABYLON {
  39671. /** @hidden */
  39672. export var defaultFragmentDeclaration: {
  39673. name: string;
  39674. shader: string;
  39675. };
  39676. }
  39677. declare module BABYLON {
  39678. /** @hidden */
  39679. export var defaultUboDeclaration: {
  39680. name: string;
  39681. shader: string;
  39682. };
  39683. }
  39684. declare module BABYLON {
  39685. /** @hidden */
  39686. export var lightFragmentDeclaration: {
  39687. name: string;
  39688. shader: string;
  39689. };
  39690. }
  39691. declare module BABYLON {
  39692. /** @hidden */
  39693. export var lightUboDeclaration: {
  39694. name: string;
  39695. shader: string;
  39696. };
  39697. }
  39698. declare module BABYLON {
  39699. /** @hidden */
  39700. export var lightsFragmentFunctions: {
  39701. name: string;
  39702. shader: string;
  39703. };
  39704. }
  39705. declare module BABYLON {
  39706. /** @hidden */
  39707. export var shadowsFragmentFunctions: {
  39708. name: string;
  39709. shader: string;
  39710. };
  39711. }
  39712. declare module BABYLON {
  39713. /** @hidden */
  39714. export var fresnelFunction: {
  39715. name: string;
  39716. shader: string;
  39717. };
  39718. }
  39719. declare module BABYLON {
  39720. /** @hidden */
  39721. export var reflectionFunction: {
  39722. name: string;
  39723. shader: string;
  39724. };
  39725. }
  39726. declare module BABYLON {
  39727. /** @hidden */
  39728. export var bumpFragmentFunctions: {
  39729. name: string;
  39730. shader: string;
  39731. };
  39732. }
  39733. declare module BABYLON {
  39734. /** @hidden */
  39735. export var logDepthDeclaration: {
  39736. name: string;
  39737. shader: string;
  39738. };
  39739. }
  39740. declare module BABYLON {
  39741. /** @hidden */
  39742. export var bumpFragment: {
  39743. name: string;
  39744. shader: string;
  39745. };
  39746. }
  39747. declare module BABYLON {
  39748. /** @hidden */
  39749. export var depthPrePass: {
  39750. name: string;
  39751. shader: string;
  39752. };
  39753. }
  39754. declare module BABYLON {
  39755. /** @hidden */
  39756. export var lightFragment: {
  39757. name: string;
  39758. shader: string;
  39759. };
  39760. }
  39761. declare module BABYLON {
  39762. /** @hidden */
  39763. export var logDepthFragment: {
  39764. name: string;
  39765. shader: string;
  39766. };
  39767. }
  39768. declare module BABYLON {
  39769. /** @hidden */
  39770. export var defaultPixelShader: {
  39771. name: string;
  39772. shader: string;
  39773. };
  39774. }
  39775. declare module BABYLON {
  39776. /** @hidden */
  39777. export var defaultVertexDeclaration: {
  39778. name: string;
  39779. shader: string;
  39780. };
  39781. }
  39782. declare module BABYLON {
  39783. /** @hidden */
  39784. export var bumpVertexDeclaration: {
  39785. name: string;
  39786. shader: string;
  39787. };
  39788. }
  39789. declare module BABYLON {
  39790. /** @hidden */
  39791. export var bumpVertex: {
  39792. name: string;
  39793. shader: string;
  39794. };
  39795. }
  39796. declare module BABYLON {
  39797. /** @hidden */
  39798. export var fogVertex: {
  39799. name: string;
  39800. shader: string;
  39801. };
  39802. }
  39803. declare module BABYLON {
  39804. /** @hidden */
  39805. export var shadowsVertex: {
  39806. name: string;
  39807. shader: string;
  39808. };
  39809. }
  39810. declare module BABYLON {
  39811. /** @hidden */
  39812. export var pointCloudVertex: {
  39813. name: string;
  39814. shader: string;
  39815. };
  39816. }
  39817. declare module BABYLON {
  39818. /** @hidden */
  39819. export var logDepthVertex: {
  39820. name: string;
  39821. shader: string;
  39822. };
  39823. }
  39824. declare module BABYLON {
  39825. /** @hidden */
  39826. export var defaultVertexShader: {
  39827. name: string;
  39828. shader: string;
  39829. };
  39830. }
  39831. declare module BABYLON {
  39832. /** @hidden */
  39833. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39834. MAINUV1: boolean;
  39835. MAINUV2: boolean;
  39836. DIFFUSE: boolean;
  39837. DIFFUSEDIRECTUV: number;
  39838. AMBIENT: boolean;
  39839. AMBIENTDIRECTUV: number;
  39840. OPACITY: boolean;
  39841. OPACITYDIRECTUV: number;
  39842. OPACITYRGB: boolean;
  39843. REFLECTION: boolean;
  39844. EMISSIVE: boolean;
  39845. EMISSIVEDIRECTUV: number;
  39846. SPECULAR: boolean;
  39847. SPECULARDIRECTUV: number;
  39848. BUMP: boolean;
  39849. BUMPDIRECTUV: number;
  39850. PARALLAX: boolean;
  39851. PARALLAXOCCLUSION: boolean;
  39852. SPECULAROVERALPHA: boolean;
  39853. CLIPPLANE: boolean;
  39854. CLIPPLANE2: boolean;
  39855. CLIPPLANE3: boolean;
  39856. CLIPPLANE4: boolean;
  39857. ALPHATEST: boolean;
  39858. DEPTHPREPASS: boolean;
  39859. ALPHAFROMDIFFUSE: boolean;
  39860. POINTSIZE: boolean;
  39861. FOG: boolean;
  39862. SPECULARTERM: boolean;
  39863. DIFFUSEFRESNEL: boolean;
  39864. OPACITYFRESNEL: boolean;
  39865. REFLECTIONFRESNEL: boolean;
  39866. REFRACTIONFRESNEL: boolean;
  39867. EMISSIVEFRESNEL: boolean;
  39868. FRESNEL: boolean;
  39869. NORMAL: boolean;
  39870. UV1: boolean;
  39871. UV2: boolean;
  39872. VERTEXCOLOR: boolean;
  39873. VERTEXALPHA: boolean;
  39874. NUM_BONE_INFLUENCERS: number;
  39875. BonesPerMesh: number;
  39876. BONETEXTURE: boolean;
  39877. INSTANCES: boolean;
  39878. GLOSSINESS: boolean;
  39879. ROUGHNESS: boolean;
  39880. EMISSIVEASILLUMINATION: boolean;
  39881. LINKEMISSIVEWITHDIFFUSE: boolean;
  39882. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39883. LIGHTMAP: boolean;
  39884. LIGHTMAPDIRECTUV: number;
  39885. OBJECTSPACE_NORMALMAP: boolean;
  39886. USELIGHTMAPASSHADOWMAP: boolean;
  39887. REFLECTIONMAP_3D: boolean;
  39888. REFLECTIONMAP_SPHERICAL: boolean;
  39889. REFLECTIONMAP_PLANAR: boolean;
  39890. REFLECTIONMAP_CUBIC: boolean;
  39891. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39892. REFLECTIONMAP_PROJECTION: boolean;
  39893. REFLECTIONMAP_SKYBOX: boolean;
  39894. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39895. REFLECTIONMAP_EXPLICIT: boolean;
  39896. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39897. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39898. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39899. INVERTCUBICMAP: boolean;
  39900. LOGARITHMICDEPTH: boolean;
  39901. REFRACTION: boolean;
  39902. REFRACTIONMAP_3D: boolean;
  39903. REFLECTIONOVERALPHA: boolean;
  39904. TWOSIDEDLIGHTING: boolean;
  39905. SHADOWFLOAT: boolean;
  39906. MORPHTARGETS: boolean;
  39907. MORPHTARGETS_NORMAL: boolean;
  39908. MORPHTARGETS_TANGENT: boolean;
  39909. MORPHTARGETS_UV: boolean;
  39910. NUM_MORPH_INFLUENCERS: number;
  39911. NONUNIFORMSCALING: boolean;
  39912. PREMULTIPLYALPHA: boolean;
  39913. IMAGEPROCESSING: boolean;
  39914. VIGNETTE: boolean;
  39915. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39916. VIGNETTEBLENDMODEOPAQUE: boolean;
  39917. TONEMAPPING: boolean;
  39918. TONEMAPPING_ACES: boolean;
  39919. CONTRAST: boolean;
  39920. COLORCURVES: boolean;
  39921. COLORGRADING: boolean;
  39922. COLORGRADING3D: boolean;
  39923. SAMPLER3DGREENDEPTH: boolean;
  39924. SAMPLER3DBGRMAP: boolean;
  39925. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39926. MULTIVIEW: boolean;
  39927. /**
  39928. * If the reflection texture on this material is in linear color space
  39929. * @hidden
  39930. */
  39931. IS_REFLECTION_LINEAR: boolean;
  39932. /**
  39933. * If the refraction texture on this material is in linear color space
  39934. * @hidden
  39935. */
  39936. IS_REFRACTION_LINEAR: boolean;
  39937. EXPOSURE: boolean;
  39938. constructor();
  39939. setReflectionMode(modeToEnable: string): void;
  39940. }
  39941. /**
  39942. * This is the default material used in Babylon. It is the best trade off between quality
  39943. * and performances.
  39944. * @see http://doc.babylonjs.com/babylon101/materials
  39945. */
  39946. export class StandardMaterial extends PushMaterial {
  39947. private _diffuseTexture;
  39948. /**
  39949. * The basic texture of the material as viewed under a light.
  39950. */
  39951. diffuseTexture: Nullable<BaseTexture>;
  39952. private _ambientTexture;
  39953. /**
  39954. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39955. */
  39956. ambientTexture: Nullable<BaseTexture>;
  39957. private _opacityTexture;
  39958. /**
  39959. * Define the transparency of the material from a texture.
  39960. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39961. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39962. */
  39963. opacityTexture: Nullable<BaseTexture>;
  39964. private _reflectionTexture;
  39965. /**
  39966. * Define the texture used to display the reflection.
  39967. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39968. */
  39969. reflectionTexture: Nullable<BaseTexture>;
  39970. private _emissiveTexture;
  39971. /**
  39972. * Define texture of the material as if self lit.
  39973. * This will be mixed in the final result even in the absence of light.
  39974. */
  39975. emissiveTexture: Nullable<BaseTexture>;
  39976. private _specularTexture;
  39977. /**
  39978. * Define how the color and intensity of the highlight given by the light in the material.
  39979. */
  39980. specularTexture: Nullable<BaseTexture>;
  39981. private _bumpTexture;
  39982. /**
  39983. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39984. * 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.
  39985. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39986. */
  39987. bumpTexture: Nullable<BaseTexture>;
  39988. private _lightmapTexture;
  39989. /**
  39990. * Complex lighting can be computationally expensive to compute at runtime.
  39991. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39992. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39993. */
  39994. lightmapTexture: Nullable<BaseTexture>;
  39995. private _refractionTexture;
  39996. /**
  39997. * Define the texture used to display the refraction.
  39998. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39999. */
  40000. refractionTexture: Nullable<BaseTexture>;
  40001. /**
  40002. * The color of the material lit by the environmental background lighting.
  40003. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40004. */
  40005. ambientColor: Color3;
  40006. /**
  40007. * The basic color of the material as viewed under a light.
  40008. */
  40009. diffuseColor: Color3;
  40010. /**
  40011. * Define how the color and intensity of the highlight given by the light in the material.
  40012. */
  40013. specularColor: Color3;
  40014. /**
  40015. * Define the color of the material as if self lit.
  40016. * This will be mixed in the final result even in the absence of light.
  40017. */
  40018. emissiveColor: Color3;
  40019. /**
  40020. * Defines how sharp are the highlights in the material.
  40021. * The bigger the value the sharper giving a more glossy feeling to the result.
  40022. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40023. */
  40024. specularPower: number;
  40025. private _useAlphaFromDiffuseTexture;
  40026. /**
  40027. * Does the transparency come from the diffuse texture alpha channel.
  40028. */
  40029. useAlphaFromDiffuseTexture: boolean;
  40030. private _useEmissiveAsIllumination;
  40031. /**
  40032. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40033. */
  40034. useEmissiveAsIllumination: boolean;
  40035. private _linkEmissiveWithDiffuse;
  40036. /**
  40037. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40038. * the emissive level when the final color is close to one.
  40039. */
  40040. linkEmissiveWithDiffuse: boolean;
  40041. private _useSpecularOverAlpha;
  40042. /**
  40043. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40044. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40045. */
  40046. useSpecularOverAlpha: boolean;
  40047. private _useReflectionOverAlpha;
  40048. /**
  40049. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40050. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40051. */
  40052. useReflectionOverAlpha: boolean;
  40053. private _disableLighting;
  40054. /**
  40055. * Does lights from the scene impacts this material.
  40056. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40057. */
  40058. disableLighting: boolean;
  40059. private _useObjectSpaceNormalMap;
  40060. /**
  40061. * Allows using an object space normal map (instead of tangent space).
  40062. */
  40063. useObjectSpaceNormalMap: boolean;
  40064. private _useParallax;
  40065. /**
  40066. * Is parallax enabled or not.
  40067. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40068. */
  40069. useParallax: boolean;
  40070. private _useParallaxOcclusion;
  40071. /**
  40072. * Is parallax occlusion enabled or not.
  40073. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40074. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40075. */
  40076. useParallaxOcclusion: boolean;
  40077. /**
  40078. * 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.
  40079. */
  40080. parallaxScaleBias: number;
  40081. private _roughness;
  40082. /**
  40083. * Helps to define how blurry the reflections should appears in the material.
  40084. */
  40085. roughness: number;
  40086. /**
  40087. * In case of refraction, define the value of the index of refraction.
  40088. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40089. */
  40090. indexOfRefraction: number;
  40091. /**
  40092. * Invert the refraction texture alongside the y axis.
  40093. * It can be useful with procedural textures or probe for instance.
  40094. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40095. */
  40096. invertRefractionY: boolean;
  40097. /**
  40098. * Defines the alpha limits in alpha test mode.
  40099. */
  40100. alphaCutOff: number;
  40101. private _useLightmapAsShadowmap;
  40102. /**
  40103. * In case of light mapping, define whether the map contains light or shadow informations.
  40104. */
  40105. useLightmapAsShadowmap: boolean;
  40106. private _diffuseFresnelParameters;
  40107. /**
  40108. * Define the diffuse fresnel parameters of the material.
  40109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40110. */
  40111. diffuseFresnelParameters: FresnelParameters;
  40112. private _opacityFresnelParameters;
  40113. /**
  40114. * Define the opacity fresnel parameters of the material.
  40115. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40116. */
  40117. opacityFresnelParameters: FresnelParameters;
  40118. private _reflectionFresnelParameters;
  40119. /**
  40120. * Define the reflection fresnel parameters of the material.
  40121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40122. */
  40123. reflectionFresnelParameters: FresnelParameters;
  40124. private _refractionFresnelParameters;
  40125. /**
  40126. * Define the refraction fresnel parameters of the material.
  40127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40128. */
  40129. refractionFresnelParameters: FresnelParameters;
  40130. private _emissiveFresnelParameters;
  40131. /**
  40132. * Define the emissive fresnel parameters of the material.
  40133. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40134. */
  40135. emissiveFresnelParameters: FresnelParameters;
  40136. private _useReflectionFresnelFromSpecular;
  40137. /**
  40138. * If true automatically deducts the fresnels values from the material specularity.
  40139. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40140. */
  40141. useReflectionFresnelFromSpecular: boolean;
  40142. private _useGlossinessFromSpecularMapAlpha;
  40143. /**
  40144. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40145. */
  40146. useGlossinessFromSpecularMapAlpha: boolean;
  40147. private _maxSimultaneousLights;
  40148. /**
  40149. * Defines the maximum number of lights that can be used in the material
  40150. */
  40151. maxSimultaneousLights: number;
  40152. private _invertNormalMapX;
  40153. /**
  40154. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40155. */
  40156. invertNormalMapX: boolean;
  40157. private _invertNormalMapY;
  40158. /**
  40159. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40160. */
  40161. invertNormalMapY: boolean;
  40162. private _twoSidedLighting;
  40163. /**
  40164. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40165. */
  40166. twoSidedLighting: boolean;
  40167. /**
  40168. * Default configuration related to image processing available in the standard Material.
  40169. */
  40170. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40171. /**
  40172. * Gets the image processing configuration used either in this material.
  40173. */
  40174. /**
  40175. * Sets the Default image processing configuration used either in the this material.
  40176. *
  40177. * If sets to null, the scene one is in use.
  40178. */
  40179. imageProcessingConfiguration: ImageProcessingConfiguration;
  40180. /**
  40181. * Keep track of the image processing observer to allow dispose and replace.
  40182. */
  40183. private _imageProcessingObserver;
  40184. /**
  40185. * Attaches a new image processing configuration to the Standard Material.
  40186. * @param configuration
  40187. */
  40188. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40189. /**
  40190. * Gets wether the color curves effect is enabled.
  40191. */
  40192. /**
  40193. * Sets wether the color curves effect is enabled.
  40194. */
  40195. cameraColorCurvesEnabled: boolean;
  40196. /**
  40197. * Gets wether the color grading effect is enabled.
  40198. */
  40199. /**
  40200. * Gets wether the color grading effect is enabled.
  40201. */
  40202. cameraColorGradingEnabled: boolean;
  40203. /**
  40204. * Gets wether tonemapping is enabled or not.
  40205. */
  40206. /**
  40207. * Sets wether tonemapping is enabled or not
  40208. */
  40209. cameraToneMappingEnabled: boolean;
  40210. /**
  40211. * The camera exposure used on this material.
  40212. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40213. * This corresponds to a photographic exposure.
  40214. */
  40215. /**
  40216. * The camera exposure used on this material.
  40217. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40218. * This corresponds to a photographic exposure.
  40219. */
  40220. cameraExposure: number;
  40221. /**
  40222. * Gets The camera contrast used on this material.
  40223. */
  40224. /**
  40225. * Sets The camera contrast used on this material.
  40226. */
  40227. cameraContrast: number;
  40228. /**
  40229. * Gets the Color Grading 2D Lookup Texture.
  40230. */
  40231. /**
  40232. * Sets the Color Grading 2D Lookup Texture.
  40233. */
  40234. cameraColorGradingTexture: Nullable<BaseTexture>;
  40235. /**
  40236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40238. * 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;
  40239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40240. */
  40241. /**
  40242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40244. * 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;
  40245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40246. */
  40247. cameraColorCurves: Nullable<ColorCurves>;
  40248. /**
  40249. * Custom callback helping to override the default shader used in the material.
  40250. */
  40251. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40252. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40253. protected _worldViewProjectionMatrix: Matrix;
  40254. protected _globalAmbientColor: Color3;
  40255. protected _useLogarithmicDepth: boolean;
  40256. protected _rebuildInParallel: boolean;
  40257. /**
  40258. * Instantiates a new standard material.
  40259. * This is the default material used in Babylon. It is the best trade off between quality
  40260. * and performances.
  40261. * @see http://doc.babylonjs.com/babylon101/materials
  40262. * @param name Define the name of the material in the scene
  40263. * @param scene Define the scene the material belong to
  40264. */
  40265. constructor(name: string, scene: Scene);
  40266. /**
  40267. * Gets a boolean indicating that current material needs to register RTT
  40268. */
  40269. readonly hasRenderTargetTextures: boolean;
  40270. /**
  40271. * Gets the current class name of the material e.g. "StandardMaterial"
  40272. * Mainly use in serialization.
  40273. * @returns the class name
  40274. */
  40275. getClassName(): string;
  40276. /**
  40277. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40278. * You can try switching to logarithmic depth.
  40279. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40280. */
  40281. useLogarithmicDepth: boolean;
  40282. /**
  40283. * Specifies if the material will require alpha blending
  40284. * @returns a boolean specifying if alpha blending is needed
  40285. */
  40286. needAlphaBlending(): boolean;
  40287. /**
  40288. * Specifies if this material should be rendered in alpha test mode
  40289. * @returns a boolean specifying if an alpha test is needed.
  40290. */
  40291. needAlphaTesting(): boolean;
  40292. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40293. /**
  40294. * Get the texture used for alpha test purpose.
  40295. * @returns the diffuse texture in case of the standard material.
  40296. */
  40297. getAlphaTestTexture(): Nullable<BaseTexture>;
  40298. /**
  40299. * Get if the submesh is ready to be used and all its information available.
  40300. * Child classes can use it to update shaders
  40301. * @param mesh defines the mesh to check
  40302. * @param subMesh defines which submesh to check
  40303. * @param useInstances specifies that instances should be used
  40304. * @returns a boolean indicating that the submesh is ready or not
  40305. */
  40306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40307. /**
  40308. * Builds the material UBO layouts.
  40309. * Used internally during the effect preparation.
  40310. */
  40311. buildUniformLayout(): void;
  40312. /**
  40313. * Unbinds the material from the mesh
  40314. */
  40315. unbind(): void;
  40316. /**
  40317. * Binds the submesh to this material by preparing the effect and shader to draw
  40318. * @param world defines the world transformation matrix
  40319. * @param mesh defines the mesh containing the submesh
  40320. * @param subMesh defines the submesh to bind the material to
  40321. */
  40322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40323. /**
  40324. * Get the list of animatables in the material.
  40325. * @returns the list of animatables object used in the material
  40326. */
  40327. getAnimatables(): IAnimatable[];
  40328. /**
  40329. * Gets the active textures from the material
  40330. * @returns an array of textures
  40331. */
  40332. getActiveTextures(): BaseTexture[];
  40333. /**
  40334. * Specifies if the material uses a texture
  40335. * @param texture defines the texture to check against the material
  40336. * @returns a boolean specifying if the material uses the texture
  40337. */
  40338. hasTexture(texture: BaseTexture): boolean;
  40339. /**
  40340. * Disposes the material
  40341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40343. */
  40344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40345. /**
  40346. * Makes a duplicate of the material, and gives it a new name
  40347. * @param name defines the new name for the duplicated material
  40348. * @returns the cloned material
  40349. */
  40350. clone(name: string): StandardMaterial;
  40351. /**
  40352. * Serializes this material in a JSON representation
  40353. * @returns the serialized material object
  40354. */
  40355. serialize(): any;
  40356. /**
  40357. * Creates a standard material from parsed material data
  40358. * @param source defines the JSON representation of the material
  40359. * @param scene defines the hosting scene
  40360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40361. * @returns a new standard material
  40362. */
  40363. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40364. /**
  40365. * Are diffuse textures enabled in the application.
  40366. */
  40367. static DiffuseTextureEnabled: boolean;
  40368. /**
  40369. * Are ambient textures enabled in the application.
  40370. */
  40371. static AmbientTextureEnabled: boolean;
  40372. /**
  40373. * Are opacity textures enabled in the application.
  40374. */
  40375. static OpacityTextureEnabled: boolean;
  40376. /**
  40377. * Are reflection textures enabled in the application.
  40378. */
  40379. static ReflectionTextureEnabled: boolean;
  40380. /**
  40381. * Are emissive textures enabled in the application.
  40382. */
  40383. static EmissiveTextureEnabled: boolean;
  40384. /**
  40385. * Are specular textures enabled in the application.
  40386. */
  40387. static SpecularTextureEnabled: boolean;
  40388. /**
  40389. * Are bump textures enabled in the application.
  40390. */
  40391. static BumpTextureEnabled: boolean;
  40392. /**
  40393. * Are lightmap textures enabled in the application.
  40394. */
  40395. static LightmapTextureEnabled: boolean;
  40396. /**
  40397. * Are refraction textures enabled in the application.
  40398. */
  40399. static RefractionTextureEnabled: boolean;
  40400. /**
  40401. * Are color grading textures enabled in the application.
  40402. */
  40403. static ColorGradingTextureEnabled: boolean;
  40404. /**
  40405. * Are fresnels enabled in the application.
  40406. */
  40407. static FresnelEnabled: boolean;
  40408. }
  40409. }
  40410. declare module BABYLON {
  40411. /**
  40412. * A class extending Texture allowing drawing on a texture
  40413. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40414. */
  40415. export class DynamicTexture extends Texture {
  40416. private _generateMipMaps;
  40417. private _canvas;
  40418. private _context;
  40419. private _engine;
  40420. /**
  40421. * Creates a DynamicTexture
  40422. * @param name defines the name of the texture
  40423. * @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
  40424. * @param scene defines the scene where you want the texture
  40425. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40426. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40427. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40428. */
  40429. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40430. /**
  40431. * Get the current class name of the texture useful for serialization or dynamic coding.
  40432. * @returns "DynamicTexture"
  40433. */
  40434. getClassName(): string;
  40435. /**
  40436. * Gets the current state of canRescale
  40437. */
  40438. readonly canRescale: boolean;
  40439. private _recreate;
  40440. /**
  40441. * Scales the texture
  40442. * @param ratio the scale factor to apply to both width and height
  40443. */
  40444. scale(ratio: number): void;
  40445. /**
  40446. * Resizes the texture
  40447. * @param width the new width
  40448. * @param height the new height
  40449. */
  40450. scaleTo(width: number, height: number): void;
  40451. /**
  40452. * Gets the context of the canvas used by the texture
  40453. * @returns the canvas context of the dynamic texture
  40454. */
  40455. getContext(): CanvasRenderingContext2D;
  40456. /**
  40457. * Clears the texture
  40458. */
  40459. clear(): void;
  40460. /**
  40461. * Updates the texture
  40462. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40463. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40464. */
  40465. update(invertY?: boolean, premulAlpha?: boolean): void;
  40466. /**
  40467. * Draws text onto the texture
  40468. * @param text defines the text to be drawn
  40469. * @param x defines the placement of the text from the left
  40470. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40471. * @param font defines the font to be used with font-style, font-size, font-name
  40472. * @param color defines the color used for the text
  40473. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40474. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40475. * @param update defines whether texture is immediately update (default is true)
  40476. */
  40477. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40478. /**
  40479. * Clones the texture
  40480. * @returns the clone of the texture.
  40481. */
  40482. clone(): DynamicTexture;
  40483. /**
  40484. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40485. * @returns a serialized dynamic texture object
  40486. */
  40487. serialize(): any;
  40488. /** @hidden */
  40489. _rebuild(): void;
  40490. }
  40491. }
  40492. declare module BABYLON {
  40493. /** @hidden */
  40494. export var imageProcessingPixelShader: {
  40495. name: string;
  40496. shader: string;
  40497. };
  40498. }
  40499. declare module BABYLON {
  40500. /**
  40501. * ImageProcessingPostProcess
  40502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40503. */
  40504. export class ImageProcessingPostProcess extends PostProcess {
  40505. /**
  40506. * Default configuration related to image processing available in the PBR Material.
  40507. */
  40508. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40509. /**
  40510. * Gets the image processing configuration used either in this material.
  40511. */
  40512. /**
  40513. * Sets the Default image processing configuration used either in the this material.
  40514. *
  40515. * If sets to null, the scene one is in use.
  40516. */
  40517. imageProcessingConfiguration: ImageProcessingConfiguration;
  40518. /**
  40519. * Keep track of the image processing observer to allow dispose and replace.
  40520. */
  40521. private _imageProcessingObserver;
  40522. /**
  40523. * Attaches a new image processing configuration to the PBR Material.
  40524. * @param configuration
  40525. */
  40526. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40527. /**
  40528. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40529. */
  40530. /**
  40531. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40532. */
  40533. colorCurves: Nullable<ColorCurves>;
  40534. /**
  40535. * Gets wether the color curves effect is enabled.
  40536. */
  40537. /**
  40538. * Sets wether the color curves effect is enabled.
  40539. */
  40540. colorCurvesEnabled: boolean;
  40541. /**
  40542. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40543. */
  40544. /**
  40545. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40546. */
  40547. colorGradingTexture: Nullable<BaseTexture>;
  40548. /**
  40549. * Gets wether the color grading effect is enabled.
  40550. */
  40551. /**
  40552. * Gets wether the color grading effect is enabled.
  40553. */
  40554. colorGradingEnabled: boolean;
  40555. /**
  40556. * Gets exposure used in the effect.
  40557. */
  40558. /**
  40559. * Sets exposure used in the effect.
  40560. */
  40561. exposure: number;
  40562. /**
  40563. * Gets wether tonemapping is enabled or not.
  40564. */
  40565. /**
  40566. * Sets wether tonemapping is enabled or not
  40567. */
  40568. toneMappingEnabled: boolean;
  40569. /**
  40570. * Gets the type of tone mapping effect.
  40571. */
  40572. /**
  40573. * Sets the type of tone mapping effect.
  40574. */
  40575. toneMappingType: number;
  40576. /**
  40577. * Gets contrast used in the effect.
  40578. */
  40579. /**
  40580. * Sets contrast used in the effect.
  40581. */
  40582. contrast: number;
  40583. /**
  40584. * Gets Vignette stretch size.
  40585. */
  40586. /**
  40587. * Sets Vignette stretch size.
  40588. */
  40589. vignetteStretch: number;
  40590. /**
  40591. * Gets Vignette centre X Offset.
  40592. */
  40593. /**
  40594. * Sets Vignette centre X Offset.
  40595. */
  40596. vignetteCentreX: number;
  40597. /**
  40598. * Gets Vignette centre Y Offset.
  40599. */
  40600. /**
  40601. * Sets Vignette centre Y Offset.
  40602. */
  40603. vignetteCentreY: number;
  40604. /**
  40605. * Gets Vignette weight or intensity of the vignette effect.
  40606. */
  40607. /**
  40608. * Sets Vignette weight or intensity of the vignette effect.
  40609. */
  40610. vignetteWeight: number;
  40611. /**
  40612. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40613. * if vignetteEnabled is set to true.
  40614. */
  40615. /**
  40616. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40617. * if vignetteEnabled is set to true.
  40618. */
  40619. vignetteColor: Color4;
  40620. /**
  40621. * Gets Camera field of view used by the Vignette effect.
  40622. */
  40623. /**
  40624. * Sets Camera field of view used by the Vignette effect.
  40625. */
  40626. vignetteCameraFov: number;
  40627. /**
  40628. * Gets the vignette blend mode allowing different kind of effect.
  40629. */
  40630. /**
  40631. * Sets the vignette blend mode allowing different kind of effect.
  40632. */
  40633. vignetteBlendMode: number;
  40634. /**
  40635. * Gets wether the vignette effect is enabled.
  40636. */
  40637. /**
  40638. * Sets wether the vignette effect is enabled.
  40639. */
  40640. vignetteEnabled: boolean;
  40641. private _fromLinearSpace;
  40642. /**
  40643. * Gets wether the input of the processing is in Gamma or Linear Space.
  40644. */
  40645. /**
  40646. * Sets wether the input of the processing is in Gamma or Linear Space.
  40647. */
  40648. fromLinearSpace: boolean;
  40649. /**
  40650. * Defines cache preventing GC.
  40651. */
  40652. private _defines;
  40653. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40654. /**
  40655. * "ImageProcessingPostProcess"
  40656. * @returns "ImageProcessingPostProcess"
  40657. */
  40658. getClassName(): string;
  40659. protected _updateParameters(): void;
  40660. dispose(camera?: Camera): void;
  40661. }
  40662. }
  40663. declare module BABYLON {
  40664. /**
  40665. * Class containing static functions to help procedurally build meshes
  40666. */
  40667. export class GroundBuilder {
  40668. /**
  40669. * Creates a ground mesh
  40670. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40671. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40673. * @param name defines the name of the mesh
  40674. * @param options defines the options used to create the mesh
  40675. * @param scene defines the hosting scene
  40676. * @returns the ground mesh
  40677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40678. */
  40679. static CreateGround(name: string, options: {
  40680. width?: number;
  40681. height?: number;
  40682. subdivisions?: number;
  40683. subdivisionsX?: number;
  40684. subdivisionsY?: number;
  40685. updatable?: boolean;
  40686. }, scene: any): Mesh;
  40687. /**
  40688. * Creates a tiled ground mesh
  40689. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40690. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40691. * * 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
  40692. * * 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
  40693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40694. * @param name defines the name of the mesh
  40695. * @param options defines the options used to create the mesh
  40696. * @param scene defines the hosting scene
  40697. * @returns the tiled ground mesh
  40698. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40699. */
  40700. static CreateTiledGround(name: string, options: {
  40701. xmin: number;
  40702. zmin: number;
  40703. xmax: number;
  40704. zmax: number;
  40705. subdivisions?: {
  40706. w: number;
  40707. h: number;
  40708. };
  40709. precision?: {
  40710. w: number;
  40711. h: number;
  40712. };
  40713. updatable?: boolean;
  40714. }, scene?: Nullable<Scene>): Mesh;
  40715. /**
  40716. * Creates a ground mesh from a height map
  40717. * * The parameter `url` sets the URL of the height map image resource.
  40718. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40719. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40720. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40721. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40722. * * 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.
  40723. * * 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).
  40724. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40726. * @param name defines the name of the mesh
  40727. * @param url defines the url to the height map
  40728. * @param options defines the options used to create the mesh
  40729. * @param scene defines the hosting scene
  40730. * @returns the ground mesh
  40731. * @see https://doc.babylonjs.com/babylon101/height_map
  40732. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40733. */
  40734. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40735. width?: number;
  40736. height?: number;
  40737. subdivisions?: number;
  40738. minHeight?: number;
  40739. maxHeight?: number;
  40740. colorFilter?: Color3;
  40741. alphaFilter?: number;
  40742. updatable?: boolean;
  40743. onReady?: (mesh: GroundMesh) => void;
  40744. }, scene?: Nullable<Scene>): GroundMesh;
  40745. }
  40746. }
  40747. declare module BABYLON {
  40748. /**
  40749. * Class containing static functions to help procedurally build meshes
  40750. */
  40751. export class TorusBuilder {
  40752. /**
  40753. * Creates a torus mesh
  40754. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40755. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40756. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40758. * * 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
  40759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40760. * @param name defines the name of the mesh
  40761. * @param options defines the options used to create the mesh
  40762. * @param scene defines the hosting scene
  40763. * @returns the torus mesh
  40764. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40765. */
  40766. static CreateTorus(name: string, options: {
  40767. diameter?: number;
  40768. thickness?: number;
  40769. tessellation?: number;
  40770. updatable?: boolean;
  40771. sideOrientation?: number;
  40772. frontUVs?: Vector4;
  40773. backUVs?: Vector4;
  40774. }, scene: any): Mesh;
  40775. }
  40776. }
  40777. declare module BABYLON {
  40778. /**
  40779. * Class containing static functions to help procedurally build meshes
  40780. */
  40781. export class CylinderBuilder {
  40782. /**
  40783. * Creates a cylinder or a cone mesh
  40784. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40785. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40786. * * 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.
  40787. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40788. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40789. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40790. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40791. * * 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).
  40792. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40793. * * 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).
  40794. * * 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
  40795. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40796. * * 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
  40797. * * 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.
  40798. * * If `enclose` is false, a ring surface is one element.
  40799. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40800. * * 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
  40801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40802. * * 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
  40803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40804. * @param name defines the name of the mesh
  40805. * @param options defines the options used to create the mesh
  40806. * @param scene defines the hosting scene
  40807. * @returns the cylinder mesh
  40808. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40809. */
  40810. static CreateCylinder(name: string, options: {
  40811. height?: number;
  40812. diameterTop?: number;
  40813. diameterBottom?: number;
  40814. diameter?: number;
  40815. tessellation?: number;
  40816. subdivisions?: number;
  40817. arc?: number;
  40818. faceColors?: Color4[];
  40819. faceUV?: Vector4[];
  40820. updatable?: boolean;
  40821. hasRings?: boolean;
  40822. enclose?: boolean;
  40823. cap?: number;
  40824. sideOrientation?: number;
  40825. frontUVs?: Vector4;
  40826. backUVs?: Vector4;
  40827. }, scene: any): Mesh;
  40828. }
  40829. }
  40830. declare module BABYLON {
  40831. /**
  40832. * Options to modify the vr teleportation behavior.
  40833. */
  40834. export interface VRTeleportationOptions {
  40835. /**
  40836. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40837. */
  40838. floorMeshName?: string;
  40839. /**
  40840. * A list of meshes to be used as the teleportation floor. (default: empty)
  40841. */
  40842. floorMeshes?: Mesh[];
  40843. }
  40844. /**
  40845. * Options to modify the vr experience helper's behavior.
  40846. */
  40847. export interface VRExperienceHelperOptions extends WebVROptions {
  40848. /**
  40849. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40850. */
  40851. createDeviceOrientationCamera?: boolean;
  40852. /**
  40853. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40854. */
  40855. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40856. /**
  40857. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40858. */
  40859. laserToggle?: boolean;
  40860. /**
  40861. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40862. */
  40863. floorMeshes?: Mesh[];
  40864. /**
  40865. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40866. */
  40867. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40868. }
  40869. /**
  40870. * Event containing information after VR has been entered
  40871. */
  40872. export class OnAfterEnteringVRObservableEvent {
  40873. /**
  40874. * If entering vr was successful
  40875. */
  40876. success: boolean;
  40877. }
  40878. /**
  40879. * Helps to quickly add VR support to an existing scene.
  40880. * See http://doc.babylonjs.com/how_to/webvr_helper
  40881. */
  40882. export class VRExperienceHelper {
  40883. /** Options to modify the vr experience helper's behavior. */
  40884. webVROptions: VRExperienceHelperOptions;
  40885. private _scene;
  40886. private _position;
  40887. private _btnVR;
  40888. private _btnVRDisplayed;
  40889. private _webVRsupported;
  40890. private _webVRready;
  40891. private _webVRrequesting;
  40892. private _webVRpresenting;
  40893. private _hasEnteredVR;
  40894. private _fullscreenVRpresenting;
  40895. private _canvas;
  40896. private _webVRCamera;
  40897. private _vrDeviceOrientationCamera;
  40898. private _deviceOrientationCamera;
  40899. private _existingCamera;
  40900. private _onKeyDown;
  40901. private _onVrDisplayPresentChange;
  40902. private _onVRDisplayChanged;
  40903. private _onVRRequestPresentStart;
  40904. private _onVRRequestPresentComplete;
  40905. /**
  40906. * 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)
  40907. */
  40908. enableGazeEvenWhenNoPointerLock: boolean;
  40909. /**
  40910. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40911. */
  40912. exitVROnDoubleTap: boolean;
  40913. /**
  40914. * Observable raised right before entering VR.
  40915. */
  40916. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40917. /**
  40918. * Observable raised when entering VR has completed.
  40919. */
  40920. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40921. /**
  40922. * Observable raised when exiting VR.
  40923. */
  40924. onExitingVRObservable: Observable<VRExperienceHelper>;
  40925. /**
  40926. * Observable raised when controller mesh is loaded.
  40927. */
  40928. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40929. /** Return this.onEnteringVRObservable
  40930. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40931. */
  40932. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40933. /** Return this.onExitingVRObservable
  40934. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40935. */
  40936. readonly onExitingVR: Observable<VRExperienceHelper>;
  40937. /** Return this.onControllerMeshLoadedObservable
  40938. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40939. */
  40940. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40941. private _rayLength;
  40942. private _useCustomVRButton;
  40943. private _teleportationRequested;
  40944. private _teleportActive;
  40945. private _floorMeshName;
  40946. private _floorMeshesCollection;
  40947. private _rotationAllowed;
  40948. private _teleportBackwardsVector;
  40949. private _teleportationTarget;
  40950. private _isDefaultTeleportationTarget;
  40951. private _postProcessMove;
  40952. private _teleportationFillColor;
  40953. private _teleportationBorderColor;
  40954. private _rotationAngle;
  40955. private _haloCenter;
  40956. private _cameraGazer;
  40957. private _padSensibilityUp;
  40958. private _padSensibilityDown;
  40959. private _leftController;
  40960. private _rightController;
  40961. /**
  40962. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40963. */
  40964. onNewMeshSelected: Observable<AbstractMesh>;
  40965. /**
  40966. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40967. * This observable will provide the mesh and the controller used to select the mesh
  40968. */
  40969. onMeshSelectedWithController: Observable<{
  40970. mesh: AbstractMesh;
  40971. controller: WebVRController;
  40972. }>;
  40973. /**
  40974. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40975. */
  40976. onNewMeshPicked: Observable<PickingInfo>;
  40977. private _circleEase;
  40978. /**
  40979. * Observable raised before camera teleportation
  40980. */
  40981. onBeforeCameraTeleport: Observable<Vector3>;
  40982. /**
  40983. * Observable raised after camera teleportation
  40984. */
  40985. onAfterCameraTeleport: Observable<Vector3>;
  40986. /**
  40987. * Observable raised when current selected mesh gets unselected
  40988. */
  40989. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40990. private _raySelectionPredicate;
  40991. /**
  40992. * To be optionaly changed by user to define custom ray selection
  40993. */
  40994. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40995. /**
  40996. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40997. */
  40998. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40999. /**
  41000. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41001. */
  41002. teleportationEnabled: boolean;
  41003. private _defaultHeight;
  41004. private _teleportationInitialized;
  41005. private _interactionsEnabled;
  41006. private _interactionsRequested;
  41007. private _displayGaze;
  41008. private _displayLaserPointer;
  41009. /**
  41010. * The mesh used to display where the user is going to teleport.
  41011. */
  41012. /**
  41013. * Sets the mesh to be used to display where the user is going to teleport.
  41014. */
  41015. teleportationTarget: Mesh;
  41016. /**
  41017. * 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
  41018. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41019. * See http://doc.babylonjs.com/resources/baking_transformations
  41020. */
  41021. gazeTrackerMesh: Mesh;
  41022. /**
  41023. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41024. */
  41025. updateGazeTrackerScale: boolean;
  41026. /**
  41027. * If the gaze trackers color should be updated when selecting meshes
  41028. */
  41029. updateGazeTrackerColor: boolean;
  41030. /**
  41031. * If the controller laser color should be updated when selecting meshes
  41032. */
  41033. updateControllerLaserColor: boolean;
  41034. /**
  41035. * The gaze tracking mesh corresponding to the left controller
  41036. */
  41037. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41038. /**
  41039. * The gaze tracking mesh corresponding to the right controller
  41040. */
  41041. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41042. /**
  41043. * If the ray of the gaze should be displayed.
  41044. */
  41045. /**
  41046. * Sets if the ray of the gaze should be displayed.
  41047. */
  41048. displayGaze: boolean;
  41049. /**
  41050. * If the ray of the LaserPointer should be displayed.
  41051. */
  41052. /**
  41053. * Sets if the ray of the LaserPointer should be displayed.
  41054. */
  41055. displayLaserPointer: boolean;
  41056. /**
  41057. * The deviceOrientationCamera used as the camera when not in VR.
  41058. */
  41059. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41060. /**
  41061. * Based on the current WebVR support, returns the current VR camera used.
  41062. */
  41063. readonly currentVRCamera: Nullable<Camera>;
  41064. /**
  41065. * The webVRCamera which is used when in VR.
  41066. */
  41067. readonly webVRCamera: WebVRFreeCamera;
  41068. /**
  41069. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41070. */
  41071. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41072. /**
  41073. * The html button that is used to trigger entering into VR.
  41074. */
  41075. readonly vrButton: Nullable<HTMLButtonElement>;
  41076. private readonly _teleportationRequestInitiated;
  41077. /**
  41078. * Defines wether or not Pointer lock should be requested when switching to
  41079. * full screen.
  41080. */
  41081. requestPointerLockOnFullScreen: boolean;
  41082. /**
  41083. * Instantiates a VRExperienceHelper.
  41084. * Helps to quickly add VR support to an existing scene.
  41085. * @param scene The scene the VRExperienceHelper belongs to.
  41086. * @param webVROptions Options to modify the vr experience helper's behavior.
  41087. */
  41088. constructor(scene: Scene,
  41089. /** Options to modify the vr experience helper's behavior. */
  41090. webVROptions?: VRExperienceHelperOptions);
  41091. private _onDefaultMeshLoaded;
  41092. private _onResize;
  41093. private _onFullscreenChange;
  41094. /**
  41095. * Gets a value indicating if we are currently in VR mode.
  41096. */
  41097. readonly isInVRMode: boolean;
  41098. private onVrDisplayPresentChange;
  41099. private onVRDisplayChanged;
  41100. private moveButtonToBottomRight;
  41101. private displayVRButton;
  41102. private updateButtonVisibility;
  41103. private _cachedAngularSensibility;
  41104. /**
  41105. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41106. * Otherwise, will use the fullscreen API.
  41107. */
  41108. enterVR(): void;
  41109. /**
  41110. * Attempt to exit VR, or fullscreen.
  41111. */
  41112. exitVR(): void;
  41113. /**
  41114. * The position of the vr experience helper.
  41115. */
  41116. /**
  41117. * Sets the position of the vr experience helper.
  41118. */
  41119. position: Vector3;
  41120. /**
  41121. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41122. */
  41123. enableInteractions(): void;
  41124. private readonly _noControllerIsActive;
  41125. private beforeRender;
  41126. private _isTeleportationFloor;
  41127. /**
  41128. * Adds a floor mesh to be used for teleportation.
  41129. * @param floorMesh the mesh to be used for teleportation.
  41130. */
  41131. addFloorMesh(floorMesh: Mesh): void;
  41132. /**
  41133. * Removes a floor mesh from being used for teleportation.
  41134. * @param floorMesh the mesh to be removed.
  41135. */
  41136. removeFloorMesh(floorMesh: Mesh): void;
  41137. /**
  41138. * Enables interactions and teleportation using the VR controllers and gaze.
  41139. * @param vrTeleportationOptions options to modify teleportation behavior.
  41140. */
  41141. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41142. private _onNewGamepadConnected;
  41143. private _tryEnableInteractionOnController;
  41144. private _onNewGamepadDisconnected;
  41145. private _enableInteractionOnController;
  41146. private _checkTeleportWithRay;
  41147. private _checkRotate;
  41148. private _checkTeleportBackwards;
  41149. private _enableTeleportationOnController;
  41150. private _createTeleportationCircles;
  41151. private _displayTeleportationTarget;
  41152. private _hideTeleportationTarget;
  41153. private _rotateCamera;
  41154. private _moveTeleportationSelectorTo;
  41155. private _workingVector;
  41156. private _workingQuaternion;
  41157. private _workingMatrix;
  41158. /**
  41159. * Teleports the users feet to the desired location
  41160. * @param location The location where the user's feet should be placed
  41161. */
  41162. teleportCamera(location: Vector3): void;
  41163. private _convertNormalToDirectionOfRay;
  41164. private _castRayAndSelectObject;
  41165. private _notifySelectedMeshUnselected;
  41166. /**
  41167. * Sets the color of the laser ray from the vr controllers.
  41168. * @param color new color for the ray.
  41169. */
  41170. changeLaserColor(color: Color3): void;
  41171. /**
  41172. * Sets the color of the ray from the vr headsets gaze.
  41173. * @param color new color for the ray.
  41174. */
  41175. changeGazeColor(color: Color3): void;
  41176. /**
  41177. * Exits VR and disposes of the vr experience helper
  41178. */
  41179. dispose(): void;
  41180. /**
  41181. * Gets the name of the VRExperienceHelper class
  41182. * @returns "VRExperienceHelper"
  41183. */
  41184. getClassName(): string;
  41185. }
  41186. }
  41187. declare module BABYLON {
  41188. /**
  41189. * Manages an XRSession to work with Babylon's engine
  41190. * @see https://doc.babylonjs.com/how_to/webxr
  41191. */
  41192. export class WebXRSessionManager implements IDisposable {
  41193. private scene;
  41194. /**
  41195. * Fires every time a new xrFrame arrives which can be used to update the camera
  41196. */
  41197. onXRFrameObservable: Observable<any>;
  41198. /**
  41199. * Fires when the xr session is ended either by the device or manually done
  41200. */
  41201. onXRSessionEnded: Observable<any>;
  41202. /**
  41203. * Underlying xr session
  41204. */
  41205. session: XRSession;
  41206. /**
  41207. * Type of reference space used when creating the session
  41208. */
  41209. referenceSpace: XRReferenceSpace;
  41210. /** @hidden */
  41211. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41212. /**
  41213. * Current XR frame
  41214. */
  41215. currentFrame: Nullable<XRFrame>;
  41216. private _xrNavigator;
  41217. private baseLayer;
  41218. /**
  41219. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41220. * @param scene The scene which the session should be created for
  41221. */
  41222. constructor(scene: Scene);
  41223. /**
  41224. * Initializes the manager
  41225. * After initialization enterXR can be called to start an XR session
  41226. * @returns Promise which resolves after it is initialized
  41227. */
  41228. initializeAsync(): Promise<void>;
  41229. /**
  41230. * Initializes an xr session
  41231. * @param xrSessionMode mode to initialize
  41232. * @returns a promise which will resolve once the session has been initialized
  41233. */
  41234. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41235. /**
  41236. * Sets the reference space on the xr session
  41237. * @param referenceSpace space to set
  41238. * @returns a promise that will resolve once the reference space has been set
  41239. */
  41240. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41241. /**
  41242. * Updates the render state of the session
  41243. * @param state state to set
  41244. * @returns a promise that resolves once the render state has been updated
  41245. */
  41246. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41247. /**
  41248. * Starts rendering to the xr layer
  41249. * @returns a promise that will resolve once rendering has started
  41250. */
  41251. startRenderingToXRAsync(): Promise<void>;
  41252. /**
  41253. * Stops the xrSession and restores the renderloop
  41254. * @returns Promise which resolves after it exits XR
  41255. */
  41256. exitXRAsync(): Promise<unknown>;
  41257. /**
  41258. * Checks if a session would be supported for the creation options specified
  41259. * @param sessionMode session mode to check if supported eg. immersive-vr
  41260. * @returns true if supported
  41261. */
  41262. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41263. /**
  41264. * @hidden
  41265. * Converts the render layer of xrSession to a render target
  41266. * @param session session to create render target for
  41267. * @param scene scene the new render target should be created for
  41268. */
  41269. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41270. /**
  41271. * Disposes of the session manager
  41272. */
  41273. dispose(): void;
  41274. }
  41275. }
  41276. declare module BABYLON {
  41277. /**
  41278. * WebXR Camera which holds the views for the xrSession
  41279. * @see https://doc.babylonjs.com/how_to/webxr
  41280. */
  41281. export class WebXRCamera extends FreeCamera {
  41282. private static _TmpMatrix;
  41283. /**
  41284. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41285. * @param name the name of the camera
  41286. * @param scene the scene to add the camera to
  41287. */
  41288. constructor(name: string, scene: Scene);
  41289. private _updateNumberOfRigCameras;
  41290. /** @hidden */
  41291. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41292. /**
  41293. * Updates the cameras position from the current pose information of the XR session
  41294. * @param xrSessionManager the session containing pose information
  41295. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41296. */
  41297. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41298. }
  41299. }
  41300. declare module BABYLON {
  41301. /**
  41302. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41303. */
  41304. export class WebXRManagedOutputCanvas implements IDisposable {
  41305. private helper;
  41306. private _canvas;
  41307. /**
  41308. * xrpresent context of the canvas which can be used to display/mirror xr content
  41309. */
  41310. canvasContext: WebGLRenderingContext;
  41311. /**
  41312. * xr layer for the canvas
  41313. */
  41314. xrLayer: Nullable<XRWebGLLayer>;
  41315. /**
  41316. * Initializes the xr layer for the session
  41317. * @param xrSession xr session
  41318. * @returns a promise that will resolve once the XR Layer has been created
  41319. */
  41320. initializeXRLayerAsync(xrSession: any): any;
  41321. /**
  41322. * Initializes the canvas to be added/removed upon entering/exiting xr
  41323. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41324. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41325. */
  41326. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41327. /**
  41328. * Disposes of the object
  41329. */
  41330. dispose(): void;
  41331. private _setManagedOutputCanvas;
  41332. private _addCanvas;
  41333. private _removeCanvas;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * States of the webXR experience
  41339. */
  41340. export enum WebXRState {
  41341. /**
  41342. * Transitioning to being in XR mode
  41343. */
  41344. ENTERING_XR = 0,
  41345. /**
  41346. * Transitioning to non XR mode
  41347. */
  41348. EXITING_XR = 1,
  41349. /**
  41350. * In XR mode and presenting
  41351. */
  41352. IN_XR = 2,
  41353. /**
  41354. * Not entered XR mode
  41355. */
  41356. NOT_IN_XR = 3
  41357. }
  41358. /**
  41359. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41360. * @see https://doc.babylonjs.com/how_to/webxr
  41361. */
  41362. export class WebXRExperienceHelper implements IDisposable {
  41363. private scene;
  41364. /**
  41365. * 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
  41366. */
  41367. container: AbstractMesh;
  41368. /**
  41369. * Camera used to render xr content
  41370. */
  41371. camera: WebXRCamera;
  41372. /**
  41373. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41374. */
  41375. state: WebXRState;
  41376. private _setState;
  41377. private static _TmpVector;
  41378. /**
  41379. * Fires when the state of the experience helper has changed
  41380. */
  41381. onStateChangedObservable: Observable<WebXRState>;
  41382. /** Session manager used to keep track of xr session */
  41383. sessionManager: WebXRSessionManager;
  41384. private _nonVRCamera;
  41385. private _originalSceneAutoClear;
  41386. private _supported;
  41387. /**
  41388. * Creates the experience helper
  41389. * @param scene the scene to attach the experience helper to
  41390. * @returns a promise for the experience helper
  41391. */
  41392. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41393. /**
  41394. * Creates a WebXRExperienceHelper
  41395. * @param scene The scene the helper should be created in
  41396. */
  41397. private constructor();
  41398. /**
  41399. * Exits XR mode and returns the scene to its original state
  41400. * @returns promise that resolves after xr mode has exited
  41401. */
  41402. exitXRAsync(): Promise<unknown>;
  41403. /**
  41404. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41405. * @param sessionCreationOptions options for the XR session
  41406. * @param referenceSpaceType frame of reference of the XR session
  41407. * @param outputCanvas the output canvas that will be used to enter XR mode
  41408. * @returns promise that resolves after xr mode has entered
  41409. */
  41410. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41411. /**
  41412. * Updates the global position of the camera by moving the camera's container
  41413. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41414. * @param position The desired global position of the camera
  41415. */
  41416. setPositionOfCameraUsingContainer(position: Vector3): void;
  41417. /**
  41418. * Rotates the xr camera by rotating the camera's container around the camera's position
  41419. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41420. * @param rotation the desired quaternion rotation to apply to the camera
  41421. */
  41422. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41423. /**
  41424. * Disposes of the experience helper
  41425. */
  41426. dispose(): void;
  41427. }
  41428. }
  41429. declare module BABYLON {
  41430. /**
  41431. * Button which can be used to enter a different mode of XR
  41432. */
  41433. export class WebXREnterExitUIButton {
  41434. /** button element */
  41435. element: HTMLElement;
  41436. /** XR initialization options for the button */
  41437. sessionMode: XRSessionMode;
  41438. /** Reference space type */
  41439. referenceSpaceType: XRReferenceSpaceType;
  41440. /**
  41441. * Creates a WebXREnterExitUIButton
  41442. * @param element button element
  41443. * @param sessionMode XR initialization session mode
  41444. * @param referenceSpaceType the type of reference space to be used
  41445. */
  41446. constructor(
  41447. /** button element */
  41448. element: HTMLElement,
  41449. /** XR initialization options for the button */
  41450. sessionMode: XRSessionMode,
  41451. /** Reference space type */
  41452. referenceSpaceType: XRReferenceSpaceType);
  41453. /**
  41454. * Overwritable function which can be used to update the button's visuals when the state changes
  41455. * @param activeButton the current active button in the UI
  41456. */
  41457. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41458. }
  41459. /**
  41460. * Options to create the webXR UI
  41461. */
  41462. export class WebXREnterExitUIOptions {
  41463. /**
  41464. * Context to enter xr with
  41465. */
  41466. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41467. /**
  41468. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41469. */
  41470. customButtons?: Array<WebXREnterExitUIButton>;
  41471. }
  41472. /**
  41473. * UI to allow the user to enter/exit XR mode
  41474. */
  41475. export class WebXREnterExitUI implements IDisposable {
  41476. private scene;
  41477. private _overlay;
  41478. private _buttons;
  41479. private _activeButton;
  41480. /**
  41481. * Fired every time the active button is changed.
  41482. *
  41483. * When xr is entered via a button that launches xr that button will be the callback parameter
  41484. *
  41485. * When exiting xr the callback parameter will be null)
  41486. */
  41487. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41488. /**
  41489. * Creates UI to allow the user to enter/exit XR mode
  41490. * @param scene the scene to add the ui to
  41491. * @param helper the xr experience helper to enter/exit xr with
  41492. * @param options options to configure the UI
  41493. * @returns the created ui
  41494. */
  41495. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41496. private constructor();
  41497. private _updateButtons;
  41498. /**
  41499. * Disposes of the object
  41500. */
  41501. dispose(): void;
  41502. }
  41503. }
  41504. declare module BABYLON {
  41505. /**
  41506. * Represents an XR input
  41507. */
  41508. export class WebXRController {
  41509. private scene;
  41510. /** The underlying input source for the controller */
  41511. inputSource: XRInputSource;
  41512. private parentContainer;
  41513. /**
  41514. * 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
  41515. */
  41516. grip?: AbstractMesh;
  41517. /**
  41518. * Pointer which can be used to select objects or attach a visible laser to
  41519. */
  41520. pointer: AbstractMesh;
  41521. /**
  41522. * Event that fires when the controller is removed/disposed
  41523. */
  41524. onDisposeObservable: Observable<{}>;
  41525. private _tmpMatrix;
  41526. private _tmpQuaternion;
  41527. private _tmpVector;
  41528. /**
  41529. * Creates the controller
  41530. * @see https://doc.babylonjs.com/how_to/webxr
  41531. * @param scene the scene which the controller should be associated to
  41532. * @param inputSource the underlying input source for the controller
  41533. * @param parentContainer parent that the controller meshes should be children of
  41534. */
  41535. constructor(scene: Scene,
  41536. /** The underlying input source for the controller */
  41537. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41538. /**
  41539. * Updates the controller pose based on the given XRFrame
  41540. * @param xrFrame xr frame to update the pose with
  41541. * @param referenceSpace reference space to use
  41542. */
  41543. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41544. /**
  41545. * Gets a world space ray coming from the controller
  41546. * @param result the resulting ray
  41547. */
  41548. getWorldPointerRayToRef(result: Ray): void;
  41549. /**
  41550. * Disposes of the object
  41551. */
  41552. dispose(): void;
  41553. }
  41554. }
  41555. declare module BABYLON {
  41556. /**
  41557. * XR input used to track XR inputs such as controllers/rays
  41558. */
  41559. export class WebXRInput implements IDisposable {
  41560. /**
  41561. * Base experience the input listens to
  41562. */
  41563. baseExperience: WebXRExperienceHelper;
  41564. /**
  41565. * XR controllers being tracked
  41566. */
  41567. controllers: Array<WebXRController>;
  41568. private _frameObserver;
  41569. private _stateObserver;
  41570. /**
  41571. * Event when a controller has been connected/added
  41572. */
  41573. onControllerAddedObservable: Observable<WebXRController>;
  41574. /**
  41575. * Event when a controller has been removed/disconnected
  41576. */
  41577. onControllerRemovedObservable: Observable<WebXRController>;
  41578. /**
  41579. * Initializes the WebXRInput
  41580. * @param baseExperience experience helper which the input should be created for
  41581. */
  41582. constructor(
  41583. /**
  41584. * Base experience the input listens to
  41585. */
  41586. baseExperience: WebXRExperienceHelper);
  41587. private _onInputSourcesChange;
  41588. private _addAndRemoveControllers;
  41589. /**
  41590. * Disposes of the object
  41591. */
  41592. dispose(): void;
  41593. }
  41594. }
  41595. declare module BABYLON {
  41596. /**
  41597. * Enables teleportation
  41598. */
  41599. export class WebXRControllerTeleportation {
  41600. private _teleportationFillColor;
  41601. private _teleportationBorderColor;
  41602. private _tmpRay;
  41603. private _tmpVector;
  41604. /**
  41605. * Creates a WebXRControllerTeleportation
  41606. * @param input input manager to add teleportation to
  41607. * @param floorMeshes floormeshes which can be teleported to
  41608. */
  41609. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41610. }
  41611. }
  41612. declare module BABYLON {
  41613. /**
  41614. * Handles pointer input automatically for the pointer of XR controllers
  41615. */
  41616. export class WebXRControllerPointerSelection {
  41617. private static _idCounter;
  41618. private _tmpRay;
  41619. /**
  41620. * Creates a WebXRControllerPointerSelection
  41621. * @param input input manager to setup pointer selection
  41622. */
  41623. constructor(input: WebXRInput);
  41624. private _convertNormalToDirectionOfRay;
  41625. private _updatePointerDistance;
  41626. }
  41627. }
  41628. declare module BABYLON {
  41629. /**
  41630. * Class used to represent data loading progression
  41631. */
  41632. export class SceneLoaderProgressEvent {
  41633. /** defines if data length to load can be evaluated */
  41634. readonly lengthComputable: boolean;
  41635. /** defines the loaded data length */
  41636. readonly loaded: number;
  41637. /** defines the data length to load */
  41638. readonly total: number;
  41639. /**
  41640. * Create a new progress event
  41641. * @param lengthComputable defines if data length to load can be evaluated
  41642. * @param loaded defines the loaded data length
  41643. * @param total defines the data length to load
  41644. */
  41645. constructor(
  41646. /** defines if data length to load can be evaluated */
  41647. lengthComputable: boolean,
  41648. /** defines the loaded data length */
  41649. loaded: number,
  41650. /** defines the data length to load */
  41651. total: number);
  41652. /**
  41653. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41654. * @param event defines the source event
  41655. * @returns a new SceneLoaderProgressEvent
  41656. */
  41657. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41658. }
  41659. /**
  41660. * Interface used by SceneLoader plugins to define supported file extensions
  41661. */
  41662. export interface ISceneLoaderPluginExtensions {
  41663. /**
  41664. * Defines the list of supported extensions
  41665. */
  41666. [extension: string]: {
  41667. isBinary: boolean;
  41668. };
  41669. }
  41670. /**
  41671. * Interface used by SceneLoader plugin factory
  41672. */
  41673. export interface ISceneLoaderPluginFactory {
  41674. /**
  41675. * Defines the name of the factory
  41676. */
  41677. name: string;
  41678. /**
  41679. * Function called to create a new plugin
  41680. * @return the new plugin
  41681. */
  41682. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41683. /**
  41684. * Boolean indicating if the plugin can direct load specific data
  41685. */
  41686. canDirectLoad?: (data: string) => boolean;
  41687. }
  41688. /**
  41689. * Interface used to define a SceneLoader plugin
  41690. */
  41691. export interface ISceneLoaderPlugin {
  41692. /**
  41693. * The friendly name of this plugin.
  41694. */
  41695. name: string;
  41696. /**
  41697. * The file extensions supported by this plugin.
  41698. */
  41699. extensions: string | ISceneLoaderPluginExtensions;
  41700. /**
  41701. * Import meshes into a scene.
  41702. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41703. * @param scene The scene to import into
  41704. * @param data The data to import
  41705. * @param rootUrl The root url for scene and resources
  41706. * @param meshes The meshes array to import into
  41707. * @param particleSystems The particle systems array to import into
  41708. * @param skeletons The skeletons array to import into
  41709. * @param onError The callback when import fails
  41710. * @returns True if successful or false otherwise
  41711. */
  41712. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41713. /**
  41714. * Load into a scene.
  41715. * @param scene The scene to load into
  41716. * @param data The data to import
  41717. * @param rootUrl The root url for scene and resources
  41718. * @param onError The callback when import fails
  41719. * @returns true if successful or false otherwise
  41720. */
  41721. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41722. /**
  41723. * The callback that returns true if the data can be directly loaded.
  41724. */
  41725. canDirectLoad?: (data: string) => boolean;
  41726. /**
  41727. * The callback that allows custom handling of the root url based on the response url.
  41728. */
  41729. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41730. /**
  41731. * Load into an asset container.
  41732. * @param scene The scene to load into
  41733. * @param data The data to import
  41734. * @param rootUrl The root url for scene and resources
  41735. * @param onError The callback when import fails
  41736. * @returns The loaded asset container
  41737. */
  41738. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41739. }
  41740. /**
  41741. * Interface used to define an async SceneLoader plugin
  41742. */
  41743. export interface ISceneLoaderPluginAsync {
  41744. /**
  41745. * The friendly name of this plugin.
  41746. */
  41747. name: string;
  41748. /**
  41749. * The file extensions supported by this plugin.
  41750. */
  41751. extensions: string | ISceneLoaderPluginExtensions;
  41752. /**
  41753. * Import meshes into a scene.
  41754. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41755. * @param scene The scene to import into
  41756. * @param data The data to import
  41757. * @param rootUrl The root url for scene and resources
  41758. * @param onProgress The callback when the load progresses
  41759. * @param fileName Defines the name of the file to load
  41760. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41761. */
  41762. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41763. meshes: AbstractMesh[];
  41764. particleSystems: IParticleSystem[];
  41765. skeletons: Skeleton[];
  41766. animationGroups: AnimationGroup[];
  41767. }>;
  41768. /**
  41769. * Load into a scene.
  41770. * @param scene The scene to load into
  41771. * @param data The data to import
  41772. * @param rootUrl The root url for scene and resources
  41773. * @param onProgress The callback when the load progresses
  41774. * @param fileName Defines the name of the file to load
  41775. * @returns Nothing
  41776. */
  41777. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41778. /**
  41779. * The callback that returns true if the data can be directly loaded.
  41780. */
  41781. canDirectLoad?: (data: string) => boolean;
  41782. /**
  41783. * The callback that allows custom handling of the root url based on the response url.
  41784. */
  41785. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41786. /**
  41787. * Load into an asset container.
  41788. * @param scene The scene to load into
  41789. * @param data The data to import
  41790. * @param rootUrl The root url for scene and resources
  41791. * @param onProgress The callback when the load progresses
  41792. * @param fileName Defines the name of the file to load
  41793. * @returns The loaded asset container
  41794. */
  41795. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41796. }
  41797. /**
  41798. * Class used to load scene from various file formats using registered plugins
  41799. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41800. */
  41801. export class SceneLoader {
  41802. /**
  41803. * No logging while loading
  41804. */
  41805. static readonly NO_LOGGING: number;
  41806. /**
  41807. * Minimal logging while loading
  41808. */
  41809. static readonly MINIMAL_LOGGING: number;
  41810. /**
  41811. * Summary logging while loading
  41812. */
  41813. static readonly SUMMARY_LOGGING: number;
  41814. /**
  41815. * Detailled logging while loading
  41816. */
  41817. static readonly DETAILED_LOGGING: number;
  41818. /**
  41819. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41820. */
  41821. static ForceFullSceneLoadingForIncremental: boolean;
  41822. /**
  41823. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41824. */
  41825. static ShowLoadingScreen: boolean;
  41826. /**
  41827. * Defines the current logging level (while loading the scene)
  41828. * @ignorenaming
  41829. */
  41830. static loggingLevel: number;
  41831. /**
  41832. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41833. */
  41834. static CleanBoneMatrixWeights: boolean;
  41835. /**
  41836. * Event raised when a plugin is used to load a scene
  41837. */
  41838. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41839. private static _registeredPlugins;
  41840. private static _getDefaultPlugin;
  41841. private static _getPluginForExtension;
  41842. private static _getPluginForDirectLoad;
  41843. private static _getPluginForFilename;
  41844. private static _getDirectLoad;
  41845. private static _loadData;
  41846. private static _getFileInfo;
  41847. /**
  41848. * Gets a plugin that can load the given extension
  41849. * @param extension defines the extension to load
  41850. * @returns a plugin or null if none works
  41851. */
  41852. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41853. /**
  41854. * Gets a boolean indicating that the given extension can be loaded
  41855. * @param extension defines the extension to load
  41856. * @returns true if the extension is supported
  41857. */
  41858. static IsPluginForExtensionAvailable(extension: string): boolean;
  41859. /**
  41860. * Adds a new plugin to the list of registered plugins
  41861. * @param plugin defines the plugin to add
  41862. */
  41863. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41864. /**
  41865. * Import meshes into a scene
  41866. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41867. * @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)
  41868. * @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)
  41869. * @param scene the instance of BABYLON.Scene to append to
  41870. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41871. * @param onProgress a callback with a progress event for each file being loaded
  41872. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41873. * @param pluginExtension the extension used to determine the plugin
  41874. * @returns The loaded plugin
  41875. */
  41876. 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>;
  41877. /**
  41878. * Import meshes into a scene
  41879. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41880. * @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)
  41881. * @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)
  41882. * @param scene the instance of BABYLON.Scene to append to
  41883. * @param onProgress a callback with a progress event for each file being loaded
  41884. * @param pluginExtension the extension used to determine the plugin
  41885. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41886. */
  41887. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41888. meshes: AbstractMesh[];
  41889. particleSystems: IParticleSystem[];
  41890. skeletons: Skeleton[];
  41891. animationGroups: AnimationGroup[];
  41892. }>;
  41893. /**
  41894. * Load a scene
  41895. * @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)
  41896. * @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)
  41897. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41898. * @param onSuccess a callback with the scene when import succeeds
  41899. * @param onProgress a callback with a progress event for each file being loaded
  41900. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41901. * @param pluginExtension the extension used to determine the plugin
  41902. * @returns The loaded plugin
  41903. */
  41904. 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>;
  41905. /**
  41906. * Load a scene
  41907. * @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)
  41908. * @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)
  41909. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41910. * @param onProgress a callback with a progress event for each file being loaded
  41911. * @param pluginExtension the extension used to determine the plugin
  41912. * @returns The loaded scene
  41913. */
  41914. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41915. /**
  41916. * Append a scene
  41917. * @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)
  41918. * @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)
  41919. * @param scene is the instance of BABYLON.Scene to append to
  41920. * @param onSuccess a callback with the scene when import succeeds
  41921. * @param onProgress a callback with a progress event for each file being loaded
  41922. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41923. * @param pluginExtension the extension used to determine the plugin
  41924. * @returns The loaded plugin
  41925. */
  41926. 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>;
  41927. /**
  41928. * Append a scene
  41929. * @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)
  41930. * @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)
  41931. * @param scene is the instance of BABYLON.Scene to append to
  41932. * @param onProgress a callback with a progress event for each file being loaded
  41933. * @param pluginExtension the extension used to determine the plugin
  41934. * @returns The given scene
  41935. */
  41936. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41937. /**
  41938. * Load a scene into an asset container
  41939. * @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)
  41940. * @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)
  41941. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41942. * @param onSuccess a callback with the scene when import succeeds
  41943. * @param onProgress a callback with a progress event for each file being loaded
  41944. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41945. * @param pluginExtension the extension used to determine the plugin
  41946. * @returns The loaded plugin
  41947. */
  41948. 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>;
  41949. /**
  41950. * Load a scene into an asset container
  41951. * @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)
  41952. * @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)
  41953. * @param scene is the instance of Scene to append to
  41954. * @param onProgress a callback with a progress event for each file being loaded
  41955. * @param pluginExtension the extension used to determine the plugin
  41956. * @returns The loaded asset container
  41957. */
  41958. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * Generic Controller
  41964. */
  41965. export class GenericController extends WebVRController {
  41966. /**
  41967. * Base Url for the controller model.
  41968. */
  41969. static readonly MODEL_BASE_URL: string;
  41970. /**
  41971. * File name for the controller model.
  41972. */
  41973. static readonly MODEL_FILENAME: string;
  41974. /**
  41975. * Creates a new GenericController from a gamepad
  41976. * @param vrGamepad the gamepad that the controller should be created from
  41977. */
  41978. constructor(vrGamepad: any);
  41979. /**
  41980. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41981. * @param scene scene in which to add meshes
  41982. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41983. */
  41984. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41985. /**
  41986. * Called once for each button that changed state since the last frame
  41987. * @param buttonIdx Which button index changed
  41988. * @param state New state of the button
  41989. * @param changes Which properties on the state changed since last frame
  41990. */
  41991. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41992. }
  41993. }
  41994. declare module BABYLON {
  41995. /**
  41996. * Defines the WindowsMotionController object that the state of the windows motion controller
  41997. */
  41998. export class WindowsMotionController extends WebVRController {
  41999. /**
  42000. * The base url used to load the left and right controller models
  42001. */
  42002. static MODEL_BASE_URL: string;
  42003. /**
  42004. * The name of the left controller model file
  42005. */
  42006. static MODEL_LEFT_FILENAME: string;
  42007. /**
  42008. * The name of the right controller model file
  42009. */
  42010. static MODEL_RIGHT_FILENAME: string;
  42011. /**
  42012. * The controller name prefix for this controller type
  42013. */
  42014. static readonly GAMEPAD_ID_PREFIX: string;
  42015. /**
  42016. * The controller id pattern for this controller type
  42017. */
  42018. private static readonly GAMEPAD_ID_PATTERN;
  42019. private _loadedMeshInfo;
  42020. private readonly _mapping;
  42021. /**
  42022. * Fired when the trackpad on this controller is clicked
  42023. */
  42024. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42025. /**
  42026. * Fired when the trackpad on this controller is modified
  42027. */
  42028. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42029. /**
  42030. * The current x and y values of this controller's trackpad
  42031. */
  42032. trackpad: StickValues;
  42033. /**
  42034. * Creates a new WindowsMotionController from a gamepad
  42035. * @param vrGamepad the gamepad that the controller should be created from
  42036. */
  42037. constructor(vrGamepad: any);
  42038. /**
  42039. * Fired when the trigger on this controller is modified
  42040. */
  42041. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42042. /**
  42043. * Fired when the menu button on this controller is modified
  42044. */
  42045. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42046. /**
  42047. * Fired when the grip button on this controller is modified
  42048. */
  42049. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42050. /**
  42051. * Fired when the thumbstick button on this controller is modified
  42052. */
  42053. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42054. /**
  42055. * Fired when the touchpad button on this controller is modified
  42056. */
  42057. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42058. /**
  42059. * Fired when the touchpad values on this controller are modified
  42060. */
  42061. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42062. private _updateTrackpad;
  42063. /**
  42064. * Called once per frame by the engine.
  42065. */
  42066. update(): void;
  42067. /**
  42068. * Called once for each button that changed state since the last frame
  42069. * @param buttonIdx Which button index changed
  42070. * @param state New state of the button
  42071. * @param changes Which properties on the state changed since last frame
  42072. */
  42073. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42074. /**
  42075. * Moves the buttons on the controller mesh based on their current state
  42076. * @param buttonName the name of the button to move
  42077. * @param buttonValue the value of the button which determines the buttons new position
  42078. */
  42079. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42080. /**
  42081. * Moves the axis on the controller mesh based on its current state
  42082. * @param axis the index of the axis
  42083. * @param axisValue the value of the axis which determines the meshes new position
  42084. * @hidden
  42085. */
  42086. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42087. /**
  42088. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42089. * @param scene scene in which to add meshes
  42090. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42091. */
  42092. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42093. /**
  42094. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42095. * can be transformed by button presses and axes values, based on this._mapping.
  42096. *
  42097. * @param scene scene in which the meshes exist
  42098. * @param meshes list of meshes that make up the controller model to process
  42099. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42100. */
  42101. private processModel;
  42102. private createMeshInfo;
  42103. /**
  42104. * Gets the ray of the controller in the direction the controller is pointing
  42105. * @param length the length the resulting ray should be
  42106. * @returns a ray in the direction the controller is pointing
  42107. */
  42108. getForwardRay(length?: number): Ray;
  42109. /**
  42110. * Disposes of the controller
  42111. */
  42112. dispose(): void;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Oculus Touch Controller
  42118. */
  42119. export class OculusTouchController extends WebVRController {
  42120. /**
  42121. * Base Url for the controller model.
  42122. */
  42123. static MODEL_BASE_URL: string;
  42124. /**
  42125. * File name for the left controller model.
  42126. */
  42127. static MODEL_LEFT_FILENAME: string;
  42128. /**
  42129. * File name for the right controller model.
  42130. */
  42131. static MODEL_RIGHT_FILENAME: string;
  42132. /**
  42133. * Base Url for the Quest controller model.
  42134. */
  42135. static QUEST_MODEL_BASE_URL: string;
  42136. /**
  42137. * @hidden
  42138. * If the controllers are running on a device that needs the updated Quest controller models
  42139. */
  42140. static _IsQuest: boolean;
  42141. /**
  42142. * Fired when the secondary trigger on this controller is modified
  42143. */
  42144. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42145. /**
  42146. * Fired when the thumb rest on this controller is modified
  42147. */
  42148. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42149. /**
  42150. * Creates a new OculusTouchController from a gamepad
  42151. * @param vrGamepad the gamepad that the controller should be created from
  42152. */
  42153. constructor(vrGamepad: any);
  42154. /**
  42155. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42156. * @param scene scene in which to add meshes
  42157. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42158. */
  42159. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42160. /**
  42161. * Fired when the A button on this controller is modified
  42162. */
  42163. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42164. /**
  42165. * Fired when the B button on this controller is modified
  42166. */
  42167. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42168. /**
  42169. * Fired when the X button on this controller is modified
  42170. */
  42171. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42172. /**
  42173. * Fired when the Y button on this controller is modified
  42174. */
  42175. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42176. /**
  42177. * Called once for each button that changed state since the last frame
  42178. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42179. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42180. * 2) secondary trigger (same)
  42181. * 3) A (right) X (left), touch, pressed = value
  42182. * 4) B / Y
  42183. * 5) thumb rest
  42184. * @param buttonIdx Which button index changed
  42185. * @param state New state of the button
  42186. * @param changes Which properties on the state changed since last frame
  42187. */
  42188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42189. }
  42190. }
  42191. declare module BABYLON {
  42192. /**
  42193. * Vive Controller
  42194. */
  42195. export class ViveController extends WebVRController {
  42196. /**
  42197. * Base Url for the controller model.
  42198. */
  42199. static MODEL_BASE_URL: string;
  42200. /**
  42201. * File name for the controller model.
  42202. */
  42203. static MODEL_FILENAME: string;
  42204. /**
  42205. * Creates a new ViveController from a gamepad
  42206. * @param vrGamepad the gamepad that the controller should be created from
  42207. */
  42208. constructor(vrGamepad: any);
  42209. /**
  42210. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42211. * @param scene scene in which to add meshes
  42212. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42213. */
  42214. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42215. /**
  42216. * Fired when the left button on this controller is modified
  42217. */
  42218. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42219. /**
  42220. * Fired when the right button on this controller is modified
  42221. */
  42222. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42223. /**
  42224. * Fired when the menu button on this controller is modified
  42225. */
  42226. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42227. /**
  42228. * Called once for each button that changed state since the last frame
  42229. * Vive mapping:
  42230. * 0: touchpad
  42231. * 1: trigger
  42232. * 2: left AND right buttons
  42233. * 3: menu button
  42234. * @param buttonIdx Which button index changed
  42235. * @param state New state of the button
  42236. * @param changes Which properties on the state changed since last frame
  42237. */
  42238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42239. }
  42240. }
  42241. declare module BABYLON {
  42242. /**
  42243. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42244. */
  42245. export class WebXRControllerModelLoader {
  42246. /**
  42247. * Creates the WebXRControllerModelLoader
  42248. * @param input xr input that creates the controllers
  42249. */
  42250. constructor(input: WebXRInput);
  42251. }
  42252. }
  42253. declare module BABYLON {
  42254. /**
  42255. * Contains an array of blocks representing the octree
  42256. */
  42257. export interface IOctreeContainer<T> {
  42258. /**
  42259. * Blocks within the octree
  42260. */
  42261. blocks: Array<OctreeBlock<T>>;
  42262. }
  42263. /**
  42264. * Class used to store a cell in an octree
  42265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42266. */
  42267. export class OctreeBlock<T> {
  42268. /**
  42269. * Gets the content of the current block
  42270. */
  42271. entries: T[];
  42272. /**
  42273. * Gets the list of block children
  42274. */
  42275. blocks: Array<OctreeBlock<T>>;
  42276. private _depth;
  42277. private _maxDepth;
  42278. private _capacity;
  42279. private _minPoint;
  42280. private _maxPoint;
  42281. private _boundingVectors;
  42282. private _creationFunc;
  42283. /**
  42284. * Creates a new block
  42285. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42286. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42287. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42288. * @param depth defines the current depth of this block in the octree
  42289. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42290. * @param creationFunc defines a callback to call when an element is added to the block
  42291. */
  42292. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42293. /**
  42294. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42295. */
  42296. readonly capacity: number;
  42297. /**
  42298. * Gets the minimum vector (in world space) of the block's bounding box
  42299. */
  42300. readonly minPoint: Vector3;
  42301. /**
  42302. * Gets the maximum vector (in world space) of the block's bounding box
  42303. */
  42304. readonly maxPoint: Vector3;
  42305. /**
  42306. * Add a new element to this block
  42307. * @param entry defines the element to add
  42308. */
  42309. addEntry(entry: T): void;
  42310. /**
  42311. * Remove an element from this block
  42312. * @param entry defines the element to remove
  42313. */
  42314. removeEntry(entry: T): void;
  42315. /**
  42316. * Add an array of elements to this block
  42317. * @param entries defines the array of elements to add
  42318. */
  42319. addEntries(entries: T[]): void;
  42320. /**
  42321. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42322. * @param frustumPlanes defines the frustum planes to test
  42323. * @param selection defines the array to store current content if selection is positive
  42324. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42325. */
  42326. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42327. /**
  42328. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42329. * @param sphereCenter defines the bounding sphere center
  42330. * @param sphereRadius defines the bounding sphere radius
  42331. * @param selection defines the array to store current content if selection is positive
  42332. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42333. */
  42334. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42335. /**
  42336. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42337. * @param ray defines the ray to test with
  42338. * @param selection defines the array to store current content if selection is positive
  42339. */
  42340. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42341. /**
  42342. * Subdivide the content into child blocks (this block will then be empty)
  42343. */
  42344. createInnerBlocks(): void;
  42345. /**
  42346. * @hidden
  42347. */
  42348. 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;
  42349. }
  42350. }
  42351. declare module BABYLON {
  42352. /**
  42353. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42354. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42355. */
  42356. export class Octree<T> {
  42357. /** 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.) */
  42358. maxDepth: number;
  42359. /**
  42360. * Blocks within the octree containing objects
  42361. */
  42362. blocks: Array<OctreeBlock<T>>;
  42363. /**
  42364. * Content stored in the octree
  42365. */
  42366. dynamicContent: T[];
  42367. private _maxBlockCapacity;
  42368. private _selectionContent;
  42369. private _creationFunc;
  42370. /**
  42371. * Creates a octree
  42372. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42373. * @param creationFunc function to be used to instatiate the octree
  42374. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42375. * @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.)
  42376. */
  42377. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42378. /** 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.) */
  42379. maxDepth?: number);
  42380. /**
  42381. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42382. * @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);
  42383. * @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);
  42384. * @param entries meshes to be added to the octree blocks
  42385. */
  42386. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42387. /**
  42388. * Adds a mesh to the octree
  42389. * @param entry Mesh to add to the octree
  42390. */
  42391. addMesh(entry: T): void;
  42392. /**
  42393. * Remove an element from the octree
  42394. * @param entry defines the element to remove
  42395. */
  42396. removeMesh(entry: T): void;
  42397. /**
  42398. * Selects an array of meshes within the frustum
  42399. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42400. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42401. * @returns array of meshes within the frustum
  42402. */
  42403. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42404. /**
  42405. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42406. * @param sphereCenter defines the bounding sphere center
  42407. * @param sphereRadius defines the bounding sphere radius
  42408. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42409. * @returns an array of objects that intersect the sphere
  42410. */
  42411. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42412. /**
  42413. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42414. * @param ray defines the ray to test with
  42415. * @returns array of intersected objects
  42416. */
  42417. intersectsRay(ray: Ray): SmartArray<T>;
  42418. /**
  42419. * Adds a mesh into the octree block if it intersects the block
  42420. */
  42421. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42422. /**
  42423. * Adds a submesh into the octree block if it intersects the block
  42424. */
  42425. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42426. }
  42427. }
  42428. declare module BABYLON {
  42429. interface Scene {
  42430. /**
  42431. * @hidden
  42432. * Backing Filed
  42433. */
  42434. _selectionOctree: Octree<AbstractMesh>;
  42435. /**
  42436. * Gets the octree used to boost mesh selection (picking)
  42437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42438. */
  42439. selectionOctree: Octree<AbstractMesh>;
  42440. /**
  42441. * Creates or updates the octree used to boost selection (picking)
  42442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42443. * @param maxCapacity defines the maximum capacity per leaf
  42444. * @param maxDepth defines the maximum depth of the octree
  42445. * @returns an octree of AbstractMesh
  42446. */
  42447. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42448. }
  42449. interface AbstractMesh {
  42450. /**
  42451. * @hidden
  42452. * Backing Field
  42453. */
  42454. _submeshesOctree: Octree<SubMesh>;
  42455. /**
  42456. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42457. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42458. * @param maxCapacity defines the maximum size of each block (64 by default)
  42459. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42460. * @returns the new octree
  42461. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42463. */
  42464. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42465. }
  42466. /**
  42467. * Defines the octree scene component responsible to manage any octrees
  42468. * in a given scene.
  42469. */
  42470. export class OctreeSceneComponent {
  42471. /**
  42472. * The component name help to identify the component in the list of scene components.
  42473. */
  42474. readonly name: string;
  42475. /**
  42476. * The scene the component belongs to.
  42477. */
  42478. scene: Scene;
  42479. /**
  42480. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42481. */
  42482. readonly checksIsEnabled: boolean;
  42483. /**
  42484. * Creates a new instance of the component for the given scene
  42485. * @param scene Defines the scene to register the component in
  42486. */
  42487. constructor(scene: Scene);
  42488. /**
  42489. * Registers the component in a given scene
  42490. */
  42491. register(): void;
  42492. /**
  42493. * Return the list of active meshes
  42494. * @returns the list of active meshes
  42495. */
  42496. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42497. /**
  42498. * Return the list of active sub meshes
  42499. * @param mesh The mesh to get the candidates sub meshes from
  42500. * @returns the list of active sub meshes
  42501. */
  42502. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42503. private _tempRay;
  42504. /**
  42505. * Return the list of sub meshes intersecting with a given local ray
  42506. * @param mesh defines the mesh to find the submesh for
  42507. * @param localRay defines the ray in local space
  42508. * @returns the list of intersecting sub meshes
  42509. */
  42510. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42511. /**
  42512. * Return the list of sub meshes colliding with a collider
  42513. * @param mesh defines the mesh to find the submesh for
  42514. * @param collider defines the collider to evaluate the collision against
  42515. * @returns the list of colliding sub meshes
  42516. */
  42517. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42518. /**
  42519. * Rebuilds the elements related to this component in case of
  42520. * context lost for instance.
  42521. */
  42522. rebuild(): void;
  42523. /**
  42524. * Disposes the component and the associated ressources.
  42525. */
  42526. dispose(): void;
  42527. }
  42528. }
  42529. declare module BABYLON {
  42530. /**
  42531. * Renders a layer on top of an existing scene
  42532. */
  42533. export class UtilityLayerRenderer implements IDisposable {
  42534. /** the original scene that will be rendered on top of */
  42535. originalScene: Scene;
  42536. private _pointerCaptures;
  42537. private _lastPointerEvents;
  42538. private static _DefaultUtilityLayer;
  42539. private static _DefaultKeepDepthUtilityLayer;
  42540. private _sharedGizmoLight;
  42541. private _renderCamera;
  42542. /**
  42543. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42544. * @returns the camera that is used when rendering the utility layer
  42545. */
  42546. getRenderCamera(): Nullable<Camera>;
  42547. /**
  42548. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42549. * @param cam the camera that should be used when rendering the utility layer
  42550. */
  42551. setRenderCamera(cam: Nullable<Camera>): void;
  42552. /**
  42553. * @hidden
  42554. * Light which used by gizmos to get light shading
  42555. */
  42556. _getSharedGizmoLight(): HemisphericLight;
  42557. /**
  42558. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42559. */
  42560. pickUtilitySceneFirst: boolean;
  42561. /**
  42562. * 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)
  42563. */
  42564. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42565. /**
  42566. * 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)
  42567. */
  42568. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42569. /**
  42570. * The scene that is rendered on top of the original scene
  42571. */
  42572. utilityLayerScene: Scene;
  42573. /**
  42574. * If the utility layer should automatically be rendered on top of existing scene
  42575. */
  42576. shouldRender: boolean;
  42577. /**
  42578. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42579. */
  42580. onlyCheckPointerDownEvents: boolean;
  42581. /**
  42582. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42583. */
  42584. processAllEvents: boolean;
  42585. /**
  42586. * Observable raised when the pointer move from the utility layer scene to the main scene
  42587. */
  42588. onPointerOutObservable: Observable<number>;
  42589. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42590. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42591. private _afterRenderObserver;
  42592. private _sceneDisposeObserver;
  42593. private _originalPointerObserver;
  42594. /**
  42595. * Instantiates a UtilityLayerRenderer
  42596. * @param originalScene the original scene that will be rendered on top of
  42597. * @param handleEvents boolean indicating if the utility layer should handle events
  42598. */
  42599. constructor(
  42600. /** the original scene that will be rendered on top of */
  42601. originalScene: Scene, handleEvents?: boolean);
  42602. private _notifyObservers;
  42603. /**
  42604. * Renders the utility layers scene on top of the original scene
  42605. */
  42606. render(): void;
  42607. /**
  42608. * Disposes of the renderer
  42609. */
  42610. dispose(): void;
  42611. private _updateCamera;
  42612. }
  42613. }
  42614. declare module BABYLON {
  42615. /**
  42616. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42617. */
  42618. export class Gizmo implements IDisposable {
  42619. /** The utility layer the gizmo will be added to */
  42620. gizmoLayer: UtilityLayerRenderer;
  42621. /**
  42622. * The root mesh of the gizmo
  42623. */
  42624. _rootMesh: Mesh;
  42625. private _attachedMesh;
  42626. /**
  42627. * Ratio for the scale of the gizmo (Default: 1)
  42628. */
  42629. scaleRatio: number;
  42630. /**
  42631. * If a custom mesh has been set (Default: false)
  42632. */
  42633. protected _customMeshSet: boolean;
  42634. /**
  42635. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42636. * * When set, interactions will be enabled
  42637. */
  42638. attachedMesh: Nullable<AbstractMesh>;
  42639. /**
  42640. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42641. * @param mesh The mesh to replace the default mesh of the gizmo
  42642. */
  42643. setCustomMesh(mesh: Mesh): void;
  42644. /**
  42645. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42646. */
  42647. updateGizmoRotationToMatchAttachedMesh: boolean;
  42648. /**
  42649. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42650. */
  42651. updateGizmoPositionToMatchAttachedMesh: boolean;
  42652. /**
  42653. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42654. */
  42655. updateScale: boolean;
  42656. protected _interactionsEnabled: boolean;
  42657. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42658. private _beforeRenderObserver;
  42659. private _tempVector;
  42660. /**
  42661. * Creates a gizmo
  42662. * @param gizmoLayer The utility layer the gizmo will be added to
  42663. */
  42664. constructor(
  42665. /** The utility layer the gizmo will be added to */
  42666. gizmoLayer?: UtilityLayerRenderer);
  42667. /**
  42668. * Updates the gizmo to match the attached mesh's position/rotation
  42669. */
  42670. protected _update(): void;
  42671. /**
  42672. * Disposes of the gizmo
  42673. */
  42674. dispose(): void;
  42675. }
  42676. }
  42677. declare module BABYLON {
  42678. /**
  42679. * Single plane drag gizmo
  42680. */
  42681. export class PlaneDragGizmo extends Gizmo {
  42682. /**
  42683. * Drag behavior responsible for the gizmos dragging interactions
  42684. */
  42685. dragBehavior: PointerDragBehavior;
  42686. private _pointerObserver;
  42687. /**
  42688. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42689. */
  42690. snapDistance: number;
  42691. /**
  42692. * Event that fires each time the gizmo snaps to a new location.
  42693. * * snapDistance is the the change in distance
  42694. */
  42695. onSnapObservable: Observable<{
  42696. snapDistance: number;
  42697. }>;
  42698. private _plane;
  42699. private _coloredMaterial;
  42700. private _hoverMaterial;
  42701. private _isEnabled;
  42702. private _parent;
  42703. /** @hidden */
  42704. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42705. /** @hidden */
  42706. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42707. /**
  42708. * Creates a PlaneDragGizmo
  42709. * @param gizmoLayer The utility layer the gizmo will be added to
  42710. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42711. * @param color The color of the gizmo
  42712. */
  42713. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42714. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42715. /**
  42716. * If the gizmo is enabled
  42717. */
  42718. isEnabled: boolean;
  42719. /**
  42720. * Disposes of the gizmo
  42721. */
  42722. dispose(): void;
  42723. }
  42724. }
  42725. declare module BABYLON {
  42726. /**
  42727. * Gizmo that enables dragging a mesh along 3 axis
  42728. */
  42729. export class PositionGizmo extends Gizmo {
  42730. /**
  42731. * Internal gizmo used for interactions on the x axis
  42732. */
  42733. xGizmo: AxisDragGizmo;
  42734. /**
  42735. * Internal gizmo used for interactions on the y axis
  42736. */
  42737. yGizmo: AxisDragGizmo;
  42738. /**
  42739. * Internal gizmo used for interactions on the z axis
  42740. */
  42741. zGizmo: AxisDragGizmo;
  42742. /**
  42743. * Internal gizmo used for interactions on the yz plane
  42744. */
  42745. xPlaneGizmo: PlaneDragGizmo;
  42746. /**
  42747. * Internal gizmo used for interactions on the xz plane
  42748. */
  42749. yPlaneGizmo: PlaneDragGizmo;
  42750. /**
  42751. * Internal gizmo used for interactions on the xy plane
  42752. */
  42753. zPlaneGizmo: PlaneDragGizmo;
  42754. /**
  42755. * private variables
  42756. */
  42757. private _meshAttached;
  42758. private _updateGizmoRotationToMatchAttachedMesh;
  42759. private _snapDistance;
  42760. private _scaleRatio;
  42761. /** Fires an event when any of it's sub gizmos are dragged */
  42762. onDragStartObservable: Observable<unknown>;
  42763. /** Fires an event when any of it's sub gizmos are released from dragging */
  42764. onDragEndObservable: Observable<unknown>;
  42765. /**
  42766. * If set to true, planar drag is enabled
  42767. */
  42768. private _planarGizmoEnabled;
  42769. attachedMesh: Nullable<AbstractMesh>;
  42770. /**
  42771. * Creates a PositionGizmo
  42772. * @param gizmoLayer The utility layer the gizmo will be added to
  42773. */
  42774. constructor(gizmoLayer?: UtilityLayerRenderer);
  42775. /**
  42776. * If the planar drag gizmo is enabled
  42777. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42778. */
  42779. planarGizmoEnabled: boolean;
  42780. updateGizmoRotationToMatchAttachedMesh: boolean;
  42781. /**
  42782. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42783. */
  42784. snapDistance: number;
  42785. /**
  42786. * Ratio for the scale of the gizmo (Default: 1)
  42787. */
  42788. scaleRatio: number;
  42789. /**
  42790. * Disposes of the gizmo
  42791. */
  42792. dispose(): void;
  42793. /**
  42794. * CustomMeshes are not supported by this gizmo
  42795. * @param mesh The mesh to replace the default mesh of the gizmo
  42796. */
  42797. setCustomMesh(mesh: Mesh): void;
  42798. }
  42799. }
  42800. declare module BABYLON {
  42801. /**
  42802. * Single axis drag gizmo
  42803. */
  42804. export class AxisDragGizmo extends Gizmo {
  42805. /**
  42806. * Drag behavior responsible for the gizmos dragging interactions
  42807. */
  42808. dragBehavior: PointerDragBehavior;
  42809. private _pointerObserver;
  42810. /**
  42811. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42812. */
  42813. snapDistance: number;
  42814. /**
  42815. * Event that fires each time the gizmo snaps to a new location.
  42816. * * snapDistance is the the change in distance
  42817. */
  42818. onSnapObservable: Observable<{
  42819. snapDistance: number;
  42820. }>;
  42821. private _isEnabled;
  42822. private _parent;
  42823. private _arrow;
  42824. private _coloredMaterial;
  42825. private _hoverMaterial;
  42826. /** @hidden */
  42827. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42828. /** @hidden */
  42829. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42830. /**
  42831. * Creates an AxisDragGizmo
  42832. * @param gizmoLayer The utility layer the gizmo will be added to
  42833. * @param dragAxis The axis which the gizmo will be able to drag on
  42834. * @param color The color of the gizmo
  42835. */
  42836. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42837. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42838. /**
  42839. * If the gizmo is enabled
  42840. */
  42841. isEnabled: boolean;
  42842. /**
  42843. * Disposes of the gizmo
  42844. */
  42845. dispose(): void;
  42846. }
  42847. }
  42848. declare module BABYLON.Debug {
  42849. /**
  42850. * The Axes viewer will show 3 axes in a specific point in space
  42851. */
  42852. export class AxesViewer {
  42853. private _xAxis;
  42854. private _yAxis;
  42855. private _zAxis;
  42856. private _scaleLinesFactor;
  42857. private _instanced;
  42858. /**
  42859. * Gets the hosting scene
  42860. */
  42861. scene: Scene;
  42862. /**
  42863. * Gets or sets a number used to scale line length
  42864. */
  42865. scaleLines: number;
  42866. /** Gets the node hierarchy used to render x-axis */
  42867. readonly xAxis: TransformNode;
  42868. /** Gets the node hierarchy used to render y-axis */
  42869. readonly yAxis: TransformNode;
  42870. /** Gets the node hierarchy used to render z-axis */
  42871. readonly zAxis: TransformNode;
  42872. /**
  42873. * Creates a new AxesViewer
  42874. * @param scene defines the hosting scene
  42875. * @param scaleLines defines a number used to scale line length (1 by default)
  42876. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42877. * @param xAxis defines the node hierarchy used to render the x-axis
  42878. * @param yAxis defines the node hierarchy used to render the y-axis
  42879. * @param zAxis defines the node hierarchy used to render the z-axis
  42880. */
  42881. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42882. /**
  42883. * Force the viewer to update
  42884. * @param position defines the position of the viewer
  42885. * @param xaxis defines the x axis of the viewer
  42886. * @param yaxis defines the y axis of the viewer
  42887. * @param zaxis defines the z axis of the viewer
  42888. */
  42889. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42890. /**
  42891. * Creates an instance of this axes viewer.
  42892. * @returns a new axes viewer with instanced meshes
  42893. */
  42894. createInstance(): AxesViewer;
  42895. /** Releases resources */
  42896. dispose(): void;
  42897. private static _SetRenderingGroupId;
  42898. }
  42899. }
  42900. declare module BABYLON.Debug {
  42901. /**
  42902. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42903. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42904. */
  42905. export class BoneAxesViewer extends AxesViewer {
  42906. /**
  42907. * Gets or sets the target mesh where to display the axes viewer
  42908. */
  42909. mesh: Nullable<Mesh>;
  42910. /**
  42911. * Gets or sets the target bone where to display the axes viewer
  42912. */
  42913. bone: Nullable<Bone>;
  42914. /** Gets current position */
  42915. pos: Vector3;
  42916. /** Gets direction of X axis */
  42917. xaxis: Vector3;
  42918. /** Gets direction of Y axis */
  42919. yaxis: Vector3;
  42920. /** Gets direction of Z axis */
  42921. zaxis: Vector3;
  42922. /**
  42923. * Creates a new BoneAxesViewer
  42924. * @param scene defines the hosting scene
  42925. * @param bone defines the target bone
  42926. * @param mesh defines the target mesh
  42927. * @param scaleLines defines a scaling factor for line length (1 by default)
  42928. */
  42929. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42930. /**
  42931. * Force the viewer to update
  42932. */
  42933. update(): void;
  42934. /** Releases resources */
  42935. dispose(): void;
  42936. }
  42937. }
  42938. declare module BABYLON {
  42939. /**
  42940. * Interface used to define scene explorer extensibility option
  42941. */
  42942. export interface IExplorerExtensibilityOption {
  42943. /**
  42944. * Define the option label
  42945. */
  42946. label: string;
  42947. /**
  42948. * Defines the action to execute on click
  42949. */
  42950. action: (entity: any) => void;
  42951. }
  42952. /**
  42953. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42954. */
  42955. export interface IExplorerExtensibilityGroup {
  42956. /**
  42957. * Defines a predicate to test if a given type mut be extended
  42958. */
  42959. predicate: (entity: any) => boolean;
  42960. /**
  42961. * Gets the list of options added to a type
  42962. */
  42963. entries: IExplorerExtensibilityOption[];
  42964. }
  42965. /**
  42966. * Interface used to define the options to use to create the Inspector
  42967. */
  42968. export interface IInspectorOptions {
  42969. /**
  42970. * Display in overlay mode (default: false)
  42971. */
  42972. overlay?: boolean;
  42973. /**
  42974. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42975. */
  42976. globalRoot?: HTMLElement;
  42977. /**
  42978. * Display the Scene explorer
  42979. */
  42980. showExplorer?: boolean;
  42981. /**
  42982. * Display the property inspector
  42983. */
  42984. showInspector?: boolean;
  42985. /**
  42986. * Display in embed mode (both panes on the right)
  42987. */
  42988. embedMode?: boolean;
  42989. /**
  42990. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42991. */
  42992. handleResize?: boolean;
  42993. /**
  42994. * Allow the panes to popup (default: true)
  42995. */
  42996. enablePopup?: boolean;
  42997. /**
  42998. * Allow the panes to be closed by users (default: true)
  42999. */
  43000. enableClose?: boolean;
  43001. /**
  43002. * Optional list of extensibility entries
  43003. */
  43004. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43005. /**
  43006. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43007. */
  43008. inspectorURL?: string;
  43009. }
  43010. interface Scene {
  43011. /**
  43012. * @hidden
  43013. * Backing field
  43014. */
  43015. _debugLayer: DebugLayer;
  43016. /**
  43017. * Gets the debug layer (aka Inspector) associated with the scene
  43018. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43019. */
  43020. debugLayer: DebugLayer;
  43021. }
  43022. /**
  43023. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43024. * what is happening in your scene
  43025. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43026. */
  43027. export class DebugLayer {
  43028. /**
  43029. * Define the url to get the inspector script from.
  43030. * By default it uses the babylonjs CDN.
  43031. * @ignoreNaming
  43032. */
  43033. static InspectorURL: string;
  43034. private _scene;
  43035. private BJSINSPECTOR;
  43036. private _onPropertyChangedObservable?;
  43037. /**
  43038. * Observable triggered when a property is changed through the inspector.
  43039. */
  43040. readonly onPropertyChangedObservable: any;
  43041. /**
  43042. * Instantiates a new debug layer.
  43043. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43044. * what is happening in your scene
  43045. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43046. * @param scene Defines the scene to inspect
  43047. */
  43048. constructor(scene: Scene);
  43049. /** Creates the inspector window. */
  43050. private _createInspector;
  43051. /**
  43052. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43053. * @param entity defines the entity to select
  43054. * @param lineContainerTitle defines the specific block to highlight
  43055. */
  43056. select(entity: any, lineContainerTitle?: string): void;
  43057. /** Get the inspector from bundle or global */
  43058. private _getGlobalInspector;
  43059. /**
  43060. * Get if the inspector is visible or not.
  43061. * @returns true if visible otherwise, false
  43062. */
  43063. isVisible(): boolean;
  43064. /**
  43065. * Hide the inspector and close its window.
  43066. */
  43067. hide(): void;
  43068. /**
  43069. * Launch the debugLayer.
  43070. * @param config Define the configuration of the inspector
  43071. * @return a promise fulfilled when the debug layer is visible
  43072. */
  43073. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43074. }
  43075. }
  43076. declare module BABYLON {
  43077. /**
  43078. * Class containing static functions to help procedurally build meshes
  43079. */
  43080. export class BoxBuilder {
  43081. /**
  43082. * Creates a box mesh
  43083. * * The parameter `size` sets the size (float) of each box side (default 1)
  43084. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43085. * * 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)
  43086. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43088. * * 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
  43089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43090. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43091. * @param name defines the name of the mesh
  43092. * @param options defines the options used to create the mesh
  43093. * @param scene defines the hosting scene
  43094. * @returns the box mesh
  43095. */
  43096. static CreateBox(name: string, options: {
  43097. size?: number;
  43098. width?: number;
  43099. height?: number;
  43100. depth?: number;
  43101. faceUV?: Vector4[];
  43102. faceColors?: Color4[];
  43103. sideOrientation?: number;
  43104. frontUVs?: Vector4;
  43105. backUVs?: Vector4;
  43106. wrap?: boolean;
  43107. topBaseAt?: number;
  43108. bottomBaseAt?: number;
  43109. updatable?: boolean;
  43110. }, scene?: Nullable<Scene>): Mesh;
  43111. }
  43112. }
  43113. declare module BABYLON {
  43114. /**
  43115. * Class containing static functions to help procedurally build meshes
  43116. */
  43117. export class SphereBuilder {
  43118. /**
  43119. * Creates a sphere mesh
  43120. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43121. * * 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`)
  43122. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43123. * * 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
  43124. * * 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)
  43125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43126. * * 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
  43127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43128. * @param name defines the name of the mesh
  43129. * @param options defines the options used to create the mesh
  43130. * @param scene defines the hosting scene
  43131. * @returns the sphere mesh
  43132. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43133. */
  43134. static CreateSphere(name: string, options: {
  43135. segments?: number;
  43136. diameter?: number;
  43137. diameterX?: number;
  43138. diameterY?: number;
  43139. diameterZ?: number;
  43140. arc?: number;
  43141. slice?: number;
  43142. sideOrientation?: number;
  43143. frontUVs?: Vector4;
  43144. backUVs?: Vector4;
  43145. updatable?: boolean;
  43146. }, scene?: Nullable<Scene>): Mesh;
  43147. }
  43148. }
  43149. declare module BABYLON.Debug {
  43150. /**
  43151. * Used to show the physics impostor around the specific mesh
  43152. */
  43153. export class PhysicsViewer {
  43154. /** @hidden */
  43155. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43156. /** @hidden */
  43157. protected _meshes: Array<Nullable<AbstractMesh>>;
  43158. /** @hidden */
  43159. protected _scene: Nullable<Scene>;
  43160. /** @hidden */
  43161. protected _numMeshes: number;
  43162. /** @hidden */
  43163. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43164. private _renderFunction;
  43165. private _utilityLayer;
  43166. private _debugBoxMesh;
  43167. private _debugSphereMesh;
  43168. private _debugCylinderMesh;
  43169. private _debugMaterial;
  43170. private _debugMeshMeshes;
  43171. /**
  43172. * Creates a new PhysicsViewer
  43173. * @param scene defines the hosting scene
  43174. */
  43175. constructor(scene: Scene);
  43176. /** @hidden */
  43177. protected _updateDebugMeshes(): void;
  43178. /**
  43179. * Renders a specified physic impostor
  43180. * @param impostor defines the impostor to render
  43181. * @param targetMesh defines the mesh represented by the impostor
  43182. * @returns the new debug mesh used to render the impostor
  43183. */
  43184. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43185. /**
  43186. * Hides a specified physic impostor
  43187. * @param impostor defines the impostor to hide
  43188. */
  43189. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43190. private _getDebugMaterial;
  43191. private _getDebugBoxMesh;
  43192. private _getDebugSphereMesh;
  43193. private _getDebugCylinderMesh;
  43194. private _getDebugMeshMesh;
  43195. private _getDebugMesh;
  43196. /** Releases all resources */
  43197. dispose(): void;
  43198. }
  43199. }
  43200. declare module BABYLON {
  43201. /**
  43202. * Class containing static functions to help procedurally build meshes
  43203. */
  43204. export class LinesBuilder {
  43205. /**
  43206. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43207. * * 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
  43208. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43209. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43210. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43211. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43212. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43213. * * 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
  43214. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43217. * @param name defines the name of the new line system
  43218. * @param options defines the options used to create the line system
  43219. * @param scene defines the hosting scene
  43220. * @returns a new line system mesh
  43221. */
  43222. static CreateLineSystem(name: string, options: {
  43223. lines: Vector3[][];
  43224. updatable?: boolean;
  43225. instance?: Nullable<LinesMesh>;
  43226. colors?: Nullable<Color4[][]>;
  43227. useVertexAlpha?: boolean;
  43228. }, scene: Nullable<Scene>): LinesMesh;
  43229. /**
  43230. * Creates a line mesh
  43231. * 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
  43232. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43233. * * The parameter `points` is an array successive Vector3
  43234. * * 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
  43235. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43236. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43237. * * When updating an instance, remember that only point positions can change, not the number of points
  43238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43240. * @param name defines the name of the new line system
  43241. * @param options defines the options used to create the line system
  43242. * @param scene defines the hosting scene
  43243. * @returns a new line mesh
  43244. */
  43245. static CreateLines(name: string, options: {
  43246. points: Vector3[];
  43247. updatable?: boolean;
  43248. instance?: Nullable<LinesMesh>;
  43249. colors?: Color4[];
  43250. useVertexAlpha?: boolean;
  43251. }, scene?: Nullable<Scene>): LinesMesh;
  43252. /**
  43253. * Creates a dashed line mesh
  43254. * * 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
  43255. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43256. * * The parameter `points` is an array successive Vector3
  43257. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43258. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43259. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43260. * * 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
  43261. * * When updating an instance, remember that only point positions can change, not the number of points
  43262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43263. * @param name defines the name of the mesh
  43264. * @param options defines the options used to create the mesh
  43265. * @param scene defines the hosting scene
  43266. * @returns the dashed line mesh
  43267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43268. */
  43269. static CreateDashedLines(name: string, options: {
  43270. points: Vector3[];
  43271. dashSize?: number;
  43272. gapSize?: number;
  43273. dashNb?: number;
  43274. updatable?: boolean;
  43275. instance?: LinesMesh;
  43276. }, scene?: Nullable<Scene>): LinesMesh;
  43277. }
  43278. }
  43279. declare module BABYLON {
  43280. /**
  43281. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43282. * in order to better appreciate the issue one might have.
  43283. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43284. */
  43285. export class RayHelper {
  43286. /**
  43287. * Defines the ray we are currently tryin to visualize.
  43288. */
  43289. ray: Nullable<Ray>;
  43290. private _renderPoints;
  43291. private _renderLine;
  43292. private _renderFunction;
  43293. private _scene;
  43294. private _updateToMeshFunction;
  43295. private _attachedToMesh;
  43296. private _meshSpaceDirection;
  43297. private _meshSpaceOrigin;
  43298. /**
  43299. * Helper function to create a colored helper in a scene in one line.
  43300. * @param ray Defines the ray we are currently tryin to visualize
  43301. * @param scene Defines the scene the ray is used in
  43302. * @param color Defines the color we want to see the ray in
  43303. * @returns The newly created ray helper.
  43304. */
  43305. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43306. /**
  43307. * Instantiate a new ray helper.
  43308. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43309. * in order to better appreciate the issue one might have.
  43310. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43311. * @param ray Defines the ray we are currently tryin to visualize
  43312. */
  43313. constructor(ray: Ray);
  43314. /**
  43315. * Shows the ray we are willing to debug.
  43316. * @param scene Defines the scene the ray needs to be rendered in
  43317. * @param color Defines the color the ray needs to be rendered in
  43318. */
  43319. show(scene: Scene, color?: Color3): void;
  43320. /**
  43321. * Hides the ray we are debugging.
  43322. */
  43323. hide(): void;
  43324. private _render;
  43325. /**
  43326. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43327. * @param mesh Defines the mesh we want the helper attached to
  43328. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43329. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43330. * @param length Defines the length of the ray
  43331. */
  43332. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43333. /**
  43334. * Detach the ray helper from the mesh it has previously been attached to.
  43335. */
  43336. detachFromMesh(): void;
  43337. private _updateToMesh;
  43338. /**
  43339. * Dispose the helper and release its associated resources.
  43340. */
  43341. dispose(): void;
  43342. }
  43343. }
  43344. declare module BABYLON.Debug {
  43345. /**
  43346. * Class used to render a debug view of a given skeleton
  43347. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43348. */
  43349. export class SkeletonViewer {
  43350. /** defines the skeleton to render */
  43351. skeleton: Skeleton;
  43352. /** defines the mesh attached to the skeleton */
  43353. mesh: AbstractMesh;
  43354. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43355. autoUpdateBonesMatrices: boolean;
  43356. /** defines the rendering group id to use with the viewer */
  43357. renderingGroupId: number;
  43358. /** Gets or sets the color used to render the skeleton */
  43359. color: Color3;
  43360. private _scene;
  43361. private _debugLines;
  43362. private _debugMesh;
  43363. private _isEnabled;
  43364. private _renderFunction;
  43365. private _utilityLayer;
  43366. /**
  43367. * Returns the mesh used to render the bones
  43368. */
  43369. readonly debugMesh: Nullable<LinesMesh>;
  43370. /**
  43371. * Creates a new SkeletonViewer
  43372. * @param skeleton defines the skeleton to render
  43373. * @param mesh defines the mesh attached to the skeleton
  43374. * @param scene defines the hosting scene
  43375. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43376. * @param renderingGroupId defines the rendering group id to use with the viewer
  43377. */
  43378. constructor(
  43379. /** defines the skeleton to render */
  43380. skeleton: Skeleton,
  43381. /** defines the mesh attached to the skeleton */
  43382. mesh: AbstractMesh, scene: Scene,
  43383. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43384. autoUpdateBonesMatrices?: boolean,
  43385. /** defines the rendering group id to use with the viewer */
  43386. renderingGroupId?: number);
  43387. /** Gets or sets a boolean indicating if the viewer is enabled */
  43388. isEnabled: boolean;
  43389. private _getBonePosition;
  43390. private _getLinesForBonesWithLength;
  43391. private _getLinesForBonesNoLength;
  43392. /** Update the viewer to sync with current skeleton state */
  43393. update(): void;
  43394. /** Release associated resources */
  43395. dispose(): void;
  43396. }
  43397. }
  43398. declare module BABYLON {
  43399. /**
  43400. * Options to create the null engine
  43401. */
  43402. export class NullEngineOptions {
  43403. /**
  43404. * Render width (Default: 512)
  43405. */
  43406. renderWidth: number;
  43407. /**
  43408. * Render height (Default: 256)
  43409. */
  43410. renderHeight: number;
  43411. /**
  43412. * Texture size (Default: 512)
  43413. */
  43414. textureSize: number;
  43415. /**
  43416. * If delta time between frames should be constant
  43417. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43418. */
  43419. deterministicLockstep: boolean;
  43420. /**
  43421. * Maximum about of steps between frames (Default: 4)
  43422. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43423. */
  43424. lockstepMaxSteps: number;
  43425. }
  43426. /**
  43427. * The null engine class provides support for headless version of babylon.js.
  43428. * This can be used in server side scenario or for testing purposes
  43429. */
  43430. export class NullEngine extends Engine {
  43431. private _options;
  43432. /**
  43433. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43434. */
  43435. isDeterministicLockStep(): boolean;
  43436. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43437. getLockstepMaxSteps(): number;
  43438. /**
  43439. * Sets hardware scaling, used to save performance if needed
  43440. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43441. */
  43442. getHardwareScalingLevel(): number;
  43443. constructor(options?: NullEngineOptions);
  43444. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43445. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43446. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43447. getRenderWidth(useScreen?: boolean): number;
  43448. getRenderHeight(useScreen?: boolean): number;
  43449. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43450. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43451. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43452. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43453. bindSamplers(effect: Effect): void;
  43454. enableEffect(effect: Effect): void;
  43455. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43456. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43457. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43458. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43459. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43460. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43461. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43462. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43463. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43464. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43465. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43466. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43467. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43468. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43469. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43470. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43471. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43472. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43473. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43474. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43475. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43476. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43477. bindBuffers(vertexBuffers: {
  43478. [key: string]: VertexBuffer;
  43479. }, indexBuffer: DataBuffer, effect: Effect): void;
  43480. wipeCaches(bruteForce?: boolean): void;
  43481. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43482. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43484. /** @hidden */
  43485. _createTexture(): WebGLTexture;
  43486. /** @hidden */
  43487. _releaseTexture(texture: InternalTexture): void;
  43488. 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;
  43489. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43490. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43491. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43492. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43493. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43495. areAllEffectsReady(): boolean;
  43496. /**
  43497. * @hidden
  43498. * Get the current error code of the webGL context
  43499. * @returns the error code
  43500. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43501. */
  43502. getError(): number;
  43503. /** @hidden */
  43504. _getUnpackAlignement(): number;
  43505. /** @hidden */
  43506. _unpackFlipY(value: boolean): void;
  43507. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43508. /**
  43509. * Updates a dynamic vertex buffer.
  43510. * @param vertexBuffer the vertex buffer to update
  43511. * @param data the data used to update the vertex buffer
  43512. * @param byteOffset the byte offset of the data (optional)
  43513. * @param byteLength the byte length of the data (optional)
  43514. */
  43515. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43516. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43517. /** @hidden */
  43518. _bindTexture(channel: number, texture: InternalTexture): void;
  43519. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43520. releaseEffects(): void;
  43521. displayLoadingUI(): void;
  43522. hideLoadingUI(): void;
  43523. /** @hidden */
  43524. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43525. /** @hidden */
  43526. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43527. /** @hidden */
  43528. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43529. /** @hidden */
  43530. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /** @hidden */
  43535. export class _OcclusionDataStorage {
  43536. /** @hidden */
  43537. occlusionInternalRetryCounter: number;
  43538. /** @hidden */
  43539. isOcclusionQueryInProgress: boolean;
  43540. /** @hidden */
  43541. isOccluded: boolean;
  43542. /** @hidden */
  43543. occlusionRetryCount: number;
  43544. /** @hidden */
  43545. occlusionType: number;
  43546. /** @hidden */
  43547. occlusionQueryAlgorithmType: number;
  43548. }
  43549. interface Engine {
  43550. /**
  43551. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43552. * @return the new query
  43553. */
  43554. createQuery(): WebGLQuery;
  43555. /**
  43556. * Delete and release a webGL query
  43557. * @param query defines the query to delete
  43558. * @return the current engine
  43559. */
  43560. deleteQuery(query: WebGLQuery): Engine;
  43561. /**
  43562. * Check if a given query has resolved and got its value
  43563. * @param query defines the query to check
  43564. * @returns true if the query got its value
  43565. */
  43566. isQueryResultAvailable(query: WebGLQuery): boolean;
  43567. /**
  43568. * Gets the value of a given query
  43569. * @param query defines the query to check
  43570. * @returns the value of the query
  43571. */
  43572. getQueryResult(query: WebGLQuery): number;
  43573. /**
  43574. * Initiates an occlusion query
  43575. * @param algorithmType defines the algorithm to use
  43576. * @param query defines the query to use
  43577. * @returns the current engine
  43578. * @see http://doc.babylonjs.com/features/occlusionquery
  43579. */
  43580. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43581. /**
  43582. * Ends an occlusion query
  43583. * @see http://doc.babylonjs.com/features/occlusionquery
  43584. * @param algorithmType defines the algorithm to use
  43585. * @returns the current engine
  43586. */
  43587. endOcclusionQuery(algorithmType: number): Engine;
  43588. /**
  43589. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43590. * Please note that only one query can be issued at a time
  43591. * @returns a time token used to track the time span
  43592. */
  43593. startTimeQuery(): Nullable<_TimeToken>;
  43594. /**
  43595. * Ends a time query
  43596. * @param token defines the token used to measure the time span
  43597. * @returns the time spent (in ns)
  43598. */
  43599. endTimeQuery(token: _TimeToken): int;
  43600. /** @hidden */
  43601. _currentNonTimestampToken: Nullable<_TimeToken>;
  43602. /** @hidden */
  43603. _createTimeQuery(): WebGLQuery;
  43604. /** @hidden */
  43605. _deleteTimeQuery(query: WebGLQuery): void;
  43606. /** @hidden */
  43607. _getGlAlgorithmType(algorithmType: number): number;
  43608. /** @hidden */
  43609. _getTimeQueryResult(query: WebGLQuery): any;
  43610. /** @hidden */
  43611. _getTimeQueryAvailability(query: WebGLQuery): any;
  43612. }
  43613. interface AbstractMesh {
  43614. /**
  43615. * Backing filed
  43616. * @hidden
  43617. */
  43618. __occlusionDataStorage: _OcclusionDataStorage;
  43619. /**
  43620. * Access property
  43621. * @hidden
  43622. */
  43623. _occlusionDataStorage: _OcclusionDataStorage;
  43624. /**
  43625. * 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.
  43626. * The default value is -1 which means don't break the query and wait till the result
  43627. * @see http://doc.babylonjs.com/features/occlusionquery
  43628. */
  43629. occlusionRetryCount: number;
  43630. /**
  43631. * 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:
  43632. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43633. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43634. * * 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.
  43635. * @see http://doc.babylonjs.com/features/occlusionquery
  43636. */
  43637. occlusionType: number;
  43638. /**
  43639. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43640. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43641. * * 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.
  43642. * @see http://doc.babylonjs.com/features/occlusionquery
  43643. */
  43644. occlusionQueryAlgorithmType: number;
  43645. /**
  43646. * 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
  43647. * @see http://doc.babylonjs.com/features/occlusionquery
  43648. */
  43649. isOccluded: boolean;
  43650. /**
  43651. * Flag to check the progress status of the query
  43652. * @see http://doc.babylonjs.com/features/occlusionquery
  43653. */
  43654. isOcclusionQueryInProgress: boolean;
  43655. }
  43656. }
  43657. declare module BABYLON {
  43658. /** @hidden */
  43659. export var _forceTransformFeedbackToBundle: boolean;
  43660. interface Engine {
  43661. /**
  43662. * Creates a webGL transform feedback object
  43663. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43664. * @returns the webGL transform feedback object
  43665. */
  43666. createTransformFeedback(): WebGLTransformFeedback;
  43667. /**
  43668. * Delete a webGL transform feedback object
  43669. * @param value defines the webGL transform feedback object to delete
  43670. */
  43671. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43672. /**
  43673. * Bind a webGL transform feedback object to the webgl context
  43674. * @param value defines the webGL transform feedback object to bind
  43675. */
  43676. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43677. /**
  43678. * Begins a transform feedback operation
  43679. * @param usePoints defines if points or triangles must be used
  43680. */
  43681. beginTransformFeedback(usePoints: boolean): void;
  43682. /**
  43683. * Ends a transform feedback operation
  43684. */
  43685. endTransformFeedback(): void;
  43686. /**
  43687. * Specify the varyings to use with transform feedback
  43688. * @param program defines the associated webGL program
  43689. * @param value defines the list of strings representing the varying names
  43690. */
  43691. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43692. /**
  43693. * Bind a webGL buffer for a transform feedback operation
  43694. * @param value defines the webGL buffer to bind
  43695. */
  43696. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43697. }
  43698. }
  43699. declare module BABYLON {
  43700. /**
  43701. * Creation options of the multi render target texture.
  43702. */
  43703. export interface IMultiRenderTargetOptions {
  43704. /**
  43705. * Define if the texture needs to create mip maps after render.
  43706. */
  43707. generateMipMaps?: boolean;
  43708. /**
  43709. * Define the types of all the draw buffers we want to create
  43710. */
  43711. types?: number[];
  43712. /**
  43713. * Define the sampling modes of all the draw buffers we want to create
  43714. */
  43715. samplingModes?: number[];
  43716. /**
  43717. * Define if a depth buffer is required
  43718. */
  43719. generateDepthBuffer?: boolean;
  43720. /**
  43721. * Define if a stencil buffer is required
  43722. */
  43723. generateStencilBuffer?: boolean;
  43724. /**
  43725. * Define if a depth texture is required instead of a depth buffer
  43726. */
  43727. generateDepthTexture?: boolean;
  43728. /**
  43729. * Define the number of desired draw buffers
  43730. */
  43731. textureCount?: number;
  43732. /**
  43733. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43734. */
  43735. doNotChangeAspectRatio?: boolean;
  43736. /**
  43737. * Define the default type of the buffers we are creating
  43738. */
  43739. defaultType?: number;
  43740. }
  43741. /**
  43742. * A multi render target, like a render target provides the ability to render to a texture.
  43743. * Unlike the render target, it can render to several draw buffers in one draw.
  43744. * This is specially interesting in deferred rendering or for any effects requiring more than
  43745. * just one color from a single pass.
  43746. */
  43747. export class MultiRenderTarget extends RenderTargetTexture {
  43748. private _internalTextures;
  43749. private _textures;
  43750. private _multiRenderTargetOptions;
  43751. /**
  43752. * Get if draw buffers are currently supported by the used hardware and browser.
  43753. */
  43754. readonly isSupported: boolean;
  43755. /**
  43756. * Get the list of textures generated by the multi render target.
  43757. */
  43758. readonly textures: Texture[];
  43759. /**
  43760. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43761. */
  43762. readonly depthTexture: Texture;
  43763. /**
  43764. * Set the wrapping mode on U of all the textures we are rendering to.
  43765. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43766. */
  43767. wrapU: number;
  43768. /**
  43769. * Set the wrapping mode on V of all the textures we are rendering to.
  43770. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43771. */
  43772. wrapV: number;
  43773. /**
  43774. * Instantiate a new multi render target texture.
  43775. * A multi render target, like a render target provides the ability to render to a texture.
  43776. * Unlike the render target, it can render to several draw buffers in one draw.
  43777. * This is specially interesting in deferred rendering or for any effects requiring more than
  43778. * just one color from a single pass.
  43779. * @param name Define the name of the texture
  43780. * @param size Define the size of the buffers to render to
  43781. * @param count Define the number of target we are rendering into
  43782. * @param scene Define the scene the texture belongs to
  43783. * @param options Define the options used to create the multi render target
  43784. */
  43785. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43786. /** @hidden */
  43787. _rebuild(): void;
  43788. private _createInternalTextures;
  43789. private _createTextures;
  43790. /**
  43791. * Define the number of samples used if MSAA is enabled.
  43792. */
  43793. samples: number;
  43794. /**
  43795. * Resize all the textures in the multi render target.
  43796. * Be carrefull as it will recreate all the data in the new texture.
  43797. * @param size Define the new size
  43798. */
  43799. resize(size: any): void;
  43800. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43801. /**
  43802. * Dispose the render targets and their associated resources
  43803. */
  43804. dispose(): void;
  43805. /**
  43806. * Release all the underlying texture used as draw buffers.
  43807. */
  43808. releaseInternalTextures(): void;
  43809. }
  43810. }
  43811. declare module BABYLON {
  43812. interface Engine {
  43813. /**
  43814. * Unbind a list of render target textures from the webGL context
  43815. * This is used only when drawBuffer extension or webGL2 are active
  43816. * @param textures defines the render target textures to unbind
  43817. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43818. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43819. */
  43820. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43821. /**
  43822. * Create a multi render target texture
  43823. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43824. * @param size defines the size of the texture
  43825. * @param options defines the creation options
  43826. * @returns the cube texture as an InternalTexture
  43827. */
  43828. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43829. /**
  43830. * Update the sample count for a given multiple render target texture
  43831. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43832. * @param textures defines the textures to update
  43833. * @param samples defines the sample count to set
  43834. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43835. */
  43836. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43837. }
  43838. }
  43839. declare module BABYLON {
  43840. /** @hidden */
  43841. export var rgbdEncodePixelShader: {
  43842. name: string;
  43843. shader: string;
  43844. };
  43845. }
  43846. declare module BABYLON {
  43847. /** @hidden */
  43848. export var rgbdDecodePixelShader: {
  43849. name: string;
  43850. shader: string;
  43851. };
  43852. }
  43853. declare module BABYLON {
  43854. /**
  43855. * Raw texture data and descriptor sufficient for WebGL texture upload
  43856. */
  43857. export interface EnvironmentTextureInfo {
  43858. /**
  43859. * Version of the environment map
  43860. */
  43861. version: number;
  43862. /**
  43863. * Width of image
  43864. */
  43865. width: number;
  43866. /**
  43867. * Irradiance information stored in the file.
  43868. */
  43869. irradiance: any;
  43870. /**
  43871. * Specular information stored in the file.
  43872. */
  43873. specular: any;
  43874. }
  43875. /**
  43876. * Defines One Image in the file. It requires only the position in the file
  43877. * as well as the length.
  43878. */
  43879. interface BufferImageData {
  43880. /**
  43881. * Length of the image data.
  43882. */
  43883. length: number;
  43884. /**
  43885. * Position of the data from the null terminator delimiting the end of the JSON.
  43886. */
  43887. position: number;
  43888. }
  43889. /**
  43890. * Defines the specular data enclosed in the file.
  43891. * This corresponds to the version 1 of the data.
  43892. */
  43893. export interface EnvironmentTextureSpecularInfoV1 {
  43894. /**
  43895. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43896. */
  43897. specularDataPosition?: number;
  43898. /**
  43899. * This contains all the images data needed to reconstruct the cubemap.
  43900. */
  43901. mipmaps: Array<BufferImageData>;
  43902. /**
  43903. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43904. */
  43905. lodGenerationScale: number;
  43906. }
  43907. /**
  43908. * Sets of helpers addressing the serialization and deserialization of environment texture
  43909. * stored in a BabylonJS env file.
  43910. * Those files are usually stored as .env files.
  43911. */
  43912. export class EnvironmentTextureTools {
  43913. /**
  43914. * Magic number identifying the env file.
  43915. */
  43916. private static _MagicBytes;
  43917. /**
  43918. * Gets the environment info from an env file.
  43919. * @param data The array buffer containing the .env bytes.
  43920. * @returns the environment file info (the json header) if successfully parsed.
  43921. */
  43922. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43923. /**
  43924. * Creates an environment texture from a loaded cube texture.
  43925. * @param texture defines the cube texture to convert in env file
  43926. * @return a promise containing the environment data if succesfull.
  43927. */
  43928. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43929. /**
  43930. * Creates a JSON representation of the spherical data.
  43931. * @param texture defines the texture containing the polynomials
  43932. * @return the JSON representation of the spherical info
  43933. */
  43934. private static _CreateEnvTextureIrradiance;
  43935. /**
  43936. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43937. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43938. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43939. * @return the views described by info providing access to the underlying buffer
  43940. */
  43941. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43942. /**
  43943. * Uploads the texture info contained in the env file to the GPU.
  43944. * @param texture defines the internal texture to upload to
  43945. * @param arrayBuffer defines the buffer cotaining the data to load
  43946. * @param info defines the texture info retrieved through the GetEnvInfo method
  43947. * @returns a promise
  43948. */
  43949. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43950. /**
  43951. * Uploads the levels of image data to the GPU.
  43952. * @param texture defines the internal texture to upload to
  43953. * @param imageData defines the array buffer views of image data [mipmap][face]
  43954. * @returns a promise
  43955. */
  43956. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43957. /**
  43958. * Uploads spherical polynomials information to the texture.
  43959. * @param texture defines the texture we are trying to upload the information to
  43960. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43961. */
  43962. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43963. /** @hidden */
  43964. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43965. }
  43966. }
  43967. declare module BABYLON {
  43968. /**
  43969. * Contains position and normal vectors for a vertex
  43970. */
  43971. export class PositionNormalVertex {
  43972. /** the position of the vertex (defaut: 0,0,0) */
  43973. position: Vector3;
  43974. /** the normal of the vertex (defaut: 0,1,0) */
  43975. normal: Vector3;
  43976. /**
  43977. * Creates a PositionNormalVertex
  43978. * @param position the position of the vertex (defaut: 0,0,0)
  43979. * @param normal the normal of the vertex (defaut: 0,1,0)
  43980. */
  43981. constructor(
  43982. /** the position of the vertex (defaut: 0,0,0) */
  43983. position?: Vector3,
  43984. /** the normal of the vertex (defaut: 0,1,0) */
  43985. normal?: Vector3);
  43986. /**
  43987. * Clones the PositionNormalVertex
  43988. * @returns the cloned PositionNormalVertex
  43989. */
  43990. clone(): PositionNormalVertex;
  43991. }
  43992. /**
  43993. * Contains position, normal and uv vectors for a vertex
  43994. */
  43995. export class PositionNormalTextureVertex {
  43996. /** the position of the vertex (defaut: 0,0,0) */
  43997. position: Vector3;
  43998. /** the normal of the vertex (defaut: 0,1,0) */
  43999. normal: Vector3;
  44000. /** the uv of the vertex (default: 0,0) */
  44001. uv: Vector2;
  44002. /**
  44003. * Creates a PositionNormalTextureVertex
  44004. * @param position the position of the vertex (defaut: 0,0,0)
  44005. * @param normal the normal of the vertex (defaut: 0,1,0)
  44006. * @param uv the uv of the vertex (default: 0,0)
  44007. */
  44008. constructor(
  44009. /** the position of the vertex (defaut: 0,0,0) */
  44010. position?: Vector3,
  44011. /** the normal of the vertex (defaut: 0,1,0) */
  44012. normal?: Vector3,
  44013. /** the uv of the vertex (default: 0,0) */
  44014. uv?: Vector2);
  44015. /**
  44016. * Clones the PositionNormalTextureVertex
  44017. * @returns the cloned PositionNormalTextureVertex
  44018. */
  44019. clone(): PositionNormalTextureVertex;
  44020. }
  44021. }
  44022. declare module BABYLON {
  44023. /** @hidden */
  44024. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44025. private _genericAttributeLocation;
  44026. private _varyingLocationCount;
  44027. private _varyingLocationMap;
  44028. private _replacements;
  44029. private _textureCount;
  44030. private _uniforms;
  44031. lineProcessor(line: string): string;
  44032. attributeProcessor(attribute: string): string;
  44033. varyingProcessor(varying: string, isFragment: boolean): string;
  44034. uniformProcessor(uniform: string): string;
  44035. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44036. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44037. }
  44038. }
  44039. declare module BABYLON {
  44040. /**
  44041. * Container for accessors for natively-stored mesh data buffers.
  44042. */
  44043. class NativeDataBuffer extends DataBuffer {
  44044. /**
  44045. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44046. */
  44047. nativeIndexBuffer?: any;
  44048. /**
  44049. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44050. */
  44051. nativeVertexBuffer?: any;
  44052. }
  44053. /** @hidden */
  44054. export class NativeEngine extends Engine {
  44055. private readonly _native;
  44056. getHardwareScalingLevel(): number;
  44057. constructor();
  44058. /**
  44059. * Can be used to override the current requestAnimationFrame requester.
  44060. * @hidden
  44061. */
  44062. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44063. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44064. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44065. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44066. recordVertexArrayObject(vertexBuffers: {
  44067. [key: string]: VertexBuffer;
  44068. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44069. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44070. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44071. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44072. /**
  44073. * Draw a list of indexed primitives
  44074. * @param fillMode defines the primitive to use
  44075. * @param indexStart defines the starting index
  44076. * @param indexCount defines the number of index to draw
  44077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44078. */
  44079. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44080. /**
  44081. * Draw a list of unindexed primitives
  44082. * @param fillMode defines the primitive to use
  44083. * @param verticesStart defines the index of first vertex to draw
  44084. * @param verticesCount defines the count of vertices to draw
  44085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44086. */
  44087. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44088. createPipelineContext(): IPipelineContext;
  44089. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44090. /** @hidden */
  44091. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44092. /** @hidden */
  44093. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44094. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44095. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44096. protected _setProgram(program: WebGLProgram): void;
  44097. _releaseEffect(effect: Effect): void;
  44098. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44099. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44100. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44101. bindSamplers(effect: Effect): void;
  44102. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44103. getRenderWidth(useScreen?: boolean): number;
  44104. getRenderHeight(useScreen?: boolean): number;
  44105. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44106. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44107. /**
  44108. * Set the z offset to apply to current rendering
  44109. * @param value defines the offset to apply
  44110. */
  44111. setZOffset(value: number): void;
  44112. /**
  44113. * Gets the current value of the zOffset
  44114. * @returns the current zOffset state
  44115. */
  44116. getZOffset(): number;
  44117. /**
  44118. * Enable or disable depth buffering
  44119. * @param enable defines the state to set
  44120. */
  44121. setDepthBuffer(enable: boolean): void;
  44122. /**
  44123. * Gets a boolean indicating if depth writing is enabled
  44124. * @returns the current depth writing state
  44125. */
  44126. getDepthWrite(): boolean;
  44127. /**
  44128. * Enable or disable depth writing
  44129. * @param enable defines the state to set
  44130. */
  44131. setDepthWrite(enable: boolean): void;
  44132. /**
  44133. * Enable or disable color writing
  44134. * @param enable defines the state to set
  44135. */
  44136. setColorWrite(enable: boolean): void;
  44137. /**
  44138. * Gets a boolean indicating if color writing is enabled
  44139. * @returns the current color writing state
  44140. */
  44141. getColorWrite(): boolean;
  44142. /**
  44143. * Sets alpha constants used by some alpha blending modes
  44144. * @param r defines the red component
  44145. * @param g defines the green component
  44146. * @param b defines the blue component
  44147. * @param a defines the alpha component
  44148. */
  44149. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44150. /**
  44151. * Sets the current alpha mode
  44152. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44153. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44154. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44155. */
  44156. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44157. /**
  44158. * Gets the current alpha mode
  44159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44160. * @returns the current alpha mode
  44161. */
  44162. getAlphaMode(): number;
  44163. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44164. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44165. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44166. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44167. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44168. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44169. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44170. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44171. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44172. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44173. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44174. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44175. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44176. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44177. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44178. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44179. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44180. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44181. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44182. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44183. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44184. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44185. wipeCaches(bruteForce?: boolean): void;
  44186. _createTexture(): WebGLTexture;
  44187. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44188. /**
  44189. * Usually called from BABYLON.Texture.ts.
  44190. * Passed information to create a WebGLTexture
  44191. * @param urlArg defines a value which contains one of the following:
  44192. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44193. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44194. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44195. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44196. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44197. * @param scene needed for loading to the correct scene
  44198. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44199. * @param onLoad optional callback to be called upon successful completion
  44200. * @param onError optional callback to be called upon failure
  44201. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44202. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44203. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44204. * @param forcedExtension defines the extension to use to pick the right loader
  44205. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44206. */
  44207. 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;
  44208. /**
  44209. * Creates a cube texture
  44210. * @param rootUrl defines the url where the files to load is located
  44211. * @param scene defines the current scene
  44212. * @param files defines the list of files to load (1 per face)
  44213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44214. * @param onLoad defines an optional callback raised when the texture is loaded
  44215. * @param onError defines an optional callback raised if there is an issue to load the texture
  44216. * @param format defines the format of the data
  44217. * @param forcedExtension defines the extension to use to pick the right loader
  44218. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44219. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44220. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44221. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44222. * @returns the cube texture as an InternalTexture
  44223. */
  44224. 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;
  44225. private _getSamplingFilter;
  44226. private static _GetNativeTextureFormat;
  44227. createRenderTargetTexture(size: number | {
  44228. width: number;
  44229. height: number;
  44230. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44231. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44232. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44233. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44234. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44235. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44236. /**
  44237. * Updates a dynamic vertex buffer.
  44238. * @param vertexBuffer the vertex buffer to update
  44239. * @param data the data used to update the vertex buffer
  44240. * @param byteOffset the byte offset of the data (optional)
  44241. * @param byteLength the byte length of the data (optional)
  44242. */
  44243. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44244. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44245. private _updateAnisotropicLevel;
  44246. private _getAddressMode;
  44247. /** @hidden */
  44248. _bindTexture(channel: number, texture: InternalTexture): void;
  44249. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44250. releaseEffects(): void;
  44251. /** @hidden */
  44252. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44253. /** @hidden */
  44254. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44255. /** @hidden */
  44256. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44257. /** @hidden */
  44258. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44259. }
  44260. }
  44261. declare module BABYLON {
  44262. /**
  44263. * Gather the list of clipboard event types as constants.
  44264. */
  44265. export class ClipboardEventTypes {
  44266. /**
  44267. * The clipboard event is fired when a copy command is active (pressed).
  44268. */
  44269. static readonly COPY: number;
  44270. /**
  44271. * The clipboard event is fired when a cut command is active (pressed).
  44272. */
  44273. static readonly CUT: number;
  44274. /**
  44275. * The clipboard event is fired when a paste command is active (pressed).
  44276. */
  44277. static readonly PASTE: number;
  44278. }
  44279. /**
  44280. * This class is used to store clipboard related info for the onClipboardObservable event.
  44281. */
  44282. export class ClipboardInfo {
  44283. /**
  44284. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44285. */
  44286. type: number;
  44287. /**
  44288. * Defines the related dom event
  44289. */
  44290. event: ClipboardEvent;
  44291. /**
  44292. *Creates an instance of ClipboardInfo.
  44293. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44294. * @param event Defines the related dom event
  44295. */
  44296. constructor(
  44297. /**
  44298. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44299. */
  44300. type: number,
  44301. /**
  44302. * Defines the related dom event
  44303. */
  44304. event: ClipboardEvent);
  44305. /**
  44306. * Get the clipboard event's type from the keycode.
  44307. * @param keyCode Defines the keyCode for the current keyboard event.
  44308. * @return {number}
  44309. */
  44310. static GetTypeFromCharacter(keyCode: number): number;
  44311. }
  44312. }
  44313. declare module BABYLON {
  44314. /**
  44315. * Google Daydream controller
  44316. */
  44317. export class DaydreamController extends WebVRController {
  44318. /**
  44319. * Base Url for the controller model.
  44320. */
  44321. static MODEL_BASE_URL: string;
  44322. /**
  44323. * File name for the controller model.
  44324. */
  44325. static MODEL_FILENAME: string;
  44326. /**
  44327. * Gamepad Id prefix used to identify Daydream Controller.
  44328. */
  44329. static readonly GAMEPAD_ID_PREFIX: string;
  44330. /**
  44331. * Creates a new DaydreamController from a gamepad
  44332. * @param vrGamepad the gamepad that the controller should be created from
  44333. */
  44334. constructor(vrGamepad: any);
  44335. /**
  44336. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44337. * @param scene scene in which to add meshes
  44338. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44339. */
  44340. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44341. /**
  44342. * Called once for each button that changed state since the last frame
  44343. * @param buttonIdx Which button index changed
  44344. * @param state New state of the button
  44345. * @param changes Which properties on the state changed since last frame
  44346. */
  44347. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44348. }
  44349. }
  44350. declare module BABYLON {
  44351. /**
  44352. * Gear VR Controller
  44353. */
  44354. export class GearVRController extends WebVRController {
  44355. /**
  44356. * Base Url for the controller model.
  44357. */
  44358. static MODEL_BASE_URL: string;
  44359. /**
  44360. * File name for the controller model.
  44361. */
  44362. static MODEL_FILENAME: string;
  44363. /**
  44364. * Gamepad Id prefix used to identify this controller.
  44365. */
  44366. static readonly GAMEPAD_ID_PREFIX: string;
  44367. private readonly _buttonIndexToObservableNameMap;
  44368. /**
  44369. * Creates a new GearVRController from a gamepad
  44370. * @param vrGamepad the gamepad that the controller should be created from
  44371. */
  44372. constructor(vrGamepad: any);
  44373. /**
  44374. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44375. * @param scene scene in which to add meshes
  44376. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44377. */
  44378. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44379. /**
  44380. * Called once for each button that changed state since the last frame
  44381. * @param buttonIdx Which button index changed
  44382. * @param state New state of the button
  44383. * @param changes Which properties on the state changed since last frame
  44384. */
  44385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44386. }
  44387. }
  44388. declare module BABYLON {
  44389. /**
  44390. * Class containing static functions to help procedurally build meshes
  44391. */
  44392. export class PolyhedronBuilder {
  44393. /**
  44394. * Creates a polyhedron mesh
  44395. * * 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
  44396. * * The parameter `size` (positive float, default 1) sets the polygon size
  44397. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44398. * * 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`
  44399. * * 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
  44400. * * 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)`)
  44401. * * 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
  44402. * * 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
  44403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44404. * * 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
  44405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44406. * @param name defines the name of the mesh
  44407. * @param options defines the options used to create the mesh
  44408. * @param scene defines the hosting scene
  44409. * @returns the polyhedron mesh
  44410. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44411. */
  44412. static CreatePolyhedron(name: string, options: {
  44413. type?: number;
  44414. size?: number;
  44415. sizeX?: number;
  44416. sizeY?: number;
  44417. sizeZ?: number;
  44418. custom?: any;
  44419. faceUV?: Vector4[];
  44420. faceColors?: Color4[];
  44421. flat?: boolean;
  44422. updatable?: boolean;
  44423. sideOrientation?: number;
  44424. frontUVs?: Vector4;
  44425. backUVs?: Vector4;
  44426. }, scene?: Nullable<Scene>): Mesh;
  44427. }
  44428. }
  44429. declare module BABYLON {
  44430. /**
  44431. * Gizmo that enables scaling a mesh along 3 axis
  44432. */
  44433. export class ScaleGizmo extends Gizmo {
  44434. /**
  44435. * Internal gizmo used for interactions on the x axis
  44436. */
  44437. xGizmo: AxisScaleGizmo;
  44438. /**
  44439. * Internal gizmo used for interactions on the y axis
  44440. */
  44441. yGizmo: AxisScaleGizmo;
  44442. /**
  44443. * Internal gizmo used for interactions on the z axis
  44444. */
  44445. zGizmo: AxisScaleGizmo;
  44446. /**
  44447. * Internal gizmo used to scale all axis equally
  44448. */
  44449. uniformScaleGizmo: AxisScaleGizmo;
  44450. private _meshAttached;
  44451. private _updateGizmoRotationToMatchAttachedMesh;
  44452. private _snapDistance;
  44453. private _scaleRatio;
  44454. private _uniformScalingMesh;
  44455. private _octahedron;
  44456. /** Fires an event when any of it's sub gizmos are dragged */
  44457. onDragStartObservable: Observable<unknown>;
  44458. /** Fires an event when any of it's sub gizmos are released from dragging */
  44459. onDragEndObservable: Observable<unknown>;
  44460. attachedMesh: Nullable<AbstractMesh>;
  44461. /**
  44462. * Creates a ScaleGizmo
  44463. * @param gizmoLayer The utility layer the gizmo will be added to
  44464. */
  44465. constructor(gizmoLayer?: UtilityLayerRenderer);
  44466. updateGizmoRotationToMatchAttachedMesh: boolean;
  44467. /**
  44468. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44469. */
  44470. snapDistance: number;
  44471. /**
  44472. * Ratio for the scale of the gizmo (Default: 1)
  44473. */
  44474. scaleRatio: number;
  44475. /**
  44476. * Disposes of the gizmo
  44477. */
  44478. dispose(): void;
  44479. }
  44480. }
  44481. declare module BABYLON {
  44482. /**
  44483. * Single axis scale gizmo
  44484. */
  44485. export class AxisScaleGizmo extends Gizmo {
  44486. /**
  44487. * Drag behavior responsible for the gizmos dragging interactions
  44488. */
  44489. dragBehavior: PointerDragBehavior;
  44490. private _pointerObserver;
  44491. /**
  44492. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44493. */
  44494. snapDistance: number;
  44495. /**
  44496. * Event that fires each time the gizmo snaps to a new location.
  44497. * * snapDistance is the the change in distance
  44498. */
  44499. onSnapObservable: Observable<{
  44500. snapDistance: number;
  44501. }>;
  44502. /**
  44503. * If the scaling operation should be done on all axis (default: false)
  44504. */
  44505. uniformScaling: boolean;
  44506. private _isEnabled;
  44507. private _parent;
  44508. private _arrow;
  44509. private _coloredMaterial;
  44510. private _hoverMaterial;
  44511. /**
  44512. * Creates an AxisScaleGizmo
  44513. * @param gizmoLayer The utility layer the gizmo will be added to
  44514. * @param dragAxis The axis which the gizmo will be able to scale on
  44515. * @param color The color of the gizmo
  44516. */
  44517. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44518. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44519. /**
  44520. * If the gizmo is enabled
  44521. */
  44522. isEnabled: boolean;
  44523. /**
  44524. * Disposes of the gizmo
  44525. */
  44526. dispose(): void;
  44527. /**
  44528. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44529. * @param mesh The mesh to replace the default mesh of the gizmo
  44530. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44531. */
  44532. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44533. }
  44534. }
  44535. declare module BABYLON {
  44536. /**
  44537. * Bounding box gizmo
  44538. */
  44539. export class BoundingBoxGizmo extends Gizmo {
  44540. private _lineBoundingBox;
  44541. private _rotateSpheresParent;
  44542. private _scaleBoxesParent;
  44543. private _boundingDimensions;
  44544. private _renderObserver;
  44545. private _pointerObserver;
  44546. private _scaleDragSpeed;
  44547. private _tmpQuaternion;
  44548. private _tmpVector;
  44549. private _tmpRotationMatrix;
  44550. /**
  44551. * 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)
  44552. */
  44553. ignoreChildren: boolean;
  44554. /**
  44555. * 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)
  44556. */
  44557. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44558. /**
  44559. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44560. */
  44561. rotationSphereSize: number;
  44562. /**
  44563. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44564. */
  44565. scaleBoxSize: number;
  44566. /**
  44567. * 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)
  44568. */
  44569. fixedDragMeshScreenSize: boolean;
  44570. /**
  44571. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44572. */
  44573. fixedDragMeshScreenSizeDistanceFactor: number;
  44574. /**
  44575. * Fired when a rotation sphere or scale box is dragged
  44576. */
  44577. onDragStartObservable: Observable<{}>;
  44578. /**
  44579. * Fired when a scale box is dragged
  44580. */
  44581. onScaleBoxDragObservable: Observable<{}>;
  44582. /**
  44583. * Fired when a scale box drag is ended
  44584. */
  44585. onScaleBoxDragEndObservable: Observable<{}>;
  44586. /**
  44587. * Fired when a rotation sphere is dragged
  44588. */
  44589. onRotationSphereDragObservable: Observable<{}>;
  44590. /**
  44591. * Fired when a rotation sphere drag is ended
  44592. */
  44593. onRotationSphereDragEndObservable: Observable<{}>;
  44594. /**
  44595. * 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)
  44596. */
  44597. scalePivot: Nullable<Vector3>;
  44598. /**
  44599. * Mesh used as a pivot to rotate the attached mesh
  44600. */
  44601. private _anchorMesh;
  44602. private _existingMeshScale;
  44603. private _dragMesh;
  44604. private pointerDragBehavior;
  44605. private coloredMaterial;
  44606. private hoverColoredMaterial;
  44607. /**
  44608. * Sets the color of the bounding box gizmo
  44609. * @param color the color to set
  44610. */
  44611. setColor(color: Color3): void;
  44612. /**
  44613. * Creates an BoundingBoxGizmo
  44614. * @param gizmoLayer The utility layer the gizmo will be added to
  44615. * @param color The color of the gizmo
  44616. */
  44617. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44618. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44619. private _selectNode;
  44620. /**
  44621. * Updates the bounding box information for the Gizmo
  44622. */
  44623. updateBoundingBox(): void;
  44624. private _updateRotationSpheres;
  44625. private _updateScaleBoxes;
  44626. /**
  44627. * Enables rotation on the specified axis and disables rotation on the others
  44628. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44629. */
  44630. setEnabledRotationAxis(axis: string): void;
  44631. /**
  44632. * Enables/disables scaling
  44633. * @param enable if scaling should be enabled
  44634. */
  44635. setEnabledScaling(enable: boolean): void;
  44636. private _updateDummy;
  44637. /**
  44638. * Enables a pointer drag behavior on the bounding box of the gizmo
  44639. */
  44640. enableDragBehavior(): void;
  44641. /**
  44642. * Disposes of the gizmo
  44643. */
  44644. dispose(): void;
  44645. /**
  44646. * 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)
  44647. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44648. * @returns the bounding box mesh with the passed in mesh as a child
  44649. */
  44650. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44651. /**
  44652. * CustomMeshes are not supported by this gizmo
  44653. * @param mesh The mesh to replace the default mesh of the gizmo
  44654. */
  44655. setCustomMesh(mesh: Mesh): void;
  44656. }
  44657. }
  44658. declare module BABYLON {
  44659. /**
  44660. * Single plane rotation gizmo
  44661. */
  44662. export class PlaneRotationGizmo extends Gizmo {
  44663. /**
  44664. * Drag behavior responsible for the gizmos dragging interactions
  44665. */
  44666. dragBehavior: PointerDragBehavior;
  44667. private _pointerObserver;
  44668. /**
  44669. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44670. */
  44671. snapDistance: number;
  44672. /**
  44673. * Event that fires each time the gizmo snaps to a new location.
  44674. * * snapDistance is the the change in distance
  44675. */
  44676. onSnapObservable: Observable<{
  44677. snapDistance: number;
  44678. }>;
  44679. private _isEnabled;
  44680. private _parent;
  44681. /**
  44682. * Creates a PlaneRotationGizmo
  44683. * @param gizmoLayer The utility layer the gizmo will be added to
  44684. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44685. * @param color The color of the gizmo
  44686. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44687. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44688. */
  44689. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44691. /**
  44692. * If the gizmo is enabled
  44693. */
  44694. isEnabled: boolean;
  44695. /**
  44696. * Disposes of the gizmo
  44697. */
  44698. dispose(): void;
  44699. }
  44700. }
  44701. declare module BABYLON {
  44702. /**
  44703. * Gizmo that enables rotating a mesh along 3 axis
  44704. */
  44705. export class RotationGizmo extends Gizmo {
  44706. /**
  44707. * Internal gizmo used for interactions on the x axis
  44708. */
  44709. xGizmo: PlaneRotationGizmo;
  44710. /**
  44711. * Internal gizmo used for interactions on the y axis
  44712. */
  44713. yGizmo: PlaneRotationGizmo;
  44714. /**
  44715. * Internal gizmo used for interactions on the z axis
  44716. */
  44717. zGizmo: PlaneRotationGizmo;
  44718. /** Fires an event when any of it's sub gizmos are dragged */
  44719. onDragStartObservable: Observable<unknown>;
  44720. /** Fires an event when any of it's sub gizmos are released from dragging */
  44721. onDragEndObservable: Observable<unknown>;
  44722. private _meshAttached;
  44723. attachedMesh: Nullable<AbstractMesh>;
  44724. /**
  44725. * Creates a RotationGizmo
  44726. * @param gizmoLayer The utility layer the gizmo will be added to
  44727. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44728. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44729. */
  44730. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44731. updateGizmoRotationToMatchAttachedMesh: boolean;
  44732. /**
  44733. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44734. */
  44735. snapDistance: number;
  44736. /**
  44737. * Ratio for the scale of the gizmo (Default: 1)
  44738. */
  44739. scaleRatio: number;
  44740. /**
  44741. * Disposes of the gizmo
  44742. */
  44743. dispose(): void;
  44744. /**
  44745. * CustomMeshes are not supported by this gizmo
  44746. * @param mesh The mesh to replace the default mesh of the gizmo
  44747. */
  44748. setCustomMesh(mesh: Mesh): void;
  44749. }
  44750. }
  44751. declare module BABYLON {
  44752. /**
  44753. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44754. */
  44755. export class GizmoManager implements IDisposable {
  44756. private scene;
  44757. /**
  44758. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44759. */
  44760. gizmos: {
  44761. positionGizmo: Nullable<PositionGizmo>;
  44762. rotationGizmo: Nullable<RotationGizmo>;
  44763. scaleGizmo: Nullable<ScaleGizmo>;
  44764. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44765. };
  44766. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44767. clearGizmoOnEmptyPointerEvent: boolean;
  44768. /** Fires an event when the manager is attached to a mesh */
  44769. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44770. private _gizmosEnabled;
  44771. private _pointerObserver;
  44772. private _attachedMesh;
  44773. private _boundingBoxColor;
  44774. private _defaultUtilityLayer;
  44775. private _defaultKeepDepthUtilityLayer;
  44776. /**
  44777. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44778. */
  44779. boundingBoxDragBehavior: SixDofDragBehavior;
  44780. /**
  44781. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44782. */
  44783. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44784. /**
  44785. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44786. */
  44787. usePointerToAttachGizmos: boolean;
  44788. /**
  44789. * Utility layer that the bounding box gizmo belongs to
  44790. */
  44791. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44792. /**
  44793. * Utility layer that all gizmos besides bounding box belong to
  44794. */
  44795. readonly utilityLayer: UtilityLayerRenderer;
  44796. /**
  44797. * Instatiates a gizmo manager
  44798. * @param scene the scene to overlay the gizmos on top of
  44799. */
  44800. constructor(scene: Scene);
  44801. /**
  44802. * Attaches a set of gizmos to the specified mesh
  44803. * @param mesh The mesh the gizmo's should be attached to
  44804. */
  44805. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44806. /**
  44807. * If the position gizmo is enabled
  44808. */
  44809. positionGizmoEnabled: boolean;
  44810. /**
  44811. * If the rotation gizmo is enabled
  44812. */
  44813. rotationGizmoEnabled: boolean;
  44814. /**
  44815. * If the scale gizmo is enabled
  44816. */
  44817. scaleGizmoEnabled: boolean;
  44818. /**
  44819. * If the boundingBox gizmo is enabled
  44820. */
  44821. boundingBoxGizmoEnabled: boolean;
  44822. /**
  44823. * Disposes of the gizmo manager
  44824. */
  44825. dispose(): void;
  44826. }
  44827. }
  44828. declare module BABYLON {
  44829. /**
  44830. * A directional light is defined by a direction (what a surprise!).
  44831. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44832. * 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.
  44833. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44834. */
  44835. export class DirectionalLight extends ShadowLight {
  44836. private _shadowFrustumSize;
  44837. /**
  44838. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44839. */
  44840. /**
  44841. * Specifies a fix frustum size for the shadow generation.
  44842. */
  44843. shadowFrustumSize: number;
  44844. private _shadowOrthoScale;
  44845. /**
  44846. * Gets the shadow projection scale against the optimal computed one.
  44847. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44848. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44849. */
  44850. /**
  44851. * Sets the shadow projection scale against the optimal computed one.
  44852. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44853. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44854. */
  44855. shadowOrthoScale: number;
  44856. /**
  44857. * Automatically compute the projection matrix to best fit (including all the casters)
  44858. * on each frame.
  44859. */
  44860. autoUpdateExtends: boolean;
  44861. private _orthoLeft;
  44862. private _orthoRight;
  44863. private _orthoTop;
  44864. private _orthoBottom;
  44865. /**
  44866. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44867. * The directional light is emitted from everywhere in the given direction.
  44868. * It can cast shadows.
  44869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44870. * @param name The friendly name of the light
  44871. * @param direction The direction of the light
  44872. * @param scene The scene the light belongs to
  44873. */
  44874. constructor(name: string, direction: Vector3, scene: Scene);
  44875. /**
  44876. * Returns the string "DirectionalLight".
  44877. * @return The class name
  44878. */
  44879. getClassName(): string;
  44880. /**
  44881. * Returns the integer 1.
  44882. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44883. */
  44884. getTypeID(): number;
  44885. /**
  44886. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44887. * Returns the DirectionalLight Shadow projection matrix.
  44888. */
  44889. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44890. /**
  44891. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44892. * Returns the DirectionalLight Shadow projection matrix.
  44893. */
  44894. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44895. /**
  44896. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44897. * Returns the DirectionalLight Shadow projection matrix.
  44898. */
  44899. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44900. protected _buildUniformLayout(): void;
  44901. /**
  44902. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44903. * @param effect The effect to update
  44904. * @param lightIndex The index of the light in the effect to update
  44905. * @returns The directional light
  44906. */
  44907. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44908. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44909. /**
  44910. * Gets the minZ used for shadow according to both the scene and the light.
  44911. *
  44912. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44913. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44914. * @param activeCamera The camera we are returning the min for
  44915. * @returns the depth min z
  44916. */
  44917. getDepthMinZ(activeCamera: Camera): number;
  44918. /**
  44919. * Gets the maxZ used for shadow according to both the scene and the light.
  44920. *
  44921. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44922. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44923. * @param activeCamera The camera we are returning the max for
  44924. * @returns the depth max z
  44925. */
  44926. getDepthMaxZ(activeCamera: Camera): number;
  44927. /**
  44928. * Prepares the list of defines specific to the light type.
  44929. * @param defines the list of defines
  44930. * @param lightIndex defines the index of the light for the effect
  44931. */
  44932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44933. }
  44934. }
  44935. declare module BABYLON {
  44936. /**
  44937. * Class containing static functions to help procedurally build meshes
  44938. */
  44939. export class HemisphereBuilder {
  44940. /**
  44941. * Creates a hemisphere mesh
  44942. * @param name defines the name of the mesh
  44943. * @param options defines the options used to create the mesh
  44944. * @param scene defines the hosting scene
  44945. * @returns the hemisphere mesh
  44946. */
  44947. static CreateHemisphere(name: string, options: {
  44948. segments?: number;
  44949. diameter?: number;
  44950. sideOrientation?: number;
  44951. }, scene: any): Mesh;
  44952. }
  44953. }
  44954. declare module BABYLON {
  44955. /**
  44956. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44957. * These values define a cone of light starting from the position, emitting toward the direction.
  44958. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44959. * and the exponent defines the speed of the decay of the light with distance (reach).
  44960. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44961. */
  44962. export class SpotLight extends ShadowLight {
  44963. private _angle;
  44964. private _innerAngle;
  44965. private _cosHalfAngle;
  44966. private _lightAngleScale;
  44967. private _lightAngleOffset;
  44968. /**
  44969. * Gets the cone angle of the spot light in Radians.
  44970. */
  44971. /**
  44972. * Sets the cone angle of the spot light in Radians.
  44973. */
  44974. angle: number;
  44975. /**
  44976. * Only used in gltf falloff mode, this defines the angle where
  44977. * the directional falloff will start before cutting at angle which could be seen
  44978. * as outer angle.
  44979. */
  44980. /**
  44981. * Only used in gltf falloff mode, this defines the angle where
  44982. * the directional falloff will start before cutting at angle which could be seen
  44983. * as outer angle.
  44984. */
  44985. innerAngle: number;
  44986. private _shadowAngleScale;
  44987. /**
  44988. * Allows scaling the angle of the light for shadow generation only.
  44989. */
  44990. /**
  44991. * Allows scaling the angle of the light for shadow generation only.
  44992. */
  44993. shadowAngleScale: number;
  44994. /**
  44995. * The light decay speed with the distance from the emission spot.
  44996. */
  44997. exponent: number;
  44998. private _projectionTextureMatrix;
  44999. /**
  45000. * Allows reading the projecton texture
  45001. */
  45002. readonly projectionTextureMatrix: Matrix;
  45003. protected _projectionTextureLightNear: number;
  45004. /**
  45005. * Gets the near clip of the Spotlight for texture projection.
  45006. */
  45007. /**
  45008. * Sets the near clip of the Spotlight for texture projection.
  45009. */
  45010. projectionTextureLightNear: number;
  45011. protected _projectionTextureLightFar: number;
  45012. /**
  45013. * Gets the far clip of the Spotlight for texture projection.
  45014. */
  45015. /**
  45016. * Sets the far clip of the Spotlight for texture projection.
  45017. */
  45018. projectionTextureLightFar: number;
  45019. protected _projectionTextureUpDirection: Vector3;
  45020. /**
  45021. * Gets the Up vector of the Spotlight for texture projection.
  45022. */
  45023. /**
  45024. * Sets the Up vector of the Spotlight for texture projection.
  45025. */
  45026. projectionTextureUpDirection: Vector3;
  45027. private _projectionTexture;
  45028. /**
  45029. * Gets the projection texture of the light.
  45030. */
  45031. /**
  45032. * Sets the projection texture of the light.
  45033. */
  45034. projectionTexture: Nullable<BaseTexture>;
  45035. private _projectionTextureViewLightDirty;
  45036. private _projectionTextureProjectionLightDirty;
  45037. private _projectionTextureDirty;
  45038. private _projectionTextureViewTargetVector;
  45039. private _projectionTextureViewLightMatrix;
  45040. private _projectionTextureProjectionLightMatrix;
  45041. private _projectionTextureScalingMatrix;
  45042. /**
  45043. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45044. * It can cast shadows.
  45045. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45046. * @param name The light friendly name
  45047. * @param position The position of the spot light in the scene
  45048. * @param direction The direction of the light in the scene
  45049. * @param angle The cone angle of the light in Radians
  45050. * @param exponent The light decay speed with the distance from the emission spot
  45051. * @param scene The scene the lights belongs to
  45052. */
  45053. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45054. /**
  45055. * Returns the string "SpotLight".
  45056. * @returns the class name
  45057. */
  45058. getClassName(): string;
  45059. /**
  45060. * Returns the integer 2.
  45061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45062. */
  45063. getTypeID(): number;
  45064. /**
  45065. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45066. */
  45067. protected _setDirection(value: Vector3): void;
  45068. /**
  45069. * Overrides the position setter to recompute the projection texture view light Matrix.
  45070. */
  45071. protected _setPosition(value: Vector3): void;
  45072. /**
  45073. * 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.
  45074. * Returns the SpotLight.
  45075. */
  45076. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45077. protected _computeProjectionTextureViewLightMatrix(): void;
  45078. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45079. /**
  45080. * Main function for light texture projection matrix computing.
  45081. */
  45082. protected _computeProjectionTextureMatrix(): void;
  45083. protected _buildUniformLayout(): void;
  45084. private _computeAngleValues;
  45085. /**
  45086. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45087. * @param effect The effect to update
  45088. * @param lightIndex The index of the light in the effect to update
  45089. * @returns The spot light
  45090. */
  45091. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45092. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45093. /**
  45094. * Disposes the light and the associated resources.
  45095. */
  45096. dispose(): void;
  45097. /**
  45098. * Prepares the list of defines specific to the light type.
  45099. * @param defines the list of defines
  45100. * @param lightIndex defines the index of the light for the effect
  45101. */
  45102. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45103. }
  45104. }
  45105. declare module BABYLON {
  45106. /**
  45107. * Gizmo that enables viewing a light
  45108. */
  45109. export class LightGizmo extends Gizmo {
  45110. private _lightMesh;
  45111. private _material;
  45112. private cachedPosition;
  45113. private cachedForward;
  45114. /**
  45115. * Creates a LightGizmo
  45116. * @param gizmoLayer The utility layer the gizmo will be added to
  45117. */
  45118. constructor(gizmoLayer?: UtilityLayerRenderer);
  45119. private _light;
  45120. /**
  45121. * The light that the gizmo is attached to
  45122. */
  45123. light: Nullable<Light>;
  45124. /**
  45125. * Gets the material used to render the light gizmo
  45126. */
  45127. readonly material: StandardMaterial;
  45128. /**
  45129. * @hidden
  45130. * Updates the gizmo to match the attached mesh's position/rotation
  45131. */
  45132. protected _update(): void;
  45133. private static _Scale;
  45134. /**
  45135. * Creates the lines for a light mesh
  45136. */
  45137. private static _createLightLines;
  45138. /**
  45139. * Disposes of the light gizmo
  45140. */
  45141. dispose(): void;
  45142. private static _CreateHemisphericLightMesh;
  45143. private static _CreatePointLightMesh;
  45144. private static _CreateSpotLightMesh;
  45145. private static _CreateDirectionalLightMesh;
  45146. }
  45147. }
  45148. declare module BABYLON {
  45149. /** @hidden */
  45150. export var backgroundFragmentDeclaration: {
  45151. name: string;
  45152. shader: string;
  45153. };
  45154. }
  45155. declare module BABYLON {
  45156. /** @hidden */
  45157. export var backgroundUboDeclaration: {
  45158. name: string;
  45159. shader: string;
  45160. };
  45161. }
  45162. declare module BABYLON {
  45163. /** @hidden */
  45164. export var backgroundPixelShader: {
  45165. name: string;
  45166. shader: string;
  45167. };
  45168. }
  45169. declare module BABYLON {
  45170. /** @hidden */
  45171. export var backgroundVertexDeclaration: {
  45172. name: string;
  45173. shader: string;
  45174. };
  45175. }
  45176. declare module BABYLON {
  45177. /** @hidden */
  45178. export var backgroundVertexShader: {
  45179. name: string;
  45180. shader: string;
  45181. };
  45182. }
  45183. declare module BABYLON {
  45184. /**
  45185. * Background material used to create an efficient environement around your scene.
  45186. */
  45187. export class BackgroundMaterial extends PushMaterial {
  45188. /**
  45189. * Standard reflectance value at parallel view angle.
  45190. */
  45191. static StandardReflectance0: number;
  45192. /**
  45193. * Standard reflectance value at grazing angle.
  45194. */
  45195. static StandardReflectance90: number;
  45196. protected _primaryColor: Color3;
  45197. /**
  45198. * Key light Color (multiply against the environement texture)
  45199. */
  45200. primaryColor: Color3;
  45201. protected __perceptualColor: Nullable<Color3>;
  45202. /**
  45203. * Experimental Internal Use Only.
  45204. *
  45205. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45206. * This acts as a helper to set the primary color to a more "human friendly" value.
  45207. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45208. * output color as close as possible from the chosen value.
  45209. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45210. * part of lighting setup.)
  45211. */
  45212. _perceptualColor: Nullable<Color3>;
  45213. protected _primaryColorShadowLevel: float;
  45214. /**
  45215. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45216. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45217. */
  45218. primaryColorShadowLevel: float;
  45219. protected _primaryColorHighlightLevel: float;
  45220. /**
  45221. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45222. * The primary color is used at the level chosen to define what the white area would look.
  45223. */
  45224. primaryColorHighlightLevel: float;
  45225. protected _reflectionTexture: Nullable<BaseTexture>;
  45226. /**
  45227. * Reflection Texture used in the material.
  45228. * Should be author in a specific way for the best result (refer to the documentation).
  45229. */
  45230. reflectionTexture: Nullable<BaseTexture>;
  45231. protected _reflectionBlur: float;
  45232. /**
  45233. * Reflection Texture level of blur.
  45234. *
  45235. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45236. * texture twice.
  45237. */
  45238. reflectionBlur: float;
  45239. protected _diffuseTexture: Nullable<BaseTexture>;
  45240. /**
  45241. * Diffuse Texture used in the material.
  45242. * Should be author in a specific way for the best result (refer to the documentation).
  45243. */
  45244. diffuseTexture: Nullable<BaseTexture>;
  45245. protected _shadowLights: Nullable<IShadowLight[]>;
  45246. /**
  45247. * Specify the list of lights casting shadow on the material.
  45248. * All scene shadow lights will be included if null.
  45249. */
  45250. shadowLights: Nullable<IShadowLight[]>;
  45251. protected _shadowLevel: float;
  45252. /**
  45253. * Helps adjusting the shadow to a softer level if required.
  45254. * 0 means black shadows and 1 means no shadows.
  45255. */
  45256. shadowLevel: float;
  45257. protected _sceneCenter: Vector3;
  45258. /**
  45259. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45260. * It is usually zero but might be interesting to modify according to your setup.
  45261. */
  45262. sceneCenter: Vector3;
  45263. protected _opacityFresnel: boolean;
  45264. /**
  45265. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45266. * This helps ensuring a nice transition when the camera goes under the ground.
  45267. */
  45268. opacityFresnel: boolean;
  45269. protected _reflectionFresnel: boolean;
  45270. /**
  45271. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45272. * This helps adding a mirror texture on the ground.
  45273. */
  45274. reflectionFresnel: boolean;
  45275. protected _reflectionFalloffDistance: number;
  45276. /**
  45277. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45278. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45279. */
  45280. reflectionFalloffDistance: number;
  45281. protected _reflectionAmount: number;
  45282. /**
  45283. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45284. */
  45285. reflectionAmount: number;
  45286. protected _reflectionReflectance0: number;
  45287. /**
  45288. * This specifies the weight of the reflection at grazing angle.
  45289. */
  45290. reflectionReflectance0: number;
  45291. protected _reflectionReflectance90: number;
  45292. /**
  45293. * This specifies the weight of the reflection at a perpendicular point of view.
  45294. */
  45295. reflectionReflectance90: number;
  45296. /**
  45297. * Sets the reflection reflectance fresnel values according to the default standard
  45298. * empirically know to work well :-)
  45299. */
  45300. reflectionStandardFresnelWeight: number;
  45301. protected _useRGBColor: boolean;
  45302. /**
  45303. * Helps to directly use the maps channels instead of their level.
  45304. */
  45305. useRGBColor: boolean;
  45306. protected _enableNoise: boolean;
  45307. /**
  45308. * This helps reducing the banding effect that could occur on the background.
  45309. */
  45310. enableNoise: boolean;
  45311. /**
  45312. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45313. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45314. * Recommended to be keep at 1.0 except for special cases.
  45315. */
  45316. fovMultiplier: number;
  45317. private _fovMultiplier;
  45318. /**
  45319. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45320. */
  45321. useEquirectangularFOV: boolean;
  45322. private _maxSimultaneousLights;
  45323. /**
  45324. * Number of Simultaneous lights allowed on the material.
  45325. */
  45326. maxSimultaneousLights: int;
  45327. /**
  45328. * Default configuration related to image processing available in the Background Material.
  45329. */
  45330. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45331. /**
  45332. * Keep track of the image processing observer to allow dispose and replace.
  45333. */
  45334. private _imageProcessingObserver;
  45335. /**
  45336. * Attaches a new image processing configuration to the PBR Material.
  45337. * @param configuration (if null the scene configuration will be use)
  45338. */
  45339. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45340. /**
  45341. * Gets the image processing configuration used either in this material.
  45342. */
  45343. /**
  45344. * Sets the Default image processing configuration used either in the this material.
  45345. *
  45346. * If sets to null, the scene one is in use.
  45347. */
  45348. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45349. /**
  45350. * Gets wether the color curves effect is enabled.
  45351. */
  45352. /**
  45353. * Sets wether the color curves effect is enabled.
  45354. */
  45355. cameraColorCurvesEnabled: boolean;
  45356. /**
  45357. * Gets wether the color grading effect is enabled.
  45358. */
  45359. /**
  45360. * Gets wether the color grading effect is enabled.
  45361. */
  45362. cameraColorGradingEnabled: boolean;
  45363. /**
  45364. * Gets wether tonemapping is enabled or not.
  45365. */
  45366. /**
  45367. * Sets wether tonemapping is enabled or not
  45368. */
  45369. cameraToneMappingEnabled: boolean;
  45370. /**
  45371. * The camera exposure used on this material.
  45372. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45373. * This corresponds to a photographic exposure.
  45374. */
  45375. /**
  45376. * The camera exposure used on this material.
  45377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45378. * This corresponds to a photographic exposure.
  45379. */
  45380. cameraExposure: float;
  45381. /**
  45382. * Gets The camera contrast used on this material.
  45383. */
  45384. /**
  45385. * Sets The camera contrast used on this material.
  45386. */
  45387. cameraContrast: float;
  45388. /**
  45389. * Gets the Color Grading 2D Lookup Texture.
  45390. */
  45391. /**
  45392. * Sets the Color Grading 2D Lookup Texture.
  45393. */
  45394. cameraColorGradingTexture: Nullable<BaseTexture>;
  45395. /**
  45396. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45397. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45398. * 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;
  45399. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45400. */
  45401. /**
  45402. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45403. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45404. * 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;
  45405. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45406. */
  45407. cameraColorCurves: Nullable<ColorCurves>;
  45408. /**
  45409. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45410. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45411. */
  45412. switchToBGR: boolean;
  45413. private _renderTargets;
  45414. private _reflectionControls;
  45415. private _white;
  45416. private _primaryShadowColor;
  45417. private _primaryHighlightColor;
  45418. /**
  45419. * Instantiates a Background Material in the given scene
  45420. * @param name The friendly name of the material
  45421. * @param scene The scene to add the material to
  45422. */
  45423. constructor(name: string, scene: Scene);
  45424. /**
  45425. * Gets a boolean indicating that current material needs to register RTT
  45426. */
  45427. readonly hasRenderTargetTextures: boolean;
  45428. /**
  45429. * The entire material has been created in order to prevent overdraw.
  45430. * @returns false
  45431. */
  45432. needAlphaTesting(): boolean;
  45433. /**
  45434. * The entire material has been created in order to prevent overdraw.
  45435. * @returns true if blending is enable
  45436. */
  45437. needAlphaBlending(): boolean;
  45438. /**
  45439. * Checks wether the material is ready to be rendered for a given mesh.
  45440. * @param mesh The mesh to render
  45441. * @param subMesh The submesh to check against
  45442. * @param useInstances Specify wether or not the material is used with instances
  45443. * @returns true if all the dependencies are ready (Textures, Effects...)
  45444. */
  45445. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45446. /**
  45447. * Compute the primary color according to the chosen perceptual color.
  45448. */
  45449. private _computePrimaryColorFromPerceptualColor;
  45450. /**
  45451. * Compute the highlights and shadow colors according to their chosen levels.
  45452. */
  45453. private _computePrimaryColors;
  45454. /**
  45455. * Build the uniform buffer used in the material.
  45456. */
  45457. buildUniformLayout(): void;
  45458. /**
  45459. * Unbind the material.
  45460. */
  45461. unbind(): void;
  45462. /**
  45463. * Bind only the world matrix to the material.
  45464. * @param world The world matrix to bind.
  45465. */
  45466. bindOnlyWorldMatrix(world: Matrix): void;
  45467. /**
  45468. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45469. * @param world The world matrix to bind.
  45470. * @param subMesh The submesh to bind for.
  45471. */
  45472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45473. /**
  45474. * Checks to see if a texture is used in the material.
  45475. * @param texture - Base texture to use.
  45476. * @returns - Boolean specifying if a texture is used in the material.
  45477. */
  45478. hasTexture(texture: BaseTexture): boolean;
  45479. /**
  45480. * Dispose the material.
  45481. * @param forceDisposeEffect Force disposal of the associated effect.
  45482. * @param forceDisposeTextures Force disposal of the associated textures.
  45483. */
  45484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45485. /**
  45486. * Clones the material.
  45487. * @param name The cloned name.
  45488. * @returns The cloned material.
  45489. */
  45490. clone(name: string): BackgroundMaterial;
  45491. /**
  45492. * Serializes the current material to its JSON representation.
  45493. * @returns The JSON representation.
  45494. */
  45495. serialize(): any;
  45496. /**
  45497. * Gets the class name of the material
  45498. * @returns "BackgroundMaterial"
  45499. */
  45500. getClassName(): string;
  45501. /**
  45502. * Parse a JSON input to create back a background material.
  45503. * @param source The JSON data to parse
  45504. * @param scene The scene to create the parsed material in
  45505. * @param rootUrl The root url of the assets the material depends upon
  45506. * @returns the instantiated BackgroundMaterial.
  45507. */
  45508. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45509. }
  45510. }
  45511. declare module BABYLON {
  45512. /**
  45513. * Represents the different options available during the creation of
  45514. * a Environment helper.
  45515. *
  45516. * This can control the default ground, skybox and image processing setup of your scene.
  45517. */
  45518. export interface IEnvironmentHelperOptions {
  45519. /**
  45520. * Specifies wether or not to create a ground.
  45521. * True by default.
  45522. */
  45523. createGround: boolean;
  45524. /**
  45525. * Specifies the ground size.
  45526. * 15 by default.
  45527. */
  45528. groundSize: number;
  45529. /**
  45530. * The texture used on the ground for the main color.
  45531. * Comes from the BabylonJS CDN by default.
  45532. *
  45533. * Remarks: Can be either a texture or a url.
  45534. */
  45535. groundTexture: string | BaseTexture;
  45536. /**
  45537. * The color mixed in the ground texture by default.
  45538. * BabylonJS clearColor by default.
  45539. */
  45540. groundColor: Color3;
  45541. /**
  45542. * Specifies the ground opacity.
  45543. * 1 by default.
  45544. */
  45545. groundOpacity: number;
  45546. /**
  45547. * Enables the ground to receive shadows.
  45548. * True by default.
  45549. */
  45550. enableGroundShadow: boolean;
  45551. /**
  45552. * Helps preventing the shadow to be fully black on the ground.
  45553. * 0.5 by default.
  45554. */
  45555. groundShadowLevel: number;
  45556. /**
  45557. * Creates a mirror texture attach to the ground.
  45558. * false by default.
  45559. */
  45560. enableGroundMirror: boolean;
  45561. /**
  45562. * Specifies the ground mirror size ratio.
  45563. * 0.3 by default as the default kernel is 64.
  45564. */
  45565. groundMirrorSizeRatio: number;
  45566. /**
  45567. * Specifies the ground mirror blur kernel size.
  45568. * 64 by default.
  45569. */
  45570. groundMirrorBlurKernel: number;
  45571. /**
  45572. * Specifies the ground mirror visibility amount.
  45573. * 1 by default
  45574. */
  45575. groundMirrorAmount: number;
  45576. /**
  45577. * Specifies the ground mirror reflectance weight.
  45578. * This uses the standard weight of the background material to setup the fresnel effect
  45579. * of the mirror.
  45580. * 1 by default.
  45581. */
  45582. groundMirrorFresnelWeight: number;
  45583. /**
  45584. * Specifies the ground mirror Falloff distance.
  45585. * This can helps reducing the size of the reflection.
  45586. * 0 by Default.
  45587. */
  45588. groundMirrorFallOffDistance: number;
  45589. /**
  45590. * Specifies the ground mirror texture type.
  45591. * Unsigned Int by Default.
  45592. */
  45593. groundMirrorTextureType: number;
  45594. /**
  45595. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45596. * the shown objects.
  45597. */
  45598. groundYBias: number;
  45599. /**
  45600. * Specifies wether or not to create a skybox.
  45601. * True by default.
  45602. */
  45603. createSkybox: boolean;
  45604. /**
  45605. * Specifies the skybox size.
  45606. * 20 by default.
  45607. */
  45608. skyboxSize: number;
  45609. /**
  45610. * The texture used on the skybox for the main color.
  45611. * Comes from the BabylonJS CDN by default.
  45612. *
  45613. * Remarks: Can be either a texture or a url.
  45614. */
  45615. skyboxTexture: string | BaseTexture;
  45616. /**
  45617. * The color mixed in the skybox texture by default.
  45618. * BabylonJS clearColor by default.
  45619. */
  45620. skyboxColor: Color3;
  45621. /**
  45622. * The background rotation around the Y axis of the scene.
  45623. * This helps aligning the key lights of your scene with the background.
  45624. * 0 by default.
  45625. */
  45626. backgroundYRotation: number;
  45627. /**
  45628. * Compute automatically the size of the elements to best fit with the scene.
  45629. */
  45630. sizeAuto: boolean;
  45631. /**
  45632. * Default position of the rootMesh if autoSize is not true.
  45633. */
  45634. rootPosition: Vector3;
  45635. /**
  45636. * Sets up the image processing in the scene.
  45637. * true by default.
  45638. */
  45639. setupImageProcessing: boolean;
  45640. /**
  45641. * The texture used as your environment texture in the scene.
  45642. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45643. *
  45644. * Remarks: Can be either a texture or a url.
  45645. */
  45646. environmentTexture: string | BaseTexture;
  45647. /**
  45648. * The value of the exposure to apply to the scene.
  45649. * 0.6 by default if setupImageProcessing is true.
  45650. */
  45651. cameraExposure: number;
  45652. /**
  45653. * The value of the contrast to apply to the scene.
  45654. * 1.6 by default if setupImageProcessing is true.
  45655. */
  45656. cameraContrast: number;
  45657. /**
  45658. * Specifies wether or not tonemapping should be enabled in the scene.
  45659. * true by default if setupImageProcessing is true.
  45660. */
  45661. toneMappingEnabled: boolean;
  45662. }
  45663. /**
  45664. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45665. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45666. * It also helps with the default setup of your imageProcessing configuration.
  45667. */
  45668. export class EnvironmentHelper {
  45669. /**
  45670. * Default ground texture URL.
  45671. */
  45672. private static _groundTextureCDNUrl;
  45673. /**
  45674. * Default skybox texture URL.
  45675. */
  45676. private static _skyboxTextureCDNUrl;
  45677. /**
  45678. * Default environment texture URL.
  45679. */
  45680. private static _environmentTextureCDNUrl;
  45681. /**
  45682. * Creates the default options for the helper.
  45683. */
  45684. private static _getDefaultOptions;
  45685. private _rootMesh;
  45686. /**
  45687. * Gets the root mesh created by the helper.
  45688. */
  45689. readonly rootMesh: Mesh;
  45690. private _skybox;
  45691. /**
  45692. * Gets the skybox created by the helper.
  45693. */
  45694. readonly skybox: Nullable<Mesh>;
  45695. private _skyboxTexture;
  45696. /**
  45697. * Gets the skybox texture created by the helper.
  45698. */
  45699. readonly skyboxTexture: Nullable<BaseTexture>;
  45700. private _skyboxMaterial;
  45701. /**
  45702. * Gets the skybox material created by the helper.
  45703. */
  45704. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45705. private _ground;
  45706. /**
  45707. * Gets the ground mesh created by the helper.
  45708. */
  45709. readonly ground: Nullable<Mesh>;
  45710. private _groundTexture;
  45711. /**
  45712. * Gets the ground texture created by the helper.
  45713. */
  45714. readonly groundTexture: Nullable<BaseTexture>;
  45715. private _groundMirror;
  45716. /**
  45717. * Gets the ground mirror created by the helper.
  45718. */
  45719. readonly groundMirror: Nullable<MirrorTexture>;
  45720. /**
  45721. * Gets the ground mirror render list to helps pushing the meshes
  45722. * you wish in the ground reflection.
  45723. */
  45724. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45725. private _groundMaterial;
  45726. /**
  45727. * Gets the ground material created by the helper.
  45728. */
  45729. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45730. /**
  45731. * Stores the creation options.
  45732. */
  45733. private readonly _scene;
  45734. private _options;
  45735. /**
  45736. * This observable will be notified with any error during the creation of the environment,
  45737. * mainly texture creation errors.
  45738. */
  45739. onErrorObservable: Observable<{
  45740. message?: string;
  45741. exception?: any;
  45742. }>;
  45743. /**
  45744. * constructor
  45745. * @param options Defines the options we want to customize the helper
  45746. * @param scene The scene to add the material to
  45747. */
  45748. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45749. /**
  45750. * Updates the background according to the new options
  45751. * @param options
  45752. */
  45753. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45754. /**
  45755. * Sets the primary color of all the available elements.
  45756. * @param color the main color to affect to the ground and the background
  45757. */
  45758. setMainColor(color: Color3): void;
  45759. /**
  45760. * Setup the image processing according to the specified options.
  45761. */
  45762. private _setupImageProcessing;
  45763. /**
  45764. * Setup the environment texture according to the specified options.
  45765. */
  45766. private _setupEnvironmentTexture;
  45767. /**
  45768. * Setup the background according to the specified options.
  45769. */
  45770. private _setupBackground;
  45771. /**
  45772. * Get the scene sizes according to the setup.
  45773. */
  45774. private _getSceneSize;
  45775. /**
  45776. * Setup the ground according to the specified options.
  45777. */
  45778. private _setupGround;
  45779. /**
  45780. * Setup the ground material according to the specified options.
  45781. */
  45782. private _setupGroundMaterial;
  45783. /**
  45784. * Setup the ground diffuse texture according to the specified options.
  45785. */
  45786. private _setupGroundDiffuseTexture;
  45787. /**
  45788. * Setup the ground mirror texture according to the specified options.
  45789. */
  45790. private _setupGroundMirrorTexture;
  45791. /**
  45792. * Setup the ground to receive the mirror texture.
  45793. */
  45794. private _setupMirrorInGroundMaterial;
  45795. /**
  45796. * Setup the skybox according to the specified options.
  45797. */
  45798. private _setupSkybox;
  45799. /**
  45800. * Setup the skybox material according to the specified options.
  45801. */
  45802. private _setupSkyboxMaterial;
  45803. /**
  45804. * Setup the skybox reflection texture according to the specified options.
  45805. */
  45806. private _setupSkyboxReflectionTexture;
  45807. private _errorHandler;
  45808. /**
  45809. * Dispose all the elements created by the Helper.
  45810. */
  45811. dispose(): void;
  45812. }
  45813. }
  45814. declare module BABYLON {
  45815. /**
  45816. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45817. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45818. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45819. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45820. */
  45821. export class PhotoDome extends TransformNode {
  45822. /**
  45823. * Define the image as a Monoscopic panoramic 360 image.
  45824. */
  45825. static readonly MODE_MONOSCOPIC: number;
  45826. /**
  45827. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45828. */
  45829. static readonly MODE_TOPBOTTOM: number;
  45830. /**
  45831. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45832. */
  45833. static readonly MODE_SIDEBYSIDE: number;
  45834. private _useDirectMapping;
  45835. /**
  45836. * The texture being displayed on the sphere
  45837. */
  45838. protected _photoTexture: Texture;
  45839. /**
  45840. * Gets or sets the texture being displayed on the sphere
  45841. */
  45842. photoTexture: Texture;
  45843. /**
  45844. * Observable raised when an error occured while loading the 360 image
  45845. */
  45846. onLoadErrorObservable: Observable<string>;
  45847. /**
  45848. * The skybox material
  45849. */
  45850. protected _material: BackgroundMaterial;
  45851. /**
  45852. * The surface used for the skybox
  45853. */
  45854. protected _mesh: Mesh;
  45855. /**
  45856. * Gets the mesh used for the skybox.
  45857. */
  45858. readonly mesh: Mesh;
  45859. /**
  45860. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45861. * Also see the options.resolution property.
  45862. */
  45863. fovMultiplier: number;
  45864. private _imageMode;
  45865. /**
  45866. * Gets or set the current video mode for the video. It can be:
  45867. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45868. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45869. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45870. */
  45871. imageMode: number;
  45872. /**
  45873. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45874. * @param name Element's name, child elements will append suffixes for their own names.
  45875. * @param urlsOfPhoto defines the url of the photo to display
  45876. * @param options defines an object containing optional or exposed sub element properties
  45877. * @param onError defines a callback called when an error occured while loading the texture
  45878. */
  45879. constructor(name: string, urlOfPhoto: string, options: {
  45880. resolution?: number;
  45881. size?: number;
  45882. useDirectMapping?: boolean;
  45883. faceForward?: boolean;
  45884. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45885. private _onBeforeCameraRenderObserver;
  45886. private _changeImageMode;
  45887. /**
  45888. * Releases resources associated with this node.
  45889. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45890. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45891. */
  45892. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45893. }
  45894. }
  45895. declare module BABYLON {
  45896. /**
  45897. * Class used to host RGBD texture specific utilities
  45898. */
  45899. export class RGBDTextureTools {
  45900. /**
  45901. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45902. * @param texture the texture to expand.
  45903. */
  45904. static ExpandRGBDTexture(texture: Texture): void;
  45905. }
  45906. }
  45907. declare module BABYLON {
  45908. /**
  45909. * Class used to host texture specific utilities
  45910. */
  45911. export class BRDFTextureTools {
  45912. /**
  45913. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45914. * @param scene defines the hosting scene
  45915. * @returns the environment BRDF texture
  45916. */
  45917. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45918. private static _environmentBRDFBase64Texture;
  45919. }
  45920. }
  45921. declare module BABYLON {
  45922. /**
  45923. * @hidden
  45924. */
  45925. export interface IMaterialClearCoatDefines {
  45926. CLEARCOAT: boolean;
  45927. CLEARCOAT_DEFAULTIOR: boolean;
  45928. CLEARCOAT_TEXTURE: boolean;
  45929. CLEARCOAT_TEXTUREDIRECTUV: number;
  45930. CLEARCOAT_BUMP: boolean;
  45931. CLEARCOAT_BUMPDIRECTUV: number;
  45932. CLEARCOAT_TINT: boolean;
  45933. CLEARCOAT_TINT_TEXTURE: boolean;
  45934. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45935. /** @hidden */
  45936. _areTexturesDirty: boolean;
  45937. }
  45938. /**
  45939. * Define the code related to the clear coat parameters of the pbr material.
  45940. */
  45941. export class PBRClearCoatConfiguration {
  45942. /**
  45943. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45944. * The default fits with a polyurethane material.
  45945. */
  45946. private static readonly _DefaultIndexOfRefraction;
  45947. private _isEnabled;
  45948. /**
  45949. * Defines if the clear coat is enabled in the material.
  45950. */
  45951. isEnabled: boolean;
  45952. /**
  45953. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45954. */
  45955. intensity: number;
  45956. /**
  45957. * Defines the clear coat layer roughness.
  45958. */
  45959. roughness: number;
  45960. private _indexOfRefraction;
  45961. /**
  45962. * Defines the index of refraction of the clear coat.
  45963. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45964. * The default fits with a polyurethane material.
  45965. * Changing the default value is more performance intensive.
  45966. */
  45967. indexOfRefraction: number;
  45968. private _texture;
  45969. /**
  45970. * Stores the clear coat values in a texture.
  45971. */
  45972. texture: Nullable<BaseTexture>;
  45973. private _bumpTexture;
  45974. /**
  45975. * Define the clear coat specific bump texture.
  45976. */
  45977. bumpTexture: Nullable<BaseTexture>;
  45978. private _isTintEnabled;
  45979. /**
  45980. * Defines if the clear coat tint is enabled in the material.
  45981. */
  45982. isTintEnabled: boolean;
  45983. /**
  45984. * Defines the clear coat tint of the material.
  45985. * This is only use if tint is enabled
  45986. */
  45987. tintColor: Color3;
  45988. /**
  45989. * Defines the distance at which the tint color should be found in the
  45990. * clear coat media.
  45991. * This is only use if tint is enabled
  45992. */
  45993. tintColorAtDistance: number;
  45994. /**
  45995. * Defines the clear coat layer thickness.
  45996. * This is only use if tint is enabled
  45997. */
  45998. tintThickness: number;
  45999. private _tintTexture;
  46000. /**
  46001. * Stores the clear tint values in a texture.
  46002. * rgb is tint
  46003. * a is a thickness factor
  46004. */
  46005. tintTexture: Nullable<BaseTexture>;
  46006. /** @hidden */
  46007. private _internalMarkAllSubMeshesAsTexturesDirty;
  46008. /** @hidden */
  46009. _markAllSubMeshesAsTexturesDirty(): void;
  46010. /**
  46011. * Instantiate a new istance of clear coat configuration.
  46012. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46013. */
  46014. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46015. /**
  46016. * Gets wehter the submesh is ready to be used or not.
  46017. * @param defines the list of "defines" to update.
  46018. * @param scene defines the scene the material belongs to.
  46019. * @param engine defines the engine the material belongs to.
  46020. * @param disableBumpMap defines wether the material disables bump or not.
  46021. * @returns - boolean indicating that the submesh is ready or not.
  46022. */
  46023. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46024. /**
  46025. * Checks to see if a texture is used in the material.
  46026. * @param defines the list of "defines" to update.
  46027. * @param scene defines the scene to the material belongs to.
  46028. */
  46029. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46030. /**
  46031. * Binds the material data.
  46032. * @param uniformBuffer defines the Uniform buffer to fill in.
  46033. * @param scene defines the scene the material belongs to.
  46034. * @param engine defines the engine the material belongs to.
  46035. * @param disableBumpMap defines wether the material disables bump or not.
  46036. * @param isFrozen defines wether the material is frozen or not.
  46037. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46038. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46039. */
  46040. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46041. /**
  46042. * Checks to see if a texture is used in the material.
  46043. * @param texture - Base texture to use.
  46044. * @returns - Boolean specifying if a texture is used in the material.
  46045. */
  46046. hasTexture(texture: BaseTexture): boolean;
  46047. /**
  46048. * Returns an array of the actively used textures.
  46049. * @param activeTextures Array of BaseTextures
  46050. */
  46051. getActiveTextures(activeTextures: BaseTexture[]): void;
  46052. /**
  46053. * Returns the animatable textures.
  46054. * @param animatables Array of animatable textures.
  46055. */
  46056. getAnimatables(animatables: IAnimatable[]): void;
  46057. /**
  46058. * Disposes the resources of the material.
  46059. * @param forceDisposeTextures - Forces the disposal of all textures.
  46060. */
  46061. dispose(forceDisposeTextures?: boolean): void;
  46062. /**
  46063. * Get the current class name of the texture useful for serialization or dynamic coding.
  46064. * @returns "PBRClearCoatConfiguration"
  46065. */
  46066. getClassName(): string;
  46067. /**
  46068. * Add fallbacks to the effect fallbacks list.
  46069. * @param defines defines the Base texture to use.
  46070. * @param fallbacks defines the current fallback list.
  46071. * @param currentRank defines the current fallback rank.
  46072. * @returns the new fallback rank.
  46073. */
  46074. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46075. /**
  46076. * Add the required uniforms to the current list.
  46077. * @param uniforms defines the current uniform list.
  46078. */
  46079. static AddUniforms(uniforms: string[]): void;
  46080. /**
  46081. * Add the required samplers to the current list.
  46082. * @param samplers defines the current sampler list.
  46083. */
  46084. static AddSamplers(samplers: string[]): void;
  46085. /**
  46086. * Add the required uniforms to the current buffer.
  46087. * @param uniformBuffer defines the current uniform buffer.
  46088. */
  46089. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46090. /**
  46091. * Makes a duplicate of the current configuration into another one.
  46092. * @param clearCoatConfiguration define the config where to copy the info
  46093. */
  46094. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46095. /**
  46096. * Serializes this clear coat configuration.
  46097. * @returns - An object with the serialized config.
  46098. */
  46099. serialize(): any;
  46100. /**
  46101. * Parses a anisotropy Configuration from a serialized object.
  46102. * @param source - Serialized object.
  46103. * @param scene Defines the scene we are parsing for
  46104. * @param rootUrl Defines the rootUrl to load from
  46105. */
  46106. parse(source: any, scene: Scene, rootUrl: string): void;
  46107. }
  46108. }
  46109. declare module BABYLON {
  46110. /**
  46111. * @hidden
  46112. */
  46113. export interface IMaterialAnisotropicDefines {
  46114. ANISOTROPIC: boolean;
  46115. ANISOTROPIC_TEXTURE: boolean;
  46116. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46117. MAINUV1: boolean;
  46118. _areTexturesDirty: boolean;
  46119. _needUVs: boolean;
  46120. }
  46121. /**
  46122. * Define the code related to the anisotropic parameters of the pbr material.
  46123. */
  46124. export class PBRAnisotropicConfiguration {
  46125. private _isEnabled;
  46126. /**
  46127. * Defines if the anisotropy is enabled in the material.
  46128. */
  46129. isEnabled: boolean;
  46130. /**
  46131. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46132. */
  46133. intensity: number;
  46134. /**
  46135. * Defines if the effect is along the tangents, bitangents or in between.
  46136. * By default, the effect is "strectching" the highlights along the tangents.
  46137. */
  46138. direction: Vector2;
  46139. private _texture;
  46140. /**
  46141. * Stores the anisotropy values in a texture.
  46142. * rg is direction (like normal from -1 to 1)
  46143. * b is a intensity
  46144. */
  46145. texture: Nullable<BaseTexture>;
  46146. /** @hidden */
  46147. private _internalMarkAllSubMeshesAsTexturesDirty;
  46148. /** @hidden */
  46149. _markAllSubMeshesAsTexturesDirty(): void;
  46150. /**
  46151. * Instantiate a new istance of anisotropy configuration.
  46152. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46153. */
  46154. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46155. /**
  46156. * Specifies that the submesh is ready to be used.
  46157. * @param defines the list of "defines" to update.
  46158. * @param scene defines the scene the material belongs to.
  46159. * @returns - boolean indicating that the submesh is ready or not.
  46160. */
  46161. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46162. /**
  46163. * Checks to see if a texture is used in the material.
  46164. * @param defines the list of "defines" to update.
  46165. * @param mesh the mesh we are preparing the defines for.
  46166. * @param scene defines the scene the material belongs to.
  46167. */
  46168. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46169. /**
  46170. * Binds the material data.
  46171. * @param uniformBuffer defines the Uniform buffer to fill in.
  46172. * @param scene defines the scene the material belongs to.
  46173. * @param isFrozen defines wether the material is frozen or not.
  46174. */
  46175. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46176. /**
  46177. * Checks to see if a texture is used in the material.
  46178. * @param texture - Base texture to use.
  46179. * @returns - Boolean specifying if a texture is used in the material.
  46180. */
  46181. hasTexture(texture: BaseTexture): boolean;
  46182. /**
  46183. * Returns an array of the actively used textures.
  46184. * @param activeTextures Array of BaseTextures
  46185. */
  46186. getActiveTextures(activeTextures: BaseTexture[]): void;
  46187. /**
  46188. * Returns the animatable textures.
  46189. * @param animatables Array of animatable textures.
  46190. */
  46191. getAnimatables(animatables: IAnimatable[]): void;
  46192. /**
  46193. * Disposes the resources of the material.
  46194. * @param forceDisposeTextures - Forces the disposal of all textures.
  46195. */
  46196. dispose(forceDisposeTextures?: boolean): void;
  46197. /**
  46198. * Get the current class name of the texture useful for serialization or dynamic coding.
  46199. * @returns "PBRAnisotropicConfiguration"
  46200. */
  46201. getClassName(): string;
  46202. /**
  46203. * Add fallbacks to the effect fallbacks list.
  46204. * @param defines defines the Base texture to use.
  46205. * @param fallbacks defines the current fallback list.
  46206. * @param currentRank defines the current fallback rank.
  46207. * @returns the new fallback rank.
  46208. */
  46209. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46210. /**
  46211. * Add the required uniforms to the current list.
  46212. * @param uniforms defines the current uniform list.
  46213. */
  46214. static AddUniforms(uniforms: string[]): void;
  46215. /**
  46216. * Add the required uniforms to the current buffer.
  46217. * @param uniformBuffer defines the current uniform buffer.
  46218. */
  46219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46220. /**
  46221. * Add the required samplers to the current list.
  46222. * @param samplers defines the current sampler list.
  46223. */
  46224. static AddSamplers(samplers: string[]): void;
  46225. /**
  46226. * Makes a duplicate of the current configuration into another one.
  46227. * @param anisotropicConfiguration define the config where to copy the info
  46228. */
  46229. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46230. /**
  46231. * Serializes this anisotropy configuration.
  46232. * @returns - An object with the serialized config.
  46233. */
  46234. serialize(): any;
  46235. /**
  46236. * Parses a anisotropy Configuration from a serialized object.
  46237. * @param source - Serialized object.
  46238. * @param scene Defines the scene we are parsing for
  46239. * @param rootUrl Defines the rootUrl to load from
  46240. */
  46241. parse(source: any, scene: Scene, rootUrl: string): void;
  46242. }
  46243. }
  46244. declare module BABYLON {
  46245. /**
  46246. * @hidden
  46247. */
  46248. export interface IMaterialBRDFDefines {
  46249. BRDF_V_HEIGHT_CORRELATED: boolean;
  46250. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46251. SPHERICAL_HARMONICS: boolean;
  46252. /** @hidden */
  46253. _areMiscDirty: boolean;
  46254. }
  46255. /**
  46256. * Define the code related to the BRDF parameters of the pbr material.
  46257. */
  46258. export class PBRBRDFConfiguration {
  46259. /**
  46260. * Default value used for the energy conservation.
  46261. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46262. */
  46263. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46264. /**
  46265. * Default value used for the Smith Visibility Height Correlated mode.
  46266. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46267. */
  46268. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46269. /**
  46270. * Default value used for the IBL diffuse part.
  46271. * This can help switching back to the polynomials mode globally which is a tiny bit
  46272. * less GPU intensive at the drawback of a lower quality.
  46273. */
  46274. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46275. private _useEnergyConservation;
  46276. /**
  46277. * Defines if the material uses energy conservation.
  46278. */
  46279. useEnergyConservation: boolean;
  46280. private _useSmithVisibilityHeightCorrelated;
  46281. /**
  46282. * LEGACY Mode set to false
  46283. * Defines if the material uses height smith correlated visibility term.
  46284. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46285. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46286. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46287. * Not relying on height correlated will also disable energy conservation.
  46288. */
  46289. useSmithVisibilityHeightCorrelated: boolean;
  46290. private _useSphericalHarmonics;
  46291. /**
  46292. * LEGACY Mode set to false
  46293. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46294. * diffuse part of the IBL.
  46295. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46296. * to the ground truth.
  46297. */
  46298. useSphericalHarmonics: boolean;
  46299. /** @hidden */
  46300. private _internalMarkAllSubMeshesAsMiscDirty;
  46301. /** @hidden */
  46302. _markAllSubMeshesAsMiscDirty(): void;
  46303. /**
  46304. * Instantiate a new istance of clear coat configuration.
  46305. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46306. */
  46307. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46308. /**
  46309. * Checks to see if a texture is used in the material.
  46310. * @param defines the list of "defines" to update.
  46311. */
  46312. prepareDefines(defines: IMaterialBRDFDefines): void;
  46313. /**
  46314. * Get the current class name of the texture useful for serialization or dynamic coding.
  46315. * @returns "PBRClearCoatConfiguration"
  46316. */
  46317. getClassName(): string;
  46318. /**
  46319. * Makes a duplicate of the current configuration into another one.
  46320. * @param brdfConfiguration define the config where to copy the info
  46321. */
  46322. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46323. /**
  46324. * Serializes this BRDF configuration.
  46325. * @returns - An object with the serialized config.
  46326. */
  46327. serialize(): any;
  46328. /**
  46329. * Parses a anisotropy Configuration from a serialized object.
  46330. * @param source - Serialized object.
  46331. * @param scene Defines the scene we are parsing for
  46332. * @param rootUrl Defines the rootUrl to load from
  46333. */
  46334. parse(source: any, scene: Scene, rootUrl: string): void;
  46335. }
  46336. }
  46337. declare module BABYLON {
  46338. /**
  46339. * @hidden
  46340. */
  46341. export interface IMaterialSheenDefines {
  46342. SHEEN: boolean;
  46343. SHEEN_TEXTURE: boolean;
  46344. SHEEN_TEXTUREDIRECTUV: number;
  46345. SHEEN_LINKWITHALBEDO: boolean;
  46346. /** @hidden */
  46347. _areTexturesDirty: boolean;
  46348. }
  46349. /**
  46350. * Define the code related to the Sheen parameters of the pbr material.
  46351. */
  46352. export class PBRSheenConfiguration {
  46353. private _isEnabled;
  46354. /**
  46355. * Defines if the material uses sheen.
  46356. */
  46357. isEnabled: boolean;
  46358. private _linkSheenWithAlbedo;
  46359. /**
  46360. * Defines if the sheen is linked to the sheen color.
  46361. */
  46362. linkSheenWithAlbedo: boolean;
  46363. /**
  46364. * Defines the sheen intensity.
  46365. */
  46366. intensity: number;
  46367. /**
  46368. * Defines the sheen color.
  46369. */
  46370. color: Color3;
  46371. private _texture;
  46372. /**
  46373. * Stores the sheen tint values in a texture.
  46374. * rgb is tint
  46375. * a is a intensity
  46376. */
  46377. texture: Nullable<BaseTexture>;
  46378. /** @hidden */
  46379. private _internalMarkAllSubMeshesAsTexturesDirty;
  46380. /** @hidden */
  46381. _markAllSubMeshesAsTexturesDirty(): void;
  46382. /**
  46383. * Instantiate a new istance of clear coat configuration.
  46384. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46385. */
  46386. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46387. /**
  46388. * Specifies that the submesh is ready to be used.
  46389. * @param defines the list of "defines" to update.
  46390. * @param scene defines the scene the material belongs to.
  46391. * @returns - boolean indicating that the submesh is ready or not.
  46392. */
  46393. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46394. /**
  46395. * Checks to see if a texture is used in the material.
  46396. * @param defines the list of "defines" to update.
  46397. * @param scene defines the scene the material belongs to.
  46398. */
  46399. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46400. /**
  46401. * Binds the material data.
  46402. * @param uniformBuffer defines the Uniform buffer to fill in.
  46403. * @param scene defines the scene the material belongs to.
  46404. * @param isFrozen defines wether the material is frozen or not.
  46405. */
  46406. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46407. /**
  46408. * Checks to see if a texture is used in the material.
  46409. * @param texture - Base texture to use.
  46410. * @returns - Boolean specifying if a texture is used in the material.
  46411. */
  46412. hasTexture(texture: BaseTexture): boolean;
  46413. /**
  46414. * Returns an array of the actively used textures.
  46415. * @param activeTextures Array of BaseTextures
  46416. */
  46417. getActiveTextures(activeTextures: BaseTexture[]): void;
  46418. /**
  46419. * Returns the animatable textures.
  46420. * @param animatables Array of animatable textures.
  46421. */
  46422. getAnimatables(animatables: IAnimatable[]): void;
  46423. /**
  46424. * Disposes the resources of the material.
  46425. * @param forceDisposeTextures - Forces the disposal of all textures.
  46426. */
  46427. dispose(forceDisposeTextures?: boolean): void;
  46428. /**
  46429. * Get the current class name of the texture useful for serialization or dynamic coding.
  46430. * @returns "PBRSheenConfiguration"
  46431. */
  46432. getClassName(): string;
  46433. /**
  46434. * Add fallbacks to the effect fallbacks list.
  46435. * @param defines defines the Base texture to use.
  46436. * @param fallbacks defines the current fallback list.
  46437. * @param currentRank defines the current fallback rank.
  46438. * @returns the new fallback rank.
  46439. */
  46440. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46441. /**
  46442. * Add the required uniforms to the current list.
  46443. * @param uniforms defines the current uniform list.
  46444. */
  46445. static AddUniforms(uniforms: string[]): void;
  46446. /**
  46447. * Add the required uniforms to the current buffer.
  46448. * @param uniformBuffer defines the current uniform buffer.
  46449. */
  46450. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46451. /**
  46452. * Add the required samplers to the current list.
  46453. * @param samplers defines the current sampler list.
  46454. */
  46455. static AddSamplers(samplers: string[]): void;
  46456. /**
  46457. * Makes a duplicate of the current configuration into another one.
  46458. * @param sheenConfiguration define the config where to copy the info
  46459. */
  46460. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46461. /**
  46462. * Serializes this BRDF configuration.
  46463. * @returns - An object with the serialized config.
  46464. */
  46465. serialize(): any;
  46466. /**
  46467. * Parses a anisotropy Configuration from a serialized object.
  46468. * @param source - Serialized object.
  46469. * @param scene Defines the scene we are parsing for
  46470. * @param rootUrl Defines the rootUrl to load from
  46471. */
  46472. parse(source: any, scene: Scene, rootUrl: string): void;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /**
  46477. * @hidden
  46478. */
  46479. export interface IMaterialSubSurfaceDefines {
  46480. SUBSURFACE: boolean;
  46481. SS_REFRACTION: boolean;
  46482. SS_TRANSLUCENCY: boolean;
  46483. SS_SCATERRING: boolean;
  46484. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46485. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46486. SS_REFRACTIONMAP_3D: boolean;
  46487. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46488. SS_LODINREFRACTIONALPHA: boolean;
  46489. SS_GAMMAREFRACTION: boolean;
  46490. SS_RGBDREFRACTION: boolean;
  46491. SS_LINEARSPECULARREFRACTION: boolean;
  46492. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46493. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46494. /** @hidden */
  46495. _areTexturesDirty: boolean;
  46496. }
  46497. /**
  46498. * Define the code related to the sub surface parameters of the pbr material.
  46499. */
  46500. export class PBRSubSurfaceConfiguration {
  46501. private _isRefractionEnabled;
  46502. /**
  46503. * Defines if the refraction is enabled in the material.
  46504. */
  46505. isRefractionEnabled: boolean;
  46506. private _isTranslucencyEnabled;
  46507. /**
  46508. * Defines if the translucency is enabled in the material.
  46509. */
  46510. isTranslucencyEnabled: boolean;
  46511. private _isScatteringEnabled;
  46512. /**
  46513. * Defines the refraction intensity of the material.
  46514. * The refraction when enabled replaces the Diffuse part of the material.
  46515. * The intensity helps transitionning between diffuse and refraction.
  46516. */
  46517. refractionIntensity: number;
  46518. /**
  46519. * Defines the translucency intensity of the material.
  46520. * When translucency has been enabled, this defines how much of the "translucency"
  46521. * is addded to the diffuse part of the material.
  46522. */
  46523. translucencyIntensity: number;
  46524. /**
  46525. * Defines the scattering intensity of the material.
  46526. * When scattering has been enabled, this defines how much of the "scattered light"
  46527. * is addded to the diffuse part of the material.
  46528. */
  46529. scatteringIntensity: number;
  46530. private _thicknessTexture;
  46531. /**
  46532. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46533. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46534. * 0 would mean minimumThickness
  46535. * 1 would mean maximumThickness
  46536. * The other channels might be use as a mask to vary the different effects intensity.
  46537. */
  46538. thicknessTexture: Nullable<BaseTexture>;
  46539. private _refractionTexture;
  46540. /**
  46541. * Defines the texture to use for refraction.
  46542. */
  46543. refractionTexture: Nullable<BaseTexture>;
  46544. private _indexOfRefraction;
  46545. /**
  46546. * Defines the index of refraction used in the material.
  46547. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46548. */
  46549. indexOfRefraction: number;
  46550. private _invertRefractionY;
  46551. /**
  46552. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46553. */
  46554. invertRefractionY: boolean;
  46555. private _linkRefractionWithTransparency;
  46556. /**
  46557. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46558. * Materials half opaque for instance using refraction could benefit from this control.
  46559. */
  46560. linkRefractionWithTransparency: boolean;
  46561. /**
  46562. * Defines the minimum thickness stored in the thickness map.
  46563. * If no thickness map is defined, this value will be used to simulate thickness.
  46564. */
  46565. minimumThickness: number;
  46566. /**
  46567. * Defines the maximum thickness stored in the thickness map.
  46568. */
  46569. maximumThickness: number;
  46570. /**
  46571. * Defines the volume tint of the material.
  46572. * This is used for both translucency and scattering.
  46573. */
  46574. tintColor: Color3;
  46575. /**
  46576. * Defines the distance at which the tint color should be found in the media.
  46577. * This is used for refraction only.
  46578. */
  46579. tintColorAtDistance: number;
  46580. /**
  46581. * Defines how far each channel transmit through the media.
  46582. * It is defined as a color to simplify it selection.
  46583. */
  46584. diffusionDistance: Color3;
  46585. private _useMaskFromThicknessTexture;
  46586. /**
  46587. * Stores the intensity of the different subsurface effects in the thickness texture.
  46588. * * the green channel is the translucency intensity.
  46589. * * the blue channel is the scattering intensity.
  46590. * * the alpha channel is the refraction intensity.
  46591. */
  46592. useMaskFromThicknessTexture: boolean;
  46593. /** @hidden */
  46594. private _internalMarkAllSubMeshesAsTexturesDirty;
  46595. /** @hidden */
  46596. _markAllSubMeshesAsTexturesDirty(): void;
  46597. /**
  46598. * Instantiate a new istance of sub surface configuration.
  46599. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46600. */
  46601. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46602. /**
  46603. * Gets wehter the submesh is ready to be used or not.
  46604. * @param defines the list of "defines" to update.
  46605. * @param scene defines the scene the material belongs to.
  46606. * @returns - boolean indicating that the submesh is ready or not.
  46607. */
  46608. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46609. /**
  46610. * Checks to see if a texture is used in the material.
  46611. * @param defines the list of "defines" to update.
  46612. * @param scene defines the scene to the material belongs to.
  46613. */
  46614. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46615. /**
  46616. * Binds the material data.
  46617. * @param uniformBuffer defines the Uniform buffer to fill in.
  46618. * @param scene defines the scene the material belongs to.
  46619. * @param engine defines the engine the material belongs to.
  46620. * @param isFrozen defines wether the material is frozen or not.
  46621. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46622. */
  46623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46624. /**
  46625. * Unbinds the material from the mesh.
  46626. * @param activeEffect defines the effect that should be unbound from.
  46627. * @returns true if unbound, otherwise false
  46628. */
  46629. unbind(activeEffect: Effect): boolean;
  46630. /**
  46631. * Returns the texture used for refraction or null if none is used.
  46632. * @param scene defines the scene the material belongs to.
  46633. * @returns - Refraction texture if present. If no refraction texture and refraction
  46634. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46635. */
  46636. private _getRefractionTexture;
  46637. /**
  46638. * Returns true if alpha blending should be disabled.
  46639. */
  46640. readonly disableAlphaBlending: boolean;
  46641. /**
  46642. * Fills the list of render target textures.
  46643. * @param renderTargets the list of render targets to update
  46644. */
  46645. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46646. /**
  46647. * Checks to see if a texture is used in the material.
  46648. * @param texture - Base texture to use.
  46649. * @returns - Boolean specifying if a texture is used in the material.
  46650. */
  46651. hasTexture(texture: BaseTexture): boolean;
  46652. /**
  46653. * Gets a boolean indicating that current material needs to register RTT
  46654. * @returns true if this uses a render target otherwise false.
  46655. */
  46656. hasRenderTargetTextures(): boolean;
  46657. /**
  46658. * Returns an array of the actively used textures.
  46659. * @param activeTextures Array of BaseTextures
  46660. */
  46661. getActiveTextures(activeTextures: BaseTexture[]): void;
  46662. /**
  46663. * Returns the animatable textures.
  46664. * @param animatables Array of animatable textures.
  46665. */
  46666. getAnimatables(animatables: IAnimatable[]): void;
  46667. /**
  46668. * Disposes the resources of the material.
  46669. * @param forceDisposeTextures - Forces the disposal of all textures.
  46670. */
  46671. dispose(forceDisposeTextures?: boolean): void;
  46672. /**
  46673. * Get the current class name of the texture useful for serialization or dynamic coding.
  46674. * @returns "PBRSubSurfaceConfiguration"
  46675. */
  46676. getClassName(): string;
  46677. /**
  46678. * Add fallbacks to the effect fallbacks list.
  46679. * @param defines defines the Base texture to use.
  46680. * @param fallbacks defines the current fallback list.
  46681. * @param currentRank defines the current fallback rank.
  46682. * @returns the new fallback rank.
  46683. */
  46684. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46685. /**
  46686. * Add the required uniforms to the current list.
  46687. * @param uniforms defines the current uniform list.
  46688. */
  46689. static AddUniforms(uniforms: string[]): void;
  46690. /**
  46691. * Add the required samplers to the current list.
  46692. * @param samplers defines the current sampler list.
  46693. */
  46694. static AddSamplers(samplers: string[]): void;
  46695. /**
  46696. * Add the required uniforms to the current buffer.
  46697. * @param uniformBuffer defines the current uniform buffer.
  46698. */
  46699. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46700. /**
  46701. * Makes a duplicate of the current configuration into another one.
  46702. * @param configuration define the config where to copy the info
  46703. */
  46704. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46705. /**
  46706. * Serializes this Sub Surface configuration.
  46707. * @returns - An object with the serialized config.
  46708. */
  46709. serialize(): any;
  46710. /**
  46711. * Parses a anisotropy Configuration from a serialized object.
  46712. * @param source - Serialized object.
  46713. * @param scene Defines the scene we are parsing for
  46714. * @param rootUrl Defines the rootUrl to load from
  46715. */
  46716. parse(source: any, scene: Scene, rootUrl: string): void;
  46717. }
  46718. }
  46719. declare module BABYLON {
  46720. /** @hidden */
  46721. export var pbrFragmentDeclaration: {
  46722. name: string;
  46723. shader: string;
  46724. };
  46725. }
  46726. declare module BABYLON {
  46727. /** @hidden */
  46728. export var pbrUboDeclaration: {
  46729. name: string;
  46730. shader: string;
  46731. };
  46732. }
  46733. declare module BABYLON {
  46734. /** @hidden */
  46735. export var pbrFragmentExtraDeclaration: {
  46736. name: string;
  46737. shader: string;
  46738. };
  46739. }
  46740. declare module BABYLON {
  46741. /** @hidden */
  46742. export var pbrFragmentSamplersDeclaration: {
  46743. name: string;
  46744. shader: string;
  46745. };
  46746. }
  46747. declare module BABYLON {
  46748. /** @hidden */
  46749. export var pbrHelperFunctions: {
  46750. name: string;
  46751. shader: string;
  46752. };
  46753. }
  46754. declare module BABYLON {
  46755. /** @hidden */
  46756. export var harmonicsFunctions: {
  46757. name: string;
  46758. shader: string;
  46759. };
  46760. }
  46761. declare module BABYLON {
  46762. /** @hidden */
  46763. export var pbrDirectLightingSetupFunctions: {
  46764. name: string;
  46765. shader: string;
  46766. };
  46767. }
  46768. declare module BABYLON {
  46769. /** @hidden */
  46770. export var pbrDirectLightingFalloffFunctions: {
  46771. name: string;
  46772. shader: string;
  46773. };
  46774. }
  46775. declare module BABYLON {
  46776. /** @hidden */
  46777. export var pbrBRDFFunctions: {
  46778. name: string;
  46779. shader: string;
  46780. };
  46781. }
  46782. declare module BABYLON {
  46783. /** @hidden */
  46784. export var pbrDirectLightingFunctions: {
  46785. name: string;
  46786. shader: string;
  46787. };
  46788. }
  46789. declare module BABYLON {
  46790. /** @hidden */
  46791. export var pbrIBLFunctions: {
  46792. name: string;
  46793. shader: string;
  46794. };
  46795. }
  46796. declare module BABYLON {
  46797. /** @hidden */
  46798. export var pbrDebug: {
  46799. name: string;
  46800. shader: string;
  46801. };
  46802. }
  46803. declare module BABYLON {
  46804. /** @hidden */
  46805. export var pbrPixelShader: {
  46806. name: string;
  46807. shader: string;
  46808. };
  46809. }
  46810. declare module BABYLON {
  46811. /** @hidden */
  46812. export var pbrVertexDeclaration: {
  46813. name: string;
  46814. shader: string;
  46815. };
  46816. }
  46817. declare module BABYLON {
  46818. /** @hidden */
  46819. export var pbrVertexShader: {
  46820. name: string;
  46821. shader: string;
  46822. };
  46823. }
  46824. declare module BABYLON {
  46825. /**
  46826. * Manages the defines for the PBR Material.
  46827. * @hidden
  46828. */
  46829. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46830. PBR: boolean;
  46831. MAINUV1: boolean;
  46832. MAINUV2: boolean;
  46833. UV1: boolean;
  46834. UV2: boolean;
  46835. ALBEDO: boolean;
  46836. ALBEDODIRECTUV: number;
  46837. VERTEXCOLOR: boolean;
  46838. AMBIENT: boolean;
  46839. AMBIENTDIRECTUV: number;
  46840. AMBIENTINGRAYSCALE: boolean;
  46841. OPACITY: boolean;
  46842. VERTEXALPHA: boolean;
  46843. OPACITYDIRECTUV: number;
  46844. OPACITYRGB: boolean;
  46845. ALPHATEST: boolean;
  46846. DEPTHPREPASS: boolean;
  46847. ALPHABLEND: boolean;
  46848. ALPHAFROMALBEDO: boolean;
  46849. ALPHATESTVALUE: string;
  46850. SPECULAROVERALPHA: boolean;
  46851. RADIANCEOVERALPHA: boolean;
  46852. ALPHAFRESNEL: boolean;
  46853. LINEARALPHAFRESNEL: boolean;
  46854. PREMULTIPLYALPHA: boolean;
  46855. EMISSIVE: boolean;
  46856. EMISSIVEDIRECTUV: number;
  46857. REFLECTIVITY: boolean;
  46858. REFLECTIVITYDIRECTUV: number;
  46859. SPECULARTERM: boolean;
  46860. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46861. MICROSURFACEAUTOMATIC: boolean;
  46862. LODBASEDMICROSFURACE: boolean;
  46863. MICROSURFACEMAP: boolean;
  46864. MICROSURFACEMAPDIRECTUV: number;
  46865. METALLICWORKFLOW: boolean;
  46866. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46867. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46868. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46869. AOSTOREINMETALMAPRED: boolean;
  46870. ENVIRONMENTBRDF: boolean;
  46871. ENVIRONMENTBRDF_RGBD: boolean;
  46872. NORMAL: boolean;
  46873. TANGENT: boolean;
  46874. BUMP: boolean;
  46875. BUMPDIRECTUV: number;
  46876. OBJECTSPACE_NORMALMAP: boolean;
  46877. PARALLAX: boolean;
  46878. PARALLAXOCCLUSION: boolean;
  46879. NORMALXYSCALE: boolean;
  46880. LIGHTMAP: boolean;
  46881. LIGHTMAPDIRECTUV: number;
  46882. USELIGHTMAPASSHADOWMAP: boolean;
  46883. GAMMALIGHTMAP: boolean;
  46884. RGBDLIGHTMAP: boolean;
  46885. REFLECTION: boolean;
  46886. REFLECTIONMAP_3D: boolean;
  46887. REFLECTIONMAP_SPHERICAL: boolean;
  46888. REFLECTIONMAP_PLANAR: boolean;
  46889. REFLECTIONMAP_CUBIC: boolean;
  46890. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46891. REFLECTIONMAP_PROJECTION: boolean;
  46892. REFLECTIONMAP_SKYBOX: boolean;
  46893. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46894. REFLECTIONMAP_EXPLICIT: boolean;
  46895. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46896. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46897. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46898. INVERTCUBICMAP: boolean;
  46899. USESPHERICALFROMREFLECTIONMAP: boolean;
  46900. USEIRRADIANCEMAP: boolean;
  46901. SPHERICAL_HARMONICS: boolean;
  46902. USESPHERICALINVERTEX: boolean;
  46903. REFLECTIONMAP_OPPOSITEZ: boolean;
  46904. LODINREFLECTIONALPHA: boolean;
  46905. GAMMAREFLECTION: boolean;
  46906. RGBDREFLECTION: boolean;
  46907. LINEARSPECULARREFLECTION: boolean;
  46908. RADIANCEOCCLUSION: boolean;
  46909. HORIZONOCCLUSION: boolean;
  46910. INSTANCES: boolean;
  46911. NUM_BONE_INFLUENCERS: number;
  46912. BonesPerMesh: number;
  46913. BONETEXTURE: boolean;
  46914. NONUNIFORMSCALING: boolean;
  46915. MORPHTARGETS: boolean;
  46916. MORPHTARGETS_NORMAL: boolean;
  46917. MORPHTARGETS_TANGENT: boolean;
  46918. MORPHTARGETS_UV: boolean;
  46919. NUM_MORPH_INFLUENCERS: number;
  46920. IMAGEPROCESSING: boolean;
  46921. VIGNETTE: boolean;
  46922. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46923. VIGNETTEBLENDMODEOPAQUE: boolean;
  46924. TONEMAPPING: boolean;
  46925. TONEMAPPING_ACES: boolean;
  46926. CONTRAST: boolean;
  46927. COLORCURVES: boolean;
  46928. COLORGRADING: boolean;
  46929. COLORGRADING3D: boolean;
  46930. SAMPLER3DGREENDEPTH: boolean;
  46931. SAMPLER3DBGRMAP: boolean;
  46932. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46933. EXPOSURE: boolean;
  46934. MULTIVIEW: boolean;
  46935. USEPHYSICALLIGHTFALLOFF: boolean;
  46936. USEGLTFLIGHTFALLOFF: boolean;
  46937. TWOSIDEDLIGHTING: boolean;
  46938. SHADOWFLOAT: boolean;
  46939. CLIPPLANE: boolean;
  46940. CLIPPLANE2: boolean;
  46941. CLIPPLANE3: boolean;
  46942. CLIPPLANE4: boolean;
  46943. POINTSIZE: boolean;
  46944. FOG: boolean;
  46945. LOGARITHMICDEPTH: boolean;
  46946. FORCENORMALFORWARD: boolean;
  46947. SPECULARAA: boolean;
  46948. CLEARCOAT: boolean;
  46949. CLEARCOAT_DEFAULTIOR: boolean;
  46950. CLEARCOAT_TEXTURE: boolean;
  46951. CLEARCOAT_TEXTUREDIRECTUV: number;
  46952. CLEARCOAT_BUMP: boolean;
  46953. CLEARCOAT_BUMPDIRECTUV: number;
  46954. CLEARCOAT_TINT: boolean;
  46955. CLEARCOAT_TINT_TEXTURE: boolean;
  46956. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46957. ANISOTROPIC: boolean;
  46958. ANISOTROPIC_TEXTURE: boolean;
  46959. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46960. BRDF_V_HEIGHT_CORRELATED: boolean;
  46961. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46962. SHEEN: boolean;
  46963. SHEEN_TEXTURE: boolean;
  46964. SHEEN_TEXTUREDIRECTUV: number;
  46965. SHEEN_LINKWITHALBEDO: boolean;
  46966. SUBSURFACE: boolean;
  46967. SS_REFRACTION: boolean;
  46968. SS_TRANSLUCENCY: boolean;
  46969. SS_SCATERRING: boolean;
  46970. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46971. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46972. SS_REFRACTIONMAP_3D: boolean;
  46973. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46974. SS_LODINREFRACTIONALPHA: boolean;
  46975. SS_GAMMAREFRACTION: boolean;
  46976. SS_RGBDREFRACTION: boolean;
  46977. SS_LINEARSPECULARREFRACTION: boolean;
  46978. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46979. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46980. UNLIT: boolean;
  46981. DEBUGMODE: number;
  46982. /**
  46983. * Initializes the PBR Material defines.
  46984. */
  46985. constructor();
  46986. /**
  46987. * Resets the PBR Material defines.
  46988. */
  46989. reset(): void;
  46990. }
  46991. /**
  46992. * The Physically based material base class of BJS.
  46993. *
  46994. * This offers the main features of a standard PBR material.
  46995. * For more information, please refer to the documentation :
  46996. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46997. */
  46998. export abstract class PBRBaseMaterial extends PushMaterial {
  46999. /**
  47000. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47001. */
  47002. static readonly PBRMATERIAL_OPAQUE: number;
  47003. /**
  47004. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47005. */
  47006. static readonly PBRMATERIAL_ALPHATEST: number;
  47007. /**
  47008. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47009. */
  47010. static readonly PBRMATERIAL_ALPHABLEND: number;
  47011. /**
  47012. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47013. * They are also discarded below the alpha cutoff threshold to improve performances.
  47014. */
  47015. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47016. /**
  47017. * Defines the default value of how much AO map is occluding the analytical lights
  47018. * (point spot...).
  47019. */
  47020. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47021. /**
  47022. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47023. */
  47024. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47025. /**
  47026. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47027. * to enhance interoperability with other engines.
  47028. */
  47029. static readonly LIGHTFALLOFF_GLTF: number;
  47030. /**
  47031. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47032. * to enhance interoperability with other materials.
  47033. */
  47034. static readonly LIGHTFALLOFF_STANDARD: number;
  47035. /**
  47036. * Intensity of the direct lights e.g. the four lights available in your scene.
  47037. * This impacts both the direct diffuse and specular highlights.
  47038. */
  47039. protected _directIntensity: number;
  47040. /**
  47041. * Intensity of the emissive part of the material.
  47042. * This helps controlling the emissive effect without modifying the emissive color.
  47043. */
  47044. protected _emissiveIntensity: number;
  47045. /**
  47046. * Intensity of the environment e.g. how much the environment will light the object
  47047. * either through harmonics for rough material or through the refelction for shiny ones.
  47048. */
  47049. protected _environmentIntensity: number;
  47050. /**
  47051. * This is a special control allowing the reduction of the specular highlights coming from the
  47052. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47053. */
  47054. protected _specularIntensity: number;
  47055. /**
  47056. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47057. */
  47058. private _lightingInfos;
  47059. /**
  47060. * Debug Control allowing disabling the bump map on this material.
  47061. */
  47062. protected _disableBumpMap: boolean;
  47063. /**
  47064. * AKA Diffuse Texture in standard nomenclature.
  47065. */
  47066. protected _albedoTexture: Nullable<BaseTexture>;
  47067. /**
  47068. * AKA Occlusion Texture in other nomenclature.
  47069. */
  47070. protected _ambientTexture: Nullable<BaseTexture>;
  47071. /**
  47072. * AKA Occlusion Texture Intensity in other nomenclature.
  47073. */
  47074. protected _ambientTextureStrength: number;
  47075. /**
  47076. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47077. * 1 means it completely occludes it
  47078. * 0 mean it has no impact
  47079. */
  47080. protected _ambientTextureImpactOnAnalyticalLights: number;
  47081. /**
  47082. * Stores the alpha values in a texture.
  47083. */
  47084. protected _opacityTexture: Nullable<BaseTexture>;
  47085. /**
  47086. * Stores the reflection values in a texture.
  47087. */
  47088. protected _reflectionTexture: Nullable<BaseTexture>;
  47089. /**
  47090. * Stores the emissive values in a texture.
  47091. */
  47092. protected _emissiveTexture: Nullable<BaseTexture>;
  47093. /**
  47094. * AKA Specular texture in other nomenclature.
  47095. */
  47096. protected _reflectivityTexture: Nullable<BaseTexture>;
  47097. /**
  47098. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47099. */
  47100. protected _metallicTexture: Nullable<BaseTexture>;
  47101. /**
  47102. * Specifies the metallic scalar of the metallic/roughness workflow.
  47103. * Can also be used to scale the metalness values of the metallic texture.
  47104. */
  47105. protected _metallic: Nullable<number>;
  47106. /**
  47107. * Specifies the roughness scalar of the metallic/roughness workflow.
  47108. * Can also be used to scale the roughness values of the metallic texture.
  47109. */
  47110. protected _roughness: Nullable<number>;
  47111. /**
  47112. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47113. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47114. */
  47115. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47116. /**
  47117. * Stores surface normal data used to displace a mesh in a texture.
  47118. */
  47119. protected _bumpTexture: Nullable<BaseTexture>;
  47120. /**
  47121. * Stores the pre-calculated light information of a mesh in a texture.
  47122. */
  47123. protected _lightmapTexture: Nullable<BaseTexture>;
  47124. /**
  47125. * The color of a material in ambient lighting.
  47126. */
  47127. protected _ambientColor: Color3;
  47128. /**
  47129. * AKA Diffuse Color in other nomenclature.
  47130. */
  47131. protected _albedoColor: Color3;
  47132. /**
  47133. * AKA Specular Color in other nomenclature.
  47134. */
  47135. protected _reflectivityColor: Color3;
  47136. /**
  47137. * The color applied when light is reflected from a material.
  47138. */
  47139. protected _reflectionColor: Color3;
  47140. /**
  47141. * The color applied when light is emitted from a material.
  47142. */
  47143. protected _emissiveColor: Color3;
  47144. /**
  47145. * AKA Glossiness in other nomenclature.
  47146. */
  47147. protected _microSurface: number;
  47148. /**
  47149. * Specifies that the material will use the light map as a show map.
  47150. */
  47151. protected _useLightmapAsShadowmap: boolean;
  47152. /**
  47153. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47154. * makes the reflect vector face the model (under horizon).
  47155. */
  47156. protected _useHorizonOcclusion: boolean;
  47157. /**
  47158. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47159. * too much the area relying on ambient texture to define their ambient occlusion.
  47160. */
  47161. protected _useRadianceOcclusion: boolean;
  47162. /**
  47163. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47164. */
  47165. protected _useAlphaFromAlbedoTexture: boolean;
  47166. /**
  47167. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47168. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47169. */
  47170. protected _useSpecularOverAlpha: boolean;
  47171. /**
  47172. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47173. */
  47174. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47175. /**
  47176. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47177. */
  47178. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47179. /**
  47180. * Specifies if the metallic texture contains the roughness information in its green channel.
  47181. */
  47182. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47183. /**
  47184. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47185. */
  47186. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47187. /**
  47188. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47189. */
  47190. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47191. /**
  47192. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47193. */
  47194. protected _useAmbientInGrayScale: boolean;
  47195. /**
  47196. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47197. * The material will try to infer what glossiness each pixel should be.
  47198. */
  47199. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47200. /**
  47201. * Defines the falloff type used in this material.
  47202. * It by default is Physical.
  47203. */
  47204. protected _lightFalloff: number;
  47205. /**
  47206. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47207. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47208. */
  47209. protected _useRadianceOverAlpha: boolean;
  47210. /**
  47211. * Allows using an object space normal map (instead of tangent space).
  47212. */
  47213. protected _useObjectSpaceNormalMap: boolean;
  47214. /**
  47215. * Allows using the bump map in parallax mode.
  47216. */
  47217. protected _useParallax: boolean;
  47218. /**
  47219. * Allows using the bump map in parallax occlusion mode.
  47220. */
  47221. protected _useParallaxOcclusion: boolean;
  47222. /**
  47223. * Controls the scale bias of the parallax mode.
  47224. */
  47225. protected _parallaxScaleBias: number;
  47226. /**
  47227. * If sets to true, disables all the lights affecting the material.
  47228. */
  47229. protected _disableLighting: boolean;
  47230. /**
  47231. * Number of Simultaneous lights allowed on the material.
  47232. */
  47233. protected _maxSimultaneousLights: number;
  47234. /**
  47235. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47236. */
  47237. protected _invertNormalMapX: boolean;
  47238. /**
  47239. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47240. */
  47241. protected _invertNormalMapY: boolean;
  47242. /**
  47243. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47244. */
  47245. protected _twoSidedLighting: boolean;
  47246. /**
  47247. * Defines the alpha limits in alpha test mode.
  47248. */
  47249. protected _alphaCutOff: number;
  47250. /**
  47251. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47252. */
  47253. protected _forceAlphaTest: boolean;
  47254. /**
  47255. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47256. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47257. */
  47258. protected _useAlphaFresnel: boolean;
  47259. /**
  47260. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47261. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47262. */
  47263. protected _useLinearAlphaFresnel: boolean;
  47264. /**
  47265. * The transparency mode of the material.
  47266. */
  47267. protected _transparencyMode: Nullable<number>;
  47268. /**
  47269. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47270. * from cos thetav and roughness:
  47271. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47272. */
  47273. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47274. /**
  47275. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47276. */
  47277. protected _forceIrradianceInFragment: boolean;
  47278. /**
  47279. * Force normal to face away from face.
  47280. */
  47281. protected _forceNormalForward: boolean;
  47282. /**
  47283. * Enables specular anti aliasing in the PBR shader.
  47284. * It will both interacts on the Geometry for analytical and IBL lighting.
  47285. * It also prefilter the roughness map based on the bump values.
  47286. */
  47287. protected _enableSpecularAntiAliasing: boolean;
  47288. /**
  47289. * Default configuration related to image processing available in the PBR Material.
  47290. */
  47291. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47292. /**
  47293. * Keep track of the image processing observer to allow dispose and replace.
  47294. */
  47295. private _imageProcessingObserver;
  47296. /**
  47297. * Attaches a new image processing configuration to the PBR Material.
  47298. * @param configuration
  47299. */
  47300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47301. /**
  47302. * Stores the available render targets.
  47303. */
  47304. private _renderTargets;
  47305. /**
  47306. * Sets the global ambient color for the material used in lighting calculations.
  47307. */
  47308. private _globalAmbientColor;
  47309. /**
  47310. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47311. */
  47312. private _useLogarithmicDepth;
  47313. /**
  47314. * If set to true, no lighting calculations will be applied.
  47315. */
  47316. private _unlit;
  47317. private _debugMode;
  47318. /**
  47319. * @hidden
  47320. * This is reserved for the inspector.
  47321. * Defines the material debug mode.
  47322. * It helps seeing only some components of the material while troubleshooting.
  47323. */
  47324. debugMode: number;
  47325. /**
  47326. * @hidden
  47327. * This is reserved for the inspector.
  47328. * Specify from where on screen the debug mode should start.
  47329. * The value goes from -1 (full screen) to 1 (not visible)
  47330. * It helps with side by side comparison against the final render
  47331. * This defaults to -1
  47332. */
  47333. private debugLimit;
  47334. /**
  47335. * @hidden
  47336. * This is reserved for the inspector.
  47337. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47338. * You can use the factor to better multiply the final value.
  47339. */
  47340. private debugFactor;
  47341. /**
  47342. * Defines the clear coat layer parameters for the material.
  47343. */
  47344. readonly clearCoat: PBRClearCoatConfiguration;
  47345. /**
  47346. * Defines the anisotropic parameters for the material.
  47347. */
  47348. readonly anisotropy: PBRAnisotropicConfiguration;
  47349. /**
  47350. * Defines the BRDF parameters for the material.
  47351. */
  47352. readonly brdf: PBRBRDFConfiguration;
  47353. /**
  47354. * Defines the Sheen parameters for the material.
  47355. */
  47356. readonly sheen: PBRSheenConfiguration;
  47357. /**
  47358. * Defines the SubSurface parameters for the material.
  47359. */
  47360. readonly subSurface: PBRSubSurfaceConfiguration;
  47361. /**
  47362. * Custom callback helping to override the default shader used in the material.
  47363. */
  47364. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47365. protected _rebuildInParallel: boolean;
  47366. /**
  47367. * Instantiates a new PBRMaterial instance.
  47368. *
  47369. * @param name The material name
  47370. * @param scene The scene the material will be use in.
  47371. */
  47372. constructor(name: string, scene: Scene);
  47373. /**
  47374. * Gets a boolean indicating that current material needs to register RTT
  47375. */
  47376. readonly hasRenderTargetTextures: boolean;
  47377. /**
  47378. * Gets the name of the material class.
  47379. */
  47380. getClassName(): string;
  47381. /**
  47382. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47383. */
  47384. /**
  47385. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47386. */
  47387. useLogarithmicDepth: boolean;
  47388. /**
  47389. * Gets the current transparency mode.
  47390. */
  47391. /**
  47392. * Sets the transparency mode of the material.
  47393. *
  47394. * | Value | Type | Description |
  47395. * | ----- | ----------------------------------- | ----------- |
  47396. * | 0 | OPAQUE | |
  47397. * | 1 | ALPHATEST | |
  47398. * | 2 | ALPHABLEND | |
  47399. * | 3 | ALPHATESTANDBLEND | |
  47400. *
  47401. */
  47402. transparencyMode: Nullable<number>;
  47403. /**
  47404. * Returns true if alpha blending should be disabled.
  47405. */
  47406. private readonly _disableAlphaBlending;
  47407. /**
  47408. * Specifies whether or not this material should be rendered in alpha blend mode.
  47409. */
  47410. needAlphaBlending(): boolean;
  47411. /**
  47412. * Specifies if the mesh will require alpha blending.
  47413. * @param mesh - BJS mesh.
  47414. */
  47415. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47416. /**
  47417. * Specifies whether or not this material should be rendered in alpha test mode.
  47418. */
  47419. needAlphaTesting(): boolean;
  47420. /**
  47421. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47422. */
  47423. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47424. /**
  47425. * Gets the texture used for the alpha test.
  47426. */
  47427. getAlphaTestTexture(): Nullable<BaseTexture>;
  47428. /**
  47429. * Specifies that the submesh is ready to be used.
  47430. * @param mesh - BJS mesh.
  47431. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47432. * @param useInstances - Specifies that instances should be used.
  47433. * @returns - boolean indicating that the submesh is ready or not.
  47434. */
  47435. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47436. /**
  47437. * Specifies if the material uses metallic roughness workflow.
  47438. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47439. */
  47440. isMetallicWorkflow(): boolean;
  47441. private _prepareEffect;
  47442. private _prepareDefines;
  47443. /**
  47444. * Force shader compilation
  47445. */
  47446. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47447. clipPlane: boolean;
  47448. }>): void;
  47449. /**
  47450. * Initializes the uniform buffer layout for the shader.
  47451. */
  47452. buildUniformLayout(): void;
  47453. /**
  47454. * Unbinds the material from the mesh
  47455. */
  47456. unbind(): void;
  47457. /**
  47458. * Binds the submesh data.
  47459. * @param world - The world matrix.
  47460. * @param mesh - The BJS mesh.
  47461. * @param subMesh - A submesh of the BJS mesh.
  47462. */
  47463. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47464. /**
  47465. * Returns the animatable textures.
  47466. * @returns - Array of animatable textures.
  47467. */
  47468. getAnimatables(): IAnimatable[];
  47469. /**
  47470. * Returns the texture used for reflections.
  47471. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47472. */
  47473. private _getReflectionTexture;
  47474. /**
  47475. * Returns an array of the actively used textures.
  47476. * @returns - Array of BaseTextures
  47477. */
  47478. getActiveTextures(): BaseTexture[];
  47479. /**
  47480. * Checks to see if a texture is used in the material.
  47481. * @param texture - Base texture to use.
  47482. * @returns - Boolean specifying if a texture is used in the material.
  47483. */
  47484. hasTexture(texture: BaseTexture): boolean;
  47485. /**
  47486. * Disposes the resources of the material.
  47487. * @param forceDisposeEffect - Forces the disposal of effects.
  47488. * @param forceDisposeTextures - Forces the disposal of all textures.
  47489. */
  47490. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47491. }
  47492. }
  47493. declare module BABYLON {
  47494. /**
  47495. * The Physically based material of BJS.
  47496. *
  47497. * This offers the main features of a standard PBR material.
  47498. * For more information, please refer to the documentation :
  47499. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47500. */
  47501. export class PBRMaterial extends PBRBaseMaterial {
  47502. /**
  47503. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47504. */
  47505. static readonly PBRMATERIAL_OPAQUE: number;
  47506. /**
  47507. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47508. */
  47509. static readonly PBRMATERIAL_ALPHATEST: number;
  47510. /**
  47511. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47512. */
  47513. static readonly PBRMATERIAL_ALPHABLEND: number;
  47514. /**
  47515. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47516. * They are also discarded below the alpha cutoff threshold to improve performances.
  47517. */
  47518. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47519. /**
  47520. * Defines the default value of how much AO map is occluding the analytical lights
  47521. * (point spot...).
  47522. */
  47523. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47524. /**
  47525. * Intensity of the direct lights e.g. the four lights available in your scene.
  47526. * This impacts both the direct diffuse and specular highlights.
  47527. */
  47528. directIntensity: number;
  47529. /**
  47530. * Intensity of the emissive part of the material.
  47531. * This helps controlling the emissive effect without modifying the emissive color.
  47532. */
  47533. emissiveIntensity: number;
  47534. /**
  47535. * Intensity of the environment e.g. how much the environment will light the object
  47536. * either through harmonics for rough material or through the refelction for shiny ones.
  47537. */
  47538. environmentIntensity: number;
  47539. /**
  47540. * This is a special control allowing the reduction of the specular highlights coming from the
  47541. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47542. */
  47543. specularIntensity: number;
  47544. /**
  47545. * Debug Control allowing disabling the bump map on this material.
  47546. */
  47547. disableBumpMap: boolean;
  47548. /**
  47549. * AKA Diffuse Texture in standard nomenclature.
  47550. */
  47551. albedoTexture: BaseTexture;
  47552. /**
  47553. * AKA Occlusion Texture in other nomenclature.
  47554. */
  47555. ambientTexture: BaseTexture;
  47556. /**
  47557. * AKA Occlusion Texture Intensity in other nomenclature.
  47558. */
  47559. ambientTextureStrength: number;
  47560. /**
  47561. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47562. * 1 means it completely occludes it
  47563. * 0 mean it has no impact
  47564. */
  47565. ambientTextureImpactOnAnalyticalLights: number;
  47566. /**
  47567. * Stores the alpha values in a texture.
  47568. */
  47569. opacityTexture: BaseTexture;
  47570. /**
  47571. * Stores the reflection values in a texture.
  47572. */
  47573. reflectionTexture: Nullable<BaseTexture>;
  47574. /**
  47575. * Stores the emissive values in a texture.
  47576. */
  47577. emissiveTexture: BaseTexture;
  47578. /**
  47579. * AKA Specular texture in other nomenclature.
  47580. */
  47581. reflectivityTexture: BaseTexture;
  47582. /**
  47583. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47584. */
  47585. metallicTexture: BaseTexture;
  47586. /**
  47587. * Specifies the metallic scalar of the metallic/roughness workflow.
  47588. * Can also be used to scale the metalness values of the metallic texture.
  47589. */
  47590. metallic: Nullable<number>;
  47591. /**
  47592. * Specifies the roughness scalar of the metallic/roughness workflow.
  47593. * Can also be used to scale the roughness values of the metallic texture.
  47594. */
  47595. roughness: Nullable<number>;
  47596. /**
  47597. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47598. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47599. */
  47600. microSurfaceTexture: BaseTexture;
  47601. /**
  47602. * Stores surface normal data used to displace a mesh in a texture.
  47603. */
  47604. bumpTexture: BaseTexture;
  47605. /**
  47606. * Stores the pre-calculated light information of a mesh in a texture.
  47607. */
  47608. lightmapTexture: BaseTexture;
  47609. /**
  47610. * Stores the refracted light information in a texture.
  47611. */
  47612. refractionTexture: Nullable<BaseTexture>;
  47613. /**
  47614. * The color of a material in ambient lighting.
  47615. */
  47616. ambientColor: Color3;
  47617. /**
  47618. * AKA Diffuse Color in other nomenclature.
  47619. */
  47620. albedoColor: Color3;
  47621. /**
  47622. * AKA Specular Color in other nomenclature.
  47623. */
  47624. reflectivityColor: Color3;
  47625. /**
  47626. * The color reflected from the material.
  47627. */
  47628. reflectionColor: Color3;
  47629. /**
  47630. * The color emitted from the material.
  47631. */
  47632. emissiveColor: Color3;
  47633. /**
  47634. * AKA Glossiness in other nomenclature.
  47635. */
  47636. microSurface: number;
  47637. /**
  47638. * source material index of refraction (IOR)' / 'destination material IOR.
  47639. */
  47640. indexOfRefraction: number;
  47641. /**
  47642. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47643. */
  47644. invertRefractionY: boolean;
  47645. /**
  47646. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47647. * Materials half opaque for instance using refraction could benefit from this control.
  47648. */
  47649. linkRefractionWithTransparency: boolean;
  47650. /**
  47651. * If true, the light map contains occlusion information instead of lighting info.
  47652. */
  47653. useLightmapAsShadowmap: boolean;
  47654. /**
  47655. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47656. */
  47657. useAlphaFromAlbedoTexture: boolean;
  47658. /**
  47659. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47660. */
  47661. forceAlphaTest: boolean;
  47662. /**
  47663. * Defines the alpha limits in alpha test mode.
  47664. */
  47665. alphaCutOff: number;
  47666. /**
  47667. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47668. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47669. */
  47670. useSpecularOverAlpha: boolean;
  47671. /**
  47672. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47673. */
  47674. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47675. /**
  47676. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47677. */
  47678. useRoughnessFromMetallicTextureAlpha: boolean;
  47679. /**
  47680. * Specifies if the metallic texture contains the roughness information in its green channel.
  47681. */
  47682. useRoughnessFromMetallicTextureGreen: boolean;
  47683. /**
  47684. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47685. */
  47686. useMetallnessFromMetallicTextureBlue: boolean;
  47687. /**
  47688. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47689. */
  47690. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47691. /**
  47692. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47693. */
  47694. useAmbientInGrayScale: boolean;
  47695. /**
  47696. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47697. * The material will try to infer what glossiness each pixel should be.
  47698. */
  47699. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47700. /**
  47701. * BJS is using an harcoded light falloff based on a manually sets up range.
  47702. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47703. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47704. */
  47705. /**
  47706. * BJS is using an harcoded light falloff based on a manually sets up range.
  47707. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47708. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47709. */
  47710. usePhysicalLightFalloff: boolean;
  47711. /**
  47712. * In order to support the falloff compatibility with gltf, a special mode has been added
  47713. * to reproduce the gltf light falloff.
  47714. */
  47715. /**
  47716. * In order to support the falloff compatibility with gltf, a special mode has been added
  47717. * to reproduce the gltf light falloff.
  47718. */
  47719. useGLTFLightFalloff: boolean;
  47720. /**
  47721. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47722. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47723. */
  47724. useRadianceOverAlpha: boolean;
  47725. /**
  47726. * Allows using an object space normal map (instead of tangent space).
  47727. */
  47728. useObjectSpaceNormalMap: boolean;
  47729. /**
  47730. * Allows using the bump map in parallax mode.
  47731. */
  47732. useParallax: boolean;
  47733. /**
  47734. * Allows using the bump map in parallax occlusion mode.
  47735. */
  47736. useParallaxOcclusion: boolean;
  47737. /**
  47738. * Controls the scale bias of the parallax mode.
  47739. */
  47740. parallaxScaleBias: number;
  47741. /**
  47742. * If sets to true, disables all the lights affecting the material.
  47743. */
  47744. disableLighting: boolean;
  47745. /**
  47746. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47747. */
  47748. forceIrradianceInFragment: boolean;
  47749. /**
  47750. * Number of Simultaneous lights allowed on the material.
  47751. */
  47752. maxSimultaneousLights: number;
  47753. /**
  47754. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47755. */
  47756. invertNormalMapX: boolean;
  47757. /**
  47758. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47759. */
  47760. invertNormalMapY: boolean;
  47761. /**
  47762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47763. */
  47764. twoSidedLighting: boolean;
  47765. /**
  47766. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47767. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47768. */
  47769. useAlphaFresnel: boolean;
  47770. /**
  47771. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47772. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47773. */
  47774. useLinearAlphaFresnel: boolean;
  47775. /**
  47776. * Let user defines the brdf lookup texture used for IBL.
  47777. * A default 8bit version is embedded but you could point at :
  47778. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47779. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47780. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47781. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47782. */
  47783. environmentBRDFTexture: Nullable<BaseTexture>;
  47784. /**
  47785. * Force normal to face away from face.
  47786. */
  47787. forceNormalForward: boolean;
  47788. /**
  47789. * Enables specular anti aliasing in the PBR shader.
  47790. * It will both interacts on the Geometry for analytical and IBL lighting.
  47791. * It also prefilter the roughness map based on the bump values.
  47792. */
  47793. enableSpecularAntiAliasing: boolean;
  47794. /**
  47795. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47796. * makes the reflect vector face the model (under horizon).
  47797. */
  47798. useHorizonOcclusion: boolean;
  47799. /**
  47800. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47801. * too much the area relying on ambient texture to define their ambient occlusion.
  47802. */
  47803. useRadianceOcclusion: boolean;
  47804. /**
  47805. * If set to true, no lighting calculations will be applied.
  47806. */
  47807. unlit: boolean;
  47808. /**
  47809. * Gets the image processing configuration used either in this material.
  47810. */
  47811. /**
  47812. * Sets the Default image processing configuration used either in the this material.
  47813. *
  47814. * If sets to null, the scene one is in use.
  47815. */
  47816. imageProcessingConfiguration: ImageProcessingConfiguration;
  47817. /**
  47818. * Gets wether the color curves effect is enabled.
  47819. */
  47820. /**
  47821. * Sets wether the color curves effect is enabled.
  47822. */
  47823. cameraColorCurvesEnabled: boolean;
  47824. /**
  47825. * Gets wether the color grading effect is enabled.
  47826. */
  47827. /**
  47828. * Gets wether the color grading effect is enabled.
  47829. */
  47830. cameraColorGradingEnabled: boolean;
  47831. /**
  47832. * Gets wether tonemapping is enabled or not.
  47833. */
  47834. /**
  47835. * Sets wether tonemapping is enabled or not
  47836. */
  47837. cameraToneMappingEnabled: boolean;
  47838. /**
  47839. * The camera exposure used on this material.
  47840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47841. * This corresponds to a photographic exposure.
  47842. */
  47843. /**
  47844. * The camera exposure used on this material.
  47845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47846. * This corresponds to a photographic exposure.
  47847. */
  47848. cameraExposure: number;
  47849. /**
  47850. * Gets The camera contrast used on this material.
  47851. */
  47852. /**
  47853. * Sets The camera contrast used on this material.
  47854. */
  47855. cameraContrast: number;
  47856. /**
  47857. * Gets the Color Grading 2D Lookup Texture.
  47858. */
  47859. /**
  47860. * Sets the Color Grading 2D Lookup Texture.
  47861. */
  47862. cameraColorGradingTexture: Nullable<BaseTexture>;
  47863. /**
  47864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47866. * 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;
  47867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47868. */
  47869. /**
  47870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47872. * 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;
  47873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47874. */
  47875. cameraColorCurves: Nullable<ColorCurves>;
  47876. /**
  47877. * Instantiates a new PBRMaterial instance.
  47878. *
  47879. * @param name The material name
  47880. * @param scene The scene the material will be use in.
  47881. */
  47882. constructor(name: string, scene: Scene);
  47883. /**
  47884. * Returns the name of this material class.
  47885. */
  47886. getClassName(): string;
  47887. /**
  47888. * Makes a duplicate of the current material.
  47889. * @param name - name to use for the new material.
  47890. */
  47891. clone(name: string): PBRMaterial;
  47892. /**
  47893. * Serializes this PBR Material.
  47894. * @returns - An object with the serialized material.
  47895. */
  47896. serialize(): any;
  47897. /**
  47898. * Parses a PBR Material from a serialized object.
  47899. * @param source - Serialized object.
  47900. * @param scene - BJS scene instance.
  47901. * @param rootUrl - url for the scene object
  47902. * @returns - PBRMaterial
  47903. */
  47904. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47905. }
  47906. }
  47907. declare module BABYLON {
  47908. /**
  47909. * Direct draw surface info
  47910. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47911. */
  47912. export interface DDSInfo {
  47913. /**
  47914. * Width of the texture
  47915. */
  47916. width: number;
  47917. /**
  47918. * Width of the texture
  47919. */
  47920. height: number;
  47921. /**
  47922. * Number of Mipmaps for the texture
  47923. * @see https://en.wikipedia.org/wiki/Mipmap
  47924. */
  47925. mipmapCount: number;
  47926. /**
  47927. * If the textures format is a known fourCC format
  47928. * @see https://www.fourcc.org/
  47929. */
  47930. isFourCC: boolean;
  47931. /**
  47932. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47933. */
  47934. isRGB: boolean;
  47935. /**
  47936. * If the texture is a lumincance format
  47937. */
  47938. isLuminance: boolean;
  47939. /**
  47940. * If this is a cube texture
  47941. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47942. */
  47943. isCube: boolean;
  47944. /**
  47945. * If the texture is a compressed format eg. FOURCC_DXT1
  47946. */
  47947. isCompressed: boolean;
  47948. /**
  47949. * The dxgiFormat of the texture
  47950. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47951. */
  47952. dxgiFormat: number;
  47953. /**
  47954. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47955. */
  47956. textureType: number;
  47957. /**
  47958. * Sphericle polynomial created for the dds texture
  47959. */
  47960. sphericalPolynomial?: SphericalPolynomial;
  47961. }
  47962. /**
  47963. * Class used to provide DDS decompression tools
  47964. */
  47965. export class DDSTools {
  47966. /**
  47967. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47968. */
  47969. static StoreLODInAlphaChannel: boolean;
  47970. /**
  47971. * Gets DDS information from an array buffer
  47972. * @param arrayBuffer defines the array buffer to read data from
  47973. * @returns the DDS information
  47974. */
  47975. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47976. private static _FloatView;
  47977. private static _Int32View;
  47978. private static _ToHalfFloat;
  47979. private static _FromHalfFloat;
  47980. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47981. private static _GetHalfFloatRGBAArrayBuffer;
  47982. private static _GetFloatRGBAArrayBuffer;
  47983. private static _GetFloatAsUIntRGBAArrayBuffer;
  47984. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47985. private static _GetRGBAArrayBuffer;
  47986. private static _ExtractLongWordOrder;
  47987. private static _GetRGBArrayBuffer;
  47988. private static _GetLuminanceArrayBuffer;
  47989. /**
  47990. * Uploads DDS Levels to a Babylon Texture
  47991. * @hidden
  47992. */
  47993. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47994. }
  47995. interface Engine {
  47996. /**
  47997. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47998. * @param rootUrl defines the url where the file to load is located
  47999. * @param scene defines the current scene
  48000. * @param lodScale defines scale to apply to the mip map selection
  48001. * @param lodOffset defines offset to apply to the mip map selection
  48002. * @param onLoad defines an optional callback raised when the texture is loaded
  48003. * @param onError defines an optional callback raised if there is an issue to load the texture
  48004. * @param format defines the format of the data
  48005. * @param forcedExtension defines the extension to use to pick the right loader
  48006. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48007. * @returns the cube texture as an InternalTexture
  48008. */
  48009. 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;
  48010. }
  48011. }
  48012. declare module BABYLON {
  48013. /**
  48014. * Implementation of the DDS Texture Loader.
  48015. * @hidden
  48016. */
  48017. export class _DDSTextureLoader implements IInternalTextureLoader {
  48018. /**
  48019. * Defines wether the loader supports cascade loading the different faces.
  48020. */
  48021. readonly supportCascades: boolean;
  48022. /**
  48023. * This returns if the loader support the current file information.
  48024. * @param extension defines the file extension of the file being loaded
  48025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48026. * @param fallback defines the fallback internal texture if any
  48027. * @param isBase64 defines whether the texture is encoded as a base64
  48028. * @param isBuffer defines whether the texture data are stored as a buffer
  48029. * @returns true if the loader can load the specified file
  48030. */
  48031. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48032. /**
  48033. * Transform the url before loading if required.
  48034. * @param rootUrl the url of the texture
  48035. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48036. * @returns the transformed texture
  48037. */
  48038. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48039. /**
  48040. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48041. * @param rootUrl the url of the texture
  48042. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48043. * @returns the fallback texture
  48044. */
  48045. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48046. /**
  48047. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48048. * @param data contains the texture data
  48049. * @param texture defines the BabylonJS internal texture
  48050. * @param createPolynomials will be true if polynomials have been requested
  48051. * @param onLoad defines the callback to trigger once the texture is ready
  48052. * @param onError defines the callback to trigger in case of error
  48053. */
  48054. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48055. /**
  48056. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48057. * @param data contains the texture data
  48058. * @param texture defines the BabylonJS internal texture
  48059. * @param callback defines the method to call once ready to upload
  48060. */
  48061. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48062. }
  48063. }
  48064. declare module BABYLON {
  48065. /**
  48066. * Implementation of the ENV Texture Loader.
  48067. * @hidden
  48068. */
  48069. export class _ENVTextureLoader implements IInternalTextureLoader {
  48070. /**
  48071. * Defines wether the loader supports cascade loading the different faces.
  48072. */
  48073. readonly supportCascades: boolean;
  48074. /**
  48075. * This returns if the loader support the current file information.
  48076. * @param extension defines the file extension of the file being loaded
  48077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48078. * @param fallback defines the fallback internal texture if any
  48079. * @param isBase64 defines whether the texture is encoded as a base64
  48080. * @param isBuffer defines whether the texture data are stored as a buffer
  48081. * @returns true if the loader can load the specified file
  48082. */
  48083. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48084. /**
  48085. * Transform the url before loading if required.
  48086. * @param rootUrl the url of the texture
  48087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48088. * @returns the transformed texture
  48089. */
  48090. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48091. /**
  48092. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48093. * @param rootUrl the url of the texture
  48094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48095. * @returns the fallback texture
  48096. */
  48097. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48098. /**
  48099. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48100. * @param data contains the texture data
  48101. * @param texture defines the BabylonJS internal texture
  48102. * @param createPolynomials will be true if polynomials have been requested
  48103. * @param onLoad defines the callback to trigger once the texture is ready
  48104. * @param onError defines the callback to trigger in case of error
  48105. */
  48106. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48107. /**
  48108. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48109. * @param data contains the texture data
  48110. * @param texture defines the BabylonJS internal texture
  48111. * @param callback defines the method to call once ready to upload
  48112. */
  48113. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48114. }
  48115. }
  48116. declare module BABYLON {
  48117. /**
  48118. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48119. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48120. */
  48121. export class KhronosTextureContainer {
  48122. /** contents of the KTX container file */
  48123. arrayBuffer: any;
  48124. private static HEADER_LEN;
  48125. private static COMPRESSED_2D;
  48126. private static COMPRESSED_3D;
  48127. private static TEX_2D;
  48128. private static TEX_3D;
  48129. /**
  48130. * Gets the openGL type
  48131. */
  48132. glType: number;
  48133. /**
  48134. * Gets the openGL type size
  48135. */
  48136. glTypeSize: number;
  48137. /**
  48138. * Gets the openGL format
  48139. */
  48140. glFormat: number;
  48141. /**
  48142. * Gets the openGL internal format
  48143. */
  48144. glInternalFormat: number;
  48145. /**
  48146. * Gets the base internal format
  48147. */
  48148. glBaseInternalFormat: number;
  48149. /**
  48150. * Gets image width in pixel
  48151. */
  48152. pixelWidth: number;
  48153. /**
  48154. * Gets image height in pixel
  48155. */
  48156. pixelHeight: number;
  48157. /**
  48158. * Gets image depth in pixels
  48159. */
  48160. pixelDepth: number;
  48161. /**
  48162. * Gets the number of array elements
  48163. */
  48164. numberOfArrayElements: number;
  48165. /**
  48166. * Gets the number of faces
  48167. */
  48168. numberOfFaces: number;
  48169. /**
  48170. * Gets the number of mipmap levels
  48171. */
  48172. numberOfMipmapLevels: number;
  48173. /**
  48174. * Gets the bytes of key value data
  48175. */
  48176. bytesOfKeyValueData: number;
  48177. /**
  48178. * Gets the load type
  48179. */
  48180. loadType: number;
  48181. /**
  48182. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48183. */
  48184. isInvalid: boolean;
  48185. /**
  48186. * Creates a new KhronosTextureContainer
  48187. * @param arrayBuffer contents of the KTX container file
  48188. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48189. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48190. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48191. */
  48192. constructor(
  48193. /** contents of the KTX container file */
  48194. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48195. /**
  48196. * Uploads KTX content to a Babylon Texture.
  48197. * It is assumed that the texture has already been created & is currently bound
  48198. * @hidden
  48199. */
  48200. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48201. private _upload2DCompressedLevels;
  48202. }
  48203. }
  48204. declare module BABYLON {
  48205. /**
  48206. * Implementation of the KTX Texture Loader.
  48207. * @hidden
  48208. */
  48209. export class _KTXTextureLoader implements IInternalTextureLoader {
  48210. /**
  48211. * Defines wether the loader supports cascade loading the different faces.
  48212. */
  48213. readonly supportCascades: boolean;
  48214. /**
  48215. * This returns if the loader support the current file information.
  48216. * @param extension defines the file extension of the file being loaded
  48217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48218. * @param fallback defines the fallback internal texture if any
  48219. * @param isBase64 defines whether the texture is encoded as a base64
  48220. * @param isBuffer defines whether the texture data are stored as a buffer
  48221. * @returns true if the loader can load the specified file
  48222. */
  48223. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48224. /**
  48225. * Transform the url before loading if required.
  48226. * @param rootUrl the url of the texture
  48227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48228. * @returns the transformed texture
  48229. */
  48230. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48231. /**
  48232. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48233. * @param rootUrl the url of the texture
  48234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48235. * @returns the fallback texture
  48236. */
  48237. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48238. /**
  48239. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48240. * @param data contains the texture data
  48241. * @param texture defines the BabylonJS internal texture
  48242. * @param createPolynomials will be true if polynomials have been requested
  48243. * @param onLoad defines the callback to trigger once the texture is ready
  48244. * @param onError defines the callback to trigger in case of error
  48245. */
  48246. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48247. /**
  48248. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48249. * @param data contains the texture data
  48250. * @param texture defines the BabylonJS internal texture
  48251. * @param callback defines the method to call once ready to upload
  48252. */
  48253. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48254. }
  48255. }
  48256. declare module BABYLON {
  48257. /**
  48258. * Options for the default xr helper
  48259. */
  48260. export class WebXRDefaultExperienceOptions {
  48261. /**
  48262. * Floor meshes that should be used for teleporting
  48263. */
  48264. floorMeshes: Array<AbstractMesh>;
  48265. }
  48266. /**
  48267. * Default experience which provides a similar setup to the previous webVRExperience
  48268. */
  48269. export class WebXRDefaultExperience {
  48270. /**
  48271. * Base experience
  48272. */
  48273. baseExperience: WebXRExperienceHelper;
  48274. /**
  48275. * Input experience extension
  48276. */
  48277. input: WebXRInput;
  48278. /**
  48279. * Loads the controller models
  48280. */
  48281. controllerModelLoader: WebXRControllerModelLoader;
  48282. /**
  48283. * Enables laser pointer and selection
  48284. */
  48285. pointerSelection: WebXRControllerPointerSelection;
  48286. /**
  48287. * Enables teleportation
  48288. */
  48289. teleportation: WebXRControllerTeleportation;
  48290. /**
  48291. * Enables ui for enetering/exiting xr
  48292. */
  48293. enterExitUI: WebXREnterExitUI;
  48294. /**
  48295. * Default output canvas xr should render to
  48296. */
  48297. outputCanvas: WebXRManagedOutputCanvas;
  48298. /**
  48299. * Creates the default xr experience
  48300. * @param scene scene
  48301. * @param options options for basic configuration
  48302. * @returns resulting WebXRDefaultExperience
  48303. */
  48304. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48305. private constructor();
  48306. /**
  48307. * DIsposes of the experience helper
  48308. */
  48309. dispose(): void;
  48310. }
  48311. }
  48312. declare module BABYLON {
  48313. /** @hidden */
  48314. export var _forceSceneHelpersToBundle: boolean;
  48315. interface Scene {
  48316. /**
  48317. * Creates a default light for the scene.
  48318. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48319. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48320. */
  48321. createDefaultLight(replace?: boolean): void;
  48322. /**
  48323. * Creates a default camera for the scene.
  48324. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48325. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48326. * @param replace has default false, when true replaces the active camera in the scene
  48327. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48328. */
  48329. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48330. /**
  48331. * Creates a default camera and a default light.
  48332. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48333. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48334. * @param replace has the default false, when true replaces the active camera/light in the scene
  48335. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48336. */
  48337. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48338. /**
  48339. * Creates a new sky box
  48340. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48341. * @param environmentTexture defines the texture to use as environment texture
  48342. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48343. * @param scale defines the overall scale of the skybox
  48344. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48345. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48346. * @returns a new mesh holding the sky box
  48347. */
  48348. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48349. /**
  48350. * Creates a new environment
  48351. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48352. * @param options defines the options you can use to configure the environment
  48353. * @returns the new EnvironmentHelper
  48354. */
  48355. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48356. /**
  48357. * Creates a new VREXperienceHelper
  48358. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48359. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48360. * @returns a new VREXperienceHelper
  48361. */
  48362. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48363. /**
  48364. * Creates a new WebXRDefaultExperience
  48365. * @see http://doc.babylonjs.com/how_to/webxr
  48366. * @param options experience options
  48367. * @returns a promise for a new WebXRDefaultExperience
  48368. */
  48369. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48370. }
  48371. }
  48372. declare module BABYLON {
  48373. /**
  48374. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48375. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48376. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48377. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48378. */
  48379. export class VideoDome extends TransformNode {
  48380. /**
  48381. * Define the video source as a Monoscopic panoramic 360 video.
  48382. */
  48383. static readonly MODE_MONOSCOPIC: number;
  48384. /**
  48385. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48386. */
  48387. static readonly MODE_TOPBOTTOM: number;
  48388. /**
  48389. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48390. */
  48391. static readonly MODE_SIDEBYSIDE: number;
  48392. private _halfDome;
  48393. private _useDirectMapping;
  48394. /**
  48395. * The video texture being displayed on the sphere
  48396. */
  48397. protected _videoTexture: VideoTexture;
  48398. /**
  48399. * Gets the video texture being displayed on the sphere
  48400. */
  48401. readonly videoTexture: VideoTexture;
  48402. /**
  48403. * The skybox material
  48404. */
  48405. protected _material: BackgroundMaterial;
  48406. /**
  48407. * The surface used for the skybox
  48408. */
  48409. protected _mesh: Mesh;
  48410. /**
  48411. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48412. */
  48413. private _halfDomeMask;
  48414. /**
  48415. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48416. * Also see the options.resolution property.
  48417. */
  48418. fovMultiplier: number;
  48419. private _videoMode;
  48420. /**
  48421. * Gets or set the current video mode for the video. It can be:
  48422. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48423. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48424. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48425. */
  48426. videoMode: number;
  48427. /**
  48428. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48429. *
  48430. */
  48431. /**
  48432. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48433. */
  48434. halfDome: boolean;
  48435. /**
  48436. * Oberserver used in Stereoscopic VR Mode.
  48437. */
  48438. private _onBeforeCameraRenderObserver;
  48439. /**
  48440. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48441. * @param name Element's name, child elements will append suffixes for their own names.
  48442. * @param urlsOrVideo defines the url(s) or the video element to use
  48443. * @param options An object containing optional or exposed sub element properties
  48444. */
  48445. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48446. resolution?: number;
  48447. clickToPlay?: boolean;
  48448. autoPlay?: boolean;
  48449. loop?: boolean;
  48450. size?: number;
  48451. poster?: string;
  48452. faceForward?: boolean;
  48453. useDirectMapping?: boolean;
  48454. halfDomeMode?: boolean;
  48455. }, scene: Scene);
  48456. private _changeVideoMode;
  48457. /**
  48458. * Releases resources associated with this node.
  48459. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48460. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48461. */
  48462. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48463. }
  48464. }
  48465. declare module BABYLON {
  48466. /**
  48467. * This class can be used to get instrumentation data from a Babylon engine
  48468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48469. */
  48470. export class EngineInstrumentation implements IDisposable {
  48471. /**
  48472. * Define the instrumented engine.
  48473. */
  48474. engine: Engine;
  48475. private _captureGPUFrameTime;
  48476. private _gpuFrameTimeToken;
  48477. private _gpuFrameTime;
  48478. private _captureShaderCompilationTime;
  48479. private _shaderCompilationTime;
  48480. private _onBeginFrameObserver;
  48481. private _onEndFrameObserver;
  48482. private _onBeforeShaderCompilationObserver;
  48483. private _onAfterShaderCompilationObserver;
  48484. /**
  48485. * Gets the perf counter used for GPU frame time
  48486. */
  48487. readonly gpuFrameTimeCounter: PerfCounter;
  48488. /**
  48489. * Gets the GPU frame time capture status
  48490. */
  48491. /**
  48492. * Enable or disable the GPU frame time capture
  48493. */
  48494. captureGPUFrameTime: boolean;
  48495. /**
  48496. * Gets the perf counter used for shader compilation time
  48497. */
  48498. readonly shaderCompilationTimeCounter: PerfCounter;
  48499. /**
  48500. * Gets the shader compilation time capture status
  48501. */
  48502. /**
  48503. * Enable or disable the shader compilation time capture
  48504. */
  48505. captureShaderCompilationTime: boolean;
  48506. /**
  48507. * Instantiates a new engine instrumentation.
  48508. * This class can be used to get instrumentation data from a Babylon engine
  48509. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48510. * @param engine Defines the engine to instrument
  48511. */
  48512. constructor(
  48513. /**
  48514. * Define the instrumented engine.
  48515. */
  48516. engine: Engine);
  48517. /**
  48518. * Dispose and release associated resources.
  48519. */
  48520. dispose(): void;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * This class can be used to get instrumentation data from a Babylon engine
  48526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48527. */
  48528. export class SceneInstrumentation implements IDisposable {
  48529. /**
  48530. * Defines the scene to instrument
  48531. */
  48532. scene: Scene;
  48533. private _captureActiveMeshesEvaluationTime;
  48534. private _activeMeshesEvaluationTime;
  48535. private _captureRenderTargetsRenderTime;
  48536. private _renderTargetsRenderTime;
  48537. private _captureFrameTime;
  48538. private _frameTime;
  48539. private _captureRenderTime;
  48540. private _renderTime;
  48541. private _captureInterFrameTime;
  48542. private _interFrameTime;
  48543. private _captureParticlesRenderTime;
  48544. private _particlesRenderTime;
  48545. private _captureSpritesRenderTime;
  48546. private _spritesRenderTime;
  48547. private _capturePhysicsTime;
  48548. private _physicsTime;
  48549. private _captureAnimationsTime;
  48550. private _animationsTime;
  48551. private _captureCameraRenderTime;
  48552. private _cameraRenderTime;
  48553. private _onBeforeActiveMeshesEvaluationObserver;
  48554. private _onAfterActiveMeshesEvaluationObserver;
  48555. private _onBeforeRenderTargetsRenderObserver;
  48556. private _onAfterRenderTargetsRenderObserver;
  48557. private _onAfterRenderObserver;
  48558. private _onBeforeDrawPhaseObserver;
  48559. private _onAfterDrawPhaseObserver;
  48560. private _onBeforeAnimationsObserver;
  48561. private _onBeforeParticlesRenderingObserver;
  48562. private _onAfterParticlesRenderingObserver;
  48563. private _onBeforeSpritesRenderingObserver;
  48564. private _onAfterSpritesRenderingObserver;
  48565. private _onBeforePhysicsObserver;
  48566. private _onAfterPhysicsObserver;
  48567. private _onAfterAnimationsObserver;
  48568. private _onBeforeCameraRenderObserver;
  48569. private _onAfterCameraRenderObserver;
  48570. /**
  48571. * Gets the perf counter used for active meshes evaluation time
  48572. */
  48573. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48574. /**
  48575. * Gets the active meshes evaluation time capture status
  48576. */
  48577. /**
  48578. * Enable or disable the active meshes evaluation time capture
  48579. */
  48580. captureActiveMeshesEvaluationTime: boolean;
  48581. /**
  48582. * Gets the perf counter used for render targets render time
  48583. */
  48584. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48585. /**
  48586. * Gets the render targets render time capture status
  48587. */
  48588. /**
  48589. * Enable or disable the render targets render time capture
  48590. */
  48591. captureRenderTargetsRenderTime: boolean;
  48592. /**
  48593. * Gets the perf counter used for particles render time
  48594. */
  48595. readonly particlesRenderTimeCounter: PerfCounter;
  48596. /**
  48597. * Gets the particles render time capture status
  48598. */
  48599. /**
  48600. * Enable or disable the particles render time capture
  48601. */
  48602. captureParticlesRenderTime: boolean;
  48603. /**
  48604. * Gets the perf counter used for sprites render time
  48605. */
  48606. readonly spritesRenderTimeCounter: PerfCounter;
  48607. /**
  48608. * Gets the sprites render time capture status
  48609. */
  48610. /**
  48611. * Enable or disable the sprites render time capture
  48612. */
  48613. captureSpritesRenderTime: boolean;
  48614. /**
  48615. * Gets the perf counter used for physics time
  48616. */
  48617. readonly physicsTimeCounter: PerfCounter;
  48618. /**
  48619. * Gets the physics time capture status
  48620. */
  48621. /**
  48622. * Enable or disable the physics time capture
  48623. */
  48624. capturePhysicsTime: boolean;
  48625. /**
  48626. * Gets the perf counter used for animations time
  48627. */
  48628. readonly animationsTimeCounter: PerfCounter;
  48629. /**
  48630. * Gets the animations time capture status
  48631. */
  48632. /**
  48633. * Enable or disable the animations time capture
  48634. */
  48635. captureAnimationsTime: boolean;
  48636. /**
  48637. * Gets the perf counter used for frame time capture
  48638. */
  48639. readonly frameTimeCounter: PerfCounter;
  48640. /**
  48641. * Gets the frame time capture status
  48642. */
  48643. /**
  48644. * Enable or disable the frame time capture
  48645. */
  48646. captureFrameTime: boolean;
  48647. /**
  48648. * Gets the perf counter used for inter-frames time capture
  48649. */
  48650. readonly interFrameTimeCounter: PerfCounter;
  48651. /**
  48652. * Gets the inter-frames time capture status
  48653. */
  48654. /**
  48655. * Enable or disable the inter-frames time capture
  48656. */
  48657. captureInterFrameTime: boolean;
  48658. /**
  48659. * Gets the perf counter used for render time capture
  48660. */
  48661. readonly renderTimeCounter: PerfCounter;
  48662. /**
  48663. * Gets the render time capture status
  48664. */
  48665. /**
  48666. * Enable or disable the render time capture
  48667. */
  48668. captureRenderTime: boolean;
  48669. /**
  48670. * Gets the perf counter used for camera render time capture
  48671. */
  48672. readonly cameraRenderTimeCounter: PerfCounter;
  48673. /**
  48674. * Gets the camera render time capture status
  48675. */
  48676. /**
  48677. * Enable or disable the camera render time capture
  48678. */
  48679. captureCameraRenderTime: boolean;
  48680. /**
  48681. * Gets the perf counter used for draw calls
  48682. */
  48683. readonly drawCallsCounter: PerfCounter;
  48684. /**
  48685. * Instantiates a new scene instrumentation.
  48686. * This class can be used to get instrumentation data from a Babylon engine
  48687. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48688. * @param scene Defines the scene to instrument
  48689. */
  48690. constructor(
  48691. /**
  48692. * Defines the scene to instrument
  48693. */
  48694. scene: Scene);
  48695. /**
  48696. * Dispose and release associated resources.
  48697. */
  48698. dispose(): void;
  48699. }
  48700. }
  48701. declare module BABYLON {
  48702. /** @hidden */
  48703. export var glowMapGenerationPixelShader: {
  48704. name: string;
  48705. shader: string;
  48706. };
  48707. }
  48708. declare module BABYLON {
  48709. /** @hidden */
  48710. export var glowMapGenerationVertexShader: {
  48711. name: string;
  48712. shader: string;
  48713. };
  48714. }
  48715. declare module BABYLON {
  48716. /**
  48717. * Effect layer options. This helps customizing the behaviour
  48718. * of the effect layer.
  48719. */
  48720. export interface IEffectLayerOptions {
  48721. /**
  48722. * Multiplication factor apply to the canvas size to compute the render target size
  48723. * used to generated the objects (the smaller the faster).
  48724. */
  48725. mainTextureRatio: number;
  48726. /**
  48727. * Enforces a fixed size texture to ensure effect stability across devices.
  48728. */
  48729. mainTextureFixedSize?: number;
  48730. /**
  48731. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48732. */
  48733. alphaBlendingMode: number;
  48734. /**
  48735. * The camera attached to the layer.
  48736. */
  48737. camera: Nullable<Camera>;
  48738. /**
  48739. * The rendering group to draw the layer in.
  48740. */
  48741. renderingGroupId: number;
  48742. }
  48743. /**
  48744. * The effect layer Helps adding post process effect blended with the main pass.
  48745. *
  48746. * This can be for instance use to generate glow or higlight effects on the scene.
  48747. *
  48748. * The effect layer class can not be used directly and is intented to inherited from to be
  48749. * customized per effects.
  48750. */
  48751. export abstract class EffectLayer {
  48752. private _vertexBuffers;
  48753. private _indexBuffer;
  48754. private _cachedDefines;
  48755. private _effectLayerMapGenerationEffect;
  48756. private _effectLayerOptions;
  48757. private _mergeEffect;
  48758. protected _scene: Scene;
  48759. protected _engine: Engine;
  48760. protected _maxSize: number;
  48761. protected _mainTextureDesiredSize: ISize;
  48762. protected _mainTexture: RenderTargetTexture;
  48763. protected _shouldRender: boolean;
  48764. protected _postProcesses: PostProcess[];
  48765. protected _textures: BaseTexture[];
  48766. protected _emissiveTextureAndColor: {
  48767. texture: Nullable<BaseTexture>;
  48768. color: Color4;
  48769. };
  48770. /**
  48771. * The name of the layer
  48772. */
  48773. name: string;
  48774. /**
  48775. * The clear color of the texture used to generate the glow map.
  48776. */
  48777. neutralColor: Color4;
  48778. /**
  48779. * Specifies wether the highlight layer is enabled or not.
  48780. */
  48781. isEnabled: boolean;
  48782. /**
  48783. * Gets the camera attached to the layer.
  48784. */
  48785. readonly camera: Nullable<Camera>;
  48786. /**
  48787. * Gets the rendering group id the layer should render in.
  48788. */
  48789. renderingGroupId: number;
  48790. /**
  48791. * An event triggered when the effect layer has been disposed.
  48792. */
  48793. onDisposeObservable: Observable<EffectLayer>;
  48794. /**
  48795. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48796. */
  48797. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48798. /**
  48799. * An event triggered when the generated texture is being merged in the scene.
  48800. */
  48801. onBeforeComposeObservable: Observable<EffectLayer>;
  48802. /**
  48803. * An event triggered when the generated texture has been merged in the scene.
  48804. */
  48805. onAfterComposeObservable: Observable<EffectLayer>;
  48806. /**
  48807. * An event triggered when the efffect layer changes its size.
  48808. */
  48809. onSizeChangedObservable: Observable<EffectLayer>;
  48810. /** @hidden */
  48811. static _SceneComponentInitialization: (scene: Scene) => void;
  48812. /**
  48813. * Instantiates a new effect Layer and references it in the scene.
  48814. * @param name The name of the layer
  48815. * @param scene The scene to use the layer in
  48816. */
  48817. constructor(
  48818. /** The Friendly of the effect in the scene */
  48819. name: string, scene: Scene);
  48820. /**
  48821. * Get the effect name of the layer.
  48822. * @return The effect name
  48823. */
  48824. abstract getEffectName(): string;
  48825. /**
  48826. * Checks for the readiness of the element composing the layer.
  48827. * @param subMesh the mesh to check for
  48828. * @param useInstances specify wether or not to use instances to render the mesh
  48829. * @return true if ready otherwise, false
  48830. */
  48831. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48832. /**
  48833. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48834. * @returns true if the effect requires stencil during the main canvas render pass.
  48835. */
  48836. abstract needStencil(): boolean;
  48837. /**
  48838. * Create the merge effect. This is the shader use to blit the information back
  48839. * to the main canvas at the end of the scene rendering.
  48840. * @returns The effect containing the shader used to merge the effect on the main canvas
  48841. */
  48842. protected abstract _createMergeEffect(): Effect;
  48843. /**
  48844. * Creates the render target textures and post processes used in the effect layer.
  48845. */
  48846. protected abstract _createTextureAndPostProcesses(): void;
  48847. /**
  48848. * Implementation specific of rendering the generating effect on the main canvas.
  48849. * @param effect The effect used to render through
  48850. */
  48851. protected abstract _internalRender(effect: Effect): void;
  48852. /**
  48853. * Sets the required values for both the emissive texture and and the main color.
  48854. */
  48855. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48856. /**
  48857. * Free any resources and references associated to a mesh.
  48858. * Internal use
  48859. * @param mesh The mesh to free.
  48860. */
  48861. abstract _disposeMesh(mesh: Mesh): void;
  48862. /**
  48863. * Serializes this layer (Glow or Highlight for example)
  48864. * @returns a serialized layer object
  48865. */
  48866. abstract serialize?(): any;
  48867. /**
  48868. * Initializes the effect layer with the required options.
  48869. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48870. */
  48871. protected _init(options: Partial<IEffectLayerOptions>): void;
  48872. /**
  48873. * Generates the index buffer of the full screen quad blending to the main canvas.
  48874. */
  48875. private _generateIndexBuffer;
  48876. /**
  48877. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48878. */
  48879. private _generateVertexBuffer;
  48880. /**
  48881. * Sets the main texture desired size which is the closest power of two
  48882. * of the engine canvas size.
  48883. */
  48884. private _setMainTextureSize;
  48885. /**
  48886. * Creates the main texture for the effect layer.
  48887. */
  48888. protected _createMainTexture(): void;
  48889. /**
  48890. * Adds specific effects defines.
  48891. * @param defines The defines to add specifics to.
  48892. */
  48893. protected _addCustomEffectDefines(defines: string[]): void;
  48894. /**
  48895. * Checks for the readiness of the element composing the layer.
  48896. * @param subMesh the mesh to check for
  48897. * @param useInstances specify wether or not to use instances to render the mesh
  48898. * @param emissiveTexture the associated emissive texture used to generate the glow
  48899. * @return true if ready otherwise, false
  48900. */
  48901. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48902. /**
  48903. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48904. */
  48905. render(): void;
  48906. /**
  48907. * Determine if a given mesh will be used in the current effect.
  48908. * @param mesh mesh to test
  48909. * @returns true if the mesh will be used
  48910. */
  48911. hasMesh(mesh: AbstractMesh): boolean;
  48912. /**
  48913. * Returns true if the layer contains information to display, otherwise false.
  48914. * @returns true if the glow layer should be rendered
  48915. */
  48916. shouldRender(): boolean;
  48917. /**
  48918. * Returns true if the mesh should render, otherwise false.
  48919. * @param mesh The mesh to render
  48920. * @returns true if it should render otherwise false
  48921. */
  48922. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48923. /**
  48924. * Returns true if the mesh can be rendered, otherwise false.
  48925. * @param mesh The mesh to render
  48926. * @param material The material used on the mesh
  48927. * @returns true if it can be rendered otherwise false
  48928. */
  48929. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48930. /**
  48931. * Returns true if the mesh should render, otherwise false.
  48932. * @param mesh The mesh to render
  48933. * @returns true if it should render otherwise false
  48934. */
  48935. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48936. /**
  48937. * Renders the submesh passed in parameter to the generation map.
  48938. */
  48939. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48940. /**
  48941. * Rebuild the required buffers.
  48942. * @hidden Internal use only.
  48943. */
  48944. _rebuild(): void;
  48945. /**
  48946. * Dispose only the render target textures and post process.
  48947. */
  48948. private _disposeTextureAndPostProcesses;
  48949. /**
  48950. * Dispose the highlight layer and free resources.
  48951. */
  48952. dispose(): void;
  48953. /**
  48954. * Gets the class name of the effect layer
  48955. * @returns the string with the class name of the effect layer
  48956. */
  48957. getClassName(): string;
  48958. /**
  48959. * Creates an effect layer from parsed effect layer data
  48960. * @param parsedEffectLayer defines effect layer data
  48961. * @param scene defines the current scene
  48962. * @param rootUrl defines the root URL containing the effect layer information
  48963. * @returns a parsed effect Layer
  48964. */
  48965. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48966. }
  48967. }
  48968. declare module BABYLON {
  48969. interface AbstractScene {
  48970. /**
  48971. * The list of effect layers (highlights/glow) added to the scene
  48972. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48973. * @see http://doc.babylonjs.com/how_to/glow_layer
  48974. */
  48975. effectLayers: Array<EffectLayer>;
  48976. /**
  48977. * Removes the given effect layer from this scene.
  48978. * @param toRemove defines the effect layer to remove
  48979. * @returns the index of the removed effect layer
  48980. */
  48981. removeEffectLayer(toRemove: EffectLayer): number;
  48982. /**
  48983. * Adds the given effect layer to this scene
  48984. * @param newEffectLayer defines the effect layer to add
  48985. */
  48986. addEffectLayer(newEffectLayer: EffectLayer): void;
  48987. }
  48988. /**
  48989. * Defines the layer scene component responsible to manage any effect layers
  48990. * in a given scene.
  48991. */
  48992. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48993. /**
  48994. * The component name helpfull to identify the component in the list of scene components.
  48995. */
  48996. readonly name: string;
  48997. /**
  48998. * The scene the component belongs to.
  48999. */
  49000. scene: Scene;
  49001. private _engine;
  49002. private _renderEffects;
  49003. private _needStencil;
  49004. private _previousStencilState;
  49005. /**
  49006. * Creates a new instance of the component for the given scene
  49007. * @param scene Defines the scene to register the component in
  49008. */
  49009. constructor(scene: Scene);
  49010. /**
  49011. * Registers the component in a given scene
  49012. */
  49013. register(): void;
  49014. /**
  49015. * Rebuilds the elements related to this component in case of
  49016. * context lost for instance.
  49017. */
  49018. rebuild(): void;
  49019. /**
  49020. * Serializes the component data to the specified json object
  49021. * @param serializationObject The object to serialize to
  49022. */
  49023. serialize(serializationObject: any): void;
  49024. /**
  49025. * Adds all the elements from the container to the scene
  49026. * @param container the container holding the elements
  49027. */
  49028. addFromContainer(container: AbstractScene): void;
  49029. /**
  49030. * Removes all the elements in the container from the scene
  49031. * @param container contains the elements to remove
  49032. * @param dispose if the removed element should be disposed (default: false)
  49033. */
  49034. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49035. /**
  49036. * Disposes the component and the associated ressources.
  49037. */
  49038. dispose(): void;
  49039. private _isReadyForMesh;
  49040. private _renderMainTexture;
  49041. private _setStencil;
  49042. private _setStencilBack;
  49043. private _draw;
  49044. private _drawCamera;
  49045. private _drawRenderingGroup;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /** @hidden */
  49050. export var glowMapMergePixelShader: {
  49051. name: string;
  49052. shader: string;
  49053. };
  49054. }
  49055. declare module BABYLON {
  49056. /** @hidden */
  49057. export var glowMapMergeVertexShader: {
  49058. name: string;
  49059. shader: string;
  49060. };
  49061. }
  49062. declare module BABYLON {
  49063. interface AbstractScene {
  49064. /**
  49065. * Return a the first highlight layer of the scene with a given name.
  49066. * @param name The name of the highlight layer to look for.
  49067. * @return The highlight layer if found otherwise null.
  49068. */
  49069. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49070. }
  49071. /**
  49072. * Glow layer options. This helps customizing the behaviour
  49073. * of the glow layer.
  49074. */
  49075. export interface IGlowLayerOptions {
  49076. /**
  49077. * Multiplication factor apply to the canvas size to compute the render target size
  49078. * used to generated the glowing objects (the smaller the faster).
  49079. */
  49080. mainTextureRatio: number;
  49081. /**
  49082. * Enforces a fixed size texture to ensure resize independant blur.
  49083. */
  49084. mainTextureFixedSize?: number;
  49085. /**
  49086. * How big is the kernel of the blur texture.
  49087. */
  49088. blurKernelSize: number;
  49089. /**
  49090. * The camera attached to the layer.
  49091. */
  49092. camera: Nullable<Camera>;
  49093. /**
  49094. * Enable MSAA by chosing the number of samples.
  49095. */
  49096. mainTextureSamples?: number;
  49097. /**
  49098. * The rendering group to draw the layer in.
  49099. */
  49100. renderingGroupId: number;
  49101. }
  49102. /**
  49103. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49104. *
  49105. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49106. * glowy meshes to your scene.
  49107. *
  49108. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49109. */
  49110. export class GlowLayer extends EffectLayer {
  49111. /**
  49112. * Effect Name of the layer.
  49113. */
  49114. static readonly EffectName: string;
  49115. /**
  49116. * The default blur kernel size used for the glow.
  49117. */
  49118. static DefaultBlurKernelSize: number;
  49119. /**
  49120. * The default texture size ratio used for the glow.
  49121. */
  49122. static DefaultTextureRatio: number;
  49123. /**
  49124. * Sets the kernel size of the blur.
  49125. */
  49126. /**
  49127. * Gets the kernel size of the blur.
  49128. */
  49129. blurKernelSize: number;
  49130. /**
  49131. * Sets the glow intensity.
  49132. */
  49133. /**
  49134. * Gets the glow intensity.
  49135. */
  49136. intensity: number;
  49137. private _options;
  49138. private _intensity;
  49139. private _horizontalBlurPostprocess1;
  49140. private _verticalBlurPostprocess1;
  49141. private _horizontalBlurPostprocess2;
  49142. private _verticalBlurPostprocess2;
  49143. private _blurTexture1;
  49144. private _blurTexture2;
  49145. private _postProcesses1;
  49146. private _postProcesses2;
  49147. private _includedOnlyMeshes;
  49148. private _excludedMeshes;
  49149. /**
  49150. * Callback used to let the user override the color selection on a per mesh basis
  49151. */
  49152. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49153. /**
  49154. * Callback used to let the user override the texture selection on a per mesh basis
  49155. */
  49156. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49157. /**
  49158. * Instantiates a new glow Layer and references it to the scene.
  49159. * @param name The name of the layer
  49160. * @param scene The scene to use the layer in
  49161. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49162. */
  49163. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49164. /**
  49165. * Get the effect name of the layer.
  49166. * @return The effect name
  49167. */
  49168. getEffectName(): string;
  49169. /**
  49170. * Create the merge effect. This is the shader use to blit the information back
  49171. * to the main canvas at the end of the scene rendering.
  49172. */
  49173. protected _createMergeEffect(): Effect;
  49174. /**
  49175. * Creates the render target textures and post processes used in the glow layer.
  49176. */
  49177. protected _createTextureAndPostProcesses(): void;
  49178. /**
  49179. * Checks for the readiness of the element composing the layer.
  49180. * @param subMesh the mesh to check for
  49181. * @param useInstances specify wether or not to use instances to render the mesh
  49182. * @param emissiveTexture the associated emissive texture used to generate the glow
  49183. * @return true if ready otherwise, false
  49184. */
  49185. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49186. /**
  49187. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49188. */
  49189. needStencil(): boolean;
  49190. /**
  49191. * Returns true if the mesh can be rendered, otherwise false.
  49192. * @param mesh The mesh to render
  49193. * @param material The material used on the mesh
  49194. * @returns true if it can be rendered otherwise false
  49195. */
  49196. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49197. /**
  49198. * Implementation specific of rendering the generating effect on the main canvas.
  49199. * @param effect The effect used to render through
  49200. */
  49201. protected _internalRender(effect: Effect): void;
  49202. /**
  49203. * Sets the required values for both the emissive texture and and the main color.
  49204. */
  49205. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49206. /**
  49207. * Returns true if the mesh should render, otherwise false.
  49208. * @param mesh The mesh to render
  49209. * @returns true if it should render otherwise false
  49210. */
  49211. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49212. /**
  49213. * Adds specific effects defines.
  49214. * @param defines The defines to add specifics to.
  49215. */
  49216. protected _addCustomEffectDefines(defines: string[]): void;
  49217. /**
  49218. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49219. * @param mesh The mesh to exclude from the glow layer
  49220. */
  49221. addExcludedMesh(mesh: Mesh): void;
  49222. /**
  49223. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49224. * @param mesh The mesh to remove
  49225. */
  49226. removeExcludedMesh(mesh: Mesh): void;
  49227. /**
  49228. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49229. * @param mesh The mesh to include in the glow layer
  49230. */
  49231. addIncludedOnlyMesh(mesh: Mesh): void;
  49232. /**
  49233. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49234. * @param mesh The mesh to remove
  49235. */
  49236. removeIncludedOnlyMesh(mesh: Mesh): void;
  49237. /**
  49238. * Determine if a given mesh will be used in the glow layer
  49239. * @param mesh The mesh to test
  49240. * @returns true if the mesh will be highlighted by the current glow layer
  49241. */
  49242. hasMesh(mesh: AbstractMesh): boolean;
  49243. /**
  49244. * Free any resources and references associated to a mesh.
  49245. * Internal use
  49246. * @param mesh The mesh to free.
  49247. * @hidden
  49248. */
  49249. _disposeMesh(mesh: Mesh): void;
  49250. /**
  49251. * Gets the class name of the effect layer
  49252. * @returns the string with the class name of the effect layer
  49253. */
  49254. getClassName(): string;
  49255. /**
  49256. * Serializes this glow layer
  49257. * @returns a serialized glow layer object
  49258. */
  49259. serialize(): any;
  49260. /**
  49261. * Creates a Glow Layer from parsed glow layer data
  49262. * @param parsedGlowLayer defines glow layer data
  49263. * @param scene defines the current scene
  49264. * @param rootUrl defines the root URL containing the glow layer information
  49265. * @returns a parsed Glow Layer
  49266. */
  49267. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /** @hidden */
  49272. export var glowBlurPostProcessPixelShader: {
  49273. name: string;
  49274. shader: string;
  49275. };
  49276. }
  49277. declare module BABYLON {
  49278. interface AbstractScene {
  49279. /**
  49280. * Return a the first highlight layer of the scene with a given name.
  49281. * @param name The name of the highlight layer to look for.
  49282. * @return The highlight layer if found otherwise null.
  49283. */
  49284. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49285. }
  49286. /**
  49287. * Highlight layer options. This helps customizing the behaviour
  49288. * of the highlight layer.
  49289. */
  49290. export interface IHighlightLayerOptions {
  49291. /**
  49292. * Multiplication factor apply to the canvas size to compute the render target size
  49293. * used to generated the glowing objects (the smaller the faster).
  49294. */
  49295. mainTextureRatio: number;
  49296. /**
  49297. * Enforces a fixed size texture to ensure resize independant blur.
  49298. */
  49299. mainTextureFixedSize?: number;
  49300. /**
  49301. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49302. * of the picture to blur (the smaller the faster).
  49303. */
  49304. blurTextureSizeRatio: number;
  49305. /**
  49306. * How big in texel of the blur texture is the vertical blur.
  49307. */
  49308. blurVerticalSize: number;
  49309. /**
  49310. * How big in texel of the blur texture is the horizontal blur.
  49311. */
  49312. blurHorizontalSize: number;
  49313. /**
  49314. * Alpha blending mode used to apply the blur. Default is combine.
  49315. */
  49316. alphaBlendingMode: number;
  49317. /**
  49318. * The camera attached to the layer.
  49319. */
  49320. camera: Nullable<Camera>;
  49321. /**
  49322. * Should we display highlight as a solid stroke?
  49323. */
  49324. isStroke?: boolean;
  49325. /**
  49326. * The rendering group to draw the layer in.
  49327. */
  49328. renderingGroupId: number;
  49329. }
  49330. /**
  49331. * The highlight layer Helps adding a glow effect around a mesh.
  49332. *
  49333. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49334. * glowy meshes to your scene.
  49335. *
  49336. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49337. */
  49338. export class HighlightLayer extends EffectLayer {
  49339. name: string;
  49340. /**
  49341. * Effect Name of the highlight layer.
  49342. */
  49343. static readonly EffectName: string;
  49344. /**
  49345. * The neutral color used during the preparation of the glow effect.
  49346. * This is black by default as the blend operation is a blend operation.
  49347. */
  49348. static NeutralColor: Color4;
  49349. /**
  49350. * Stencil value used for glowing meshes.
  49351. */
  49352. static GlowingMeshStencilReference: number;
  49353. /**
  49354. * Stencil value used for the other meshes in the scene.
  49355. */
  49356. static NormalMeshStencilReference: number;
  49357. /**
  49358. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49359. */
  49360. innerGlow: boolean;
  49361. /**
  49362. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49363. */
  49364. outerGlow: boolean;
  49365. /**
  49366. * Specifies the horizontal size of the blur.
  49367. */
  49368. /**
  49369. * Gets the horizontal size of the blur.
  49370. */
  49371. blurHorizontalSize: number;
  49372. /**
  49373. * Specifies the vertical size of the blur.
  49374. */
  49375. /**
  49376. * Gets the vertical size of the blur.
  49377. */
  49378. blurVerticalSize: number;
  49379. /**
  49380. * An event triggered when the highlight layer is being blurred.
  49381. */
  49382. onBeforeBlurObservable: Observable<HighlightLayer>;
  49383. /**
  49384. * An event triggered when the highlight layer has been blurred.
  49385. */
  49386. onAfterBlurObservable: Observable<HighlightLayer>;
  49387. private _instanceGlowingMeshStencilReference;
  49388. private _options;
  49389. private _downSamplePostprocess;
  49390. private _horizontalBlurPostprocess;
  49391. private _verticalBlurPostprocess;
  49392. private _blurTexture;
  49393. private _meshes;
  49394. private _excludedMeshes;
  49395. /**
  49396. * Instantiates a new highlight Layer and references it to the scene..
  49397. * @param name The name of the layer
  49398. * @param scene The scene to use the layer in
  49399. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49400. */
  49401. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49402. /**
  49403. * Get the effect name of the layer.
  49404. * @return The effect name
  49405. */
  49406. getEffectName(): string;
  49407. /**
  49408. * Create the merge effect. This is the shader use to blit the information back
  49409. * to the main canvas at the end of the scene rendering.
  49410. */
  49411. protected _createMergeEffect(): Effect;
  49412. /**
  49413. * Creates the render target textures and post processes used in the highlight layer.
  49414. */
  49415. protected _createTextureAndPostProcesses(): void;
  49416. /**
  49417. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49418. */
  49419. needStencil(): boolean;
  49420. /**
  49421. * Checks for the readiness of the element composing the layer.
  49422. * @param subMesh the mesh to check for
  49423. * @param useInstances specify wether or not to use instances to render the mesh
  49424. * @param emissiveTexture the associated emissive texture used to generate the glow
  49425. * @return true if ready otherwise, false
  49426. */
  49427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49428. /**
  49429. * Implementation specific of rendering the generating effect on the main canvas.
  49430. * @param effect The effect used to render through
  49431. */
  49432. protected _internalRender(effect: Effect): void;
  49433. /**
  49434. * Returns true if the layer contains information to display, otherwise false.
  49435. */
  49436. shouldRender(): boolean;
  49437. /**
  49438. * Returns true if the mesh should render, otherwise false.
  49439. * @param mesh The mesh to render
  49440. * @returns true if it should render otherwise false
  49441. */
  49442. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49443. /**
  49444. * Sets the required values for both the emissive texture and and the main color.
  49445. */
  49446. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49447. /**
  49448. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49449. * @param mesh The mesh to exclude from the highlight layer
  49450. */
  49451. addExcludedMesh(mesh: Mesh): void;
  49452. /**
  49453. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49454. * @param mesh The mesh to highlight
  49455. */
  49456. removeExcludedMesh(mesh: Mesh): void;
  49457. /**
  49458. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49459. * @param mesh mesh to test
  49460. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49461. */
  49462. hasMesh(mesh: AbstractMesh): boolean;
  49463. /**
  49464. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49465. * @param mesh The mesh to highlight
  49466. * @param color The color of the highlight
  49467. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49468. */
  49469. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49470. /**
  49471. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49472. * @param mesh The mesh to highlight
  49473. */
  49474. removeMesh(mesh: Mesh): void;
  49475. /**
  49476. * Force the stencil to the normal expected value for none glowing parts
  49477. */
  49478. private _defaultStencilReference;
  49479. /**
  49480. * Free any resources and references associated to a mesh.
  49481. * Internal use
  49482. * @param mesh The mesh to free.
  49483. * @hidden
  49484. */
  49485. _disposeMesh(mesh: Mesh): void;
  49486. /**
  49487. * Dispose the highlight layer and free resources.
  49488. */
  49489. dispose(): void;
  49490. /**
  49491. * Gets the class name of the effect layer
  49492. * @returns the string with the class name of the effect layer
  49493. */
  49494. getClassName(): string;
  49495. /**
  49496. * Serializes this Highlight layer
  49497. * @returns a serialized Highlight layer object
  49498. */
  49499. serialize(): any;
  49500. /**
  49501. * Creates a Highlight layer from parsed Highlight layer data
  49502. * @param parsedHightlightLayer defines the Highlight layer data
  49503. * @param scene defines the current scene
  49504. * @param rootUrl defines the root URL containing the Highlight layer information
  49505. * @returns a parsed Highlight layer
  49506. */
  49507. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49508. }
  49509. }
  49510. declare module BABYLON {
  49511. interface AbstractScene {
  49512. /**
  49513. * The list of layers (background and foreground) of the scene
  49514. */
  49515. layers: Array<Layer>;
  49516. }
  49517. /**
  49518. * Defines the layer scene component responsible to manage any layers
  49519. * in a given scene.
  49520. */
  49521. export class LayerSceneComponent implements ISceneComponent {
  49522. /**
  49523. * The component name helpfull to identify the component in the list of scene components.
  49524. */
  49525. readonly name: string;
  49526. /**
  49527. * The scene the component belongs to.
  49528. */
  49529. scene: Scene;
  49530. private _engine;
  49531. /**
  49532. * Creates a new instance of the component for the given scene
  49533. * @param scene Defines the scene to register the component in
  49534. */
  49535. constructor(scene: Scene);
  49536. /**
  49537. * Registers the component in a given scene
  49538. */
  49539. register(): void;
  49540. /**
  49541. * Rebuilds the elements related to this component in case of
  49542. * context lost for instance.
  49543. */
  49544. rebuild(): void;
  49545. /**
  49546. * Disposes the component and the associated ressources.
  49547. */
  49548. dispose(): void;
  49549. private _draw;
  49550. private _drawCameraPredicate;
  49551. private _drawCameraBackground;
  49552. private _drawCameraForeground;
  49553. private _drawRenderTargetPredicate;
  49554. private _drawRenderTargetBackground;
  49555. private _drawRenderTargetForeground;
  49556. /**
  49557. * Adds all the elements from the container to the scene
  49558. * @param container the container holding the elements
  49559. */
  49560. addFromContainer(container: AbstractScene): void;
  49561. /**
  49562. * Removes all the elements in the container from the scene
  49563. * @param container contains the elements to remove
  49564. * @param dispose if the removed element should be disposed (default: false)
  49565. */
  49566. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49567. }
  49568. }
  49569. declare module BABYLON {
  49570. /** @hidden */
  49571. export var layerPixelShader: {
  49572. name: string;
  49573. shader: string;
  49574. };
  49575. }
  49576. declare module BABYLON {
  49577. /** @hidden */
  49578. export var layerVertexShader: {
  49579. name: string;
  49580. shader: string;
  49581. };
  49582. }
  49583. declare module BABYLON {
  49584. /**
  49585. * This represents a full screen 2d layer.
  49586. * This can be useful to display a picture in the background of your scene for instance.
  49587. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49588. */
  49589. export class Layer {
  49590. /**
  49591. * Define the name of the layer.
  49592. */
  49593. name: string;
  49594. /**
  49595. * Define the texture the layer should display.
  49596. */
  49597. texture: Nullable<Texture>;
  49598. /**
  49599. * Is the layer in background or foreground.
  49600. */
  49601. isBackground: boolean;
  49602. /**
  49603. * Define the color of the layer (instead of texture).
  49604. */
  49605. color: Color4;
  49606. /**
  49607. * Define the scale of the layer in order to zoom in out of the texture.
  49608. */
  49609. scale: Vector2;
  49610. /**
  49611. * Define an offset for the layer in order to shift the texture.
  49612. */
  49613. offset: Vector2;
  49614. /**
  49615. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49616. */
  49617. alphaBlendingMode: number;
  49618. /**
  49619. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49620. * Alpha test will not mix with the background color in case of transparency.
  49621. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49622. */
  49623. alphaTest: boolean;
  49624. /**
  49625. * Define a mask to restrict the layer to only some of the scene cameras.
  49626. */
  49627. layerMask: number;
  49628. /**
  49629. * Define the list of render target the layer is visible into.
  49630. */
  49631. renderTargetTextures: RenderTargetTexture[];
  49632. /**
  49633. * Define if the layer is only used in renderTarget or if it also
  49634. * renders in the main frame buffer of the canvas.
  49635. */
  49636. renderOnlyInRenderTargetTextures: boolean;
  49637. private _scene;
  49638. private _vertexBuffers;
  49639. private _indexBuffer;
  49640. private _effect;
  49641. private _alphaTestEffect;
  49642. /**
  49643. * An event triggered when the layer is disposed.
  49644. */
  49645. onDisposeObservable: Observable<Layer>;
  49646. private _onDisposeObserver;
  49647. /**
  49648. * Back compatibility with callback before the onDisposeObservable existed.
  49649. * The set callback will be triggered when the layer has been disposed.
  49650. */
  49651. onDispose: () => void;
  49652. /**
  49653. * An event triggered before rendering the scene
  49654. */
  49655. onBeforeRenderObservable: Observable<Layer>;
  49656. private _onBeforeRenderObserver;
  49657. /**
  49658. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49659. * The set callback will be triggered just before rendering the layer.
  49660. */
  49661. onBeforeRender: () => void;
  49662. /**
  49663. * An event triggered after rendering the scene
  49664. */
  49665. onAfterRenderObservable: Observable<Layer>;
  49666. private _onAfterRenderObserver;
  49667. /**
  49668. * Back compatibility with callback before the onAfterRenderObservable existed.
  49669. * The set callback will be triggered just after rendering the layer.
  49670. */
  49671. onAfterRender: () => void;
  49672. /**
  49673. * Instantiates a new layer.
  49674. * This represents a full screen 2d layer.
  49675. * This can be useful to display a picture in the background of your scene for instance.
  49676. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49677. * @param name Define the name of the layer in the scene
  49678. * @param imgUrl Define the url of the texture to display in the layer
  49679. * @param scene Define the scene the layer belongs to
  49680. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49681. * @param color Defines a color for the layer
  49682. */
  49683. constructor(
  49684. /**
  49685. * Define the name of the layer.
  49686. */
  49687. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49688. private _createIndexBuffer;
  49689. /** @hidden */
  49690. _rebuild(): void;
  49691. /**
  49692. * Renders the layer in the scene.
  49693. */
  49694. render(): void;
  49695. /**
  49696. * Disposes and releases the associated ressources.
  49697. */
  49698. dispose(): void;
  49699. }
  49700. }
  49701. declare module BABYLON {
  49702. /** @hidden */
  49703. export var lensFlarePixelShader: {
  49704. name: string;
  49705. shader: string;
  49706. };
  49707. }
  49708. declare module BABYLON {
  49709. /** @hidden */
  49710. export var lensFlareVertexShader: {
  49711. name: string;
  49712. shader: string;
  49713. };
  49714. }
  49715. declare module BABYLON {
  49716. /**
  49717. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49718. * It is usually composed of several `lensFlare`.
  49719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49720. */
  49721. export class LensFlareSystem {
  49722. /**
  49723. * Define the name of the lens flare system
  49724. */
  49725. name: string;
  49726. /**
  49727. * List of lens flares used in this system.
  49728. */
  49729. lensFlares: LensFlare[];
  49730. /**
  49731. * Define a limit from the border the lens flare can be visible.
  49732. */
  49733. borderLimit: number;
  49734. /**
  49735. * Define a viewport border we do not want to see the lens flare in.
  49736. */
  49737. viewportBorder: number;
  49738. /**
  49739. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49740. */
  49741. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49742. /**
  49743. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49744. */
  49745. layerMask: number;
  49746. /**
  49747. * Define the id of the lens flare system in the scene.
  49748. * (equal to name by default)
  49749. */
  49750. id: string;
  49751. private _scene;
  49752. private _emitter;
  49753. private _vertexBuffers;
  49754. private _indexBuffer;
  49755. private _effect;
  49756. private _positionX;
  49757. private _positionY;
  49758. private _isEnabled;
  49759. /** @hidden */
  49760. static _SceneComponentInitialization: (scene: Scene) => void;
  49761. /**
  49762. * Instantiates a lens flare system.
  49763. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49764. * It is usually composed of several `lensFlare`.
  49765. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49766. * @param name Define the name of the lens flare system in the scene
  49767. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49768. * @param scene Define the scene the lens flare system belongs to
  49769. */
  49770. constructor(
  49771. /**
  49772. * Define the name of the lens flare system
  49773. */
  49774. name: string, emitter: any, scene: Scene);
  49775. /**
  49776. * Define if the lens flare system is enabled.
  49777. */
  49778. isEnabled: boolean;
  49779. /**
  49780. * Get the scene the effects belongs to.
  49781. * @returns the scene holding the lens flare system
  49782. */
  49783. getScene(): Scene;
  49784. /**
  49785. * Get the emitter of the lens flare system.
  49786. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49787. * @returns the emitter of the lens flare system
  49788. */
  49789. getEmitter(): any;
  49790. /**
  49791. * Set the emitter of the lens flare system.
  49792. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49793. * @param newEmitter Define the new emitter of the system
  49794. */
  49795. setEmitter(newEmitter: any): void;
  49796. /**
  49797. * Get the lens flare system emitter position.
  49798. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49799. * @returns the position
  49800. */
  49801. getEmitterPosition(): Vector3;
  49802. /**
  49803. * @hidden
  49804. */
  49805. computeEffectivePosition(globalViewport: Viewport): boolean;
  49806. /** @hidden */
  49807. _isVisible(): boolean;
  49808. /**
  49809. * @hidden
  49810. */
  49811. render(): boolean;
  49812. /**
  49813. * Dispose and release the lens flare with its associated resources.
  49814. */
  49815. dispose(): void;
  49816. /**
  49817. * Parse a lens flare system from a JSON repressentation
  49818. * @param parsedLensFlareSystem Define the JSON to parse
  49819. * @param scene Define the scene the parsed system should be instantiated in
  49820. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49821. * @returns the parsed system
  49822. */
  49823. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49824. /**
  49825. * Serialize the current Lens Flare System into a JSON representation.
  49826. * @returns the serialized JSON
  49827. */
  49828. serialize(): any;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * This represents one of the lens effect in a `lensFlareSystem`.
  49834. * It controls one of the indiviual texture used in the effect.
  49835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49836. */
  49837. export class LensFlare {
  49838. /**
  49839. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49840. */
  49841. size: number;
  49842. /**
  49843. * 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.
  49844. */
  49845. position: number;
  49846. /**
  49847. * Define the lens color.
  49848. */
  49849. color: Color3;
  49850. /**
  49851. * Define the lens texture.
  49852. */
  49853. texture: Nullable<Texture>;
  49854. /**
  49855. * Define the alpha mode to render this particular lens.
  49856. */
  49857. alphaMode: number;
  49858. private _system;
  49859. /**
  49860. * Creates a new Lens Flare.
  49861. * This represents one of the lens effect in a `lensFlareSystem`.
  49862. * It controls one of the indiviual texture used in the effect.
  49863. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49864. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49865. * @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.
  49866. * @param color Define the lens color
  49867. * @param imgUrl Define the lens texture url
  49868. * @param system Define the `lensFlareSystem` this flare is part of
  49869. * @returns The newly created Lens Flare
  49870. */
  49871. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49872. /**
  49873. * Instantiates a new Lens Flare.
  49874. * This represents one of the lens effect in a `lensFlareSystem`.
  49875. * It controls one of the indiviual texture used in the effect.
  49876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49877. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49878. * @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.
  49879. * @param color Define the lens color
  49880. * @param imgUrl Define the lens texture url
  49881. * @param system Define the `lensFlareSystem` this flare is part of
  49882. */
  49883. constructor(
  49884. /**
  49885. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49886. */
  49887. size: number,
  49888. /**
  49889. * 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.
  49890. */
  49891. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49892. /**
  49893. * Dispose and release the lens flare with its associated resources.
  49894. */
  49895. dispose(): void;
  49896. }
  49897. }
  49898. declare module BABYLON {
  49899. interface AbstractScene {
  49900. /**
  49901. * The list of lens flare system added to the scene
  49902. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49903. */
  49904. lensFlareSystems: Array<LensFlareSystem>;
  49905. /**
  49906. * Removes the given lens flare system from this scene.
  49907. * @param toRemove The lens flare system to remove
  49908. * @returns The index of the removed lens flare system
  49909. */
  49910. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49911. /**
  49912. * Adds the given lens flare system to this scene
  49913. * @param newLensFlareSystem The lens flare system to add
  49914. */
  49915. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49916. /**
  49917. * Gets a lens flare system using its name
  49918. * @param name defines the name to look for
  49919. * @returns the lens flare system or null if not found
  49920. */
  49921. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49922. /**
  49923. * Gets a lens flare system using its id
  49924. * @param id defines the id to look for
  49925. * @returns the lens flare system or null if not found
  49926. */
  49927. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49928. }
  49929. /**
  49930. * Defines the lens flare scene component responsible to manage any lens flares
  49931. * in a given scene.
  49932. */
  49933. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49934. /**
  49935. * The component name helpfull to identify the component in the list of scene components.
  49936. */
  49937. readonly name: string;
  49938. /**
  49939. * The scene the component belongs to.
  49940. */
  49941. scene: Scene;
  49942. /**
  49943. * Creates a new instance of the component for the given scene
  49944. * @param scene Defines the scene to register the component in
  49945. */
  49946. constructor(scene: Scene);
  49947. /**
  49948. * Registers the component in a given scene
  49949. */
  49950. register(): void;
  49951. /**
  49952. * Rebuilds the elements related to this component in case of
  49953. * context lost for instance.
  49954. */
  49955. rebuild(): void;
  49956. /**
  49957. * Adds all the elements from the container to the scene
  49958. * @param container the container holding the elements
  49959. */
  49960. addFromContainer(container: AbstractScene): void;
  49961. /**
  49962. * Removes all the elements in the container from the scene
  49963. * @param container contains the elements to remove
  49964. * @param dispose if the removed element should be disposed (default: false)
  49965. */
  49966. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49967. /**
  49968. * Serializes the component data to the specified json object
  49969. * @param serializationObject The object to serialize to
  49970. */
  49971. serialize(serializationObject: any): void;
  49972. /**
  49973. * Disposes the component and the associated ressources.
  49974. */
  49975. dispose(): void;
  49976. private _draw;
  49977. }
  49978. }
  49979. declare module BABYLON {
  49980. /**
  49981. * Defines the shadow generator component responsible to manage any shadow generators
  49982. * in a given scene.
  49983. */
  49984. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49985. /**
  49986. * The component name helpfull to identify the component in the list of scene components.
  49987. */
  49988. readonly name: string;
  49989. /**
  49990. * The scene the component belongs to.
  49991. */
  49992. scene: Scene;
  49993. /**
  49994. * Creates a new instance of the component for the given scene
  49995. * @param scene Defines the scene to register the component in
  49996. */
  49997. constructor(scene: Scene);
  49998. /**
  49999. * Registers the component in a given scene
  50000. */
  50001. register(): void;
  50002. /**
  50003. * Rebuilds the elements related to this component in case of
  50004. * context lost for instance.
  50005. */
  50006. rebuild(): void;
  50007. /**
  50008. * Serializes the component data to the specified json object
  50009. * @param serializationObject The object to serialize to
  50010. */
  50011. serialize(serializationObject: any): void;
  50012. /**
  50013. * Adds all the elements from the container to the scene
  50014. * @param container the container holding the elements
  50015. */
  50016. addFromContainer(container: AbstractScene): void;
  50017. /**
  50018. * Removes all the elements in the container from the scene
  50019. * @param container contains the elements to remove
  50020. * @param dispose if the removed element should be disposed (default: false)
  50021. */
  50022. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50023. /**
  50024. * Rebuilds the elements related to this component in case of
  50025. * context lost for instance.
  50026. */
  50027. dispose(): void;
  50028. private _gatherRenderTargets;
  50029. }
  50030. }
  50031. declare module BABYLON {
  50032. /**
  50033. * A point light is a light defined by an unique point in world space.
  50034. * The light is emitted in every direction from this point.
  50035. * A good example of a point light is a standard light bulb.
  50036. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50037. */
  50038. export class PointLight extends ShadowLight {
  50039. private _shadowAngle;
  50040. /**
  50041. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50042. * This specifies what angle the shadow will use to be created.
  50043. *
  50044. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50045. */
  50046. /**
  50047. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50048. * This specifies what angle the shadow will use to be created.
  50049. *
  50050. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50051. */
  50052. shadowAngle: number;
  50053. /**
  50054. * Gets the direction if it has been set.
  50055. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50056. */
  50057. /**
  50058. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50059. */
  50060. direction: Vector3;
  50061. /**
  50062. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50063. * A PointLight emits the light in every direction.
  50064. * It can cast shadows.
  50065. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50066. * ```javascript
  50067. * var pointLight = new PointLight("pl", camera.position, scene);
  50068. * ```
  50069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50070. * @param name The light friendly name
  50071. * @param position The position of the point light in the scene
  50072. * @param scene The scene the lights belongs to
  50073. */
  50074. constructor(name: string, position: Vector3, scene: Scene);
  50075. /**
  50076. * Returns the string "PointLight"
  50077. * @returns the class name
  50078. */
  50079. getClassName(): string;
  50080. /**
  50081. * Returns the integer 0.
  50082. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50083. */
  50084. getTypeID(): number;
  50085. /**
  50086. * Specifies wether or not the shadowmap should be a cube texture.
  50087. * @returns true if the shadowmap needs to be a cube texture.
  50088. */
  50089. needCube(): boolean;
  50090. /**
  50091. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50092. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50093. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50094. */
  50095. getShadowDirection(faceIndex?: number): Vector3;
  50096. /**
  50097. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50098. * - fov = PI / 2
  50099. * - aspect ratio : 1.0
  50100. * - z-near and far equal to the active camera minZ and maxZ.
  50101. * Returns the PointLight.
  50102. */
  50103. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50104. protected _buildUniformLayout(): void;
  50105. /**
  50106. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50107. * @param effect The effect to update
  50108. * @param lightIndex The index of the light in the effect to update
  50109. * @returns The point light
  50110. */
  50111. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50112. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50113. /**
  50114. * Prepares the list of defines specific to the light type.
  50115. * @param defines the list of defines
  50116. * @param lightIndex defines the index of the light for the effect
  50117. */
  50118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50119. }
  50120. }
  50121. declare module BABYLON {
  50122. /**
  50123. * Header information of HDR texture files.
  50124. */
  50125. export interface HDRInfo {
  50126. /**
  50127. * The height of the texture in pixels.
  50128. */
  50129. height: number;
  50130. /**
  50131. * The width of the texture in pixels.
  50132. */
  50133. width: number;
  50134. /**
  50135. * The index of the beginning of the data in the binary file.
  50136. */
  50137. dataPosition: number;
  50138. }
  50139. /**
  50140. * This groups tools to convert HDR texture to native colors array.
  50141. */
  50142. export class HDRTools {
  50143. private static Ldexp;
  50144. private static Rgbe2float;
  50145. private static readStringLine;
  50146. /**
  50147. * Reads header information from an RGBE texture stored in a native array.
  50148. * More information on this format are available here:
  50149. * https://en.wikipedia.org/wiki/RGBE_image_format
  50150. *
  50151. * @param uint8array The binary file stored in native array.
  50152. * @return The header information.
  50153. */
  50154. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50155. /**
  50156. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50157. * This RGBE texture needs to store the information as a panorama.
  50158. *
  50159. * More information on this format are available here:
  50160. * https://en.wikipedia.org/wiki/RGBE_image_format
  50161. *
  50162. * @param buffer The binary file stored in an array buffer.
  50163. * @param size The expected size of the extracted cubemap.
  50164. * @return The Cube Map information.
  50165. */
  50166. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50167. /**
  50168. * Returns the pixels data extracted from an RGBE texture.
  50169. * This pixels will be stored left to right up to down in the R G B order in one array.
  50170. *
  50171. * More information on this format are available here:
  50172. * https://en.wikipedia.org/wiki/RGBE_image_format
  50173. *
  50174. * @param uint8array The binary file stored in an array buffer.
  50175. * @param hdrInfo The header information of the file.
  50176. * @return The pixels data in RGB right to left up to down order.
  50177. */
  50178. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50179. private static RGBE_ReadPixels_RLE;
  50180. }
  50181. }
  50182. declare module BABYLON {
  50183. /**
  50184. * This represents a texture coming from an HDR input.
  50185. *
  50186. * The only supported format is currently panorama picture stored in RGBE format.
  50187. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50188. */
  50189. export class HDRCubeTexture extends BaseTexture {
  50190. private static _facesMapping;
  50191. private _generateHarmonics;
  50192. private _noMipmap;
  50193. private _textureMatrix;
  50194. private _size;
  50195. private _onLoad;
  50196. private _onError;
  50197. /**
  50198. * The texture URL.
  50199. */
  50200. url: string;
  50201. /**
  50202. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50203. */
  50204. coordinatesMode: number;
  50205. protected _isBlocking: boolean;
  50206. /**
  50207. * Sets wether or not the texture is blocking during loading.
  50208. */
  50209. /**
  50210. * Gets wether or not the texture is blocking during loading.
  50211. */
  50212. isBlocking: boolean;
  50213. protected _rotationY: number;
  50214. /**
  50215. * Sets texture matrix rotation angle around Y axis in radians.
  50216. */
  50217. /**
  50218. * Gets texture matrix rotation angle around Y axis radians.
  50219. */
  50220. rotationY: number;
  50221. /**
  50222. * Gets or sets the center of the bounding box associated with the cube texture
  50223. * It must define where the camera used to render the texture was set
  50224. */
  50225. boundingBoxPosition: Vector3;
  50226. private _boundingBoxSize;
  50227. /**
  50228. * Gets or sets the size of the bounding box associated with the cube texture
  50229. * When defined, the cubemap will switch to local mode
  50230. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50231. * @example https://www.babylonjs-playground.com/#RNASML
  50232. */
  50233. boundingBoxSize: Vector3;
  50234. /**
  50235. * Instantiates an HDRTexture from the following parameters.
  50236. *
  50237. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50238. * @param scene The scene the texture will be used in
  50239. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50240. * @param noMipmap Forces to not generate the mipmap if true
  50241. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50242. * @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)
  50243. * @param reserved Reserved flag for internal use.
  50244. */
  50245. 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>);
  50246. /**
  50247. * Get the current class name of the texture useful for serialization or dynamic coding.
  50248. * @returns "HDRCubeTexture"
  50249. */
  50250. getClassName(): string;
  50251. /**
  50252. * Occurs when the file is raw .hdr file.
  50253. */
  50254. private loadTexture;
  50255. clone(): HDRCubeTexture;
  50256. delayLoad(): void;
  50257. /**
  50258. * Get the texture reflection matrix used to rotate/transform the reflection.
  50259. * @returns the reflection matrix
  50260. */
  50261. getReflectionTextureMatrix(): Matrix;
  50262. /**
  50263. * Set the texture reflection matrix used to rotate/transform the reflection.
  50264. * @param value Define the reflection matrix to set
  50265. */
  50266. setReflectionTextureMatrix(value: Matrix): void;
  50267. /**
  50268. * Parses a JSON representation of an HDR Texture in order to create the texture
  50269. * @param parsedTexture Define the JSON representation
  50270. * @param scene Define the scene the texture should be created in
  50271. * @param rootUrl Define the root url in case we need to load relative dependencies
  50272. * @returns the newly created texture after parsing
  50273. */
  50274. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50275. serialize(): any;
  50276. }
  50277. }
  50278. declare module BABYLON {
  50279. /**
  50280. * Class used to control physics engine
  50281. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50282. */
  50283. export class PhysicsEngine implements IPhysicsEngine {
  50284. private _physicsPlugin;
  50285. /**
  50286. * Global value used to control the smallest number supported by the simulation
  50287. */
  50288. static Epsilon: number;
  50289. private _impostors;
  50290. private _joints;
  50291. /**
  50292. * Gets the gravity vector used by the simulation
  50293. */
  50294. gravity: Vector3;
  50295. /**
  50296. * Factory used to create the default physics plugin.
  50297. * @returns The default physics plugin
  50298. */
  50299. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50300. /**
  50301. * Creates a new Physics Engine
  50302. * @param gravity defines the gravity vector used by the simulation
  50303. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50304. */
  50305. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50306. /**
  50307. * Sets the gravity vector used by the simulation
  50308. * @param gravity defines the gravity vector to use
  50309. */
  50310. setGravity(gravity: Vector3): void;
  50311. /**
  50312. * Set the time step of the physics engine.
  50313. * Default is 1/60.
  50314. * To slow it down, enter 1/600 for example.
  50315. * To speed it up, 1/30
  50316. * @param newTimeStep defines the new timestep to apply to this world.
  50317. */
  50318. setTimeStep(newTimeStep?: number): void;
  50319. /**
  50320. * Get the time step of the physics engine.
  50321. * @returns the current time step
  50322. */
  50323. getTimeStep(): number;
  50324. /**
  50325. * Release all resources
  50326. */
  50327. dispose(): void;
  50328. /**
  50329. * Gets the name of the current physics plugin
  50330. * @returns the name of the plugin
  50331. */
  50332. getPhysicsPluginName(): string;
  50333. /**
  50334. * Adding a new impostor for the impostor tracking.
  50335. * This will be done by the impostor itself.
  50336. * @param impostor the impostor to add
  50337. */
  50338. addImpostor(impostor: PhysicsImpostor): void;
  50339. /**
  50340. * Remove an impostor from the engine.
  50341. * This impostor and its mesh will not longer be updated by the physics engine.
  50342. * @param impostor the impostor to remove
  50343. */
  50344. removeImpostor(impostor: PhysicsImpostor): void;
  50345. /**
  50346. * Add a joint to the physics engine
  50347. * @param mainImpostor defines the main impostor to which the joint is added.
  50348. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50349. * @param joint defines the joint that will connect both impostors.
  50350. */
  50351. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50352. /**
  50353. * Removes a joint from the simulation
  50354. * @param mainImpostor defines the impostor used with the joint
  50355. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50356. * @param joint defines the joint to remove
  50357. */
  50358. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50359. /**
  50360. * Called by the scene. No need to call it.
  50361. * @param delta defines the timespam between frames
  50362. */
  50363. _step(delta: number): void;
  50364. /**
  50365. * Gets the current plugin used to run the simulation
  50366. * @returns current plugin
  50367. */
  50368. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50369. /**
  50370. * Gets the list of physic impostors
  50371. * @returns an array of PhysicsImpostor
  50372. */
  50373. getImpostors(): Array<PhysicsImpostor>;
  50374. /**
  50375. * Gets the impostor for a physics enabled object
  50376. * @param object defines the object impersonated by the impostor
  50377. * @returns the PhysicsImpostor or null if not found
  50378. */
  50379. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50380. /**
  50381. * Gets the impostor for a physics body object
  50382. * @param body defines physics body used by the impostor
  50383. * @returns the PhysicsImpostor or null if not found
  50384. */
  50385. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50386. /**
  50387. * Does a raycast in the physics world
  50388. * @param from when should the ray start?
  50389. * @param to when should the ray end?
  50390. * @returns PhysicsRaycastResult
  50391. */
  50392. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50393. }
  50394. }
  50395. declare module BABYLON {
  50396. /** @hidden */
  50397. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50398. private _useDeltaForWorldStep;
  50399. world: any;
  50400. name: string;
  50401. private _physicsMaterials;
  50402. private _fixedTimeStep;
  50403. private _cannonRaycastResult;
  50404. private _raycastResult;
  50405. private _physicsBodysToRemoveAfterStep;
  50406. BJSCANNON: any;
  50407. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50408. setGravity(gravity: Vector3): void;
  50409. setTimeStep(timeStep: number): void;
  50410. getTimeStep(): number;
  50411. executeStep(delta: number): void;
  50412. private _removeMarkedPhysicsBodiesFromWorld;
  50413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50416. private _processChildMeshes;
  50417. removePhysicsBody(impostor: PhysicsImpostor): void;
  50418. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50419. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50420. private _addMaterial;
  50421. private _checkWithEpsilon;
  50422. private _createShape;
  50423. private _createHeightmap;
  50424. private _minus90X;
  50425. private _plus90X;
  50426. private _tmpPosition;
  50427. private _tmpDeltaPosition;
  50428. private _tmpUnityRotation;
  50429. private _updatePhysicsBodyTransformation;
  50430. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50431. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50432. isSupported(): boolean;
  50433. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50434. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50435. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50436. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50437. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50438. getBodyMass(impostor: PhysicsImpostor): number;
  50439. getBodyFriction(impostor: PhysicsImpostor): number;
  50440. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50441. getBodyRestitution(impostor: PhysicsImpostor): number;
  50442. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50443. sleepBody(impostor: PhysicsImpostor): void;
  50444. wakeUpBody(impostor: PhysicsImpostor): void;
  50445. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50446. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50447. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50448. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50449. getRadius(impostor: PhysicsImpostor): number;
  50450. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50451. dispose(): void;
  50452. private _extendNamespace;
  50453. /**
  50454. * Does a raycast in the physics world
  50455. * @param from when should the ray start?
  50456. * @param to when should the ray end?
  50457. * @returns PhysicsRaycastResult
  50458. */
  50459. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50460. }
  50461. }
  50462. declare module BABYLON {
  50463. /** @hidden */
  50464. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50465. world: any;
  50466. name: string;
  50467. BJSOIMO: any;
  50468. private _raycastResult;
  50469. constructor(iterations?: number, oimoInjection?: any);
  50470. setGravity(gravity: Vector3): void;
  50471. setTimeStep(timeStep: number): void;
  50472. getTimeStep(): number;
  50473. private _tmpImpostorsArray;
  50474. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50475. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50476. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50477. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50478. private _tmpPositionVector;
  50479. removePhysicsBody(impostor: PhysicsImpostor): void;
  50480. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50481. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50482. isSupported(): boolean;
  50483. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50484. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50485. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50486. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50487. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50488. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50489. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50490. getBodyMass(impostor: PhysicsImpostor): number;
  50491. getBodyFriction(impostor: PhysicsImpostor): number;
  50492. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50493. getBodyRestitution(impostor: PhysicsImpostor): number;
  50494. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50495. sleepBody(impostor: PhysicsImpostor): void;
  50496. wakeUpBody(impostor: PhysicsImpostor): void;
  50497. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50498. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50499. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50500. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50501. getRadius(impostor: PhysicsImpostor): number;
  50502. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50503. dispose(): void;
  50504. /**
  50505. * Does a raycast in the physics world
  50506. * @param from when should the ray start?
  50507. * @param to when should the ray end?
  50508. * @returns PhysicsRaycastResult
  50509. */
  50510. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50511. }
  50512. }
  50513. declare module BABYLON {
  50514. /**
  50515. * Class containing static functions to help procedurally build meshes
  50516. */
  50517. export class RibbonBuilder {
  50518. /**
  50519. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50520. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50521. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50522. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50523. * * 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
  50524. * * 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
  50525. * * 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
  50526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50527. * * 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
  50528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50529. * * 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
  50530. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50531. * * 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
  50532. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50534. * @param name defines the name of the mesh
  50535. * @param options defines the options used to create the mesh
  50536. * @param scene defines the hosting scene
  50537. * @returns the ribbon mesh
  50538. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50540. */
  50541. static CreateRibbon(name: string, options: {
  50542. pathArray: Vector3[][];
  50543. closeArray?: boolean;
  50544. closePath?: boolean;
  50545. offset?: number;
  50546. updatable?: boolean;
  50547. sideOrientation?: number;
  50548. frontUVs?: Vector4;
  50549. backUVs?: Vector4;
  50550. instance?: Mesh;
  50551. invertUV?: boolean;
  50552. uvs?: Vector2[];
  50553. colors?: Color4[];
  50554. }, scene?: Nullable<Scene>): Mesh;
  50555. }
  50556. }
  50557. declare module BABYLON {
  50558. /**
  50559. * Class containing static functions to help procedurally build meshes
  50560. */
  50561. export class ShapeBuilder {
  50562. /**
  50563. * 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.
  50564. * * 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.
  50565. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50566. * * 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.
  50567. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50568. * * 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
  50569. * * 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
  50570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50572. * * 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
  50573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50575. * @param name defines the name of the mesh
  50576. * @param options defines the options used to create the mesh
  50577. * @param scene defines the hosting scene
  50578. * @returns the extruded shape mesh
  50579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50581. */
  50582. static ExtrudeShape(name: string, options: {
  50583. shape: Vector3[];
  50584. path: Vector3[];
  50585. scale?: number;
  50586. rotation?: number;
  50587. cap?: number;
  50588. updatable?: boolean;
  50589. sideOrientation?: number;
  50590. frontUVs?: Vector4;
  50591. backUVs?: Vector4;
  50592. instance?: Mesh;
  50593. invertUV?: boolean;
  50594. }, scene?: Nullable<Scene>): Mesh;
  50595. /**
  50596. * Creates an custom extruded shape mesh.
  50597. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50598. * * 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.
  50599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50600. * * 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
  50601. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50602. * * 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
  50603. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50604. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50605. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50606. * * 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
  50607. * * 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
  50608. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50610. * * 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
  50611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50613. * @param name defines the name of the mesh
  50614. * @param options defines the options used to create the mesh
  50615. * @param scene defines the hosting scene
  50616. * @returns the custom extruded shape mesh
  50617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50620. */
  50621. static ExtrudeShapeCustom(name: string, options: {
  50622. shape: Vector3[];
  50623. path: Vector3[];
  50624. scaleFunction?: any;
  50625. rotationFunction?: any;
  50626. ribbonCloseArray?: boolean;
  50627. ribbonClosePath?: boolean;
  50628. cap?: number;
  50629. updatable?: boolean;
  50630. sideOrientation?: number;
  50631. frontUVs?: Vector4;
  50632. backUVs?: Vector4;
  50633. instance?: Mesh;
  50634. invertUV?: boolean;
  50635. }, scene?: Nullable<Scene>): Mesh;
  50636. private static _ExtrudeShapeGeneric;
  50637. }
  50638. }
  50639. declare module BABYLON {
  50640. /**
  50641. * AmmoJS Physics plugin
  50642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50643. * @see https://github.com/kripken/ammo.js/
  50644. */
  50645. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50646. private _useDeltaForWorldStep;
  50647. /**
  50648. * Reference to the Ammo library
  50649. */
  50650. bjsAMMO: any;
  50651. /**
  50652. * Created ammoJS world which physics bodies are added to
  50653. */
  50654. world: any;
  50655. /**
  50656. * Name of the plugin
  50657. */
  50658. name: string;
  50659. private _timeStep;
  50660. private _fixedTimeStep;
  50661. private _maxSteps;
  50662. private _tmpQuaternion;
  50663. private _tmpAmmoTransform;
  50664. private _tmpAmmoQuaternion;
  50665. private _tmpAmmoConcreteContactResultCallback;
  50666. private _collisionConfiguration;
  50667. private _dispatcher;
  50668. private _overlappingPairCache;
  50669. private _solver;
  50670. private _softBodySolver;
  50671. private _tmpAmmoVectorA;
  50672. private _tmpAmmoVectorB;
  50673. private _tmpAmmoVectorC;
  50674. private _tmpAmmoVectorD;
  50675. private _tmpContactCallbackResult;
  50676. private _tmpAmmoVectorRCA;
  50677. private _tmpAmmoVectorRCB;
  50678. private _raycastResult;
  50679. private static readonly DISABLE_COLLISION_FLAG;
  50680. private static readonly KINEMATIC_FLAG;
  50681. private static readonly DISABLE_DEACTIVATION_FLAG;
  50682. /**
  50683. * Initializes the ammoJS plugin
  50684. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50685. * @param ammoInjection can be used to inject your own ammo reference
  50686. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50687. */
  50688. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50689. /**
  50690. * Sets the gravity of the physics world (m/(s^2))
  50691. * @param gravity Gravity to set
  50692. */
  50693. setGravity(gravity: Vector3): void;
  50694. /**
  50695. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50696. * @param timeStep timestep to use in seconds
  50697. */
  50698. setTimeStep(timeStep: number): void;
  50699. /**
  50700. * 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)
  50701. * @param fixedTimeStep fixedTimeStep to use in seconds
  50702. */
  50703. setFixedTimeStep(fixedTimeStep: number): void;
  50704. /**
  50705. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50706. * @param maxSteps the maximum number of steps by the physics engine per frame
  50707. */
  50708. setMaxSteps(maxSteps: number): void;
  50709. /**
  50710. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50711. * @returns the current timestep in seconds
  50712. */
  50713. getTimeStep(): number;
  50714. private _isImpostorInContact;
  50715. private _isImpostorPairInContact;
  50716. private _stepSimulation;
  50717. /**
  50718. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50719. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50720. * After the step the babylon meshes are set to the position of the physics imposters
  50721. * @param delta amount of time to step forward
  50722. * @param impostors array of imposters to update before/after the step
  50723. */
  50724. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50725. /**
  50726. * Update babylon mesh to match physics world object
  50727. * @param impostor imposter to match
  50728. */
  50729. private _afterSoftStep;
  50730. /**
  50731. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50732. * @param impostor imposter to match
  50733. */
  50734. private _ropeStep;
  50735. /**
  50736. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50737. * @param impostor imposter to match
  50738. */
  50739. private _softbodyOrClothStep;
  50740. private _tmpVector;
  50741. private _tmpMatrix;
  50742. /**
  50743. * Applies an impulse on the imposter
  50744. * @param impostor imposter to apply impulse to
  50745. * @param force amount of force to be applied to the imposter
  50746. * @param contactPoint the location to apply the impulse on the imposter
  50747. */
  50748. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50749. /**
  50750. * Applies a force on the imposter
  50751. * @param impostor imposter to apply force
  50752. * @param force amount of force to be applied to the imposter
  50753. * @param contactPoint the location to apply the force on the imposter
  50754. */
  50755. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50756. /**
  50757. * Creates a physics body using the plugin
  50758. * @param impostor the imposter to create the physics body on
  50759. */
  50760. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50761. /**
  50762. * Removes the physics body from the imposter and disposes of the body's memory
  50763. * @param impostor imposter to remove the physics body from
  50764. */
  50765. removePhysicsBody(impostor: PhysicsImpostor): void;
  50766. /**
  50767. * Generates a joint
  50768. * @param impostorJoint the imposter joint to create the joint with
  50769. */
  50770. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50771. /**
  50772. * Removes a joint
  50773. * @param impostorJoint the imposter joint to remove the joint from
  50774. */
  50775. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50776. private _addMeshVerts;
  50777. /**
  50778. * Initialise the soft body vertices to match its object's (mesh) vertices
  50779. * Softbody vertices (nodes) are in world space and to match this
  50780. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50781. * @param impostor to create the softbody for
  50782. */
  50783. private _softVertexData;
  50784. /**
  50785. * Create an impostor's soft body
  50786. * @param impostor to create the softbody for
  50787. */
  50788. private _createSoftbody;
  50789. /**
  50790. * Create cloth for an impostor
  50791. * @param impostor to create the softbody for
  50792. */
  50793. private _createCloth;
  50794. /**
  50795. * Create rope for an impostor
  50796. * @param impostor to create the softbody for
  50797. */
  50798. private _createRope;
  50799. private _addHullVerts;
  50800. private _createShape;
  50801. /**
  50802. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50803. * @param impostor imposter containing the physics body and babylon object
  50804. */
  50805. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50806. /**
  50807. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50808. * @param impostor imposter containing the physics body and babylon object
  50809. * @param newPosition new position
  50810. * @param newRotation new rotation
  50811. */
  50812. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50813. /**
  50814. * If this plugin is supported
  50815. * @returns true if its supported
  50816. */
  50817. isSupported(): boolean;
  50818. /**
  50819. * Sets the linear velocity of the physics body
  50820. * @param impostor imposter to set the velocity on
  50821. * @param velocity velocity to set
  50822. */
  50823. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50824. /**
  50825. * Sets the angular velocity of the physics body
  50826. * @param impostor imposter to set the velocity on
  50827. * @param velocity velocity to set
  50828. */
  50829. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50830. /**
  50831. * gets the linear velocity
  50832. * @param impostor imposter to get linear velocity from
  50833. * @returns linear velocity
  50834. */
  50835. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50836. /**
  50837. * gets the angular velocity
  50838. * @param impostor imposter to get angular velocity from
  50839. * @returns angular velocity
  50840. */
  50841. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50842. /**
  50843. * Sets the mass of physics body
  50844. * @param impostor imposter to set the mass on
  50845. * @param mass mass to set
  50846. */
  50847. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50848. /**
  50849. * Gets the mass of the physics body
  50850. * @param impostor imposter to get the mass from
  50851. * @returns mass
  50852. */
  50853. getBodyMass(impostor: PhysicsImpostor): number;
  50854. /**
  50855. * Gets friction of the impostor
  50856. * @param impostor impostor to get friction from
  50857. * @returns friction value
  50858. */
  50859. getBodyFriction(impostor: PhysicsImpostor): number;
  50860. /**
  50861. * Sets friction of the impostor
  50862. * @param impostor impostor to set friction on
  50863. * @param friction friction value
  50864. */
  50865. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50866. /**
  50867. * Gets restitution of the impostor
  50868. * @param impostor impostor to get restitution from
  50869. * @returns restitution value
  50870. */
  50871. getBodyRestitution(impostor: PhysicsImpostor): number;
  50872. /**
  50873. * Sets resitution of the impostor
  50874. * @param impostor impostor to set resitution on
  50875. * @param restitution resitution value
  50876. */
  50877. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50878. /**
  50879. * Gets pressure inside the impostor
  50880. * @param impostor impostor to get pressure from
  50881. * @returns pressure value
  50882. */
  50883. getBodyPressure(impostor: PhysicsImpostor): number;
  50884. /**
  50885. * Sets pressure inside a soft body impostor
  50886. * Cloth and rope must remain 0 pressure
  50887. * @param impostor impostor to set pressure on
  50888. * @param pressure pressure value
  50889. */
  50890. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50891. /**
  50892. * Gets stiffness of the impostor
  50893. * @param impostor impostor to get stiffness from
  50894. * @returns pressure value
  50895. */
  50896. getBodyStiffness(impostor: PhysicsImpostor): number;
  50897. /**
  50898. * Sets stiffness of the impostor
  50899. * @param impostor impostor to set stiffness on
  50900. * @param stiffness stiffness value from 0 to 1
  50901. */
  50902. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50903. /**
  50904. * Gets velocityIterations of the impostor
  50905. * @param impostor impostor to get velocity iterations from
  50906. * @returns velocityIterations value
  50907. */
  50908. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50909. /**
  50910. * Sets velocityIterations of the impostor
  50911. * @param impostor impostor to set velocity iterations on
  50912. * @param velocityIterations velocityIterations value
  50913. */
  50914. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50915. /**
  50916. * Gets positionIterations of the impostor
  50917. * @param impostor impostor to get position iterations from
  50918. * @returns positionIterations value
  50919. */
  50920. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50921. /**
  50922. * Sets positionIterations of the impostor
  50923. * @param impostor impostor to set position on
  50924. * @param positionIterations positionIterations value
  50925. */
  50926. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50927. /**
  50928. * Append an anchor to a cloth object
  50929. * @param impostor is the cloth impostor to add anchor to
  50930. * @param otherImpostor is the rigid impostor to anchor to
  50931. * @param width ratio across width from 0 to 1
  50932. * @param height ratio up height from 0 to 1
  50933. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50934. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50935. */
  50936. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50937. /**
  50938. * Append an hook to a rope object
  50939. * @param impostor is the rope impostor to add hook to
  50940. * @param otherImpostor is the rigid impostor to hook to
  50941. * @param length ratio along the rope from 0 to 1
  50942. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50943. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50944. */
  50945. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50946. /**
  50947. * Sleeps the physics body and stops it from being active
  50948. * @param impostor impostor to sleep
  50949. */
  50950. sleepBody(impostor: PhysicsImpostor): void;
  50951. /**
  50952. * Activates the physics body
  50953. * @param impostor impostor to activate
  50954. */
  50955. wakeUpBody(impostor: PhysicsImpostor): void;
  50956. /**
  50957. * Updates the distance parameters of the joint
  50958. * @param joint joint to update
  50959. * @param maxDistance maximum distance of the joint
  50960. * @param minDistance minimum distance of the joint
  50961. */
  50962. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50963. /**
  50964. * Sets a motor on the joint
  50965. * @param joint joint to set motor on
  50966. * @param speed speed of the motor
  50967. * @param maxForce maximum force of the motor
  50968. * @param motorIndex index of the motor
  50969. */
  50970. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50971. /**
  50972. * Sets the motors limit
  50973. * @param joint joint to set limit on
  50974. * @param upperLimit upper limit
  50975. * @param lowerLimit lower limit
  50976. */
  50977. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50978. /**
  50979. * Syncs the position and rotation of a mesh with the impostor
  50980. * @param mesh mesh to sync
  50981. * @param impostor impostor to update the mesh with
  50982. */
  50983. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50984. /**
  50985. * Gets the radius of the impostor
  50986. * @param impostor impostor to get radius from
  50987. * @returns the radius
  50988. */
  50989. getRadius(impostor: PhysicsImpostor): number;
  50990. /**
  50991. * Gets the box size of the impostor
  50992. * @param impostor impostor to get box size from
  50993. * @param result the resulting box size
  50994. */
  50995. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50996. /**
  50997. * Disposes of the impostor
  50998. */
  50999. dispose(): void;
  51000. /**
  51001. * Does a raycast in the physics world
  51002. * @param from when should the ray start?
  51003. * @param to when should the ray end?
  51004. * @returns PhysicsRaycastResult
  51005. */
  51006. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51007. }
  51008. }
  51009. declare module BABYLON {
  51010. interface AbstractScene {
  51011. /**
  51012. * The list of reflection probes added to the scene
  51013. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51014. */
  51015. reflectionProbes: Array<ReflectionProbe>;
  51016. /**
  51017. * Removes the given reflection probe from this scene.
  51018. * @param toRemove The reflection probe to remove
  51019. * @returns The index of the removed reflection probe
  51020. */
  51021. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51022. /**
  51023. * Adds the given reflection probe to this scene.
  51024. * @param newReflectionProbe The reflection probe to add
  51025. */
  51026. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51027. }
  51028. /**
  51029. * Class used to generate realtime reflection / refraction cube textures
  51030. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51031. */
  51032. export class ReflectionProbe {
  51033. /** defines the name of the probe */
  51034. name: string;
  51035. private _scene;
  51036. private _renderTargetTexture;
  51037. private _projectionMatrix;
  51038. private _viewMatrix;
  51039. private _target;
  51040. private _add;
  51041. private _attachedMesh;
  51042. private _invertYAxis;
  51043. /** Gets or sets probe position (center of the cube map) */
  51044. position: Vector3;
  51045. /**
  51046. * Creates a new reflection probe
  51047. * @param name defines the name of the probe
  51048. * @param size defines the texture resolution (for each face)
  51049. * @param scene defines the hosting scene
  51050. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51051. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51052. */
  51053. constructor(
  51054. /** defines the name of the probe */
  51055. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51056. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51057. samples: number;
  51058. /** Gets or sets the refresh rate to use (on every frame by default) */
  51059. refreshRate: number;
  51060. /**
  51061. * Gets the hosting scene
  51062. * @returns a Scene
  51063. */
  51064. getScene(): Scene;
  51065. /** Gets the internal CubeTexture used to render to */
  51066. readonly cubeTexture: RenderTargetTexture;
  51067. /** Gets the list of meshes to render */
  51068. readonly renderList: Nullable<AbstractMesh[]>;
  51069. /**
  51070. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51071. * @param mesh defines the mesh to attach to
  51072. */
  51073. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51074. /**
  51075. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51076. * @param renderingGroupId The rendering group id corresponding to its index
  51077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51078. */
  51079. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51080. /**
  51081. * Clean all associated resources
  51082. */
  51083. dispose(): void;
  51084. /**
  51085. * Converts the reflection probe information to a readable string for debug purpose.
  51086. * @param fullDetails Supports for multiple levels of logging within scene loading
  51087. * @returns the human readable reflection probe info
  51088. */
  51089. toString(fullDetails?: boolean): string;
  51090. /**
  51091. * Get the class name of the relfection probe.
  51092. * @returns "ReflectionProbe"
  51093. */
  51094. getClassName(): string;
  51095. /**
  51096. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51097. * @returns The JSON representation of the texture
  51098. */
  51099. serialize(): any;
  51100. /**
  51101. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51102. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51103. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51104. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51105. * @returns The parsed reflection probe if successful
  51106. */
  51107. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51108. }
  51109. }
  51110. declare module BABYLON {
  51111. /** @hidden */
  51112. export var _BabylonLoaderRegistered: boolean;
  51113. }
  51114. declare module BABYLON {
  51115. /**
  51116. * The Physically based simple base material of BJS.
  51117. *
  51118. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51119. * It is used as the base class for both the specGloss and metalRough conventions.
  51120. */
  51121. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51122. /**
  51123. * Number of Simultaneous lights allowed on the material.
  51124. */
  51125. maxSimultaneousLights: number;
  51126. /**
  51127. * If sets to true, disables all the lights affecting the material.
  51128. */
  51129. disableLighting: boolean;
  51130. /**
  51131. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51132. */
  51133. environmentTexture: BaseTexture;
  51134. /**
  51135. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51136. */
  51137. invertNormalMapX: boolean;
  51138. /**
  51139. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51140. */
  51141. invertNormalMapY: boolean;
  51142. /**
  51143. * Normal map used in the model.
  51144. */
  51145. normalTexture: BaseTexture;
  51146. /**
  51147. * Emissivie color used to self-illuminate the model.
  51148. */
  51149. emissiveColor: Color3;
  51150. /**
  51151. * Emissivie texture used to self-illuminate the model.
  51152. */
  51153. emissiveTexture: BaseTexture;
  51154. /**
  51155. * Occlusion Channel Strenght.
  51156. */
  51157. occlusionStrength: number;
  51158. /**
  51159. * Occlusion Texture of the material (adding extra occlusion effects).
  51160. */
  51161. occlusionTexture: BaseTexture;
  51162. /**
  51163. * Defines the alpha limits in alpha test mode.
  51164. */
  51165. alphaCutOff: number;
  51166. /**
  51167. * Gets the current double sided mode.
  51168. */
  51169. /**
  51170. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51171. */
  51172. doubleSided: boolean;
  51173. /**
  51174. * Stores the pre-calculated light information of a mesh in a texture.
  51175. */
  51176. lightmapTexture: BaseTexture;
  51177. /**
  51178. * If true, the light map contains occlusion information instead of lighting info.
  51179. */
  51180. useLightmapAsShadowmap: boolean;
  51181. /**
  51182. * Instantiates a new PBRMaterial instance.
  51183. *
  51184. * @param name The material name
  51185. * @param scene The scene the material will be use in.
  51186. */
  51187. constructor(name: string, scene: Scene);
  51188. getClassName(): string;
  51189. }
  51190. }
  51191. declare module BABYLON {
  51192. /**
  51193. * The PBR material of BJS following the metal roughness convention.
  51194. *
  51195. * This fits to the PBR convention in the GLTF definition:
  51196. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51197. */
  51198. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51199. /**
  51200. * The base color has two different interpretations depending on the value of metalness.
  51201. * When the material is a metal, the base color is the specific measured reflectance value
  51202. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51203. * of the material.
  51204. */
  51205. baseColor: Color3;
  51206. /**
  51207. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51208. * well as opacity information in the alpha channel.
  51209. */
  51210. baseTexture: BaseTexture;
  51211. /**
  51212. * Specifies the metallic scalar value of the material.
  51213. * Can also be used to scale the metalness values of the metallic texture.
  51214. */
  51215. metallic: number;
  51216. /**
  51217. * Specifies the roughness scalar value of the material.
  51218. * Can also be used to scale the roughness values of the metallic texture.
  51219. */
  51220. roughness: number;
  51221. /**
  51222. * Texture containing both the metallic value in the B channel and the
  51223. * roughness value in the G channel to keep better precision.
  51224. */
  51225. metallicRoughnessTexture: BaseTexture;
  51226. /**
  51227. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51228. *
  51229. * @param name The material name
  51230. * @param scene The scene the material will be use in.
  51231. */
  51232. constructor(name: string, scene: Scene);
  51233. /**
  51234. * Return the currrent class name of the material.
  51235. */
  51236. getClassName(): string;
  51237. /**
  51238. * Makes a duplicate of the current material.
  51239. * @param name - name to use for the new material.
  51240. */
  51241. clone(name: string): PBRMetallicRoughnessMaterial;
  51242. /**
  51243. * Serialize the material to a parsable JSON object.
  51244. */
  51245. serialize(): any;
  51246. /**
  51247. * Parses a JSON object correponding to the serialize function.
  51248. */
  51249. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51250. }
  51251. }
  51252. declare module BABYLON {
  51253. /**
  51254. * The PBR material of BJS following the specular glossiness convention.
  51255. *
  51256. * This fits to the PBR convention in the GLTF definition:
  51257. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51258. */
  51259. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51260. /**
  51261. * Specifies the diffuse color of the material.
  51262. */
  51263. diffuseColor: Color3;
  51264. /**
  51265. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51266. * channel.
  51267. */
  51268. diffuseTexture: BaseTexture;
  51269. /**
  51270. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51271. */
  51272. specularColor: Color3;
  51273. /**
  51274. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51275. */
  51276. glossiness: number;
  51277. /**
  51278. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51279. */
  51280. specularGlossinessTexture: BaseTexture;
  51281. /**
  51282. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51283. *
  51284. * @param name The material name
  51285. * @param scene The scene the material will be use in.
  51286. */
  51287. constructor(name: string, scene: Scene);
  51288. /**
  51289. * Return the currrent class name of the material.
  51290. */
  51291. getClassName(): string;
  51292. /**
  51293. * Makes a duplicate of the current material.
  51294. * @param name - name to use for the new material.
  51295. */
  51296. clone(name: string): PBRSpecularGlossinessMaterial;
  51297. /**
  51298. * Serialize the material to a parsable JSON object.
  51299. */
  51300. serialize(): any;
  51301. /**
  51302. * Parses a JSON object correponding to the serialize function.
  51303. */
  51304. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51305. }
  51306. }
  51307. declare module BABYLON {
  51308. /**
  51309. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51310. * It can help converting any input color in a desired output one. This can then be used to create effects
  51311. * from sepia, black and white to sixties or futuristic rendering...
  51312. *
  51313. * The only supported format is currently 3dl.
  51314. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51315. */
  51316. export class ColorGradingTexture extends BaseTexture {
  51317. /**
  51318. * The current texture matrix. (will always be identity in color grading texture)
  51319. */
  51320. private _textureMatrix;
  51321. /**
  51322. * The texture URL.
  51323. */
  51324. url: string;
  51325. /**
  51326. * Empty line regex stored for GC.
  51327. */
  51328. private static _noneEmptyLineRegex;
  51329. private _engine;
  51330. /**
  51331. * Instantiates a ColorGradingTexture from the following parameters.
  51332. *
  51333. * @param url The location of the color gradind data (currently only supporting 3dl)
  51334. * @param scene The scene the texture will be used in
  51335. */
  51336. constructor(url: string, scene: Scene);
  51337. /**
  51338. * Returns the texture matrix used in most of the material.
  51339. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51340. */
  51341. getTextureMatrix(): Matrix;
  51342. /**
  51343. * Occurs when the file being loaded is a .3dl LUT file.
  51344. */
  51345. private load3dlTexture;
  51346. /**
  51347. * Starts the loading process of the texture.
  51348. */
  51349. private loadTexture;
  51350. /**
  51351. * Clones the color gradind texture.
  51352. */
  51353. clone(): ColorGradingTexture;
  51354. /**
  51355. * Called during delayed load for textures.
  51356. */
  51357. delayLoad(): void;
  51358. /**
  51359. * Parses a color grading texture serialized by Babylon.
  51360. * @param parsedTexture The texture information being parsedTexture
  51361. * @param scene The scene to load the texture in
  51362. * @param rootUrl The root url of the data assets to load
  51363. * @return A color gradind texture
  51364. */
  51365. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51366. /**
  51367. * Serializes the LUT texture to json format.
  51368. */
  51369. serialize(): any;
  51370. }
  51371. }
  51372. declare module BABYLON {
  51373. /**
  51374. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51375. */
  51376. export class EquiRectangularCubeTexture extends BaseTexture {
  51377. /** The six faces of the cube. */
  51378. private static _FacesMapping;
  51379. private _noMipmap;
  51380. private _onLoad;
  51381. private _onError;
  51382. /** The size of the cubemap. */
  51383. private _size;
  51384. /** The buffer of the image. */
  51385. private _buffer;
  51386. /** The width of the input image. */
  51387. private _width;
  51388. /** The height of the input image. */
  51389. private _height;
  51390. /** The URL to the image. */
  51391. url: string;
  51392. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51393. coordinatesMode: number;
  51394. /**
  51395. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51396. * @param url The location of the image
  51397. * @param scene The scene the texture will be used in
  51398. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51399. * @param noMipmap Forces to not generate the mipmap if true
  51400. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51401. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51402. * @param onLoad — defines a callback called when texture is loaded
  51403. * @param onError — defines a callback called if there is an error
  51404. */
  51405. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51406. /**
  51407. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51408. */
  51409. private loadImage;
  51410. /**
  51411. * Convert the image buffer into a cubemap and create a CubeTexture.
  51412. */
  51413. private loadTexture;
  51414. /**
  51415. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51416. * @param buffer The ArrayBuffer that should be converted.
  51417. * @returns The buffer as Float32Array.
  51418. */
  51419. private getFloat32ArrayFromArrayBuffer;
  51420. /**
  51421. * Get the current class name of the texture useful for serialization or dynamic coding.
  51422. * @returns "EquiRectangularCubeTexture"
  51423. */
  51424. getClassName(): string;
  51425. /**
  51426. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51427. * @returns A clone of the current EquiRectangularCubeTexture.
  51428. */
  51429. clone(): EquiRectangularCubeTexture;
  51430. }
  51431. }
  51432. declare module BABYLON {
  51433. /**
  51434. * Based on jsTGALoader - Javascript loader for TGA file
  51435. * By Vincent Thibault
  51436. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51437. */
  51438. export class TGATools {
  51439. private static _TYPE_INDEXED;
  51440. private static _TYPE_RGB;
  51441. private static _TYPE_GREY;
  51442. private static _TYPE_RLE_INDEXED;
  51443. private static _TYPE_RLE_RGB;
  51444. private static _TYPE_RLE_GREY;
  51445. private static _ORIGIN_MASK;
  51446. private static _ORIGIN_SHIFT;
  51447. private static _ORIGIN_BL;
  51448. private static _ORIGIN_BR;
  51449. private static _ORIGIN_UL;
  51450. private static _ORIGIN_UR;
  51451. /**
  51452. * Gets the header of a TGA file
  51453. * @param data defines the TGA data
  51454. * @returns the header
  51455. */
  51456. static GetTGAHeader(data: Uint8Array): any;
  51457. /**
  51458. * Uploads TGA content to a Babylon Texture
  51459. * @hidden
  51460. */
  51461. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51462. /** @hidden */
  51463. 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;
  51464. /** @hidden */
  51465. 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;
  51466. /** @hidden */
  51467. 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;
  51468. /** @hidden */
  51469. 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;
  51470. /** @hidden */
  51471. 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;
  51472. /** @hidden */
  51473. 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;
  51474. }
  51475. }
  51476. declare module BABYLON {
  51477. /**
  51478. * Implementation of the TGA Texture Loader.
  51479. * @hidden
  51480. */
  51481. export class _TGATextureLoader implements IInternalTextureLoader {
  51482. /**
  51483. * Defines wether the loader supports cascade loading the different faces.
  51484. */
  51485. readonly supportCascades: boolean;
  51486. /**
  51487. * This returns if the loader support the current file information.
  51488. * @param extension defines the file extension of the file being loaded
  51489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51490. * @param fallback defines the fallback internal texture if any
  51491. * @param isBase64 defines whether the texture is encoded as a base64
  51492. * @param isBuffer defines whether the texture data are stored as a buffer
  51493. * @returns true if the loader can load the specified file
  51494. */
  51495. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51496. /**
  51497. * Transform the url before loading if required.
  51498. * @param rootUrl the url of the texture
  51499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51500. * @returns the transformed texture
  51501. */
  51502. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51503. /**
  51504. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51505. * @param rootUrl the url of the texture
  51506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51507. * @returns the fallback texture
  51508. */
  51509. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51510. /**
  51511. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51512. * @param data contains the texture data
  51513. * @param texture defines the BabylonJS internal texture
  51514. * @param createPolynomials will be true if polynomials have been requested
  51515. * @param onLoad defines the callback to trigger once the texture is ready
  51516. * @param onError defines the callback to trigger in case of error
  51517. */
  51518. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51519. /**
  51520. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51521. * @param data contains the texture data
  51522. * @param texture defines the BabylonJS internal texture
  51523. * @param callback defines the method to call once ready to upload
  51524. */
  51525. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51526. }
  51527. }
  51528. declare module BABYLON {
  51529. /**
  51530. * Info about the .basis files
  51531. */
  51532. class BasisFileInfo {
  51533. /**
  51534. * If the file has alpha
  51535. */
  51536. hasAlpha: boolean;
  51537. /**
  51538. * Info about each image of the basis file
  51539. */
  51540. images: Array<{
  51541. levels: Array<{
  51542. width: number;
  51543. height: number;
  51544. transcodedPixels: ArrayBufferView;
  51545. }>;
  51546. }>;
  51547. }
  51548. /**
  51549. * Result of transcoding a basis file
  51550. */
  51551. class TranscodeResult {
  51552. /**
  51553. * Info about the .basis file
  51554. */
  51555. fileInfo: BasisFileInfo;
  51556. /**
  51557. * Format to use when loading the file
  51558. */
  51559. format: number;
  51560. }
  51561. /**
  51562. * Configuration options for the Basis transcoder
  51563. */
  51564. export class BasisTranscodeConfiguration {
  51565. /**
  51566. * Supported compression formats used to determine the supported output format of the transcoder
  51567. */
  51568. supportedCompressionFormats?: {
  51569. /**
  51570. * etc1 compression format
  51571. */
  51572. etc1?: boolean;
  51573. /**
  51574. * s3tc compression format
  51575. */
  51576. s3tc?: boolean;
  51577. /**
  51578. * pvrtc compression format
  51579. */
  51580. pvrtc?: boolean;
  51581. /**
  51582. * etc2 compression format
  51583. */
  51584. etc2?: boolean;
  51585. };
  51586. /**
  51587. * If mipmap levels should be loaded for transcoded images (Default: true)
  51588. */
  51589. loadMipmapLevels?: boolean;
  51590. /**
  51591. * Index of a single image to load (Default: all images)
  51592. */
  51593. loadSingleImage?: number;
  51594. }
  51595. /**
  51596. * Used to load .Basis files
  51597. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51598. */
  51599. export class BasisTools {
  51600. private static _IgnoreSupportedFormats;
  51601. /**
  51602. * URL to use when loading the basis transcoder
  51603. */
  51604. static JSModuleURL: string;
  51605. /**
  51606. * URL to use when loading the wasm module for the transcoder
  51607. */
  51608. static WasmModuleURL: string;
  51609. /**
  51610. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51611. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51612. * @returns internal format corresponding to the Basis format
  51613. */
  51614. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51615. private static _WorkerPromise;
  51616. private static _Worker;
  51617. private static _actionId;
  51618. private static _CreateWorkerAsync;
  51619. /**
  51620. * Transcodes a loaded image file to compressed pixel data
  51621. * @param imageData image data to transcode
  51622. * @param config configuration options for the transcoding
  51623. * @returns a promise resulting in the transcoded image
  51624. */
  51625. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51626. /**
  51627. * Loads a texture from the transcode result
  51628. * @param texture texture load to
  51629. * @param transcodeResult the result of transcoding the basis file to load from
  51630. */
  51631. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51632. }
  51633. }
  51634. declare module BABYLON {
  51635. /**
  51636. * Loader for .basis file format
  51637. */
  51638. export class _BasisTextureLoader implements IInternalTextureLoader {
  51639. /**
  51640. * Defines whether the loader supports cascade loading the different faces.
  51641. */
  51642. readonly supportCascades: boolean;
  51643. /**
  51644. * This returns if the loader support the current file information.
  51645. * @param extension defines the file extension of the file being loaded
  51646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51647. * @param fallback defines the fallback internal texture if any
  51648. * @param isBase64 defines whether the texture is encoded as a base64
  51649. * @param isBuffer defines whether the texture data are stored as a buffer
  51650. * @returns true if the loader can load the specified file
  51651. */
  51652. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51653. /**
  51654. * Transform the url before loading if required.
  51655. * @param rootUrl the url of the texture
  51656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51657. * @returns the transformed texture
  51658. */
  51659. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51660. /**
  51661. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51662. * @param rootUrl the url of the texture
  51663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51664. * @returns the fallback texture
  51665. */
  51666. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51667. /**
  51668. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51669. * @param data contains the texture data
  51670. * @param texture defines the BabylonJS internal texture
  51671. * @param createPolynomials will be true if polynomials have been requested
  51672. * @param onLoad defines the callback to trigger once the texture is ready
  51673. * @param onError defines the callback to trigger in case of error
  51674. */
  51675. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51676. /**
  51677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51678. * @param data contains the texture data
  51679. * @param texture defines the BabylonJS internal texture
  51680. * @param callback defines the method to call once ready to upload
  51681. */
  51682. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51683. }
  51684. }
  51685. declare module BABYLON {
  51686. /**
  51687. * 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.
  51688. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51689. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51690. */
  51691. export class CustomProceduralTexture extends ProceduralTexture {
  51692. private _animate;
  51693. private _time;
  51694. private _config;
  51695. private _texturePath;
  51696. /**
  51697. * Instantiates a new Custom Procedural Texture.
  51698. * 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.
  51699. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51700. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51701. * @param name Define the name of the texture
  51702. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51703. * @param size Define the size of the texture to create
  51704. * @param scene Define the scene the texture belongs to
  51705. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51706. * @param generateMipMaps Define if the texture should creates mip maps or not
  51707. */
  51708. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51709. private _loadJson;
  51710. /**
  51711. * Is the texture ready to be used ? (rendered at least once)
  51712. * @returns true if ready, otherwise, false.
  51713. */
  51714. isReady(): boolean;
  51715. /**
  51716. * Render the texture to its associated render target.
  51717. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51718. */
  51719. render(useCameraPostProcess?: boolean): void;
  51720. /**
  51721. * Update the list of dependant textures samplers in the shader.
  51722. */
  51723. updateTextures(): void;
  51724. /**
  51725. * Update the uniform values of the procedural texture in the shader.
  51726. */
  51727. updateShaderUniforms(): void;
  51728. /**
  51729. * Define if the texture animates or not.
  51730. */
  51731. animate: boolean;
  51732. }
  51733. }
  51734. declare module BABYLON {
  51735. /** @hidden */
  51736. export var noisePixelShader: {
  51737. name: string;
  51738. shader: string;
  51739. };
  51740. }
  51741. declare module BABYLON {
  51742. /**
  51743. * Class used to generate noise procedural textures
  51744. */
  51745. export class NoiseProceduralTexture extends ProceduralTexture {
  51746. private _time;
  51747. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51748. brightness: number;
  51749. /** Defines the number of octaves to process */
  51750. octaves: number;
  51751. /** Defines the level of persistence (0.8 by default) */
  51752. persistence: number;
  51753. /** Gets or sets animation speed factor (default is 1) */
  51754. animationSpeedFactor: number;
  51755. /**
  51756. * Creates a new NoiseProceduralTexture
  51757. * @param name defines the name fo the texture
  51758. * @param size defines the size of the texture (default is 256)
  51759. * @param scene defines the hosting scene
  51760. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51761. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51762. */
  51763. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51764. private _updateShaderUniforms;
  51765. protected _getDefines(): string;
  51766. /** Generate the current state of the procedural texture */
  51767. render(useCameraPostProcess?: boolean): void;
  51768. /**
  51769. * Serializes this noise procedural texture
  51770. * @returns a serialized noise procedural texture object
  51771. */
  51772. serialize(): any;
  51773. /**
  51774. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51775. * @param parsedTexture defines parsed texture data
  51776. * @param scene defines the current scene
  51777. * @param rootUrl defines the root URL containing noise procedural texture information
  51778. * @returns a parsed NoiseProceduralTexture
  51779. */
  51780. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51781. }
  51782. }
  51783. declare module BABYLON {
  51784. /**
  51785. * Raw cube texture where the raw buffers are passed in
  51786. */
  51787. export class RawCubeTexture extends CubeTexture {
  51788. /**
  51789. * Creates a cube texture where the raw buffers are passed in.
  51790. * @param scene defines the scene the texture is attached to
  51791. * @param data defines the array of data to use to create each face
  51792. * @param size defines the size of the textures
  51793. * @param format defines the format of the data
  51794. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51795. * @param generateMipMaps defines if the engine should generate the mip levels
  51796. * @param invertY defines if data must be stored with Y axis inverted
  51797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51798. * @param compression defines the compression used (null by default)
  51799. */
  51800. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51801. /**
  51802. * Updates the raw cube texture.
  51803. * @param data defines the data to store
  51804. * @param format defines the data format
  51805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51806. * @param invertY defines if data must be stored with Y axis inverted
  51807. * @param compression defines the compression used (null by default)
  51808. * @param level defines which level of the texture to update
  51809. */
  51810. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51811. /**
  51812. * Updates a raw cube texture with RGBD encoded data.
  51813. * @param data defines the array of data [mipmap][face] to use to create each face
  51814. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51817. * @returns a promsie that resolves when the operation is complete
  51818. */
  51819. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51820. /**
  51821. * Clones the raw cube texture.
  51822. * @return a new cube texture
  51823. */
  51824. clone(): CubeTexture;
  51825. /** @hidden */
  51826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51827. }
  51828. }
  51829. declare module BABYLON {
  51830. /**
  51831. * Class used to store 3D textures containing user data
  51832. */
  51833. export class RawTexture3D extends Texture {
  51834. /** Gets or sets the texture format to use */
  51835. format: number;
  51836. private _engine;
  51837. /**
  51838. * Create a new RawTexture3D
  51839. * @param data defines the data of the texture
  51840. * @param width defines the width of the texture
  51841. * @param height defines the height of the texture
  51842. * @param depth defines the depth of the texture
  51843. * @param format defines the texture format to use
  51844. * @param scene defines the hosting scene
  51845. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51846. * @param invertY defines if texture must be stored with Y axis inverted
  51847. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51848. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51849. */
  51850. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51851. /** Gets or sets the texture format to use */
  51852. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51853. /**
  51854. * Update the texture with new data
  51855. * @param data defines the data to store in the texture
  51856. */
  51857. update(data: ArrayBufferView): void;
  51858. }
  51859. }
  51860. declare module BABYLON {
  51861. /**
  51862. * Creates a refraction texture used by refraction channel of the standard material.
  51863. * It is like a mirror but to see through a material.
  51864. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51865. */
  51866. export class RefractionTexture extends RenderTargetTexture {
  51867. /**
  51868. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51869. * 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.
  51870. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51871. */
  51872. refractionPlane: Plane;
  51873. /**
  51874. * Define how deep under the surface we should see.
  51875. */
  51876. depth: number;
  51877. /**
  51878. * Creates a refraction texture used by refraction channel of the standard material.
  51879. * It is like a mirror but to see through a material.
  51880. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51881. * @param name Define the texture name
  51882. * @param size Define the size of the underlying texture
  51883. * @param scene Define the scene the refraction belongs to
  51884. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51885. */
  51886. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51887. /**
  51888. * Clone the refraction texture.
  51889. * @returns the cloned texture
  51890. */
  51891. clone(): RefractionTexture;
  51892. /**
  51893. * Serialize the texture to a JSON representation you could use in Parse later on
  51894. * @returns the serialized JSON representation
  51895. */
  51896. serialize(): any;
  51897. }
  51898. }
  51899. declare module BABYLON {
  51900. /**
  51901. * Defines the options related to the creation of an HtmlElementTexture
  51902. */
  51903. export interface IHtmlElementTextureOptions {
  51904. /**
  51905. * Defines wether mip maps should be created or not.
  51906. */
  51907. generateMipMaps?: boolean;
  51908. /**
  51909. * Defines the sampling mode of the texture.
  51910. */
  51911. samplingMode?: number;
  51912. /**
  51913. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51914. */
  51915. engine: Nullable<Engine>;
  51916. /**
  51917. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51918. */
  51919. scene: Nullable<Scene>;
  51920. }
  51921. /**
  51922. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51923. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51924. * is automatically managed.
  51925. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51926. * in your application.
  51927. *
  51928. * As the update is not automatic, you need to call them manually.
  51929. */
  51930. export class HtmlElementTexture extends BaseTexture {
  51931. /**
  51932. * The texture URL.
  51933. */
  51934. element: HTMLVideoElement | HTMLCanvasElement;
  51935. private static readonly DefaultOptions;
  51936. private _textureMatrix;
  51937. private _engine;
  51938. private _isVideo;
  51939. private _generateMipMaps;
  51940. private _samplingMode;
  51941. /**
  51942. * Instantiates a HtmlElementTexture from the following parameters.
  51943. *
  51944. * @param name Defines the name of the texture
  51945. * @param element Defines the video or canvas the texture is filled with
  51946. * @param options Defines the other none mandatory texture creation options
  51947. */
  51948. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51949. private _createInternalTexture;
  51950. /**
  51951. * Returns the texture matrix used in most of the material.
  51952. */
  51953. getTextureMatrix(): Matrix;
  51954. /**
  51955. * Updates the content of the texture.
  51956. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51957. */
  51958. update(invertY?: Nullable<boolean>): void;
  51959. }
  51960. }
  51961. declare module BABYLON {
  51962. /**
  51963. * Enum used to define the target of a block
  51964. */
  51965. export enum NodeMaterialBlockTargets {
  51966. /** Vertex shader */
  51967. Vertex = 1,
  51968. /** Fragment shader */
  51969. Fragment = 2,
  51970. /** Neutral */
  51971. Neutral = 4,
  51972. /** Vertex and Fragment */
  51973. VertexAndFragment = 3
  51974. }
  51975. }
  51976. declare module BABYLON {
  51977. /**
  51978. * Defines the kind of connection point for node based material
  51979. */
  51980. export enum NodeMaterialBlockConnectionPointTypes {
  51981. /** Float */
  51982. Float = 1,
  51983. /** Int */
  51984. Int = 2,
  51985. /** Vector2 */
  51986. Vector2 = 4,
  51987. /** Vector3 */
  51988. Vector3 = 8,
  51989. /** Vector4 */
  51990. Vector4 = 16,
  51991. /** Color3 */
  51992. Color3 = 32,
  51993. /** Color4 */
  51994. Color4 = 64,
  51995. /** Matrix */
  51996. Matrix = 128,
  51997. /** Detect type based on connection */
  51998. AutoDetect = 1024,
  51999. /** Output type that will be defined by input type */
  52000. BasedOnInput = 2048
  52001. }
  52002. }
  52003. declare module BABYLON {
  52004. /**
  52005. * Root class for all node material optimizers
  52006. */
  52007. export class NodeMaterialOptimizer {
  52008. /**
  52009. * Function used to optimize a NodeMaterial graph
  52010. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52011. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52012. */
  52013. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52019. */
  52020. export class TransformBlock extends NodeMaterialBlock {
  52021. /**
  52022. * Defines the value to use to complement W value to transform it to a Vector4
  52023. */
  52024. complementW: number;
  52025. /**
  52026. * Defines the value to use to complement z value to transform it to a Vector4
  52027. */
  52028. complementZ: number;
  52029. /**
  52030. * Creates a new TransformBlock
  52031. * @param name defines the block name
  52032. */
  52033. constructor(name: string);
  52034. /**
  52035. * Gets the current class name
  52036. * @returns the class name
  52037. */
  52038. getClassName(): string;
  52039. /**
  52040. * Gets the vector input
  52041. */
  52042. readonly vector: NodeMaterialConnectionPoint;
  52043. /**
  52044. * Gets the output component
  52045. */
  52046. readonly output: NodeMaterialConnectionPoint;
  52047. /**
  52048. * Gets the matrix transform input
  52049. */
  52050. readonly transform: NodeMaterialConnectionPoint;
  52051. protected _buildBlock(state: NodeMaterialBuildState): this;
  52052. serialize(): any;
  52053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52054. protected _dumpPropertiesCode(): string;
  52055. }
  52056. }
  52057. declare module BABYLON {
  52058. /**
  52059. * Block used to output the vertex position
  52060. */
  52061. export class VertexOutputBlock extends NodeMaterialBlock {
  52062. /**
  52063. * Creates a new VertexOutputBlock
  52064. * @param name defines the block name
  52065. */
  52066. constructor(name: string);
  52067. /**
  52068. * Gets the current class name
  52069. * @returns the class name
  52070. */
  52071. getClassName(): string;
  52072. /**
  52073. * Gets the vector input component
  52074. */
  52075. readonly vector: NodeMaterialConnectionPoint;
  52076. protected _buildBlock(state: NodeMaterialBuildState): this;
  52077. }
  52078. }
  52079. declare module BABYLON {
  52080. /**
  52081. * Block used to output the final color
  52082. */
  52083. export class FragmentOutputBlock extends NodeMaterialBlock {
  52084. /**
  52085. * Create a new FragmentOutputBlock
  52086. * @param name defines the block name
  52087. */
  52088. constructor(name: string);
  52089. /**
  52090. * Gets the current class name
  52091. * @returns the class name
  52092. */
  52093. getClassName(): string;
  52094. /**
  52095. * Gets the rgba input component
  52096. */
  52097. readonly rgba: NodeMaterialConnectionPoint;
  52098. /**
  52099. * Gets the rgb input component
  52100. */
  52101. readonly rgb: NodeMaterialConnectionPoint;
  52102. /**
  52103. * Gets the a input component
  52104. */
  52105. readonly a: NodeMaterialConnectionPoint;
  52106. protected _buildBlock(state: NodeMaterialBuildState): this;
  52107. }
  52108. }
  52109. declare module BABYLON {
  52110. /**
  52111. * Enum used to define system values e.g. values automatically provided by the system
  52112. */
  52113. export enum NodeMaterialSystemValues {
  52114. /** World */
  52115. World = 1,
  52116. /** View */
  52117. View = 2,
  52118. /** Projection */
  52119. Projection = 3,
  52120. /** ViewProjection */
  52121. ViewProjection = 4,
  52122. /** WorldView */
  52123. WorldView = 5,
  52124. /** WorldViewProjection */
  52125. WorldViewProjection = 6,
  52126. /** CameraPosition */
  52127. CameraPosition = 7,
  52128. /** Fog Color */
  52129. FogColor = 8
  52130. }
  52131. }
  52132. declare module BABYLON {
  52133. /**
  52134. * Block used to read a reflection texture from a sampler
  52135. */
  52136. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52137. private _define3DName;
  52138. private _defineCubicName;
  52139. private _defineExplicitName;
  52140. private _defineProjectionName;
  52141. private _defineLocalCubicName;
  52142. private _defineSphericalName;
  52143. private _definePlanarName;
  52144. private _defineEquirectangularName;
  52145. private _defineMirroredEquirectangularFixedName;
  52146. private _defineEquirectangularFixedName;
  52147. private _defineSkyboxName;
  52148. private _cubeSamplerName;
  52149. private _2DSamplerName;
  52150. private _positionUVWName;
  52151. private _directionWName;
  52152. private _reflectionCoordsName;
  52153. private _reflection2DCoordsName;
  52154. private _reflectionColorName;
  52155. private _reflectionMatrixName;
  52156. /**
  52157. * Gets or sets the texture associated with the node
  52158. */
  52159. texture: Nullable<BaseTexture>;
  52160. /**
  52161. * Create a new TextureBlock
  52162. * @param name defines the block name
  52163. */
  52164. constructor(name: string);
  52165. /**
  52166. * Gets the current class name
  52167. * @returns the class name
  52168. */
  52169. getClassName(): string;
  52170. /**
  52171. * Gets the world position input component
  52172. */
  52173. readonly position: NodeMaterialConnectionPoint;
  52174. /**
  52175. * Gets the world position input component
  52176. */
  52177. readonly worldPosition: NodeMaterialConnectionPoint;
  52178. /**
  52179. * Gets the world normal input component
  52180. */
  52181. readonly worldNormal: NodeMaterialConnectionPoint;
  52182. /**
  52183. * Gets the world input component
  52184. */
  52185. readonly world: NodeMaterialConnectionPoint;
  52186. /**
  52187. * Gets the camera (or eye) position component
  52188. */
  52189. readonly cameraPosition: NodeMaterialConnectionPoint;
  52190. /**
  52191. * Gets the view input component
  52192. */
  52193. readonly view: NodeMaterialConnectionPoint;
  52194. /**
  52195. * Gets the rgb output component
  52196. */
  52197. readonly rgb: NodeMaterialConnectionPoint;
  52198. /**
  52199. * Gets the r output component
  52200. */
  52201. readonly r: NodeMaterialConnectionPoint;
  52202. /**
  52203. * Gets the g output component
  52204. */
  52205. readonly g: NodeMaterialConnectionPoint;
  52206. /**
  52207. * Gets the b output component
  52208. */
  52209. readonly b: NodeMaterialConnectionPoint;
  52210. autoConfigure(material: NodeMaterial): void;
  52211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52212. isReady(): boolean;
  52213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52214. private _injectVertexCode;
  52215. private _writeOutput;
  52216. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52217. serialize(): any;
  52218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52219. }
  52220. }
  52221. declare module BABYLON {
  52222. /**
  52223. * Interface used to configure the node material editor
  52224. */
  52225. export interface INodeMaterialEditorOptions {
  52226. /** Define the URl to load node editor script */
  52227. editorURL?: string;
  52228. }
  52229. /** @hidden */
  52230. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52231. /** BONES */
  52232. NUM_BONE_INFLUENCERS: number;
  52233. BonesPerMesh: number;
  52234. BONETEXTURE: boolean;
  52235. /** MORPH TARGETS */
  52236. MORPHTARGETS: boolean;
  52237. MORPHTARGETS_NORMAL: boolean;
  52238. MORPHTARGETS_TANGENT: boolean;
  52239. MORPHTARGETS_UV: boolean;
  52240. NUM_MORPH_INFLUENCERS: number;
  52241. /** IMAGE PROCESSING */
  52242. IMAGEPROCESSING: boolean;
  52243. VIGNETTE: boolean;
  52244. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52245. VIGNETTEBLENDMODEOPAQUE: boolean;
  52246. TONEMAPPING: boolean;
  52247. TONEMAPPING_ACES: boolean;
  52248. CONTRAST: boolean;
  52249. EXPOSURE: boolean;
  52250. COLORCURVES: boolean;
  52251. COLORGRADING: boolean;
  52252. COLORGRADING3D: boolean;
  52253. SAMPLER3DGREENDEPTH: boolean;
  52254. SAMPLER3DBGRMAP: boolean;
  52255. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52256. /** MISC. */
  52257. BUMPDIRECTUV: number;
  52258. constructor();
  52259. setValue(name: string, value: boolean): void;
  52260. }
  52261. /**
  52262. * Class used to configure NodeMaterial
  52263. */
  52264. export interface INodeMaterialOptions {
  52265. /**
  52266. * Defines if blocks should emit comments
  52267. */
  52268. emitComments: boolean;
  52269. }
  52270. /**
  52271. * Class used to create a node based material built by assembling shader blocks
  52272. */
  52273. export class NodeMaterial extends PushMaterial {
  52274. private static _BuildIdGenerator;
  52275. private _options;
  52276. private _vertexCompilationState;
  52277. private _fragmentCompilationState;
  52278. private _sharedData;
  52279. private _buildId;
  52280. private _buildWasSuccessful;
  52281. private _cachedWorldViewMatrix;
  52282. private _cachedWorldViewProjectionMatrix;
  52283. private _optimizers;
  52284. private _animationFrame;
  52285. /** Define the URl to load node editor script */
  52286. static EditorURL: string;
  52287. private BJSNODEMATERIALEDITOR;
  52288. /** Get the inspector from bundle or global */
  52289. private _getGlobalNodeMaterialEditor;
  52290. /**
  52291. * 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)
  52292. */
  52293. ignoreAlpha: boolean;
  52294. /**
  52295. * Defines the maximum number of lights that can be used in the material
  52296. */
  52297. maxSimultaneousLights: number;
  52298. /**
  52299. * Observable raised when the material is built
  52300. */
  52301. onBuildObservable: Observable<NodeMaterial>;
  52302. /**
  52303. * Gets or sets the root nodes of the material vertex shader
  52304. */
  52305. _vertexOutputNodes: NodeMaterialBlock[];
  52306. /**
  52307. * Gets or sets the root nodes of the material fragment (pixel) shader
  52308. */
  52309. _fragmentOutputNodes: NodeMaterialBlock[];
  52310. /** Gets or sets options to control the node material overall behavior */
  52311. options: INodeMaterialOptions;
  52312. /**
  52313. * Default configuration related to image processing available in the standard Material.
  52314. */
  52315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52316. /**
  52317. * Gets the image processing configuration used either in this material.
  52318. */
  52319. /**
  52320. * Sets the Default image processing configuration used either in the this material.
  52321. *
  52322. * If sets to null, the scene one is in use.
  52323. */
  52324. imageProcessingConfiguration: ImageProcessingConfiguration;
  52325. /**
  52326. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52327. */
  52328. attachedBlocks: NodeMaterialBlock[];
  52329. /**
  52330. * Create a new node based material
  52331. * @param name defines the material name
  52332. * @param scene defines the hosting scene
  52333. * @param options defines creation option
  52334. */
  52335. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52336. /**
  52337. * Gets the current class name of the material e.g. "NodeMaterial"
  52338. * @returns the class name
  52339. */
  52340. getClassName(): string;
  52341. /**
  52342. * Keep track of the image processing observer to allow dispose and replace.
  52343. */
  52344. private _imageProcessingObserver;
  52345. /**
  52346. * Attaches a new image processing configuration to the Standard Material.
  52347. * @param configuration
  52348. */
  52349. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52350. /**
  52351. * Get a block by its name
  52352. * @param name defines the name of the block to retrieve
  52353. * @returns the required block or null if not found
  52354. */
  52355. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52356. /**
  52357. * Get a block by its name
  52358. * @param predicate defines the predicate used to find the good candidate
  52359. * @returns the required block or null if not found
  52360. */
  52361. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52362. /**
  52363. * Get an input block by its name
  52364. * @param predicate defines the predicate used to find the good candidate
  52365. * @returns the required input block or null if not found
  52366. */
  52367. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52368. /**
  52369. * Gets the list of input blocks attached to this material
  52370. * @returns an array of InputBlocks
  52371. */
  52372. getInputBlocks(): InputBlock[];
  52373. /**
  52374. * Adds a new optimizer to the list of optimizers
  52375. * @param optimizer defines the optimizers to add
  52376. * @returns the current material
  52377. */
  52378. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52379. /**
  52380. * Remove an optimizer from the list of optimizers
  52381. * @param optimizer defines the optimizers to remove
  52382. * @returns the current material
  52383. */
  52384. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52385. /**
  52386. * Add a new block to the list of output nodes
  52387. * @param node defines the node to add
  52388. * @returns the current material
  52389. */
  52390. addOutputNode(node: NodeMaterialBlock): this;
  52391. /**
  52392. * Remove a block from the list of root nodes
  52393. * @param node defines the node to remove
  52394. * @returns the current material
  52395. */
  52396. removeOutputNode(node: NodeMaterialBlock): this;
  52397. private _addVertexOutputNode;
  52398. private _removeVertexOutputNode;
  52399. private _addFragmentOutputNode;
  52400. private _removeFragmentOutputNode;
  52401. /**
  52402. * Specifies if the material will require alpha blending
  52403. * @returns a boolean specifying if alpha blending is needed
  52404. */
  52405. needAlphaBlending(): boolean;
  52406. /**
  52407. * Specifies if this material should be rendered in alpha test mode
  52408. * @returns a boolean specifying if an alpha test is needed.
  52409. */
  52410. needAlphaTesting(): boolean;
  52411. private _initializeBlock;
  52412. private _resetDualBlocks;
  52413. /**
  52414. * Build the material and generates the inner effect
  52415. * @param verbose defines if the build should log activity
  52416. */
  52417. build(verbose?: boolean): void;
  52418. /**
  52419. * Runs an otpimization phase to try to improve the shader code
  52420. */
  52421. optimize(): void;
  52422. private _prepareDefinesForAttributes;
  52423. /**
  52424. * Get if the submesh is ready to be used and all its information available.
  52425. * Child classes can use it to update shaders
  52426. * @param mesh defines the mesh to check
  52427. * @param subMesh defines which submesh to check
  52428. * @param useInstances specifies that instances should be used
  52429. * @returns a boolean indicating that the submesh is ready or not
  52430. */
  52431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52432. /**
  52433. * Get a string representing the shaders built by the current node graph
  52434. */
  52435. readonly compiledShaders: string;
  52436. /**
  52437. * Binds the world matrix to the material
  52438. * @param world defines the world transformation matrix
  52439. */
  52440. bindOnlyWorldMatrix(world: Matrix): void;
  52441. /**
  52442. * Binds the submesh to this material by preparing the effect and shader to draw
  52443. * @param world defines the world transformation matrix
  52444. * @param mesh defines the mesh containing the submesh
  52445. * @param subMesh defines the submesh to bind the material to
  52446. */
  52447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52448. /**
  52449. * Gets the active textures from the material
  52450. * @returns an array of textures
  52451. */
  52452. getActiveTextures(): BaseTexture[];
  52453. /**
  52454. * Gets the list of texture blocks
  52455. * @returns an array of texture blocks
  52456. */
  52457. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52458. /**
  52459. * Specifies if the material uses a texture
  52460. * @param texture defines the texture to check against the material
  52461. * @returns a boolean specifying if the material uses the texture
  52462. */
  52463. hasTexture(texture: BaseTexture): boolean;
  52464. /**
  52465. * Disposes the material
  52466. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52467. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52468. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52469. */
  52470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52471. /** Creates the node editor window. */
  52472. private _createNodeEditor;
  52473. /**
  52474. * Launch the node material editor
  52475. * @param config Define the configuration of the editor
  52476. * @return a promise fulfilled when the node editor is visible
  52477. */
  52478. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52479. /**
  52480. * Clear the current material
  52481. */
  52482. clear(): void;
  52483. /**
  52484. * Clear the current material and set it to a default state
  52485. */
  52486. setToDefault(): void;
  52487. /**
  52488. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52489. * @param url defines the url to load from
  52490. * @returns a promise that will fullfil when the material is fully loaded
  52491. */
  52492. loadAsync(url: string): Promise<unknown>;
  52493. private _gatherBlocks;
  52494. /**
  52495. * Generate a string containing the code declaration required to create an equivalent of this material
  52496. * @returns a string
  52497. */
  52498. generateCode(): string;
  52499. /**
  52500. * Serializes this material in a JSON representation
  52501. * @returns the serialized material object
  52502. */
  52503. serialize(): any;
  52504. private _restoreConnections;
  52505. /**
  52506. * Clear the current graph and load a new one from a serialization object
  52507. * @param source defines the JSON representation of the material
  52508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52509. */
  52510. loadFromSerialization(source: any, rootUrl?: string): void;
  52511. /**
  52512. * Creates a node material from parsed material data
  52513. * @param source defines the JSON representation of the material
  52514. * @param scene defines the hosting scene
  52515. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52516. * @returns a new node material
  52517. */
  52518. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52519. /**
  52520. * Creates a new node material set to default basic configuration
  52521. * @param name defines the name of the material
  52522. * @param scene defines the hosting scene
  52523. * @returns a new NodeMaterial
  52524. */
  52525. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52526. }
  52527. }
  52528. declare module BABYLON {
  52529. /**
  52530. * Block used to read a texture from a sampler
  52531. */
  52532. export class TextureBlock extends NodeMaterialBlock {
  52533. private _defineName;
  52534. private _samplerName;
  52535. private _transformedUVName;
  52536. private _textureTransformName;
  52537. private _textureInfoName;
  52538. private _mainUVName;
  52539. private _mainUVDefineName;
  52540. /**
  52541. * Gets or sets the texture associated with the node
  52542. */
  52543. texture: Nullable<Texture>;
  52544. /**
  52545. * Create a new TextureBlock
  52546. * @param name defines the block name
  52547. */
  52548. constructor(name: string);
  52549. /**
  52550. * Gets the current class name
  52551. * @returns the class name
  52552. */
  52553. getClassName(): string;
  52554. /**
  52555. * Gets the uv input component
  52556. */
  52557. readonly uv: NodeMaterialConnectionPoint;
  52558. /**
  52559. * Gets the rgba output component
  52560. */
  52561. readonly rgba: NodeMaterialConnectionPoint;
  52562. /**
  52563. * Gets the rgb output component
  52564. */
  52565. readonly rgb: NodeMaterialConnectionPoint;
  52566. /**
  52567. * Gets the r output component
  52568. */
  52569. readonly r: NodeMaterialConnectionPoint;
  52570. /**
  52571. * Gets the g output component
  52572. */
  52573. readonly g: NodeMaterialConnectionPoint;
  52574. /**
  52575. * Gets the b output component
  52576. */
  52577. readonly b: NodeMaterialConnectionPoint;
  52578. /**
  52579. * Gets the a output component
  52580. */
  52581. readonly a: NodeMaterialConnectionPoint;
  52582. readonly target: NodeMaterialBlockTargets;
  52583. autoConfigure(material: NodeMaterial): void;
  52584. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52586. isReady(): boolean;
  52587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52588. private readonly _isMixed;
  52589. private _injectVertexCode;
  52590. private _writeOutput;
  52591. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52592. protected _dumpPropertiesCode(): string;
  52593. serialize(): any;
  52594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /**
  52599. * Class used to store shared data between 2 NodeMaterialBuildState
  52600. */
  52601. export class NodeMaterialBuildStateSharedData {
  52602. /**
  52603. * Gets the list of emitted varyings
  52604. */
  52605. temps: string[];
  52606. /**
  52607. * Gets the list of emitted varyings
  52608. */
  52609. varyings: string[];
  52610. /**
  52611. * Gets the varying declaration string
  52612. */
  52613. varyingDeclaration: string;
  52614. /**
  52615. * Input blocks
  52616. */
  52617. inputBlocks: InputBlock[];
  52618. /**
  52619. * Input blocks
  52620. */
  52621. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52622. /**
  52623. * Bindable blocks (Blocks that need to set data to the effect)
  52624. */
  52625. bindableBlocks: NodeMaterialBlock[];
  52626. /**
  52627. * List of blocks that can provide a compilation fallback
  52628. */
  52629. blocksWithFallbacks: NodeMaterialBlock[];
  52630. /**
  52631. * List of blocks that can provide a define update
  52632. */
  52633. blocksWithDefines: NodeMaterialBlock[];
  52634. /**
  52635. * List of blocks that can provide a repeatable content
  52636. */
  52637. repeatableContentBlocks: NodeMaterialBlock[];
  52638. /**
  52639. * List of blocks that can provide a dynamic list of uniforms
  52640. */
  52641. dynamicUniformBlocks: NodeMaterialBlock[];
  52642. /**
  52643. * List of blocks that can block the isReady function for the material
  52644. */
  52645. blockingBlocks: NodeMaterialBlock[];
  52646. /**
  52647. * Gets the list of animated inputs
  52648. */
  52649. animatedInputs: InputBlock[];
  52650. /**
  52651. * Build Id used to avoid multiple recompilations
  52652. */
  52653. buildId: number;
  52654. /** List of emitted variables */
  52655. variableNames: {
  52656. [key: string]: number;
  52657. };
  52658. /** List of emitted defines */
  52659. defineNames: {
  52660. [key: string]: number;
  52661. };
  52662. /** Should emit comments? */
  52663. emitComments: boolean;
  52664. /** Emit build activity */
  52665. verbose: boolean;
  52666. /**
  52667. * Gets the compilation hints emitted at compilation time
  52668. */
  52669. hints: {
  52670. needWorldViewMatrix: boolean;
  52671. needWorldViewProjectionMatrix: boolean;
  52672. needAlphaBlending: boolean;
  52673. needAlphaTesting: boolean;
  52674. };
  52675. /**
  52676. * List of compilation checks
  52677. */
  52678. checks: {
  52679. emitVertex: boolean;
  52680. emitFragment: boolean;
  52681. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52682. };
  52683. /** Creates a new shared data */
  52684. constructor();
  52685. /**
  52686. * Emits console errors and exceptions if there is a failing check
  52687. */
  52688. emitErrors(): void;
  52689. }
  52690. }
  52691. declare module BABYLON {
  52692. /**
  52693. * Class used to store node based material build state
  52694. */
  52695. export class NodeMaterialBuildState {
  52696. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52697. supportUniformBuffers: boolean;
  52698. /**
  52699. * Gets the list of emitted attributes
  52700. */
  52701. attributes: string[];
  52702. /**
  52703. * Gets the list of emitted uniforms
  52704. */
  52705. uniforms: string[];
  52706. /**
  52707. * Gets the list of emitted uniform buffers
  52708. */
  52709. uniformBuffers: string[];
  52710. /**
  52711. * Gets the list of emitted samplers
  52712. */
  52713. samplers: string[];
  52714. /**
  52715. * Gets the list of emitted functions
  52716. */
  52717. functions: {
  52718. [key: string]: string;
  52719. };
  52720. /**
  52721. * Gets the list of emitted extensions
  52722. */
  52723. extensions: {
  52724. [key: string]: string;
  52725. };
  52726. /**
  52727. * Gets the target of the compilation state
  52728. */
  52729. target: NodeMaterialBlockTargets;
  52730. /**
  52731. * Gets the list of emitted counters
  52732. */
  52733. counters: {
  52734. [key: string]: number;
  52735. };
  52736. /**
  52737. * Shared data between multiple NodeMaterialBuildState instances
  52738. */
  52739. sharedData: NodeMaterialBuildStateSharedData;
  52740. /** @hidden */
  52741. _vertexState: NodeMaterialBuildState;
  52742. /** @hidden */
  52743. _attributeDeclaration: string;
  52744. /** @hidden */
  52745. _uniformDeclaration: string;
  52746. /** @hidden */
  52747. _samplerDeclaration: string;
  52748. /** @hidden */
  52749. _varyingTransfer: string;
  52750. private _repeatableContentAnchorIndex;
  52751. /** @hidden */
  52752. _builtCompilationString: string;
  52753. /**
  52754. * Gets the emitted compilation strings
  52755. */
  52756. compilationString: string;
  52757. /**
  52758. * Finalize the compilation strings
  52759. * @param state defines the current compilation state
  52760. */
  52761. finalize(state: NodeMaterialBuildState): void;
  52762. /** @hidden */
  52763. readonly _repeatableContentAnchor: string;
  52764. /** @hidden */
  52765. _getFreeVariableName(prefix: string): string;
  52766. /** @hidden */
  52767. _getFreeDefineName(prefix: string): string;
  52768. /** @hidden */
  52769. _excludeVariableName(name: string): void;
  52770. /** @hidden */
  52771. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52772. /** @hidden */
  52773. _emitExtension(name: string, extension: string): void;
  52774. /** @hidden */
  52775. _emitFunction(name: string, code: string, comments: string): void;
  52776. /** @hidden */
  52777. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52778. replaceStrings?: {
  52779. search: RegExp;
  52780. replace: string;
  52781. }[];
  52782. repeatKey?: string;
  52783. }): string;
  52784. /** @hidden */
  52785. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52786. repeatKey?: string;
  52787. removeAttributes?: boolean;
  52788. removeUniforms?: boolean;
  52789. removeVaryings?: boolean;
  52790. removeIfDef?: boolean;
  52791. replaceStrings?: {
  52792. search: RegExp;
  52793. replace: string;
  52794. }[];
  52795. }, storeKey?: string): void;
  52796. /** @hidden */
  52797. _registerTempVariable(name: string): boolean;
  52798. /** @hidden */
  52799. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52800. /** @hidden */
  52801. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52802. }
  52803. }
  52804. declare module BABYLON {
  52805. /**
  52806. * Defines a block that can be used inside a node based material
  52807. */
  52808. export class NodeMaterialBlock {
  52809. private _buildId;
  52810. private _buildTarget;
  52811. private _target;
  52812. private _isFinalMerger;
  52813. private _isInput;
  52814. /** @hidden */
  52815. _codeVariableName: string;
  52816. /** @hidden */
  52817. _inputs: NodeMaterialConnectionPoint[];
  52818. /** @hidden */
  52819. _outputs: NodeMaterialConnectionPoint[];
  52820. /** @hidden */
  52821. _preparationId: number;
  52822. /**
  52823. * Gets or sets the name of the block
  52824. */
  52825. name: string;
  52826. /**
  52827. * Gets or sets the unique id of the node
  52828. */
  52829. uniqueId: number;
  52830. /**
  52831. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52832. */
  52833. readonly isFinalMerger: boolean;
  52834. /**
  52835. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52836. */
  52837. readonly isInput: boolean;
  52838. /**
  52839. * Gets or sets the build Id
  52840. */
  52841. buildId: number;
  52842. /**
  52843. * Gets or sets the target of the block
  52844. */
  52845. target: NodeMaterialBlockTargets;
  52846. /**
  52847. * Gets the list of input points
  52848. */
  52849. readonly inputs: NodeMaterialConnectionPoint[];
  52850. /** Gets the list of output points */
  52851. readonly outputs: NodeMaterialConnectionPoint[];
  52852. /**
  52853. * Find an input by its name
  52854. * @param name defines the name of the input to look for
  52855. * @returns the input or null if not found
  52856. */
  52857. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52858. /**
  52859. * Find an output by its name
  52860. * @param name defines the name of the outputto look for
  52861. * @returns the output or null if not found
  52862. */
  52863. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52864. /**
  52865. * Creates a new NodeMaterialBlock
  52866. * @param name defines the block name
  52867. * @param target defines the target of that block (Vertex by default)
  52868. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52869. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52870. */
  52871. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52872. /**
  52873. * Initialize the block and prepare the context for build
  52874. * @param state defines the state that will be used for the build
  52875. */
  52876. initialize(state: NodeMaterialBuildState): void;
  52877. /**
  52878. * Bind data to effect. Will only be called for blocks with isBindable === true
  52879. * @param effect defines the effect to bind data to
  52880. * @param nodeMaterial defines the hosting NodeMaterial
  52881. * @param mesh defines the mesh that will be rendered
  52882. */
  52883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52884. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52885. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52886. protected _writeFloat(value: number): string;
  52887. /**
  52888. * Gets the current class name e.g. "NodeMaterialBlock"
  52889. * @returns the class name
  52890. */
  52891. getClassName(): string;
  52892. /**
  52893. * Register a new input. Must be called inside a block constructor
  52894. * @param name defines the connection point name
  52895. * @param type defines the connection point type
  52896. * @param isOptional defines a boolean indicating that this input can be omitted
  52897. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52898. * @returns the current block
  52899. */
  52900. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52901. /**
  52902. * Register a new output. Must be called inside a block constructor
  52903. * @param name defines the connection point name
  52904. * @param type defines the connection point type
  52905. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52906. * @returns the current block
  52907. */
  52908. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52909. /**
  52910. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52911. * @param forOutput defines an optional connection point to check compatibility with
  52912. * @returns the first available input or null
  52913. */
  52914. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52915. /**
  52916. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52917. * @param forBlock defines an optional block to check compatibility with
  52918. * @returns the first available input or null
  52919. */
  52920. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52921. /**
  52922. * Gets the sibling of the given output
  52923. * @param current defines the current output
  52924. * @returns the next output in the list or null
  52925. */
  52926. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52927. /**
  52928. * Connect current block with another block
  52929. * @param other defines the block to connect with
  52930. * @param options define the various options to help pick the right connections
  52931. * @returns the current block
  52932. */
  52933. connectTo(other: NodeMaterialBlock, options?: {
  52934. input?: string;
  52935. output?: string;
  52936. outputSwizzle?: string;
  52937. }): this | undefined;
  52938. protected _buildBlock(state: NodeMaterialBuildState): void;
  52939. /**
  52940. * Add uniforms, samplers and uniform buffers at compilation time
  52941. * @param state defines the state to update
  52942. * @param nodeMaterial defines the node material requesting the update
  52943. * @param defines defines the material defines to update
  52944. */
  52945. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52946. /**
  52947. * Add potential fallbacks if shader compilation fails
  52948. * @param mesh defines the mesh to be rendered
  52949. * @param fallbacks defines the current prioritized list of fallbacks
  52950. */
  52951. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52952. /**
  52953. * Update defines for shader compilation
  52954. * @param mesh defines the mesh to be rendered
  52955. * @param nodeMaterial defines the node material requesting the update
  52956. * @param defines defines the material defines to update
  52957. * @param useInstances specifies that instances should be used
  52958. */
  52959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52960. /**
  52961. * Initialize defines for shader compilation
  52962. * @param mesh defines the mesh to be rendered
  52963. * @param nodeMaterial defines the node material requesting the update
  52964. * @param defines defines the material defines to be prepared
  52965. * @param useInstances specifies that instances should be used
  52966. */
  52967. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52968. /**
  52969. * Lets the block try to connect some inputs automatically
  52970. * @param material defines the hosting NodeMaterial
  52971. */
  52972. autoConfigure(material: NodeMaterial): void;
  52973. /**
  52974. * Function called when a block is declared as repeatable content generator
  52975. * @param vertexShaderState defines the current compilation state for the vertex shader
  52976. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52977. * @param mesh defines the mesh to be rendered
  52978. * @param defines defines the material defines to update
  52979. */
  52980. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52981. /**
  52982. * Checks if the block is ready
  52983. * @param mesh defines the mesh to be rendered
  52984. * @param nodeMaterial defines the node material requesting the update
  52985. * @param defines defines the material defines to update
  52986. * @param useInstances specifies that instances should be used
  52987. * @returns true if the block is ready
  52988. */
  52989. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52990. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52991. private _processBuild;
  52992. /**
  52993. * Compile the current node and generate the shader code
  52994. * @param state defines the current compilation state (uniforms, samplers, current string)
  52995. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52996. * @returns true if already built
  52997. */
  52998. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52999. protected _inputRename(name: string): string;
  53000. protected _outputRename(name: string): string;
  53001. protected _dumpPropertiesCode(): string;
  53002. /** @hidden */
  53003. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53004. /**
  53005. * Clone the current block to a new identical block
  53006. * @param scene defines the hosting scene
  53007. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53008. * @returns a copy of the current block
  53009. */
  53010. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53011. /**
  53012. * Serializes this block in a JSON representation
  53013. * @returns the serialized block object
  53014. */
  53015. serialize(): any;
  53016. /** @hidden */
  53017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53018. }
  53019. }
  53020. declare module BABYLON {
  53021. /**
  53022. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53023. */
  53024. export enum NodeMaterialBlockConnectionPointMode {
  53025. /** Value is an uniform */
  53026. Uniform = 0,
  53027. /** Value is a mesh attribute */
  53028. Attribute = 1,
  53029. /** Value is a varying between vertex and fragment shaders */
  53030. Varying = 2,
  53031. /** Mode is undefined */
  53032. Undefined = 3
  53033. }
  53034. }
  53035. declare module BABYLON {
  53036. /**
  53037. * Enum defining the type of animations supported by InputBlock
  53038. */
  53039. export enum AnimatedInputBlockTypes {
  53040. /** No animation */
  53041. None = 0,
  53042. /** Time based animation. Will only work for floats */
  53043. Time = 1
  53044. }
  53045. }
  53046. declare module BABYLON {
  53047. /**
  53048. * Block used to expose an input value
  53049. */
  53050. export class InputBlock extends NodeMaterialBlock {
  53051. private _mode;
  53052. private _associatedVariableName;
  53053. private _storedValue;
  53054. private _valueCallback;
  53055. private _type;
  53056. private _animationType;
  53057. /** Gets or set a value used to limit the range of float values */
  53058. min: number;
  53059. /** Gets or set a value used to limit the range of float values */
  53060. max: number;
  53061. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53062. matrixMode: number;
  53063. /** @hidden */
  53064. _systemValue: Nullable<NodeMaterialSystemValues>;
  53065. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53066. visibleInInspector: boolean;
  53067. /**
  53068. * Gets or sets the connection point type (default is float)
  53069. */
  53070. readonly type: NodeMaterialBlockConnectionPointTypes;
  53071. /**
  53072. * Creates a new InputBlock
  53073. * @param name defines the block name
  53074. * @param target defines the target of that block (Vertex by default)
  53075. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53076. */
  53077. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53078. /**
  53079. * Gets the output component
  53080. */
  53081. readonly output: NodeMaterialConnectionPoint;
  53082. /**
  53083. * Set the source of this connection point to a vertex attribute
  53084. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53085. * @returns the current connection point
  53086. */
  53087. setAsAttribute(attributeName?: string): InputBlock;
  53088. /**
  53089. * Set the source of this connection point to a system value
  53090. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53091. * @returns the current connection point
  53092. */
  53093. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53094. /**
  53095. * Gets or sets the value of that point.
  53096. * Please note that this value will be ignored if valueCallback is defined
  53097. */
  53098. value: any;
  53099. /**
  53100. * Gets or sets a callback used to get the value of that point.
  53101. * Please note that setting this value will force the connection point to ignore the value property
  53102. */
  53103. valueCallback: () => any;
  53104. /**
  53105. * Gets or sets the associated variable name in the shader
  53106. */
  53107. associatedVariableName: string;
  53108. /** Gets or sets the type of animation applied to the input */
  53109. animationType: AnimatedInputBlockTypes;
  53110. /**
  53111. * Gets a boolean indicating that this connection point not defined yet
  53112. */
  53113. readonly isUndefined: boolean;
  53114. /**
  53115. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53116. * In this case the connection point name must be the name of the uniform to use.
  53117. * Can only be set on inputs
  53118. */
  53119. isUniform: boolean;
  53120. /**
  53121. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53122. * In this case the connection point name must be the name of the attribute to use
  53123. * Can only be set on inputs
  53124. */
  53125. isAttribute: boolean;
  53126. /**
  53127. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53128. * Can only be set on exit points
  53129. */
  53130. isVarying: boolean;
  53131. /**
  53132. * Gets a boolean indicating that the current connection point is a system value
  53133. */
  53134. readonly isSystemValue: boolean;
  53135. /**
  53136. * Gets or sets the current well known value or null if not defined as a system value
  53137. */
  53138. systemValue: Nullable<NodeMaterialSystemValues>;
  53139. /**
  53140. * Gets the current class name
  53141. * @returns the class name
  53142. */
  53143. getClassName(): string;
  53144. /**
  53145. * Animate the input if animationType !== None
  53146. * @param scene defines the rendering scene
  53147. */
  53148. animate(scene: Scene): void;
  53149. private _emitDefine;
  53150. initialize(state: NodeMaterialBuildState): void;
  53151. /**
  53152. * Set the input block to its default value (based on its type)
  53153. */
  53154. setDefaultValue(): void;
  53155. protected _dumpPropertiesCode(): string;
  53156. private _emit;
  53157. /** @hidden */
  53158. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53159. /** @hidden */
  53160. _transmit(effect: Effect, scene: Scene): void;
  53161. protected _buildBlock(state: NodeMaterialBuildState): void;
  53162. serialize(): any;
  53163. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53164. }
  53165. }
  53166. declare module BABYLON {
  53167. /**
  53168. * Defines a connection point for a block
  53169. */
  53170. export class NodeMaterialConnectionPoint {
  53171. /** @hidden */
  53172. _ownerBlock: NodeMaterialBlock;
  53173. /** @hidden */
  53174. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53175. private _endpoints;
  53176. private _associatedVariableName;
  53177. /** @hidden */
  53178. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53179. /** @hidden */
  53180. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53181. private _type;
  53182. /** @hidden */
  53183. _enforceAssociatedVariableName: boolean;
  53184. /**
  53185. * Gets or sets the additional types supported byt this connection point
  53186. */
  53187. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53188. /**
  53189. * Gets or sets the associated variable name in the shader
  53190. */
  53191. associatedVariableName: string;
  53192. /**
  53193. * Gets or sets the connection point type (default is float)
  53194. */
  53195. type: NodeMaterialBlockConnectionPointTypes;
  53196. /**
  53197. * Gets or sets the connection point name
  53198. */
  53199. name: string;
  53200. /**
  53201. * Gets or sets a boolean indicating that this connection point can be omitted
  53202. */
  53203. isOptional: boolean;
  53204. /**
  53205. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53206. */
  53207. define: string;
  53208. /** Gets or sets the target of that connection point */
  53209. target: NodeMaterialBlockTargets;
  53210. /**
  53211. * Gets a boolean indicating that the current point is connected
  53212. */
  53213. readonly isConnected: boolean;
  53214. /**
  53215. * Gets a boolean indicating that the current point is connected to an input block
  53216. */
  53217. readonly isConnectedToInputBlock: boolean;
  53218. /**
  53219. * Gets a the connected input block (if any)
  53220. */
  53221. readonly connectInputBlock: Nullable<InputBlock>;
  53222. /** Get the other side of the connection (if any) */
  53223. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53224. /** Get the block that owns this connection point */
  53225. readonly ownerBlock: NodeMaterialBlock;
  53226. /** Get the block connected on the other side of this connection (if any) */
  53227. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53228. /** Get the block connected on the endpoints of this connection (if any) */
  53229. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53230. /** Gets the list of connected endpoints */
  53231. readonly endpoints: NodeMaterialConnectionPoint[];
  53232. /** Gets a boolean indicating if that output point is connected to at least one input */
  53233. readonly hasEndpoints: boolean;
  53234. /**
  53235. * Creates a new connection point
  53236. * @param name defines the connection point name
  53237. * @param ownerBlock defines the block hosting this connection point
  53238. */
  53239. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53240. /**
  53241. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53242. * @returns the class name
  53243. */
  53244. getClassName(): string;
  53245. /**
  53246. * Gets an boolean indicating if the current point can be connected to another point
  53247. * @param connectionPoint defines the other connection point
  53248. * @returns true if the connection is possible
  53249. */
  53250. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53251. /**
  53252. * Connect this point to another connection point
  53253. * @param connectionPoint defines the other connection point
  53254. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53255. * @returns the current connection point
  53256. */
  53257. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53258. /**
  53259. * Disconnect this point from one of his endpoint
  53260. * @param endpoint defines the other connection point
  53261. * @returns the current connection point
  53262. */
  53263. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53264. /**
  53265. * Serializes this point in a JSON representation
  53266. * @returns the serialized point object
  53267. */
  53268. serialize(): any;
  53269. }
  53270. }
  53271. declare module BABYLON {
  53272. /**
  53273. * Block used to add support for vertex skinning (bones)
  53274. */
  53275. export class BonesBlock extends NodeMaterialBlock {
  53276. /**
  53277. * Creates a new BonesBlock
  53278. * @param name defines the block name
  53279. */
  53280. constructor(name: string);
  53281. /**
  53282. * Initialize the block and prepare the context for build
  53283. * @param state defines the state that will be used for the build
  53284. */
  53285. initialize(state: NodeMaterialBuildState): void;
  53286. /**
  53287. * Gets the current class name
  53288. * @returns the class name
  53289. */
  53290. getClassName(): string;
  53291. /**
  53292. * Gets the matrix indices input component
  53293. */
  53294. readonly matricesIndices: NodeMaterialConnectionPoint;
  53295. /**
  53296. * Gets the matrix weights input component
  53297. */
  53298. readonly matricesWeights: NodeMaterialConnectionPoint;
  53299. /**
  53300. * Gets the extra matrix indices input component
  53301. */
  53302. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53303. /**
  53304. * Gets the extra matrix weights input component
  53305. */
  53306. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53307. /**
  53308. * Gets the world input component
  53309. */
  53310. readonly world: NodeMaterialConnectionPoint;
  53311. /**
  53312. * Gets the output component
  53313. */
  53314. readonly output: NodeMaterialConnectionPoint;
  53315. autoConfigure(material: NodeMaterial): void;
  53316. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53317. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53319. protected _buildBlock(state: NodeMaterialBuildState): this;
  53320. }
  53321. }
  53322. declare module BABYLON {
  53323. /**
  53324. * Block used to add support for instances
  53325. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53326. */
  53327. export class InstancesBlock extends NodeMaterialBlock {
  53328. /**
  53329. * Creates a new InstancesBlock
  53330. * @param name defines the block name
  53331. */
  53332. constructor(name: string);
  53333. /**
  53334. * Gets the current class name
  53335. * @returns the class name
  53336. */
  53337. getClassName(): string;
  53338. /**
  53339. * Gets the first world row input component
  53340. */
  53341. readonly world0: NodeMaterialConnectionPoint;
  53342. /**
  53343. * Gets the second world row input component
  53344. */
  53345. readonly world1: NodeMaterialConnectionPoint;
  53346. /**
  53347. * Gets the third world row input component
  53348. */
  53349. readonly world2: NodeMaterialConnectionPoint;
  53350. /**
  53351. * Gets the forth world row input component
  53352. */
  53353. readonly world3: NodeMaterialConnectionPoint;
  53354. /**
  53355. * Gets the world input component
  53356. */
  53357. readonly world: NodeMaterialConnectionPoint;
  53358. /**
  53359. * Gets the output component
  53360. */
  53361. readonly output: NodeMaterialConnectionPoint;
  53362. autoConfigure(material: NodeMaterial): void;
  53363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53364. protected _buildBlock(state: NodeMaterialBuildState): this;
  53365. }
  53366. }
  53367. declare module BABYLON {
  53368. /**
  53369. * Block used to add morph targets support to vertex shader
  53370. */
  53371. export class MorphTargetsBlock extends NodeMaterialBlock {
  53372. private _repeatableContentAnchor;
  53373. private _repeatebleContentGenerated;
  53374. /**
  53375. * Create a new MorphTargetsBlock
  53376. * @param name defines the block name
  53377. */
  53378. constructor(name: string);
  53379. /**
  53380. * Gets the current class name
  53381. * @returns the class name
  53382. */
  53383. getClassName(): string;
  53384. /**
  53385. * Gets the position input component
  53386. */
  53387. readonly position: NodeMaterialConnectionPoint;
  53388. /**
  53389. * Gets the normal input component
  53390. */
  53391. readonly normal: NodeMaterialConnectionPoint;
  53392. /**
  53393. * Gets the tangent input component
  53394. */
  53395. readonly tangent: NodeMaterialConnectionPoint;
  53396. /**
  53397. * Gets the tangent input component
  53398. */
  53399. readonly uv: NodeMaterialConnectionPoint;
  53400. /**
  53401. * Gets the position output component
  53402. */
  53403. readonly positionOutput: NodeMaterialConnectionPoint;
  53404. /**
  53405. * Gets the normal output component
  53406. */
  53407. readonly normalOutput: NodeMaterialConnectionPoint;
  53408. /**
  53409. * Gets the tangent output component
  53410. */
  53411. readonly tangentOutput: NodeMaterialConnectionPoint;
  53412. /**
  53413. * Gets the tangent output component
  53414. */
  53415. readonly uvOutput: NodeMaterialConnectionPoint;
  53416. initialize(state: NodeMaterialBuildState): void;
  53417. autoConfigure(material: NodeMaterial): void;
  53418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53419. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53420. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53421. protected _buildBlock(state: NodeMaterialBuildState): this;
  53422. }
  53423. }
  53424. declare module BABYLON {
  53425. /**
  53426. * Block used to get data information from a light
  53427. */
  53428. export class LightInformationBlock extends NodeMaterialBlock {
  53429. private _lightDataDefineName;
  53430. private _lightColorDefineName;
  53431. /**
  53432. * Gets or sets the light associated with this block
  53433. */
  53434. light: Nullable<Light>;
  53435. /**
  53436. * Creates a new LightInformationBlock
  53437. * @param name defines the block name
  53438. */
  53439. constructor(name: string);
  53440. /**
  53441. * Gets the current class name
  53442. * @returns the class name
  53443. */
  53444. getClassName(): string;
  53445. /**
  53446. * Gets the world position input component
  53447. */
  53448. readonly worldPosition: NodeMaterialConnectionPoint;
  53449. /**
  53450. * Gets the direction output component
  53451. */
  53452. readonly direction: NodeMaterialConnectionPoint;
  53453. /**
  53454. * Gets the direction output component
  53455. */
  53456. readonly color: NodeMaterialConnectionPoint;
  53457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53458. protected _buildBlock(state: NodeMaterialBuildState): this;
  53459. serialize(): any;
  53460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53461. }
  53462. }
  53463. declare module BABYLON {
  53464. /**
  53465. * Block used to add an alpha test in the fragment shader
  53466. */
  53467. export class AlphaTestBlock extends NodeMaterialBlock {
  53468. /**
  53469. * Gets or sets the alpha value where alpha testing happens
  53470. */
  53471. alphaCutOff: number;
  53472. /**
  53473. * Create a new AlphaTestBlock
  53474. * @param name defines the block name
  53475. */
  53476. constructor(name: string);
  53477. /**
  53478. * Gets the current class name
  53479. * @returns the class name
  53480. */
  53481. getClassName(): string;
  53482. /**
  53483. * Gets the color input component
  53484. */
  53485. readonly color: NodeMaterialConnectionPoint;
  53486. /**
  53487. * Gets the alpha input component
  53488. */
  53489. readonly alpha: NodeMaterialConnectionPoint;
  53490. protected _buildBlock(state: NodeMaterialBuildState): this;
  53491. protected _dumpPropertiesCode(): string;
  53492. serialize(): any;
  53493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53494. }
  53495. }
  53496. declare module BABYLON {
  53497. /**
  53498. * Block used to add image processing support to fragment shader
  53499. */
  53500. export class ImageProcessingBlock extends NodeMaterialBlock {
  53501. /**
  53502. * Create a new ImageProcessingBlock
  53503. * @param name defines the block name
  53504. */
  53505. constructor(name: string);
  53506. /**
  53507. * Gets the current class name
  53508. * @returns the class name
  53509. */
  53510. getClassName(): string;
  53511. /**
  53512. * Gets the color input component
  53513. */
  53514. readonly color: NodeMaterialConnectionPoint;
  53515. /**
  53516. * Gets the output component
  53517. */
  53518. readonly output: NodeMaterialConnectionPoint;
  53519. /**
  53520. * Initialize the block and prepare the context for build
  53521. * @param state defines the state that will be used for the build
  53522. */
  53523. initialize(state: NodeMaterialBuildState): void;
  53524. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53527. protected _buildBlock(state: NodeMaterialBuildState): this;
  53528. }
  53529. }
  53530. declare module BABYLON {
  53531. /**
  53532. * Block used to pertub normals based on a normal map
  53533. */
  53534. export class PerturbNormalBlock extends NodeMaterialBlock {
  53535. private _tangentSpaceParameterName;
  53536. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53537. invertX: boolean;
  53538. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53539. invertY: boolean;
  53540. /**
  53541. * Create a new PerturbNormalBlock
  53542. * @param name defines the block name
  53543. */
  53544. constructor(name: string);
  53545. /**
  53546. * Gets the current class name
  53547. * @returns the class name
  53548. */
  53549. getClassName(): string;
  53550. /**
  53551. * Gets the world position input component
  53552. */
  53553. readonly worldPosition: NodeMaterialConnectionPoint;
  53554. /**
  53555. * Gets the world normal input component
  53556. */
  53557. readonly worldNormal: NodeMaterialConnectionPoint;
  53558. /**
  53559. * Gets the uv input component
  53560. */
  53561. readonly uv: NodeMaterialConnectionPoint;
  53562. /**
  53563. * Gets the normal map color input component
  53564. */
  53565. readonly normalMapColor: NodeMaterialConnectionPoint;
  53566. /**
  53567. * Gets the strength input component
  53568. */
  53569. readonly strength: NodeMaterialConnectionPoint;
  53570. /**
  53571. * Gets the output component
  53572. */
  53573. readonly output: NodeMaterialConnectionPoint;
  53574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53576. autoConfigure(material: NodeMaterial): void;
  53577. protected _buildBlock(state: NodeMaterialBuildState): this;
  53578. protected _dumpPropertiesCode(): string;
  53579. serialize(): any;
  53580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53581. }
  53582. }
  53583. declare module BABYLON {
  53584. /**
  53585. * Block used to add support for scene fog
  53586. */
  53587. export class FogBlock extends NodeMaterialBlock {
  53588. private _fogDistanceName;
  53589. private _fogParameters;
  53590. /**
  53591. * Create a new FogBlock
  53592. * @param name defines the block name
  53593. */
  53594. constructor(name: string);
  53595. /**
  53596. * Gets the current class name
  53597. * @returns the class name
  53598. */
  53599. getClassName(): string;
  53600. /**
  53601. * Gets the world position input component
  53602. */
  53603. readonly worldPosition: NodeMaterialConnectionPoint;
  53604. /**
  53605. * Gets the view input component
  53606. */
  53607. readonly view: NodeMaterialConnectionPoint;
  53608. /**
  53609. * Gets the color input component
  53610. */
  53611. readonly input: NodeMaterialConnectionPoint;
  53612. /**
  53613. * Gets the fog color input component
  53614. */
  53615. readonly fogColor: NodeMaterialConnectionPoint;
  53616. /**
  53617. * Gets the output component
  53618. */
  53619. readonly output: NodeMaterialConnectionPoint;
  53620. autoConfigure(material: NodeMaterial): void;
  53621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53623. protected _buildBlock(state: NodeMaterialBuildState): this;
  53624. }
  53625. }
  53626. declare module BABYLON {
  53627. /**
  53628. * Block used to add light in the fragment shader
  53629. */
  53630. export class LightBlock extends NodeMaterialBlock {
  53631. private _lightId;
  53632. /**
  53633. * Gets or sets the light associated with this block
  53634. */
  53635. light: Nullable<Light>;
  53636. /**
  53637. * Create a new LightBlock
  53638. * @param name defines the block name
  53639. */
  53640. constructor(name: string);
  53641. /**
  53642. * Gets the current class name
  53643. * @returns the class name
  53644. */
  53645. getClassName(): string;
  53646. /**
  53647. * Gets the world position input component
  53648. */
  53649. readonly worldPosition: NodeMaterialConnectionPoint;
  53650. /**
  53651. * Gets the world normal input component
  53652. */
  53653. readonly worldNormal: NodeMaterialConnectionPoint;
  53654. /**
  53655. * Gets the camera (or eye) position component
  53656. */
  53657. readonly cameraPosition: NodeMaterialConnectionPoint;
  53658. /**
  53659. * Gets the diffuse output component
  53660. */
  53661. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53662. /**
  53663. * Gets the specular output component
  53664. */
  53665. readonly specularOutput: NodeMaterialConnectionPoint;
  53666. autoConfigure(material: NodeMaterial): void;
  53667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53668. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53670. private _injectVertexCode;
  53671. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53672. serialize(): any;
  53673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * Block used to multiply 2 values
  53679. */
  53680. export class MultiplyBlock extends NodeMaterialBlock {
  53681. /**
  53682. * Creates a new MultiplyBlock
  53683. * @param name defines the block name
  53684. */
  53685. constructor(name: string);
  53686. /**
  53687. * Gets the current class name
  53688. * @returns the class name
  53689. */
  53690. getClassName(): string;
  53691. /**
  53692. * Gets the left operand input component
  53693. */
  53694. readonly left: NodeMaterialConnectionPoint;
  53695. /**
  53696. * Gets the right operand input component
  53697. */
  53698. readonly right: NodeMaterialConnectionPoint;
  53699. /**
  53700. * Gets the output component
  53701. */
  53702. readonly output: NodeMaterialConnectionPoint;
  53703. protected _buildBlock(state: NodeMaterialBuildState): this;
  53704. }
  53705. }
  53706. declare module BABYLON {
  53707. /**
  53708. * Block used to add 2 vectors
  53709. */
  53710. export class AddBlock extends NodeMaterialBlock {
  53711. /**
  53712. * Creates a new AddBlock
  53713. * @param name defines the block name
  53714. */
  53715. constructor(name: string);
  53716. /**
  53717. * Gets the current class name
  53718. * @returns the class name
  53719. */
  53720. getClassName(): string;
  53721. /**
  53722. * Gets the left operand input component
  53723. */
  53724. readonly left: NodeMaterialConnectionPoint;
  53725. /**
  53726. * Gets the right operand input component
  53727. */
  53728. readonly right: NodeMaterialConnectionPoint;
  53729. /**
  53730. * Gets the output component
  53731. */
  53732. readonly output: NodeMaterialConnectionPoint;
  53733. protected _buildBlock(state: NodeMaterialBuildState): this;
  53734. }
  53735. }
  53736. declare module BABYLON {
  53737. /**
  53738. * Block used to scale a vector by a float
  53739. */
  53740. export class ScaleBlock extends NodeMaterialBlock {
  53741. /**
  53742. * Creates a new ScaleBlock
  53743. * @param name defines the block name
  53744. */
  53745. constructor(name: string);
  53746. /**
  53747. * Gets the current class name
  53748. * @returns the class name
  53749. */
  53750. getClassName(): string;
  53751. /**
  53752. * Gets the input component
  53753. */
  53754. readonly input: NodeMaterialConnectionPoint;
  53755. /**
  53756. * Gets the factor input component
  53757. */
  53758. readonly factor: NodeMaterialConnectionPoint;
  53759. /**
  53760. * Gets the output component
  53761. */
  53762. readonly output: NodeMaterialConnectionPoint;
  53763. protected _buildBlock(state: NodeMaterialBuildState): this;
  53764. }
  53765. }
  53766. declare module BABYLON {
  53767. /**
  53768. * Block used to clamp a float
  53769. */
  53770. export class ClampBlock extends NodeMaterialBlock {
  53771. /** Gets or sets the minimum range */
  53772. minimum: number;
  53773. /** Gets or sets the maximum range */
  53774. maximum: number;
  53775. /**
  53776. * Creates a new ClampBlock
  53777. * @param name defines the block name
  53778. */
  53779. constructor(name: string);
  53780. /**
  53781. * Gets the current class name
  53782. * @returns the class name
  53783. */
  53784. getClassName(): string;
  53785. /**
  53786. * Gets the value input component
  53787. */
  53788. readonly value: NodeMaterialConnectionPoint;
  53789. /**
  53790. * Gets the output component
  53791. */
  53792. readonly output: NodeMaterialConnectionPoint;
  53793. protected _buildBlock(state: NodeMaterialBuildState): this;
  53794. protected _dumpPropertiesCode(): string;
  53795. serialize(): any;
  53796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53797. }
  53798. }
  53799. declare module BABYLON {
  53800. /**
  53801. * Block used to apply a cross product between 2 vectors
  53802. */
  53803. export class CrossBlock extends NodeMaterialBlock {
  53804. /**
  53805. * Creates a new CrossBlock
  53806. * @param name defines the block name
  53807. */
  53808. constructor(name: string);
  53809. /**
  53810. * Gets the current class name
  53811. * @returns the class name
  53812. */
  53813. getClassName(): string;
  53814. /**
  53815. * Gets the left operand input component
  53816. */
  53817. readonly left: NodeMaterialConnectionPoint;
  53818. /**
  53819. * Gets the right operand input component
  53820. */
  53821. readonly right: NodeMaterialConnectionPoint;
  53822. /**
  53823. * Gets the output component
  53824. */
  53825. readonly output: NodeMaterialConnectionPoint;
  53826. protected _buildBlock(state: NodeMaterialBuildState): this;
  53827. }
  53828. }
  53829. declare module BABYLON {
  53830. /**
  53831. * Block used to apply a dot product between 2 vectors
  53832. */
  53833. export class DotBlock extends NodeMaterialBlock {
  53834. /**
  53835. * Creates a new DotBlock
  53836. * @param name defines the block name
  53837. */
  53838. constructor(name: string);
  53839. /**
  53840. * Gets the current class name
  53841. * @returns the class name
  53842. */
  53843. getClassName(): string;
  53844. /**
  53845. * Gets the left operand input component
  53846. */
  53847. readonly left: NodeMaterialConnectionPoint;
  53848. /**
  53849. * Gets the right operand input component
  53850. */
  53851. readonly right: NodeMaterialConnectionPoint;
  53852. /**
  53853. * Gets the output component
  53854. */
  53855. readonly output: NodeMaterialConnectionPoint;
  53856. protected _buildBlock(state: NodeMaterialBuildState): this;
  53857. }
  53858. }
  53859. declare module BABYLON {
  53860. /**
  53861. * Block used to remap a float from a range to a new one
  53862. */
  53863. export class RemapBlock extends NodeMaterialBlock {
  53864. /**
  53865. * Gets or sets the source range
  53866. */
  53867. sourceRange: Vector2;
  53868. /**
  53869. * Gets or sets the target range
  53870. */
  53871. targetRange: Vector2;
  53872. /**
  53873. * Creates a new RemapBlock
  53874. * @param name defines the block name
  53875. */
  53876. constructor(name: string);
  53877. /**
  53878. * Gets the current class name
  53879. * @returns the class name
  53880. */
  53881. getClassName(): string;
  53882. /**
  53883. * Gets the input component
  53884. */
  53885. readonly input: NodeMaterialConnectionPoint;
  53886. /**
  53887. * Gets the source min input component
  53888. */
  53889. readonly sourceMin: NodeMaterialConnectionPoint;
  53890. /**
  53891. * Gets the source max input component
  53892. */
  53893. readonly sourceMax: NodeMaterialConnectionPoint;
  53894. /**
  53895. * Gets the target min input component
  53896. */
  53897. readonly targetMin: NodeMaterialConnectionPoint;
  53898. /**
  53899. * Gets the target max input component
  53900. */
  53901. readonly targetMax: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the output component
  53904. */
  53905. readonly output: NodeMaterialConnectionPoint;
  53906. protected _buildBlock(state: NodeMaterialBuildState): this;
  53907. protected _dumpPropertiesCode(): string;
  53908. serialize(): any;
  53909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53910. }
  53911. }
  53912. declare module BABYLON {
  53913. /**
  53914. * Block used to normalize a vector
  53915. */
  53916. export class NormalizeBlock extends NodeMaterialBlock {
  53917. /**
  53918. * Creates a new NormalizeBlock
  53919. * @param name defines the block name
  53920. */
  53921. constructor(name: string);
  53922. /**
  53923. * Gets the current class name
  53924. * @returns the class name
  53925. */
  53926. getClassName(): string;
  53927. /**
  53928. * Gets the input component
  53929. */
  53930. readonly input: NodeMaterialConnectionPoint;
  53931. /**
  53932. * Gets the output component
  53933. */
  53934. readonly output: NodeMaterialConnectionPoint;
  53935. protected _buildBlock(state: NodeMaterialBuildState): this;
  53936. }
  53937. }
  53938. declare module BABYLON {
  53939. /**
  53940. * Operations supported by the Trigonometry block
  53941. */
  53942. export enum TrigonometryBlockOperations {
  53943. /** Cos */
  53944. Cos = 0,
  53945. /** Sin */
  53946. Sin = 1,
  53947. /** Abs */
  53948. Abs = 2,
  53949. /** Exp */
  53950. Exp = 3,
  53951. /** Exp2 */
  53952. Exp2 = 4,
  53953. /** Round */
  53954. Round = 5,
  53955. /** Floor */
  53956. Floor = 6,
  53957. /** Ceiling */
  53958. Ceiling = 7
  53959. }
  53960. /**
  53961. * Block used to apply trigonometry operation to floats
  53962. */
  53963. export class TrigonometryBlock extends NodeMaterialBlock {
  53964. /**
  53965. * Gets or sets the operation applied by the block
  53966. */
  53967. operation: TrigonometryBlockOperations;
  53968. /**
  53969. * Creates a new TrigonometryBlock
  53970. * @param name defines the block name
  53971. */
  53972. constructor(name: string);
  53973. /**
  53974. * Gets the current class name
  53975. * @returns the class name
  53976. */
  53977. getClassName(): string;
  53978. /**
  53979. * Gets the input component
  53980. */
  53981. readonly input: NodeMaterialConnectionPoint;
  53982. /**
  53983. * Gets the output component
  53984. */
  53985. readonly output: NodeMaterialConnectionPoint;
  53986. protected _buildBlock(state: NodeMaterialBuildState): this;
  53987. serialize(): any;
  53988. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53989. }
  53990. }
  53991. declare module BABYLON {
  53992. /**
  53993. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53994. */
  53995. export class ColorMergerBlock extends NodeMaterialBlock {
  53996. /**
  53997. * Create a new ColorMergerBlock
  53998. * @param name defines the block name
  53999. */
  54000. constructor(name: string);
  54001. /**
  54002. * Gets the current class name
  54003. * @returns the class name
  54004. */
  54005. getClassName(): string;
  54006. /**
  54007. * Gets the r component (input)
  54008. */
  54009. readonly r: NodeMaterialConnectionPoint;
  54010. /**
  54011. * Gets the g component (input)
  54012. */
  54013. readonly g: NodeMaterialConnectionPoint;
  54014. /**
  54015. * Gets the b component (input)
  54016. */
  54017. readonly b: NodeMaterialConnectionPoint;
  54018. /**
  54019. * Gets the a component (input)
  54020. */
  54021. readonly a: NodeMaterialConnectionPoint;
  54022. /**
  54023. * Gets the rgba component (output)
  54024. */
  54025. readonly rgba: NodeMaterialConnectionPoint;
  54026. /**
  54027. * Gets the rgb component (output)
  54028. */
  54029. readonly rgb: NodeMaterialConnectionPoint;
  54030. protected _buildBlock(state: NodeMaterialBuildState): this;
  54031. }
  54032. }
  54033. declare module BABYLON {
  54034. /**
  54035. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54036. */
  54037. export class VectorMergerBlock extends NodeMaterialBlock {
  54038. /**
  54039. * Create a new VectorMergerBlock
  54040. * @param name defines the block name
  54041. */
  54042. constructor(name: string);
  54043. /**
  54044. * Gets the current class name
  54045. * @returns the class name
  54046. */
  54047. getClassName(): string;
  54048. /**
  54049. * Gets the x component (input)
  54050. */
  54051. readonly x: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Gets the y component (input)
  54054. */
  54055. readonly y: NodeMaterialConnectionPoint;
  54056. /**
  54057. * Gets the z component (input)
  54058. */
  54059. readonly z: NodeMaterialConnectionPoint;
  54060. /**
  54061. * Gets the w component (input)
  54062. */
  54063. readonly w: NodeMaterialConnectionPoint;
  54064. /**
  54065. * Gets the xyzw component (output)
  54066. */
  54067. readonly xyzw: NodeMaterialConnectionPoint;
  54068. /**
  54069. * Gets the xyz component (output)
  54070. */
  54071. readonly xyz: NodeMaterialConnectionPoint;
  54072. /**
  54073. * Gets the xy component (output)
  54074. */
  54075. readonly xy: NodeMaterialConnectionPoint;
  54076. protected _buildBlock(state: NodeMaterialBuildState): this;
  54077. }
  54078. }
  54079. declare module BABYLON {
  54080. /**
  54081. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54082. */
  54083. export class ColorSplitterBlock extends NodeMaterialBlock {
  54084. /**
  54085. * Create a new ColorSplitterBlock
  54086. * @param name defines the block name
  54087. */
  54088. constructor(name: string);
  54089. /**
  54090. * Gets the current class name
  54091. * @returns the class name
  54092. */
  54093. getClassName(): string;
  54094. /**
  54095. * Gets the rgba component (input)
  54096. */
  54097. readonly rgba: NodeMaterialConnectionPoint;
  54098. /**
  54099. * Gets the rgb component (input)
  54100. */
  54101. readonly rgbIn: NodeMaterialConnectionPoint;
  54102. /**
  54103. * Gets the rgb component (output)
  54104. */
  54105. readonly rgbOut: NodeMaterialConnectionPoint;
  54106. /**
  54107. * Gets the r component (output)
  54108. */
  54109. readonly r: NodeMaterialConnectionPoint;
  54110. /**
  54111. * Gets the g component (output)
  54112. */
  54113. readonly g: NodeMaterialConnectionPoint;
  54114. /**
  54115. * Gets the b component (output)
  54116. */
  54117. readonly b: NodeMaterialConnectionPoint;
  54118. /**
  54119. * Gets the a component (output)
  54120. */
  54121. readonly a: NodeMaterialConnectionPoint;
  54122. protected _inputRename(name: string): string;
  54123. protected _outputRename(name: string): string;
  54124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54125. }
  54126. }
  54127. declare module BABYLON {
  54128. /**
  54129. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54130. */
  54131. export class VectorSplitterBlock extends NodeMaterialBlock {
  54132. /**
  54133. * Create a new VectorSplitterBlock
  54134. * @param name defines the block name
  54135. */
  54136. constructor(name: string);
  54137. /**
  54138. * Gets the current class name
  54139. * @returns the class name
  54140. */
  54141. getClassName(): string;
  54142. /**
  54143. * Gets the xyzw component (input)
  54144. */
  54145. readonly xyzw: NodeMaterialConnectionPoint;
  54146. /**
  54147. * Gets the xyz component (input)
  54148. */
  54149. readonly xyzIn: NodeMaterialConnectionPoint;
  54150. /**
  54151. * Gets the xy component (input)
  54152. */
  54153. readonly xyIn: NodeMaterialConnectionPoint;
  54154. /**
  54155. * Gets the xyz component (output)
  54156. */
  54157. readonly xyzOut: NodeMaterialConnectionPoint;
  54158. /**
  54159. * Gets the xy component (output)
  54160. */
  54161. readonly xyOut: NodeMaterialConnectionPoint;
  54162. /**
  54163. * Gets the x component (output)
  54164. */
  54165. readonly x: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the y component (output)
  54168. */
  54169. readonly y: NodeMaterialConnectionPoint;
  54170. /**
  54171. * Gets the z component (output)
  54172. */
  54173. readonly z: NodeMaterialConnectionPoint;
  54174. /**
  54175. * Gets the w component (output)
  54176. */
  54177. readonly w: NodeMaterialConnectionPoint;
  54178. protected _inputRename(name: string): string;
  54179. protected _outputRename(name: string): string;
  54180. protected _buildBlock(state: NodeMaterialBuildState): this;
  54181. }
  54182. }
  54183. declare module BABYLON {
  54184. /**
  54185. * Block used to lerp 2 values
  54186. */
  54187. export class LerpBlock extends NodeMaterialBlock {
  54188. /**
  54189. * Creates a new LerpBlock
  54190. * @param name defines the block name
  54191. */
  54192. constructor(name: string);
  54193. /**
  54194. * Gets the current class name
  54195. * @returns the class name
  54196. */
  54197. getClassName(): string;
  54198. /**
  54199. * Gets the left operand input component
  54200. */
  54201. readonly left: NodeMaterialConnectionPoint;
  54202. /**
  54203. * Gets the right operand input component
  54204. */
  54205. readonly right: NodeMaterialConnectionPoint;
  54206. /**
  54207. * Gets the gradient operand input component
  54208. */
  54209. readonly gradient: NodeMaterialConnectionPoint;
  54210. /**
  54211. * Gets the output component
  54212. */
  54213. readonly output: NodeMaterialConnectionPoint;
  54214. protected _buildBlock(state: NodeMaterialBuildState): this;
  54215. }
  54216. }
  54217. declare module BABYLON {
  54218. /**
  54219. * Block used to divide 2 vectors
  54220. */
  54221. export class DivideBlock extends NodeMaterialBlock {
  54222. /**
  54223. * Creates a new DivideBlock
  54224. * @param name defines the block name
  54225. */
  54226. constructor(name: string);
  54227. /**
  54228. * Gets the current class name
  54229. * @returns the class name
  54230. */
  54231. getClassName(): string;
  54232. /**
  54233. * Gets the left operand input component
  54234. */
  54235. readonly left: NodeMaterialConnectionPoint;
  54236. /**
  54237. * Gets the right operand input component
  54238. */
  54239. readonly right: NodeMaterialConnectionPoint;
  54240. /**
  54241. * Gets the output component
  54242. */
  54243. readonly output: NodeMaterialConnectionPoint;
  54244. protected _buildBlock(state: NodeMaterialBuildState): this;
  54245. }
  54246. }
  54247. declare module BABYLON {
  54248. /**
  54249. * Block used to subtract 2 vectors
  54250. */
  54251. export class SubtractBlock extends NodeMaterialBlock {
  54252. /**
  54253. * Creates a new SubtractBlock
  54254. * @param name defines the block name
  54255. */
  54256. constructor(name: string);
  54257. /**
  54258. * Gets the current class name
  54259. * @returns the class name
  54260. */
  54261. getClassName(): string;
  54262. /**
  54263. * Gets the left operand input component
  54264. */
  54265. readonly left: NodeMaterialConnectionPoint;
  54266. /**
  54267. * Gets the right operand input component
  54268. */
  54269. readonly right: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the output component
  54272. */
  54273. readonly output: NodeMaterialConnectionPoint;
  54274. protected _buildBlock(state: NodeMaterialBuildState): this;
  54275. }
  54276. }
  54277. declare module BABYLON {
  54278. /**
  54279. * Block used to step a value
  54280. */
  54281. export class StepBlock extends NodeMaterialBlock {
  54282. /**
  54283. * Creates a new AddBlock
  54284. * @param name defines the block name
  54285. */
  54286. constructor(name: string);
  54287. /**
  54288. * Gets the current class name
  54289. * @returns the class name
  54290. */
  54291. getClassName(): string;
  54292. /**
  54293. * Gets the value operand input component
  54294. */
  54295. readonly value: NodeMaterialConnectionPoint;
  54296. /**
  54297. * Gets the edge operand input component
  54298. */
  54299. readonly edge: NodeMaterialConnectionPoint;
  54300. /**
  54301. * Gets the output component
  54302. */
  54303. readonly output: NodeMaterialConnectionPoint;
  54304. protected _buildBlock(state: NodeMaterialBuildState): this;
  54305. }
  54306. }
  54307. declare module BABYLON {
  54308. /**
  54309. * Block used to get the opposite (1 - x) of a value
  54310. */
  54311. export class OneMinusBlock extends NodeMaterialBlock {
  54312. /**
  54313. * Creates a new OneMinusBlock
  54314. * @param name defines the block name
  54315. */
  54316. constructor(name: string);
  54317. /**
  54318. * Gets the current class name
  54319. * @returns the class name
  54320. */
  54321. getClassName(): string;
  54322. /**
  54323. * Gets the input component
  54324. */
  54325. readonly input: NodeMaterialConnectionPoint;
  54326. /**
  54327. * Gets the output component
  54328. */
  54329. readonly output: NodeMaterialConnectionPoint;
  54330. protected _buildBlock(state: NodeMaterialBuildState): this;
  54331. }
  54332. }
  54333. declare module BABYLON {
  54334. /**
  54335. * Block used to get the view direction
  54336. */
  54337. export class ViewDirectionBlock extends NodeMaterialBlock {
  54338. /**
  54339. * Creates a new ViewDirectionBlock
  54340. * @param name defines the block name
  54341. */
  54342. constructor(name: string);
  54343. /**
  54344. * Gets the current class name
  54345. * @returns the class name
  54346. */
  54347. getClassName(): string;
  54348. /**
  54349. * Gets the world position component
  54350. */
  54351. readonly worldPosition: NodeMaterialConnectionPoint;
  54352. /**
  54353. * Gets the camera position component
  54354. */
  54355. readonly cameraPosition: NodeMaterialConnectionPoint;
  54356. /**
  54357. * Gets the output component
  54358. */
  54359. readonly output: NodeMaterialConnectionPoint;
  54360. autoConfigure(material: NodeMaterial): void;
  54361. protected _buildBlock(state: NodeMaterialBuildState): this;
  54362. }
  54363. }
  54364. declare module BABYLON {
  54365. /**
  54366. * Block used to compute fresnel value
  54367. */
  54368. export class FresnelBlock extends NodeMaterialBlock {
  54369. /**
  54370. * Create a new FresnelBlock
  54371. * @param name defines the block name
  54372. */
  54373. constructor(name: string);
  54374. /**
  54375. * Gets the current class name
  54376. * @returns the class name
  54377. */
  54378. getClassName(): string;
  54379. /**
  54380. * Gets the world normal input component
  54381. */
  54382. readonly worldNormal: NodeMaterialConnectionPoint;
  54383. /**
  54384. * Gets the view direction input component
  54385. */
  54386. readonly viewDirection: NodeMaterialConnectionPoint;
  54387. /**
  54388. * Gets the bias input component
  54389. */
  54390. readonly bias: NodeMaterialConnectionPoint;
  54391. /**
  54392. * Gets the camera (or eye) position component
  54393. */
  54394. readonly power: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the fresnel output component
  54397. */
  54398. readonly fresnel: NodeMaterialConnectionPoint;
  54399. autoConfigure(material: NodeMaterial): void;
  54400. protected _buildBlock(state: NodeMaterialBuildState): this;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Block used to get the max of 2 values
  54406. */
  54407. export class MaxBlock extends NodeMaterialBlock {
  54408. /**
  54409. * Creates a new MaxBlock
  54410. * @param name defines the block name
  54411. */
  54412. constructor(name: string);
  54413. /**
  54414. * Gets the current class name
  54415. * @returns the class name
  54416. */
  54417. getClassName(): string;
  54418. /**
  54419. * Gets the left operand input component
  54420. */
  54421. readonly left: NodeMaterialConnectionPoint;
  54422. /**
  54423. * Gets the right operand input component
  54424. */
  54425. readonly right: NodeMaterialConnectionPoint;
  54426. /**
  54427. * Gets the output component
  54428. */
  54429. readonly output: NodeMaterialConnectionPoint;
  54430. protected _buildBlock(state: NodeMaterialBuildState): this;
  54431. }
  54432. }
  54433. declare module BABYLON {
  54434. /**
  54435. * Block used to get the min of 2 values
  54436. */
  54437. export class MinBlock extends NodeMaterialBlock {
  54438. /**
  54439. * Creates a new MinBlock
  54440. * @param name defines the block name
  54441. */
  54442. constructor(name: string);
  54443. /**
  54444. * Gets the current class name
  54445. * @returns the class name
  54446. */
  54447. getClassName(): string;
  54448. /**
  54449. * Gets the left operand input component
  54450. */
  54451. readonly left: NodeMaterialConnectionPoint;
  54452. /**
  54453. * Gets the right operand input component
  54454. */
  54455. readonly right: NodeMaterialConnectionPoint;
  54456. /**
  54457. * Gets the output component
  54458. */
  54459. readonly output: NodeMaterialConnectionPoint;
  54460. protected _buildBlock(state: NodeMaterialBuildState): this;
  54461. }
  54462. }
  54463. declare module BABYLON {
  54464. /**
  54465. * Block used to get the distance between 2 values
  54466. */
  54467. export class DistanceBlock extends NodeMaterialBlock {
  54468. /**
  54469. * Creates a new DistanceBlock
  54470. * @param name defines the block name
  54471. */
  54472. constructor(name: string);
  54473. /**
  54474. * Gets the current class name
  54475. * @returns the class name
  54476. */
  54477. getClassName(): string;
  54478. /**
  54479. * Gets the left operand input component
  54480. */
  54481. readonly left: NodeMaterialConnectionPoint;
  54482. /**
  54483. * Gets the right operand input component
  54484. */
  54485. readonly right: NodeMaterialConnectionPoint;
  54486. /**
  54487. * Gets the output component
  54488. */
  54489. readonly output: NodeMaterialConnectionPoint;
  54490. protected _buildBlock(state: NodeMaterialBuildState): this;
  54491. }
  54492. }
  54493. declare module BABYLON {
  54494. /**
  54495. * Block used to get the length of a vector
  54496. */
  54497. export class LengthBlock extends NodeMaterialBlock {
  54498. /**
  54499. * Creates a new LengthBlock
  54500. * @param name defines the block name
  54501. */
  54502. constructor(name: string);
  54503. /**
  54504. * Gets the current class name
  54505. * @returns the class name
  54506. */
  54507. getClassName(): string;
  54508. /**
  54509. * Gets the value input component
  54510. */
  54511. readonly value: NodeMaterialConnectionPoint;
  54512. /**
  54513. * Gets the output component
  54514. */
  54515. readonly output: NodeMaterialConnectionPoint;
  54516. protected _buildBlock(state: NodeMaterialBuildState): this;
  54517. }
  54518. }
  54519. declare module BABYLON {
  54520. /**
  54521. * Block used to get negative version of a value (i.e. x * -1)
  54522. */
  54523. export class NegateBlock extends NodeMaterialBlock {
  54524. /**
  54525. * Creates a new NegateBlock
  54526. * @param name defines the block name
  54527. */
  54528. constructor(name: string);
  54529. /**
  54530. * Gets the current class name
  54531. * @returns the class name
  54532. */
  54533. getClassName(): string;
  54534. /**
  54535. * Gets the value input component
  54536. */
  54537. readonly value: NodeMaterialConnectionPoint;
  54538. /**
  54539. * Gets the output component
  54540. */
  54541. readonly output: NodeMaterialConnectionPoint;
  54542. protected _buildBlock(state: NodeMaterialBuildState): this;
  54543. }
  54544. }
  54545. declare module BABYLON {
  54546. /**
  54547. * Effect Render Options
  54548. */
  54549. export interface IEffectRendererOptions {
  54550. /**
  54551. * Defines the vertices positions.
  54552. */
  54553. positions?: number[];
  54554. /**
  54555. * Defines the indices.
  54556. */
  54557. indices?: number[];
  54558. }
  54559. /**
  54560. * Helper class to render one or more effects
  54561. */
  54562. export class EffectRenderer {
  54563. private engine;
  54564. private static _DefaultOptions;
  54565. private _vertexBuffers;
  54566. private _indexBuffer;
  54567. private _ringBufferIndex;
  54568. private _ringScreenBuffer;
  54569. private _fullscreenViewport;
  54570. private _getNextFrameBuffer;
  54571. /**
  54572. * Creates an effect renderer
  54573. * @param engine the engine to use for rendering
  54574. * @param options defines the options of the effect renderer
  54575. */
  54576. constructor(engine: Engine, options?: IEffectRendererOptions);
  54577. /**
  54578. * Sets the current viewport in normalized coordinates 0-1
  54579. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54580. */
  54581. setViewport(viewport?: Viewport): void;
  54582. /**
  54583. * Binds the embedded attributes buffer to the effect.
  54584. * @param effect Defines the effect to bind the attributes for
  54585. */
  54586. bindBuffers(effect: Effect): void;
  54587. /**
  54588. * Sets the current effect wrapper to use during draw.
  54589. * The effect needs to be ready before calling this api.
  54590. * This also sets the default full screen position attribute.
  54591. * @param effectWrapper Defines the effect to draw with
  54592. */
  54593. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54594. /**
  54595. * Draws a full screen quad.
  54596. */
  54597. draw(): void;
  54598. /**
  54599. * renders one or more effects to a specified texture
  54600. * @param effectWrappers list of effects to renderer
  54601. * @param outputTexture texture to draw to, if null it will render to the screen
  54602. */
  54603. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54604. /**
  54605. * Disposes of the effect renderer
  54606. */
  54607. dispose(): void;
  54608. }
  54609. /**
  54610. * Options to create an EffectWrapper
  54611. */
  54612. interface EffectWrapperCreationOptions {
  54613. /**
  54614. * Engine to use to create the effect
  54615. */
  54616. engine: Engine;
  54617. /**
  54618. * Fragment shader for the effect
  54619. */
  54620. fragmentShader: string;
  54621. /**
  54622. * Vertex shader for the effect
  54623. */
  54624. vertexShader?: string;
  54625. /**
  54626. * Attributes to use in the shader
  54627. */
  54628. attributeNames?: Array<string>;
  54629. /**
  54630. * Uniforms to use in the shader
  54631. */
  54632. uniformNames?: Array<string>;
  54633. /**
  54634. * Texture sampler names to use in the shader
  54635. */
  54636. samplerNames?: Array<string>;
  54637. /**
  54638. * The friendly name of the effect displayed in Spector.
  54639. */
  54640. name?: string;
  54641. }
  54642. /**
  54643. * Wraps an effect to be used for rendering
  54644. */
  54645. export class EffectWrapper {
  54646. /**
  54647. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54648. */
  54649. onApplyObservable: Observable<{}>;
  54650. /**
  54651. * The underlying effect
  54652. */
  54653. effect: Effect;
  54654. /**
  54655. * Creates an effect to be renderer
  54656. * @param creationOptions options to create the effect
  54657. */
  54658. constructor(creationOptions: EffectWrapperCreationOptions);
  54659. /**
  54660. * Disposes of the effect wrapper
  54661. */
  54662. dispose(): void;
  54663. }
  54664. }
  54665. declare module BABYLON {
  54666. /**
  54667. * Helper class to push actions to a pool of workers.
  54668. */
  54669. export class WorkerPool implements IDisposable {
  54670. private _workerInfos;
  54671. private _pendingActions;
  54672. /**
  54673. * Constructor
  54674. * @param workers Array of workers to use for actions
  54675. */
  54676. constructor(workers: Array<Worker>);
  54677. /**
  54678. * Terminates all workers and clears any pending actions.
  54679. */
  54680. dispose(): void;
  54681. /**
  54682. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54683. * pended until a worker has completed its action.
  54684. * @param action The action to perform. Call onComplete when the action is complete.
  54685. */
  54686. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54687. private _execute;
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. /**
  54692. * Configuration for Draco compression
  54693. */
  54694. export interface IDracoCompressionConfiguration {
  54695. /**
  54696. * Configuration for the decoder.
  54697. */
  54698. decoder: {
  54699. /**
  54700. * The url to the WebAssembly module.
  54701. */
  54702. wasmUrl?: string;
  54703. /**
  54704. * The url to the WebAssembly binary.
  54705. */
  54706. wasmBinaryUrl?: string;
  54707. /**
  54708. * The url to the fallback JavaScript module.
  54709. */
  54710. fallbackUrl?: string;
  54711. };
  54712. }
  54713. /**
  54714. * Draco compression (https://google.github.io/draco/)
  54715. *
  54716. * This class wraps the Draco module.
  54717. *
  54718. * **Encoder**
  54719. *
  54720. * The encoder is not currently implemented.
  54721. *
  54722. * **Decoder**
  54723. *
  54724. * 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.
  54725. *
  54726. * To update the configuration, use the following code:
  54727. * ```javascript
  54728. * DracoCompression.Configuration = {
  54729. * decoder: {
  54730. * wasmUrl: "<url to the WebAssembly library>",
  54731. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54732. * fallbackUrl: "<url to the fallback JavaScript library>",
  54733. * }
  54734. * };
  54735. * ```
  54736. *
  54737. * 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.
  54738. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54739. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54740. *
  54741. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54742. * ```javascript
  54743. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54744. * ```
  54745. *
  54746. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54747. */
  54748. export class DracoCompression implements IDisposable {
  54749. private _workerPoolPromise?;
  54750. private _decoderModulePromise?;
  54751. /**
  54752. * The configuration. Defaults to the following urls:
  54753. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54754. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54755. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54756. */
  54757. static Configuration: IDracoCompressionConfiguration;
  54758. /**
  54759. * Returns true if the decoder configuration is available.
  54760. */
  54761. static readonly DecoderAvailable: boolean;
  54762. /**
  54763. * Default number of workers to create when creating the draco compression object.
  54764. */
  54765. static DefaultNumWorkers: number;
  54766. private static GetDefaultNumWorkers;
  54767. private static _Default;
  54768. /**
  54769. * Default instance for the draco compression object.
  54770. */
  54771. static readonly Default: DracoCompression;
  54772. /**
  54773. * Constructor
  54774. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54775. */
  54776. constructor(numWorkers?: number);
  54777. /**
  54778. * Stop all async operations and release resources.
  54779. */
  54780. dispose(): void;
  54781. /**
  54782. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54783. * @returns a promise that resolves when ready
  54784. */
  54785. whenReadyAsync(): Promise<void>;
  54786. /**
  54787. * Decode Draco compressed mesh data to vertex data.
  54788. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54789. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54790. * @returns A promise that resolves with the decoded vertex data
  54791. */
  54792. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54793. [kind: string]: number;
  54794. }): Promise<VertexData>;
  54795. }
  54796. }
  54797. declare module BABYLON {
  54798. /**
  54799. * Class for building Constructive Solid Geometry
  54800. */
  54801. export class CSG {
  54802. private polygons;
  54803. /**
  54804. * The world matrix
  54805. */
  54806. matrix: Matrix;
  54807. /**
  54808. * Stores the position
  54809. */
  54810. position: Vector3;
  54811. /**
  54812. * Stores the rotation
  54813. */
  54814. rotation: Vector3;
  54815. /**
  54816. * Stores the rotation quaternion
  54817. */
  54818. rotationQuaternion: Nullable<Quaternion>;
  54819. /**
  54820. * Stores the scaling vector
  54821. */
  54822. scaling: Vector3;
  54823. /**
  54824. * Convert the Mesh to CSG
  54825. * @param mesh The Mesh to convert to CSG
  54826. * @returns A new CSG from the Mesh
  54827. */
  54828. static FromMesh(mesh: Mesh): CSG;
  54829. /**
  54830. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54831. * @param polygons Polygons used to construct a CSG solid
  54832. */
  54833. private static FromPolygons;
  54834. /**
  54835. * Clones, or makes a deep copy, of the CSG
  54836. * @returns A new CSG
  54837. */
  54838. clone(): CSG;
  54839. /**
  54840. * Unions this CSG with another CSG
  54841. * @param csg The CSG to union against this CSG
  54842. * @returns The unioned CSG
  54843. */
  54844. union(csg: CSG): CSG;
  54845. /**
  54846. * Unions this CSG with another CSG in place
  54847. * @param csg The CSG to union against this CSG
  54848. */
  54849. unionInPlace(csg: CSG): void;
  54850. /**
  54851. * Subtracts this CSG with another CSG
  54852. * @param csg The CSG to subtract against this CSG
  54853. * @returns A new CSG
  54854. */
  54855. subtract(csg: CSG): CSG;
  54856. /**
  54857. * Subtracts this CSG with another CSG in place
  54858. * @param csg The CSG to subtact against this CSG
  54859. */
  54860. subtractInPlace(csg: CSG): void;
  54861. /**
  54862. * Intersect this CSG with another CSG
  54863. * @param csg The CSG to intersect against this CSG
  54864. * @returns A new CSG
  54865. */
  54866. intersect(csg: CSG): CSG;
  54867. /**
  54868. * Intersects this CSG with another CSG in place
  54869. * @param csg The CSG to intersect against this CSG
  54870. */
  54871. intersectInPlace(csg: CSG): void;
  54872. /**
  54873. * Return a new CSG solid with solid and empty space switched. This solid is
  54874. * not modified.
  54875. * @returns A new CSG solid with solid and empty space switched
  54876. */
  54877. inverse(): CSG;
  54878. /**
  54879. * Inverses the CSG in place
  54880. */
  54881. inverseInPlace(): void;
  54882. /**
  54883. * This is used to keep meshes transformations so they can be restored
  54884. * when we build back a Babylon Mesh
  54885. * NB : All CSG operations are performed in world coordinates
  54886. * @param csg The CSG to copy the transform attributes from
  54887. * @returns This CSG
  54888. */
  54889. copyTransformAttributes(csg: CSG): CSG;
  54890. /**
  54891. * Build Raw mesh from CSG
  54892. * Coordinates here are in world space
  54893. * @param name The name of the mesh geometry
  54894. * @param scene The Scene
  54895. * @param keepSubMeshes Specifies if the submeshes should be kept
  54896. * @returns A new Mesh
  54897. */
  54898. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54899. /**
  54900. * Build Mesh from CSG taking material and transforms into account
  54901. * @param name The name of the Mesh
  54902. * @param material The material of the Mesh
  54903. * @param scene The Scene
  54904. * @param keepSubMeshes Specifies if submeshes should be kept
  54905. * @returns The new Mesh
  54906. */
  54907. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54908. }
  54909. }
  54910. declare module BABYLON {
  54911. /**
  54912. * Class used to create a trail following a mesh
  54913. */
  54914. export class TrailMesh extends Mesh {
  54915. private _generator;
  54916. private _autoStart;
  54917. private _running;
  54918. private _diameter;
  54919. private _length;
  54920. private _sectionPolygonPointsCount;
  54921. private _sectionVectors;
  54922. private _sectionNormalVectors;
  54923. private _beforeRenderObserver;
  54924. /**
  54925. * @constructor
  54926. * @param name The value used by scene.getMeshByName() to do a lookup.
  54927. * @param generator The mesh to generate a trail.
  54928. * @param scene The scene to add this mesh to.
  54929. * @param diameter Diameter of trailing mesh. Default is 1.
  54930. * @param length Length of trailing mesh. Default is 60.
  54931. * @param autoStart Automatically start trailing mesh. Default true.
  54932. */
  54933. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54934. /**
  54935. * "TrailMesh"
  54936. * @returns "TrailMesh"
  54937. */
  54938. getClassName(): string;
  54939. private _createMesh;
  54940. /**
  54941. * Start trailing mesh.
  54942. */
  54943. start(): void;
  54944. /**
  54945. * Stop trailing mesh.
  54946. */
  54947. stop(): void;
  54948. /**
  54949. * Update trailing mesh geometry.
  54950. */
  54951. update(): void;
  54952. /**
  54953. * Returns a new TrailMesh object.
  54954. * @param name is a string, the name given to the new mesh
  54955. * @param newGenerator use new generator object for cloned trail mesh
  54956. * @returns a new mesh
  54957. */
  54958. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54959. /**
  54960. * Serializes this trail mesh
  54961. * @param serializationObject object to write serialization to
  54962. */
  54963. serialize(serializationObject: any): void;
  54964. /**
  54965. * Parses a serialized trail mesh
  54966. * @param parsedMesh the serialized mesh
  54967. * @param scene the scene to create the trail mesh in
  54968. * @returns the created trail mesh
  54969. */
  54970. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54971. }
  54972. }
  54973. declare module BABYLON {
  54974. /**
  54975. * Class containing static functions to help procedurally build meshes
  54976. */
  54977. export class TiledBoxBuilder {
  54978. /**
  54979. * Creates a box mesh
  54980. * 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)
  54981. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54983. * * 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
  54984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54985. * @param name defines the name of the mesh
  54986. * @param options defines the options used to create the mesh
  54987. * @param scene defines the hosting scene
  54988. * @returns the box mesh
  54989. */
  54990. static CreateTiledBox(name: string, options: {
  54991. pattern?: number;
  54992. width?: number;
  54993. height?: number;
  54994. depth?: number;
  54995. tileSize?: number;
  54996. tileWidth?: number;
  54997. tileHeight?: number;
  54998. alignHorizontal?: number;
  54999. alignVertical?: number;
  55000. faceUV?: Vector4[];
  55001. faceColors?: Color4[];
  55002. sideOrientation?: number;
  55003. updatable?: boolean;
  55004. }, scene?: Nullable<Scene>): Mesh;
  55005. }
  55006. }
  55007. declare module BABYLON {
  55008. /**
  55009. * Class containing static functions to help procedurally build meshes
  55010. */
  55011. export class TorusKnotBuilder {
  55012. /**
  55013. * Creates a torus knot mesh
  55014. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55015. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55016. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55017. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55019. * * 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
  55020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55021. * @param name defines the name of the mesh
  55022. * @param options defines the options used to create the mesh
  55023. * @param scene defines the hosting scene
  55024. * @returns the torus knot mesh
  55025. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55026. */
  55027. static CreateTorusKnot(name: string, options: {
  55028. radius?: number;
  55029. tube?: number;
  55030. radialSegments?: number;
  55031. tubularSegments?: number;
  55032. p?: number;
  55033. q?: number;
  55034. updatable?: boolean;
  55035. sideOrientation?: number;
  55036. frontUVs?: Vector4;
  55037. backUVs?: Vector4;
  55038. }, scene: any): Mesh;
  55039. }
  55040. }
  55041. declare module BABYLON {
  55042. /**
  55043. * Polygon
  55044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55045. */
  55046. export class Polygon {
  55047. /**
  55048. * Creates a rectangle
  55049. * @param xmin bottom X coord
  55050. * @param ymin bottom Y coord
  55051. * @param xmax top X coord
  55052. * @param ymax top Y coord
  55053. * @returns points that make the resulting rectation
  55054. */
  55055. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55056. /**
  55057. * Creates a circle
  55058. * @param radius radius of circle
  55059. * @param cx scale in x
  55060. * @param cy scale in y
  55061. * @param numberOfSides number of sides that make up the circle
  55062. * @returns points that make the resulting circle
  55063. */
  55064. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55065. /**
  55066. * Creates a polygon from input string
  55067. * @param input Input polygon data
  55068. * @returns the parsed points
  55069. */
  55070. static Parse(input: string): Vector2[];
  55071. /**
  55072. * Starts building a polygon from x and y coordinates
  55073. * @param x x coordinate
  55074. * @param y y coordinate
  55075. * @returns the started path2
  55076. */
  55077. static StartingAt(x: number, y: number): Path2;
  55078. }
  55079. /**
  55080. * Builds a polygon
  55081. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55082. */
  55083. export class PolygonMeshBuilder {
  55084. private _points;
  55085. private _outlinepoints;
  55086. private _holes;
  55087. private _name;
  55088. private _scene;
  55089. private _epoints;
  55090. private _eholes;
  55091. private _addToepoint;
  55092. /**
  55093. * Babylon reference to the earcut plugin.
  55094. */
  55095. bjsEarcut: any;
  55096. /**
  55097. * Creates a PolygonMeshBuilder
  55098. * @param name name of the builder
  55099. * @param contours Path of the polygon
  55100. * @param scene scene to add to when creating the mesh
  55101. * @param earcutInjection can be used to inject your own earcut reference
  55102. */
  55103. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55104. /**
  55105. * Adds a whole within the polygon
  55106. * @param hole Array of points defining the hole
  55107. * @returns this
  55108. */
  55109. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55110. /**
  55111. * Creates the polygon
  55112. * @param updatable If the mesh should be updatable
  55113. * @param depth The depth of the mesh created
  55114. * @returns the created mesh
  55115. */
  55116. build(updatable?: boolean, depth?: number): Mesh;
  55117. /**
  55118. * Creates the polygon
  55119. * @param depth The depth of the mesh created
  55120. * @returns the created VertexData
  55121. */
  55122. buildVertexData(depth?: number): VertexData;
  55123. /**
  55124. * Adds a side to the polygon
  55125. * @param positions points that make the polygon
  55126. * @param normals normals of the polygon
  55127. * @param uvs uvs of the polygon
  55128. * @param indices indices of the polygon
  55129. * @param bounds bounds of the polygon
  55130. * @param points points of the polygon
  55131. * @param depth depth of the polygon
  55132. * @param flip flip of the polygon
  55133. */
  55134. private addSide;
  55135. }
  55136. }
  55137. declare module BABYLON {
  55138. /**
  55139. * Class containing static functions to help procedurally build meshes
  55140. */
  55141. export class PolygonBuilder {
  55142. /**
  55143. * Creates a polygon mesh
  55144. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55145. * * 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
  55146. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55148. * * 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)
  55149. * * Remember you can only change the shape positions, not their number when updating a polygon
  55150. * @param name defines the name of the mesh
  55151. * @param options defines the options used to create the mesh
  55152. * @param scene defines the hosting scene
  55153. * @param earcutInjection can be used to inject your own earcut reference
  55154. * @returns the polygon mesh
  55155. */
  55156. static CreatePolygon(name: string, options: {
  55157. shape: Vector3[];
  55158. holes?: Vector3[][];
  55159. depth?: number;
  55160. faceUV?: Vector4[];
  55161. faceColors?: Color4[];
  55162. updatable?: boolean;
  55163. sideOrientation?: number;
  55164. frontUVs?: Vector4;
  55165. backUVs?: Vector4;
  55166. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55167. /**
  55168. * Creates an extruded polygon mesh, with depth in the Y direction.
  55169. * * 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)
  55170. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55171. * @param name defines the name of the mesh
  55172. * @param options defines the options used to create the mesh
  55173. * @param scene defines the hosting scene
  55174. * @param earcutInjection can be used to inject your own earcut reference
  55175. * @returns the polygon mesh
  55176. */
  55177. static ExtrudePolygon(name: string, options: {
  55178. shape: Vector3[];
  55179. holes?: Vector3[][];
  55180. depth?: number;
  55181. faceUV?: Vector4[];
  55182. faceColors?: Color4[];
  55183. updatable?: boolean;
  55184. sideOrientation?: number;
  55185. frontUVs?: Vector4;
  55186. backUVs?: Vector4;
  55187. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55188. }
  55189. }
  55190. declare module BABYLON {
  55191. /**
  55192. * Class containing static functions to help procedurally build meshes
  55193. */
  55194. export class LatheBuilder {
  55195. /**
  55196. * Creates lathe mesh.
  55197. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55198. * * 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
  55199. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55200. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55201. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55202. * * 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
  55203. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55204. * * 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
  55205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55206. * * 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
  55207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55209. * @param name defines the name of the mesh
  55210. * @param options defines the options used to create the mesh
  55211. * @param scene defines the hosting scene
  55212. * @returns the lathe mesh
  55213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55214. */
  55215. static CreateLathe(name: string, options: {
  55216. shape: Vector3[];
  55217. radius?: number;
  55218. tessellation?: number;
  55219. clip?: number;
  55220. arc?: number;
  55221. closed?: boolean;
  55222. updatable?: boolean;
  55223. sideOrientation?: number;
  55224. frontUVs?: Vector4;
  55225. backUVs?: Vector4;
  55226. cap?: number;
  55227. invertUV?: boolean;
  55228. }, scene?: Nullable<Scene>): Mesh;
  55229. }
  55230. }
  55231. declare module BABYLON {
  55232. /**
  55233. * Class containing static functions to help procedurally build meshes
  55234. */
  55235. export class TiledPlaneBuilder {
  55236. /**
  55237. * Creates a tiled plane mesh
  55238. * * The parameter `pattern` will, depending on value, do nothing or
  55239. * * * flip (reflect about central vertical) alternate tiles across and up
  55240. * * * flip every tile on alternate rows
  55241. * * * rotate (180 degs) alternate tiles across and up
  55242. * * * rotate every tile on alternate rows
  55243. * * * flip and rotate alternate tiles across and up
  55244. * * * flip and rotate every tile on alternate rows
  55245. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55246. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55247. * * 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
  55248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55249. * * 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)
  55250. * * 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)
  55251. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55252. * @param name defines the name of the mesh
  55253. * @param options defines the options used to create the mesh
  55254. * @param scene defines the hosting scene
  55255. * @returns the box mesh
  55256. */
  55257. static CreateTiledPlane(name: string, options: {
  55258. pattern?: number;
  55259. tileSize?: number;
  55260. tileWidth?: number;
  55261. tileHeight?: number;
  55262. size?: number;
  55263. width?: number;
  55264. height?: number;
  55265. alignHorizontal?: number;
  55266. alignVertical?: number;
  55267. sideOrientation?: number;
  55268. frontUVs?: Vector4;
  55269. backUVs?: Vector4;
  55270. updatable?: boolean;
  55271. }, scene?: Nullable<Scene>): Mesh;
  55272. }
  55273. }
  55274. declare module BABYLON {
  55275. /**
  55276. * Class containing static functions to help procedurally build meshes
  55277. */
  55278. export class TubeBuilder {
  55279. /**
  55280. * Creates a tube mesh.
  55281. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55282. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55283. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55284. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55285. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55286. * * 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)
  55287. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55288. * * 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
  55289. * * 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
  55290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55291. * * 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
  55292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55294. * @param name defines the name of the mesh
  55295. * @param options defines the options used to create the mesh
  55296. * @param scene defines the hosting scene
  55297. * @returns the tube mesh
  55298. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55299. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55300. */
  55301. static CreateTube(name: string, options: {
  55302. path: Vector3[];
  55303. radius?: number;
  55304. tessellation?: number;
  55305. radiusFunction?: {
  55306. (i: number, distance: number): number;
  55307. };
  55308. cap?: number;
  55309. arc?: number;
  55310. updatable?: boolean;
  55311. sideOrientation?: number;
  55312. frontUVs?: Vector4;
  55313. backUVs?: Vector4;
  55314. instance?: Mesh;
  55315. invertUV?: boolean;
  55316. }, scene?: Nullable<Scene>): Mesh;
  55317. }
  55318. }
  55319. declare module BABYLON {
  55320. /**
  55321. * Class containing static functions to help procedurally build meshes
  55322. */
  55323. export class IcoSphereBuilder {
  55324. /**
  55325. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55326. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55327. * * 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`)
  55328. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55329. * * 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
  55330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55331. * * 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
  55332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55333. * @param name defines the name of the mesh
  55334. * @param options defines the options used to create the mesh
  55335. * @param scene defines the hosting scene
  55336. * @returns the icosahedron mesh
  55337. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55338. */
  55339. static CreateIcoSphere(name: string, options: {
  55340. radius?: number;
  55341. radiusX?: number;
  55342. radiusY?: number;
  55343. radiusZ?: number;
  55344. flat?: boolean;
  55345. subdivisions?: number;
  55346. sideOrientation?: number;
  55347. frontUVs?: Vector4;
  55348. backUVs?: Vector4;
  55349. updatable?: boolean;
  55350. }, scene?: Nullable<Scene>): Mesh;
  55351. }
  55352. }
  55353. declare module BABYLON {
  55354. /**
  55355. * Class containing static functions to help procedurally build meshes
  55356. */
  55357. export class DecalBuilder {
  55358. /**
  55359. * Creates a decal mesh.
  55360. * 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
  55361. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55362. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55363. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55364. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55365. * @param name defines the name of the mesh
  55366. * @param sourceMesh defines the mesh where the decal must be applied
  55367. * @param options defines the options used to create the mesh
  55368. * @param scene defines the hosting scene
  55369. * @returns the decal mesh
  55370. * @see https://doc.babylonjs.com/how_to/decals
  55371. */
  55372. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55373. position?: Vector3;
  55374. normal?: Vector3;
  55375. size?: Vector3;
  55376. angle?: number;
  55377. }): Mesh;
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * Class containing static functions to help procedurally build meshes
  55383. */
  55384. export class MeshBuilder {
  55385. /**
  55386. * Creates a box mesh
  55387. * * The parameter `size` sets the size (float) of each box side (default 1)
  55388. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55389. * * 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)
  55390. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55392. * * 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
  55393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55394. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55395. * @param name defines the name of the mesh
  55396. * @param options defines the options used to create the mesh
  55397. * @param scene defines the hosting scene
  55398. * @returns the box mesh
  55399. */
  55400. static CreateBox(name: string, options: {
  55401. size?: number;
  55402. width?: number;
  55403. height?: number;
  55404. depth?: number;
  55405. faceUV?: Vector4[];
  55406. faceColors?: Color4[];
  55407. sideOrientation?: number;
  55408. frontUVs?: Vector4;
  55409. backUVs?: Vector4;
  55410. updatable?: boolean;
  55411. }, scene?: Nullable<Scene>): Mesh;
  55412. /**
  55413. * Creates a tiled box mesh
  55414. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55416. * @param name defines the name of the mesh
  55417. * @param options defines the options used to create the mesh
  55418. * @param scene defines the hosting scene
  55419. * @returns the tiled box mesh
  55420. */
  55421. static CreateTiledBox(name: string, options: {
  55422. pattern?: number;
  55423. size?: number;
  55424. width?: number;
  55425. height?: number;
  55426. depth: number;
  55427. tileSize?: number;
  55428. tileWidth?: number;
  55429. tileHeight?: number;
  55430. faceUV?: Vector4[];
  55431. faceColors?: Color4[];
  55432. alignHorizontal?: number;
  55433. alignVertical?: number;
  55434. sideOrientation?: number;
  55435. updatable?: boolean;
  55436. }, scene?: Nullable<Scene>): Mesh;
  55437. /**
  55438. * Creates a sphere mesh
  55439. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55440. * * 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`)
  55441. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55442. * * 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
  55443. * * 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)
  55444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55445. * * 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
  55446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55447. * @param name defines the name of the mesh
  55448. * @param options defines the options used to create the mesh
  55449. * @param scene defines the hosting scene
  55450. * @returns the sphere mesh
  55451. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55452. */
  55453. static CreateSphere(name: string, options: {
  55454. segments?: number;
  55455. diameter?: number;
  55456. diameterX?: number;
  55457. diameterY?: number;
  55458. diameterZ?: number;
  55459. arc?: number;
  55460. slice?: number;
  55461. sideOrientation?: number;
  55462. frontUVs?: Vector4;
  55463. backUVs?: Vector4;
  55464. updatable?: boolean;
  55465. }, scene?: Nullable<Scene>): Mesh;
  55466. /**
  55467. * Creates a plane polygonal mesh. By default, this is a disc
  55468. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55469. * * 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
  55470. * * 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
  55471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55472. * * 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
  55473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55474. * @param name defines the name of the mesh
  55475. * @param options defines the options used to create the mesh
  55476. * @param scene defines the hosting scene
  55477. * @returns the plane polygonal mesh
  55478. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55479. */
  55480. static CreateDisc(name: string, options: {
  55481. radius?: number;
  55482. tessellation?: number;
  55483. arc?: number;
  55484. updatable?: boolean;
  55485. sideOrientation?: number;
  55486. frontUVs?: Vector4;
  55487. backUVs?: Vector4;
  55488. }, scene?: Nullable<Scene>): Mesh;
  55489. /**
  55490. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55491. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55492. * * 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`)
  55493. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55494. * * 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
  55495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55496. * * 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
  55497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55498. * @param name defines the name of the mesh
  55499. * @param options defines the options used to create the mesh
  55500. * @param scene defines the hosting scene
  55501. * @returns the icosahedron mesh
  55502. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55503. */
  55504. static CreateIcoSphere(name: string, options: {
  55505. radius?: number;
  55506. radiusX?: number;
  55507. radiusY?: number;
  55508. radiusZ?: number;
  55509. flat?: boolean;
  55510. subdivisions?: number;
  55511. sideOrientation?: number;
  55512. frontUVs?: Vector4;
  55513. backUVs?: Vector4;
  55514. updatable?: boolean;
  55515. }, scene?: Nullable<Scene>): Mesh;
  55516. /**
  55517. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55518. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55519. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55520. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55521. * * 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
  55522. * * 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
  55523. * * 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
  55524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55525. * * 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
  55526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55527. * * 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
  55528. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55529. * * 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
  55530. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55532. * @param name defines the name of the mesh
  55533. * @param options defines the options used to create the mesh
  55534. * @param scene defines the hosting scene
  55535. * @returns the ribbon mesh
  55536. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55537. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55538. */
  55539. static CreateRibbon(name: string, options: {
  55540. pathArray: Vector3[][];
  55541. closeArray?: boolean;
  55542. closePath?: boolean;
  55543. offset?: number;
  55544. updatable?: boolean;
  55545. sideOrientation?: number;
  55546. frontUVs?: Vector4;
  55547. backUVs?: Vector4;
  55548. instance?: Mesh;
  55549. invertUV?: boolean;
  55550. uvs?: Vector2[];
  55551. colors?: Color4[];
  55552. }, scene?: Nullable<Scene>): Mesh;
  55553. /**
  55554. * Creates a cylinder or a cone mesh
  55555. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55556. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55557. * * 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.
  55558. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55559. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55560. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55561. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55562. * * 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).
  55563. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55564. * * 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).
  55565. * * 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
  55566. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55567. * * 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
  55568. * * 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.
  55569. * * If `enclose` is false, a ring surface is one element.
  55570. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55571. * * 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
  55572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55573. * * 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
  55574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55575. * @param name defines the name of the mesh
  55576. * @param options defines the options used to create the mesh
  55577. * @param scene defines the hosting scene
  55578. * @returns the cylinder mesh
  55579. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55580. */
  55581. static CreateCylinder(name: string, options: {
  55582. height?: number;
  55583. diameterTop?: number;
  55584. diameterBottom?: number;
  55585. diameter?: number;
  55586. tessellation?: number;
  55587. subdivisions?: number;
  55588. arc?: number;
  55589. faceColors?: Color4[];
  55590. faceUV?: Vector4[];
  55591. updatable?: boolean;
  55592. hasRings?: boolean;
  55593. enclose?: boolean;
  55594. cap?: number;
  55595. sideOrientation?: number;
  55596. frontUVs?: Vector4;
  55597. backUVs?: Vector4;
  55598. }, scene?: Nullable<Scene>): Mesh;
  55599. /**
  55600. * Creates a torus mesh
  55601. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55602. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55603. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55605. * * 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
  55606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55607. * @param name defines the name of the mesh
  55608. * @param options defines the options used to create the mesh
  55609. * @param scene defines the hosting scene
  55610. * @returns the torus mesh
  55611. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55612. */
  55613. static CreateTorus(name: string, options: {
  55614. diameter?: number;
  55615. thickness?: number;
  55616. tessellation?: number;
  55617. updatable?: boolean;
  55618. sideOrientation?: number;
  55619. frontUVs?: Vector4;
  55620. backUVs?: Vector4;
  55621. }, scene?: Nullable<Scene>): Mesh;
  55622. /**
  55623. * Creates a torus knot mesh
  55624. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55625. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55626. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55627. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55629. * * 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
  55630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55631. * @param name defines the name of the mesh
  55632. * @param options defines the options used to create the mesh
  55633. * @param scene defines the hosting scene
  55634. * @returns the torus knot mesh
  55635. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55636. */
  55637. static CreateTorusKnot(name: string, options: {
  55638. radius?: number;
  55639. tube?: number;
  55640. radialSegments?: number;
  55641. tubularSegments?: number;
  55642. p?: number;
  55643. q?: number;
  55644. updatable?: boolean;
  55645. sideOrientation?: number;
  55646. frontUVs?: Vector4;
  55647. backUVs?: Vector4;
  55648. }, scene?: Nullable<Scene>): Mesh;
  55649. /**
  55650. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55651. * * 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
  55652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55653. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55654. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55655. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55656. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55657. * * 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
  55658. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55661. * @param name defines the name of the new line system
  55662. * @param options defines the options used to create the line system
  55663. * @param scene defines the hosting scene
  55664. * @returns a new line system mesh
  55665. */
  55666. static CreateLineSystem(name: string, options: {
  55667. lines: Vector3[][];
  55668. updatable?: boolean;
  55669. instance?: Nullable<LinesMesh>;
  55670. colors?: Nullable<Color4[][]>;
  55671. useVertexAlpha?: boolean;
  55672. }, scene: Nullable<Scene>): LinesMesh;
  55673. /**
  55674. * Creates a line mesh
  55675. * 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
  55676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55677. * * The parameter `points` is an array successive Vector3
  55678. * * 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
  55679. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55680. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55681. * * When updating an instance, remember that only point positions can change, not the number of points
  55682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55684. * @param name defines the name of the new line system
  55685. * @param options defines the options used to create the line system
  55686. * @param scene defines the hosting scene
  55687. * @returns a new line mesh
  55688. */
  55689. static CreateLines(name: string, options: {
  55690. points: Vector3[];
  55691. updatable?: boolean;
  55692. instance?: Nullable<LinesMesh>;
  55693. colors?: Color4[];
  55694. useVertexAlpha?: boolean;
  55695. }, scene?: Nullable<Scene>): LinesMesh;
  55696. /**
  55697. * Creates a dashed line mesh
  55698. * * 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
  55699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55700. * * The parameter `points` is an array successive Vector3
  55701. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55702. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55703. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55704. * * 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
  55705. * * When updating an instance, remember that only point positions can change, not the number of points
  55706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55707. * @param name defines the name of the mesh
  55708. * @param options defines the options used to create the mesh
  55709. * @param scene defines the hosting scene
  55710. * @returns the dashed line mesh
  55711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55712. */
  55713. static CreateDashedLines(name: string, options: {
  55714. points: Vector3[];
  55715. dashSize?: number;
  55716. gapSize?: number;
  55717. dashNb?: number;
  55718. updatable?: boolean;
  55719. instance?: LinesMesh;
  55720. }, scene?: Nullable<Scene>): LinesMesh;
  55721. /**
  55722. * 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.
  55723. * * 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.
  55724. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55725. * * 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.
  55726. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55727. * * 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
  55728. * * 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
  55729. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55731. * * 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
  55732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55734. * @param name defines the name of the mesh
  55735. * @param options defines the options used to create the mesh
  55736. * @param scene defines the hosting scene
  55737. * @returns the extruded shape mesh
  55738. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55740. */
  55741. static ExtrudeShape(name: string, options: {
  55742. shape: Vector3[];
  55743. path: Vector3[];
  55744. scale?: number;
  55745. rotation?: number;
  55746. cap?: number;
  55747. updatable?: boolean;
  55748. sideOrientation?: number;
  55749. frontUVs?: Vector4;
  55750. backUVs?: Vector4;
  55751. instance?: Mesh;
  55752. invertUV?: boolean;
  55753. }, scene?: Nullable<Scene>): Mesh;
  55754. /**
  55755. * Creates an custom extruded shape mesh.
  55756. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55757. * * 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.
  55758. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55759. * * 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
  55760. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55761. * * 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
  55762. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55763. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55764. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55765. * * 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
  55766. * * 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
  55767. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55769. * * 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
  55770. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55772. * @param name defines the name of the mesh
  55773. * @param options defines the options used to create the mesh
  55774. * @param scene defines the hosting scene
  55775. * @returns the custom extruded shape mesh
  55776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55777. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55779. */
  55780. static ExtrudeShapeCustom(name: string, options: {
  55781. shape: Vector3[];
  55782. path: Vector3[];
  55783. scaleFunction?: any;
  55784. rotationFunction?: any;
  55785. ribbonCloseArray?: boolean;
  55786. ribbonClosePath?: boolean;
  55787. cap?: number;
  55788. updatable?: boolean;
  55789. sideOrientation?: number;
  55790. frontUVs?: Vector4;
  55791. backUVs?: Vector4;
  55792. instance?: Mesh;
  55793. invertUV?: boolean;
  55794. }, scene?: Nullable<Scene>): Mesh;
  55795. /**
  55796. * Creates lathe mesh.
  55797. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55798. * * 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
  55799. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55800. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55801. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55802. * * 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
  55803. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55804. * * 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
  55805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55806. * * 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
  55807. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55809. * @param name defines the name of the mesh
  55810. * @param options defines the options used to create the mesh
  55811. * @param scene defines the hosting scene
  55812. * @returns the lathe mesh
  55813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55814. */
  55815. static CreateLathe(name: string, options: {
  55816. shape: Vector3[];
  55817. radius?: number;
  55818. tessellation?: number;
  55819. clip?: number;
  55820. arc?: number;
  55821. closed?: boolean;
  55822. updatable?: boolean;
  55823. sideOrientation?: number;
  55824. frontUVs?: Vector4;
  55825. backUVs?: Vector4;
  55826. cap?: number;
  55827. invertUV?: boolean;
  55828. }, scene?: Nullable<Scene>): Mesh;
  55829. /**
  55830. * Creates a tiled plane mesh
  55831. * * You can set a limited pattern arrangement with the tiles
  55832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55833. * * 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
  55834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55835. * @param name defines the name of the mesh
  55836. * @param options defines the options used to create the mesh
  55837. * @param scene defines the hosting scene
  55838. * @returns the plane mesh
  55839. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55840. */
  55841. static CreateTiledPlane(name: string, options: {
  55842. pattern?: number;
  55843. tileSize?: number;
  55844. tileWidth?: number;
  55845. tileHeight?: number;
  55846. size?: number;
  55847. width?: number;
  55848. height?: number;
  55849. alignHorizontal?: number;
  55850. alignVertical?: number;
  55851. sideOrientation?: number;
  55852. frontUVs?: Vector4;
  55853. backUVs?: Vector4;
  55854. updatable?: boolean;
  55855. }, scene?: Nullable<Scene>): Mesh;
  55856. /**
  55857. * Creates a plane mesh
  55858. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55859. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55860. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55862. * * 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
  55863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55864. * @param name defines the name of the mesh
  55865. * @param options defines the options used to create the mesh
  55866. * @param scene defines the hosting scene
  55867. * @returns the plane mesh
  55868. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55869. */
  55870. static CreatePlane(name: string, options: {
  55871. size?: number;
  55872. width?: number;
  55873. height?: number;
  55874. sideOrientation?: number;
  55875. frontUVs?: Vector4;
  55876. backUVs?: Vector4;
  55877. updatable?: boolean;
  55878. sourcePlane?: Plane;
  55879. }, scene?: Nullable<Scene>): Mesh;
  55880. /**
  55881. * Creates a ground mesh
  55882. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55883. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55885. * @param name defines the name of the mesh
  55886. * @param options defines the options used to create the mesh
  55887. * @param scene defines the hosting scene
  55888. * @returns the ground mesh
  55889. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55890. */
  55891. static CreateGround(name: string, options: {
  55892. width?: number;
  55893. height?: number;
  55894. subdivisions?: number;
  55895. subdivisionsX?: number;
  55896. subdivisionsY?: number;
  55897. updatable?: boolean;
  55898. }, scene?: Nullable<Scene>): Mesh;
  55899. /**
  55900. * Creates a tiled ground mesh
  55901. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55902. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55903. * * 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
  55904. * * 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
  55905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55906. * @param name defines the name of the mesh
  55907. * @param options defines the options used to create the mesh
  55908. * @param scene defines the hosting scene
  55909. * @returns the tiled ground mesh
  55910. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55911. */
  55912. static CreateTiledGround(name: string, options: {
  55913. xmin: number;
  55914. zmin: number;
  55915. xmax: number;
  55916. zmax: number;
  55917. subdivisions?: {
  55918. w: number;
  55919. h: number;
  55920. };
  55921. precision?: {
  55922. w: number;
  55923. h: number;
  55924. };
  55925. updatable?: boolean;
  55926. }, scene?: Nullable<Scene>): Mesh;
  55927. /**
  55928. * Creates a ground mesh from a height map
  55929. * * The parameter `url` sets the URL of the height map image resource.
  55930. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55931. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55932. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55933. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55934. * * 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.
  55935. * * 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).
  55936. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55938. * @param name defines the name of the mesh
  55939. * @param url defines the url to the height map
  55940. * @param options defines the options used to create the mesh
  55941. * @param scene defines the hosting scene
  55942. * @returns the ground mesh
  55943. * @see https://doc.babylonjs.com/babylon101/height_map
  55944. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55945. */
  55946. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55947. width?: number;
  55948. height?: number;
  55949. subdivisions?: number;
  55950. minHeight?: number;
  55951. maxHeight?: number;
  55952. colorFilter?: Color3;
  55953. alphaFilter?: number;
  55954. updatable?: boolean;
  55955. onReady?: (mesh: GroundMesh) => void;
  55956. }, scene?: Nullable<Scene>): GroundMesh;
  55957. /**
  55958. * Creates a polygon mesh
  55959. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55960. * * 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
  55961. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55963. * * 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)
  55964. * * Remember you can only change the shape positions, not their number when updating a polygon
  55965. * @param name defines the name of the mesh
  55966. * @param options defines the options used to create the mesh
  55967. * @param scene defines the hosting scene
  55968. * @param earcutInjection can be used to inject your own earcut reference
  55969. * @returns the polygon mesh
  55970. */
  55971. static CreatePolygon(name: string, options: {
  55972. shape: Vector3[];
  55973. holes?: Vector3[][];
  55974. depth?: number;
  55975. faceUV?: Vector4[];
  55976. faceColors?: Color4[];
  55977. updatable?: boolean;
  55978. sideOrientation?: number;
  55979. frontUVs?: Vector4;
  55980. backUVs?: Vector4;
  55981. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55982. /**
  55983. * Creates an extruded polygon mesh, with depth in the Y direction.
  55984. * * 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)
  55985. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55986. * @param name defines the name of the mesh
  55987. * @param options defines the options used to create the mesh
  55988. * @param scene defines the hosting scene
  55989. * @param earcutInjection can be used to inject your own earcut reference
  55990. * @returns the polygon mesh
  55991. */
  55992. static ExtrudePolygon(name: string, options: {
  55993. shape: Vector3[];
  55994. holes?: Vector3[][];
  55995. depth?: number;
  55996. faceUV?: Vector4[];
  55997. faceColors?: Color4[];
  55998. updatable?: boolean;
  55999. sideOrientation?: number;
  56000. frontUVs?: Vector4;
  56001. backUVs?: Vector4;
  56002. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56003. /**
  56004. * Creates a tube mesh.
  56005. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56006. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56007. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56008. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56009. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56010. * * 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)
  56011. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56012. * * 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
  56013. * * 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
  56014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56015. * * 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
  56016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56018. * @param name defines the name of the mesh
  56019. * @param options defines the options used to create the mesh
  56020. * @param scene defines the hosting scene
  56021. * @returns the tube mesh
  56022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56023. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56024. */
  56025. static CreateTube(name: string, options: {
  56026. path: Vector3[];
  56027. radius?: number;
  56028. tessellation?: number;
  56029. radiusFunction?: {
  56030. (i: number, distance: number): number;
  56031. };
  56032. cap?: number;
  56033. arc?: number;
  56034. updatable?: boolean;
  56035. sideOrientation?: number;
  56036. frontUVs?: Vector4;
  56037. backUVs?: Vector4;
  56038. instance?: Mesh;
  56039. invertUV?: boolean;
  56040. }, scene?: Nullable<Scene>): Mesh;
  56041. /**
  56042. * Creates a polyhedron mesh
  56043. * * 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
  56044. * * The parameter `size` (positive float, default 1) sets the polygon size
  56045. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56046. * * 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`
  56047. * * 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
  56048. * * 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)`)
  56049. * * 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
  56050. * * 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
  56051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56052. * * 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
  56053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56054. * @param name defines the name of the mesh
  56055. * @param options defines the options used to create the mesh
  56056. * @param scene defines the hosting scene
  56057. * @returns the polyhedron mesh
  56058. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56059. */
  56060. static CreatePolyhedron(name: string, options: {
  56061. type?: number;
  56062. size?: number;
  56063. sizeX?: number;
  56064. sizeY?: number;
  56065. sizeZ?: number;
  56066. custom?: any;
  56067. faceUV?: Vector4[];
  56068. faceColors?: Color4[];
  56069. flat?: boolean;
  56070. updatable?: boolean;
  56071. sideOrientation?: number;
  56072. frontUVs?: Vector4;
  56073. backUVs?: Vector4;
  56074. }, scene?: Nullable<Scene>): Mesh;
  56075. /**
  56076. * Creates a decal mesh.
  56077. * 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
  56078. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56079. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56080. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56081. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56082. * @param name defines the name of the mesh
  56083. * @param sourceMesh defines the mesh where the decal must be applied
  56084. * @param options defines the options used to create the mesh
  56085. * @param scene defines the hosting scene
  56086. * @returns the decal mesh
  56087. * @see https://doc.babylonjs.com/how_to/decals
  56088. */
  56089. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56090. position?: Vector3;
  56091. normal?: Vector3;
  56092. size?: Vector3;
  56093. angle?: number;
  56094. }): Mesh;
  56095. }
  56096. }
  56097. declare module BABYLON {
  56098. /**
  56099. * A simplifier interface for future simplification implementations
  56100. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56101. */
  56102. export interface ISimplifier {
  56103. /**
  56104. * Simplification of a given mesh according to the given settings.
  56105. * Since this requires computation, it is assumed that the function runs async.
  56106. * @param settings The settings of the simplification, including quality and distance
  56107. * @param successCallback A callback that will be called after the mesh was simplified.
  56108. * @param errorCallback in case of an error, this callback will be called. optional.
  56109. */
  56110. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56111. }
  56112. /**
  56113. * Expected simplification settings.
  56114. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56116. */
  56117. export interface ISimplificationSettings {
  56118. /**
  56119. * Gets or sets the expected quality
  56120. */
  56121. quality: number;
  56122. /**
  56123. * Gets or sets the distance when this optimized version should be used
  56124. */
  56125. distance: number;
  56126. /**
  56127. * Gets an already optimized mesh
  56128. */
  56129. optimizeMesh?: boolean;
  56130. }
  56131. /**
  56132. * Class used to specify simplification options
  56133. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56134. */
  56135. export class SimplificationSettings implements ISimplificationSettings {
  56136. /** expected quality */
  56137. quality: number;
  56138. /** distance when this optimized version should be used */
  56139. distance: number;
  56140. /** already optimized mesh */
  56141. optimizeMesh?: boolean | undefined;
  56142. /**
  56143. * Creates a SimplificationSettings
  56144. * @param quality expected quality
  56145. * @param distance distance when this optimized version should be used
  56146. * @param optimizeMesh already optimized mesh
  56147. */
  56148. constructor(
  56149. /** expected quality */
  56150. quality: number,
  56151. /** distance when this optimized version should be used */
  56152. distance: number,
  56153. /** already optimized mesh */
  56154. optimizeMesh?: boolean | undefined);
  56155. }
  56156. /**
  56157. * Interface used to define a simplification task
  56158. */
  56159. export interface ISimplificationTask {
  56160. /**
  56161. * Array of settings
  56162. */
  56163. settings: Array<ISimplificationSettings>;
  56164. /**
  56165. * Simplification type
  56166. */
  56167. simplificationType: SimplificationType;
  56168. /**
  56169. * Mesh to simplify
  56170. */
  56171. mesh: Mesh;
  56172. /**
  56173. * Callback called on success
  56174. */
  56175. successCallback?: () => void;
  56176. /**
  56177. * Defines if parallel processing can be used
  56178. */
  56179. parallelProcessing: boolean;
  56180. }
  56181. /**
  56182. * Queue used to order the simplification tasks
  56183. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56184. */
  56185. export class SimplificationQueue {
  56186. private _simplificationArray;
  56187. /**
  56188. * Gets a boolean indicating that the process is still running
  56189. */
  56190. running: boolean;
  56191. /**
  56192. * Creates a new queue
  56193. */
  56194. constructor();
  56195. /**
  56196. * Adds a new simplification task
  56197. * @param task defines a task to add
  56198. */
  56199. addTask(task: ISimplificationTask): void;
  56200. /**
  56201. * Execute next task
  56202. */
  56203. executeNext(): void;
  56204. /**
  56205. * Execute a simplification task
  56206. * @param task defines the task to run
  56207. */
  56208. runSimplification(task: ISimplificationTask): void;
  56209. private getSimplifier;
  56210. }
  56211. /**
  56212. * The implemented types of simplification
  56213. * At the moment only Quadratic Error Decimation is implemented
  56214. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56215. */
  56216. export enum SimplificationType {
  56217. /** Quadratic error decimation */
  56218. QUADRATIC = 0
  56219. }
  56220. }
  56221. declare module BABYLON {
  56222. interface Scene {
  56223. /** @hidden (Backing field) */
  56224. _simplificationQueue: SimplificationQueue;
  56225. /**
  56226. * Gets or sets the simplification queue attached to the scene
  56227. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56228. */
  56229. simplificationQueue: SimplificationQueue;
  56230. }
  56231. interface Mesh {
  56232. /**
  56233. * Simplify the mesh according to the given array of settings.
  56234. * Function will return immediately and will simplify async
  56235. * @param settings a collection of simplification settings
  56236. * @param parallelProcessing should all levels calculate parallel or one after the other
  56237. * @param simplificationType the type of simplification to run
  56238. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56239. * @returns the current mesh
  56240. */
  56241. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56242. }
  56243. /**
  56244. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56245. * created in a scene
  56246. */
  56247. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56248. /**
  56249. * The component name helpfull to identify the component in the list of scene components.
  56250. */
  56251. readonly name: string;
  56252. /**
  56253. * The scene the component belongs to.
  56254. */
  56255. scene: Scene;
  56256. /**
  56257. * Creates a new instance of the component for the given scene
  56258. * @param scene Defines the scene to register the component in
  56259. */
  56260. constructor(scene: Scene);
  56261. /**
  56262. * Registers the component in a given scene
  56263. */
  56264. register(): void;
  56265. /**
  56266. * Rebuilds the elements related to this component in case of
  56267. * context lost for instance.
  56268. */
  56269. rebuild(): void;
  56270. /**
  56271. * Disposes the component and the associated ressources
  56272. */
  56273. dispose(): void;
  56274. private _beforeCameraUpdate;
  56275. }
  56276. }
  56277. declare module BABYLON {
  56278. /**
  56279. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56280. */
  56281. export interface INavigationEnginePlugin {
  56282. /**
  56283. * plugin name
  56284. */
  56285. name: string;
  56286. /**
  56287. * Creates a navigation mesh
  56288. * @param meshes array of all the geometry used to compute the navigatio mesh
  56289. * @param parameters bunch of parameters used to filter geometry
  56290. */
  56291. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56292. /**
  56293. * Create a navigation mesh debug mesh
  56294. * @param scene is where the mesh will be added
  56295. * @returns debug display mesh
  56296. */
  56297. createDebugNavMesh(scene: Scene): Mesh;
  56298. /**
  56299. * Get a navigation mesh constrained position, closest to the parameter position
  56300. * @param position world position
  56301. * @returns the closest point to position constrained by the navigation mesh
  56302. */
  56303. getClosestPoint(position: Vector3): Vector3;
  56304. /**
  56305. * Get a navigation mesh constrained position, within a particular radius
  56306. * @param position world position
  56307. * @param maxRadius the maximum distance to the constrained world position
  56308. * @returns the closest point to position constrained by the navigation mesh
  56309. */
  56310. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56311. /**
  56312. * Compute the final position from a segment made of destination-position
  56313. * @param position world position
  56314. * @param destination world position
  56315. * @returns the resulting point along the navmesh
  56316. */
  56317. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56318. /**
  56319. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56320. * @param start world position
  56321. * @param end world position
  56322. * @returns array containing world position composing the path
  56323. */
  56324. computePath(start: Vector3, end: Vector3): Vector3[];
  56325. /**
  56326. * If this plugin is supported
  56327. * @returns true if plugin is supported
  56328. */
  56329. isSupported(): boolean;
  56330. /**
  56331. * Create a new Crowd so you can add agents
  56332. * @param maxAgents the maximum agent count in the crowd
  56333. * @param maxAgentRadius the maximum radius an agent can have
  56334. * @param scene to attach the crowd to
  56335. * @returns the crowd you can add agents to
  56336. */
  56337. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56338. /**
  56339. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56340. * The queries will try to find a solution within those bounds
  56341. * default is (1,1,1)
  56342. * @param extent x,y,z value that define the extent around the queries point of reference
  56343. */
  56344. setDefaultQueryExtent(extent: Vector3): void;
  56345. /**
  56346. * Get the Bounding box extent specified by setDefaultQueryExtent
  56347. * @returns the box extent values
  56348. */
  56349. getDefaultQueryExtent(): Vector3;
  56350. /**
  56351. * Release all resources
  56352. */
  56353. dispose(): void;
  56354. }
  56355. /**
  56356. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56357. */
  56358. export interface ICrowd {
  56359. /**
  56360. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56361. * You can attach anything to that node. The node position is updated in the scene update tick.
  56362. * @param pos world position that will be constrained by the navigation mesh
  56363. * @param parameters agent parameters
  56364. * @param transform hooked to the agent that will be update by the scene
  56365. * @returns agent index
  56366. */
  56367. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56368. /**
  56369. * Returns the agent position in world space
  56370. * @param index agent index returned by addAgent
  56371. * @returns world space position
  56372. */
  56373. getAgentPosition(index: number): Vector3;
  56374. /**
  56375. * Gets the agent velocity in world space
  56376. * @param index agent index returned by addAgent
  56377. * @returns world space velocity
  56378. */
  56379. getAgentVelocity(index: number): Vector3;
  56380. /**
  56381. * remove a particular agent previously created
  56382. * @param index agent index returned by addAgent
  56383. */
  56384. removeAgent(index: number): void;
  56385. /**
  56386. * get the list of all agents attached to this crowd
  56387. * @returns list of agent indices
  56388. */
  56389. getAgents(): number[];
  56390. /**
  56391. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56392. * @param deltaTime in seconds
  56393. */
  56394. update(deltaTime: number): void;
  56395. /**
  56396. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56397. * @param index agent index returned by addAgent
  56398. * @param destination targeted world position
  56399. */
  56400. agentGoto(index: number, destination: Vector3): void;
  56401. /**
  56402. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56403. * The queries will try to find a solution within those bounds
  56404. * default is (1,1,1)
  56405. * @param extent x,y,z value that define the extent around the queries point of reference
  56406. */
  56407. setDefaultQueryExtent(extent: Vector3): void;
  56408. /**
  56409. * Get the Bounding box extent specified by setDefaultQueryExtent
  56410. * @returns the box extent values
  56411. */
  56412. getDefaultQueryExtent(): Vector3;
  56413. /**
  56414. * Release all resources
  56415. */
  56416. dispose(): void;
  56417. }
  56418. /**
  56419. * Configures an agent
  56420. */
  56421. export interface IAgentParameters {
  56422. /**
  56423. * Agent radius. [Limit: >= 0]
  56424. */
  56425. radius: number;
  56426. /**
  56427. * Agent height. [Limit: > 0]
  56428. */
  56429. height: number;
  56430. /**
  56431. * Maximum allowed acceleration. [Limit: >= 0]
  56432. */
  56433. maxAcceleration: number;
  56434. /**
  56435. * Maximum allowed speed. [Limit: >= 0]
  56436. */
  56437. maxSpeed: number;
  56438. /**
  56439. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56440. */
  56441. collisionQueryRange: number;
  56442. /**
  56443. * The path visibility optimization range. [Limit: > 0]
  56444. */
  56445. pathOptimizationRange: number;
  56446. /**
  56447. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56448. */
  56449. separationWeight: number;
  56450. }
  56451. /**
  56452. * Configures the navigation mesh creation
  56453. */
  56454. export interface INavMeshParameters {
  56455. /**
  56456. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56457. */
  56458. cs: number;
  56459. /**
  56460. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56461. */
  56462. ch: number;
  56463. /**
  56464. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56465. */
  56466. walkableSlopeAngle: number;
  56467. /**
  56468. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56469. * be considered walkable. [Limit: >= 3] [Units: vx]
  56470. */
  56471. walkableHeight: number;
  56472. /**
  56473. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56474. */
  56475. walkableClimb: number;
  56476. /**
  56477. * The distance to erode/shrink the walkable area of the heightfield away from
  56478. * obstructions. [Limit: >=0] [Units: vx]
  56479. */
  56480. walkableRadius: number;
  56481. /**
  56482. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56483. */
  56484. maxEdgeLen: number;
  56485. /**
  56486. * The maximum distance a simplfied contour's border edges should deviate
  56487. * the original raw contour. [Limit: >=0] [Units: vx]
  56488. */
  56489. maxSimplificationError: number;
  56490. /**
  56491. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56492. */
  56493. minRegionArea: number;
  56494. /**
  56495. * Any regions with a span count smaller than this value will, if possible,
  56496. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56497. */
  56498. mergeRegionArea: number;
  56499. /**
  56500. * The maximum number of vertices allowed for polygons generated during the
  56501. * contour to polygon conversion process. [Limit: >= 3]
  56502. */
  56503. maxVertsPerPoly: number;
  56504. /**
  56505. * Sets the sampling distance to use when generating the detail mesh.
  56506. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56507. */
  56508. detailSampleDist: number;
  56509. /**
  56510. * The maximum distance the detail mesh surface should deviate from heightfield
  56511. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56512. */
  56513. detailSampleMaxError: number;
  56514. }
  56515. }
  56516. declare module BABYLON {
  56517. /**
  56518. * RecastJS navigation plugin
  56519. */
  56520. export class RecastJSPlugin implements INavigationEnginePlugin {
  56521. /**
  56522. * Reference to the Recast library
  56523. */
  56524. bjsRECAST: any;
  56525. /**
  56526. * plugin name
  56527. */
  56528. name: string;
  56529. /**
  56530. * the first navmesh created. We might extend this to support multiple navmeshes
  56531. */
  56532. navMesh: any;
  56533. /**
  56534. * Initializes the recastJS plugin
  56535. * @param recastInjection can be used to inject your own recast reference
  56536. */
  56537. constructor(recastInjection?: any);
  56538. /**
  56539. * Creates a navigation mesh
  56540. * @param meshes array of all the geometry used to compute the navigatio mesh
  56541. * @param parameters bunch of parameters used to filter geometry
  56542. */
  56543. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56544. /**
  56545. * Create a navigation mesh debug mesh
  56546. * @param scene is where the mesh will be added
  56547. * @returns debug display mesh
  56548. */
  56549. createDebugNavMesh(scene: Scene): Mesh;
  56550. /**
  56551. * Get a navigation mesh constrained position, closest to the parameter position
  56552. * @param position world position
  56553. * @returns the closest point to position constrained by the navigation mesh
  56554. */
  56555. getClosestPoint(position: Vector3): Vector3;
  56556. /**
  56557. * Get a navigation mesh constrained position, within a particular radius
  56558. * @param position world position
  56559. * @param maxRadius the maximum distance to the constrained world position
  56560. * @returns the closest point to position constrained by the navigation mesh
  56561. */
  56562. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56563. /**
  56564. * Compute the final position from a segment made of destination-position
  56565. * @param position world position
  56566. * @param destination world position
  56567. * @returns the resulting point along the navmesh
  56568. */
  56569. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56570. /**
  56571. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56572. * @param start world position
  56573. * @param end world position
  56574. * @returns array containing world position composing the path
  56575. */
  56576. computePath(start: Vector3, end: Vector3): Vector3[];
  56577. /**
  56578. * Create a new Crowd so you can add agents
  56579. * @param maxAgents the maximum agent count in the crowd
  56580. * @param maxAgentRadius the maximum radius an agent can have
  56581. * @param scene to attach the crowd to
  56582. * @returns the crowd you can add agents to
  56583. */
  56584. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56585. /**
  56586. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56587. * The queries will try to find a solution within those bounds
  56588. * default is (1,1,1)
  56589. * @param extent x,y,z value that define the extent around the queries point of reference
  56590. */
  56591. setDefaultQueryExtent(extent: Vector3): void;
  56592. /**
  56593. * Get the Bounding box extent specified by setDefaultQueryExtent
  56594. * @returns the box extent values
  56595. */
  56596. getDefaultQueryExtent(): Vector3;
  56597. /**
  56598. * Disposes
  56599. */
  56600. dispose(): void;
  56601. /**
  56602. * If this plugin is supported
  56603. * @returns true if plugin is supported
  56604. */
  56605. isSupported(): boolean;
  56606. }
  56607. /**
  56608. * Recast detour crowd implementation
  56609. */
  56610. export class RecastJSCrowd implements ICrowd {
  56611. /**
  56612. * Recast/detour plugin
  56613. */
  56614. bjsRECASTPlugin: RecastJSPlugin;
  56615. /**
  56616. * Link to the detour crowd
  56617. */
  56618. recastCrowd: any;
  56619. /**
  56620. * One transform per agent
  56621. */
  56622. transforms: TransformNode[];
  56623. /**
  56624. * All agents created
  56625. */
  56626. agents: number[];
  56627. /**
  56628. * Link to the scene is kept to unregister the crowd from the scene
  56629. */
  56630. private _scene;
  56631. /**
  56632. * Observer for crowd updates
  56633. */
  56634. private _onBeforeAnimationsObserver;
  56635. /**
  56636. * Constructor
  56637. * @param plugin recastJS plugin
  56638. * @param maxAgents the maximum agent count in the crowd
  56639. * @param maxAgentRadius the maximum radius an agent can have
  56640. * @param scene to attach the crowd to
  56641. * @returns the crowd you can add agents to
  56642. */
  56643. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56644. /**
  56645. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56646. * You can attach anything to that node. The node position is updated in the scene update tick.
  56647. * @param pos world position that will be constrained by the navigation mesh
  56648. * @param parameters agent parameters
  56649. * @param transform hooked to the agent that will be update by the scene
  56650. * @returns agent index
  56651. */
  56652. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56653. /**
  56654. * Returns the agent position in world space
  56655. * @param index agent index returned by addAgent
  56656. * @returns world space position
  56657. */
  56658. getAgentPosition(index: number): Vector3;
  56659. /**
  56660. * Returns the agent velocity in world space
  56661. * @param index agent index returned by addAgent
  56662. * @returns world space velocity
  56663. */
  56664. getAgentVelocity(index: number): Vector3;
  56665. /**
  56666. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56667. * @param index agent index returned by addAgent
  56668. * @param destination targeted world position
  56669. */
  56670. agentGoto(index: number, destination: Vector3): void;
  56671. /**
  56672. * remove a particular agent previously created
  56673. * @param index agent index returned by addAgent
  56674. */
  56675. removeAgent(index: number): void;
  56676. /**
  56677. * get the list of all agents attached to this crowd
  56678. * @returns list of agent indices
  56679. */
  56680. getAgents(): number[];
  56681. /**
  56682. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56683. * @param deltaTime in seconds
  56684. */
  56685. update(deltaTime: number): void;
  56686. /**
  56687. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56688. * The queries will try to find a solution within those bounds
  56689. * default is (1,1,1)
  56690. * @param extent x,y,z value that define the extent around the queries point of reference
  56691. */
  56692. setDefaultQueryExtent(extent: Vector3): void;
  56693. /**
  56694. * Get the Bounding box extent specified by setDefaultQueryExtent
  56695. * @returns the box extent values
  56696. */
  56697. getDefaultQueryExtent(): Vector3;
  56698. /**
  56699. * Release all resources
  56700. */
  56701. dispose(): void;
  56702. }
  56703. }
  56704. declare module BABYLON {
  56705. /**
  56706. * Class used to enable access to IndexedDB
  56707. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56708. */
  56709. export class Database implements IOfflineProvider {
  56710. private _callbackManifestChecked;
  56711. private _currentSceneUrl;
  56712. private _db;
  56713. private _enableSceneOffline;
  56714. private _enableTexturesOffline;
  56715. private _manifestVersionFound;
  56716. private _mustUpdateRessources;
  56717. private _hasReachedQuota;
  56718. private _isSupported;
  56719. private _idbFactory;
  56720. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56721. private static IsUASupportingBlobStorage;
  56722. /**
  56723. * Gets a boolean indicating if Database storate is enabled (off by default)
  56724. */
  56725. static IDBStorageEnabled: boolean;
  56726. /**
  56727. * Gets a boolean indicating if scene must be saved in the database
  56728. */
  56729. readonly enableSceneOffline: boolean;
  56730. /**
  56731. * Gets a boolean indicating if textures must be saved in the database
  56732. */
  56733. readonly enableTexturesOffline: boolean;
  56734. /**
  56735. * Creates a new Database
  56736. * @param urlToScene defines the url to load the scene
  56737. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56738. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56739. */
  56740. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56741. private static _ParseURL;
  56742. private static _ReturnFullUrlLocation;
  56743. private _checkManifestFile;
  56744. /**
  56745. * Open the database and make it available
  56746. * @param successCallback defines the callback to call on success
  56747. * @param errorCallback defines the callback to call on error
  56748. */
  56749. open(successCallback: () => void, errorCallback: () => void): void;
  56750. /**
  56751. * Loads an image from the database
  56752. * @param url defines the url to load from
  56753. * @param image defines the target DOM image
  56754. */
  56755. loadImage(url: string, image: HTMLImageElement): void;
  56756. private _loadImageFromDBAsync;
  56757. private _saveImageIntoDBAsync;
  56758. private _checkVersionFromDB;
  56759. private _loadVersionFromDBAsync;
  56760. private _saveVersionIntoDBAsync;
  56761. /**
  56762. * Loads a file from database
  56763. * @param url defines the URL to load from
  56764. * @param sceneLoaded defines a callback to call on success
  56765. * @param progressCallBack defines a callback to call when progress changed
  56766. * @param errorCallback defines a callback to call on error
  56767. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56768. */
  56769. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56770. private _loadFileAsync;
  56771. private _saveFileAsync;
  56772. /**
  56773. * Validates if xhr data is correct
  56774. * @param xhr defines the request to validate
  56775. * @param dataType defines the expected data type
  56776. * @returns true if data is correct
  56777. */
  56778. private static _ValidateXHRData;
  56779. }
  56780. }
  56781. declare module BABYLON {
  56782. /** @hidden */
  56783. export var gpuUpdateParticlesPixelShader: {
  56784. name: string;
  56785. shader: string;
  56786. };
  56787. }
  56788. declare module BABYLON {
  56789. /** @hidden */
  56790. export var gpuUpdateParticlesVertexShader: {
  56791. name: string;
  56792. shader: string;
  56793. };
  56794. }
  56795. declare module BABYLON {
  56796. /** @hidden */
  56797. export var clipPlaneFragmentDeclaration2: {
  56798. name: string;
  56799. shader: string;
  56800. };
  56801. }
  56802. declare module BABYLON {
  56803. /** @hidden */
  56804. export var gpuRenderParticlesPixelShader: {
  56805. name: string;
  56806. shader: string;
  56807. };
  56808. }
  56809. declare module BABYLON {
  56810. /** @hidden */
  56811. export var clipPlaneVertexDeclaration2: {
  56812. name: string;
  56813. shader: string;
  56814. };
  56815. }
  56816. declare module BABYLON {
  56817. /** @hidden */
  56818. export var gpuRenderParticlesVertexShader: {
  56819. name: string;
  56820. shader: string;
  56821. };
  56822. }
  56823. declare module BABYLON {
  56824. /**
  56825. * This represents a GPU particle system in Babylon
  56826. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56827. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56828. */
  56829. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56830. /**
  56831. * The layer mask we are rendering the particles through.
  56832. */
  56833. layerMask: number;
  56834. private _capacity;
  56835. private _activeCount;
  56836. private _currentActiveCount;
  56837. private _accumulatedCount;
  56838. private _renderEffect;
  56839. private _updateEffect;
  56840. private _buffer0;
  56841. private _buffer1;
  56842. private _spriteBuffer;
  56843. private _updateVAO;
  56844. private _renderVAO;
  56845. private _targetIndex;
  56846. private _sourceBuffer;
  56847. private _targetBuffer;
  56848. private _engine;
  56849. private _currentRenderId;
  56850. private _started;
  56851. private _stopped;
  56852. private _timeDelta;
  56853. private _randomTexture;
  56854. private _randomTexture2;
  56855. private _attributesStrideSize;
  56856. private _updateEffectOptions;
  56857. private _randomTextureSize;
  56858. private _actualFrame;
  56859. private readonly _rawTextureWidth;
  56860. /**
  56861. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56862. */
  56863. static readonly IsSupported: boolean;
  56864. /**
  56865. * An event triggered when the system is disposed.
  56866. */
  56867. onDisposeObservable: Observable<GPUParticleSystem>;
  56868. /**
  56869. * Gets the maximum number of particles active at the same time.
  56870. * @returns The max number of active particles.
  56871. */
  56872. getCapacity(): number;
  56873. /**
  56874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56875. * to override the particles.
  56876. */
  56877. forceDepthWrite: boolean;
  56878. /**
  56879. * Gets or set the number of active particles
  56880. */
  56881. activeParticleCount: number;
  56882. private _preWarmDone;
  56883. /**
  56884. * Is this system ready to be used/rendered
  56885. * @return true if the system is ready
  56886. */
  56887. isReady(): boolean;
  56888. /**
  56889. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56890. * @returns True if it has been started, otherwise false.
  56891. */
  56892. isStarted(): boolean;
  56893. /**
  56894. * Starts the particle system and begins to emit
  56895. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56896. */
  56897. start(delay?: number): void;
  56898. /**
  56899. * Stops the particle system.
  56900. */
  56901. stop(): void;
  56902. /**
  56903. * Remove all active particles
  56904. */
  56905. reset(): void;
  56906. /**
  56907. * Returns the string "GPUParticleSystem"
  56908. * @returns a string containing the class name
  56909. */
  56910. getClassName(): string;
  56911. private _colorGradientsTexture;
  56912. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56913. /**
  56914. * Adds a new color gradient
  56915. * @param gradient defines the gradient to use (between 0 and 1)
  56916. * @param color1 defines the color to affect to the specified gradient
  56917. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56918. * @returns the current particle system
  56919. */
  56920. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56921. /**
  56922. * Remove a specific color gradient
  56923. * @param gradient defines the gradient to remove
  56924. * @returns the current particle system
  56925. */
  56926. removeColorGradient(gradient: number): GPUParticleSystem;
  56927. private _angularSpeedGradientsTexture;
  56928. private _sizeGradientsTexture;
  56929. private _velocityGradientsTexture;
  56930. private _limitVelocityGradientsTexture;
  56931. private _dragGradientsTexture;
  56932. private _addFactorGradient;
  56933. /**
  56934. * Adds a new size gradient
  56935. * @param gradient defines the gradient to use (between 0 and 1)
  56936. * @param factor defines the size factor to affect to the specified gradient
  56937. * @returns the current particle system
  56938. */
  56939. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56940. /**
  56941. * Remove a specific size gradient
  56942. * @param gradient defines the gradient to remove
  56943. * @returns the current particle system
  56944. */
  56945. removeSizeGradient(gradient: number): GPUParticleSystem;
  56946. /**
  56947. * Adds a new angular speed gradient
  56948. * @param gradient defines the gradient to use (between 0 and 1)
  56949. * @param factor defines the angular speed to affect to the specified gradient
  56950. * @returns the current particle system
  56951. */
  56952. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56953. /**
  56954. * Remove a specific angular speed gradient
  56955. * @param gradient defines the gradient to remove
  56956. * @returns the current particle system
  56957. */
  56958. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56959. /**
  56960. * Adds a new velocity gradient
  56961. * @param gradient defines the gradient to use (between 0 and 1)
  56962. * @param factor defines the velocity to affect to the specified gradient
  56963. * @returns the current particle system
  56964. */
  56965. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56966. /**
  56967. * Remove a specific velocity gradient
  56968. * @param gradient defines the gradient to remove
  56969. * @returns the current particle system
  56970. */
  56971. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56972. /**
  56973. * Adds a new limit velocity gradient
  56974. * @param gradient defines the gradient to use (between 0 and 1)
  56975. * @param factor defines the limit velocity value to affect to the specified gradient
  56976. * @returns the current particle system
  56977. */
  56978. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56979. /**
  56980. * Remove a specific limit velocity gradient
  56981. * @param gradient defines the gradient to remove
  56982. * @returns the current particle system
  56983. */
  56984. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56985. /**
  56986. * Adds a new drag gradient
  56987. * @param gradient defines the gradient to use (between 0 and 1)
  56988. * @param factor defines the drag value to affect to the specified gradient
  56989. * @returns the current particle system
  56990. */
  56991. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56992. /**
  56993. * Remove a specific drag gradient
  56994. * @param gradient defines the gradient to remove
  56995. * @returns the current particle system
  56996. */
  56997. removeDragGradient(gradient: number): GPUParticleSystem;
  56998. /**
  56999. * Not supported by GPUParticleSystem
  57000. * @param gradient defines the gradient to use (between 0 and 1)
  57001. * @param factor defines the emit rate value to affect to the specified gradient
  57002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57003. * @returns the current particle system
  57004. */
  57005. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57006. /**
  57007. * Not supported by GPUParticleSystem
  57008. * @param gradient defines the gradient to remove
  57009. * @returns the current particle system
  57010. */
  57011. removeEmitRateGradient(gradient: number): IParticleSystem;
  57012. /**
  57013. * Not supported by GPUParticleSystem
  57014. * @param gradient defines the gradient to use (between 0 and 1)
  57015. * @param factor defines the start size value to affect to the specified gradient
  57016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57017. * @returns the current particle system
  57018. */
  57019. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57020. /**
  57021. * Not supported by GPUParticleSystem
  57022. * @param gradient defines the gradient to remove
  57023. * @returns the current particle system
  57024. */
  57025. removeStartSizeGradient(gradient: number): IParticleSystem;
  57026. /**
  57027. * Not supported by GPUParticleSystem
  57028. * @param gradient defines the gradient to use (between 0 and 1)
  57029. * @param min defines the color remap minimal range
  57030. * @param max defines the color remap maximal range
  57031. * @returns the current particle system
  57032. */
  57033. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57034. /**
  57035. * Not supported by GPUParticleSystem
  57036. * @param gradient defines the gradient to remove
  57037. * @returns the current particle system
  57038. */
  57039. removeColorRemapGradient(): IParticleSystem;
  57040. /**
  57041. * Not supported by GPUParticleSystem
  57042. * @param gradient defines the gradient to use (between 0 and 1)
  57043. * @param min defines the alpha remap minimal range
  57044. * @param max defines the alpha remap maximal range
  57045. * @returns the current particle system
  57046. */
  57047. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57048. /**
  57049. * Not supported by GPUParticleSystem
  57050. * @param gradient defines the gradient to remove
  57051. * @returns the current particle system
  57052. */
  57053. removeAlphaRemapGradient(): IParticleSystem;
  57054. /**
  57055. * Not supported by GPUParticleSystem
  57056. * @param gradient defines the gradient to use (between 0 and 1)
  57057. * @param color defines the color to affect to the specified gradient
  57058. * @returns the current particle system
  57059. */
  57060. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57061. /**
  57062. * Not supported by GPUParticleSystem
  57063. * @param gradient defines the gradient to remove
  57064. * @returns the current particle system
  57065. */
  57066. removeRampGradient(): IParticleSystem;
  57067. /**
  57068. * Not supported by GPUParticleSystem
  57069. * @returns the list of ramp gradients
  57070. */
  57071. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57072. /**
  57073. * Not supported by GPUParticleSystem
  57074. * Gets or sets a boolean indicating that ramp gradients must be used
  57075. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57076. */
  57077. useRampGradients: boolean;
  57078. /**
  57079. * Not supported by GPUParticleSystem
  57080. * @param gradient defines the gradient to use (between 0 and 1)
  57081. * @param factor defines the life time factor to affect to the specified gradient
  57082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57083. * @returns the current particle system
  57084. */
  57085. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57086. /**
  57087. * Not supported by GPUParticleSystem
  57088. * @param gradient defines the gradient to remove
  57089. * @returns the current particle system
  57090. */
  57091. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57092. /**
  57093. * Instantiates a GPU particle system.
  57094. * 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.
  57095. * @param name The name of the particle system
  57096. * @param options The options used to create the system
  57097. * @param scene The scene the particle system belongs to
  57098. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57099. */
  57100. constructor(name: string, options: Partial<{
  57101. capacity: number;
  57102. randomTextureSize: number;
  57103. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57104. protected _reset(): void;
  57105. private _createUpdateVAO;
  57106. private _createRenderVAO;
  57107. private _initialize;
  57108. /** @hidden */
  57109. _recreateUpdateEffect(): void;
  57110. /** @hidden */
  57111. _recreateRenderEffect(): void;
  57112. /**
  57113. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57114. * @param preWarm defines if we are in the pre-warmimg phase
  57115. */
  57116. animate(preWarm?: boolean): void;
  57117. private _createFactorGradientTexture;
  57118. private _createSizeGradientTexture;
  57119. private _createAngularSpeedGradientTexture;
  57120. private _createVelocityGradientTexture;
  57121. private _createLimitVelocityGradientTexture;
  57122. private _createDragGradientTexture;
  57123. private _createColorGradientTexture;
  57124. /**
  57125. * Renders the particle system in its current state
  57126. * @param preWarm defines if the system should only update the particles but not render them
  57127. * @returns the current number of particles
  57128. */
  57129. render(preWarm?: boolean): number;
  57130. /**
  57131. * Rebuilds the particle system
  57132. */
  57133. rebuild(): void;
  57134. private _releaseBuffers;
  57135. private _releaseVAOs;
  57136. /**
  57137. * Disposes the particle system and free the associated resources
  57138. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57139. */
  57140. dispose(disposeTexture?: boolean): void;
  57141. /**
  57142. * Clones the particle system.
  57143. * @param name The name of the cloned object
  57144. * @param newEmitter The new emitter to use
  57145. * @returns the cloned particle system
  57146. */
  57147. clone(name: string, newEmitter: any): GPUParticleSystem;
  57148. /**
  57149. * Serializes the particle system to a JSON object.
  57150. * @returns the JSON object
  57151. */
  57152. serialize(): any;
  57153. /**
  57154. * Parses a JSON object to create a GPU particle system.
  57155. * @param parsedParticleSystem The JSON object to parse
  57156. * @param scene The scene to create the particle system in
  57157. * @param rootUrl The root url to use to load external dependencies like texture
  57158. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57159. * @returns the parsed GPU particle system
  57160. */
  57161. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57162. }
  57163. }
  57164. declare module BABYLON {
  57165. /**
  57166. * Represents a set of particle systems working together to create a specific effect
  57167. */
  57168. export class ParticleSystemSet implements IDisposable {
  57169. private _emitterCreationOptions;
  57170. private _emitterNode;
  57171. /**
  57172. * Gets the particle system list
  57173. */
  57174. systems: IParticleSystem[];
  57175. /**
  57176. * Gets the emitter node used with this set
  57177. */
  57178. readonly emitterNode: Nullable<TransformNode>;
  57179. /**
  57180. * Creates a new emitter mesh as a sphere
  57181. * @param options defines the options used to create the sphere
  57182. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57183. * @param scene defines the hosting scene
  57184. */
  57185. setEmitterAsSphere(options: {
  57186. diameter: number;
  57187. segments: number;
  57188. color: Color3;
  57189. }, renderingGroupId: number, scene: Scene): void;
  57190. /**
  57191. * Starts all particle systems of the set
  57192. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57193. */
  57194. start(emitter?: AbstractMesh): void;
  57195. /**
  57196. * Release all associated resources
  57197. */
  57198. dispose(): void;
  57199. /**
  57200. * Serialize the set into a JSON compatible object
  57201. * @returns a JSON compatible representation of the set
  57202. */
  57203. serialize(): any;
  57204. /**
  57205. * Parse a new ParticleSystemSet from a serialized source
  57206. * @param data defines a JSON compatible representation of the set
  57207. * @param scene defines the hosting scene
  57208. * @param gpu defines if we want GPU particles or CPU particles
  57209. * @returns a new ParticleSystemSet
  57210. */
  57211. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57212. }
  57213. }
  57214. declare module BABYLON {
  57215. /**
  57216. * This class is made for on one-liner static method to help creating particle system set.
  57217. */
  57218. export class ParticleHelper {
  57219. /**
  57220. * Gets or sets base Assets URL
  57221. */
  57222. static BaseAssetsUrl: string;
  57223. /**
  57224. * Create a default particle system that you can tweak
  57225. * @param emitter defines the emitter to use
  57226. * @param capacity defines the system capacity (default is 500 particles)
  57227. * @param scene defines the hosting scene
  57228. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57229. * @returns the new Particle system
  57230. */
  57231. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57232. /**
  57233. * This is the main static method (one-liner) of this helper to create different particle systems
  57234. * @param type This string represents the type to the particle system to create
  57235. * @param scene The scene where the particle system should live
  57236. * @param gpu If the system will use gpu
  57237. * @returns the ParticleSystemSet created
  57238. */
  57239. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57240. /**
  57241. * Static function used to export a particle system to a ParticleSystemSet variable.
  57242. * Please note that the emitter shape is not exported
  57243. * @param systems defines the particle systems to export
  57244. * @returns the created particle system set
  57245. */
  57246. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57247. }
  57248. }
  57249. declare module BABYLON {
  57250. interface Engine {
  57251. /**
  57252. * Create an effect to use with particle systems.
  57253. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57254. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57255. * @param uniformsNames defines a list of attribute names
  57256. * @param samplers defines an array of string used to represent textures
  57257. * @param defines defines the string containing the defines to use to compile the shaders
  57258. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57259. * @param onCompiled defines a function to call when the effect creation is successful
  57260. * @param onError defines a function to call when the effect creation has failed
  57261. * @returns the new Effect
  57262. */
  57263. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57264. }
  57265. interface Mesh {
  57266. /**
  57267. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57268. * @returns an array of IParticleSystem
  57269. */
  57270. getEmittedParticleSystems(): IParticleSystem[];
  57271. /**
  57272. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57273. * @returns an array of IParticleSystem
  57274. */
  57275. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57276. }
  57277. /**
  57278. * @hidden
  57279. */
  57280. export var _IDoNeedToBeInTheBuild: number;
  57281. }
  57282. declare module BABYLON {
  57283. interface Scene {
  57284. /** @hidden (Backing field) */
  57285. _physicsEngine: Nullable<IPhysicsEngine>;
  57286. /**
  57287. * Gets the current physics engine
  57288. * @returns a IPhysicsEngine or null if none attached
  57289. */
  57290. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57291. /**
  57292. * Enables physics to the current scene
  57293. * @param gravity defines the scene's gravity for the physics engine
  57294. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57295. * @return a boolean indicating if the physics engine was initialized
  57296. */
  57297. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57298. /**
  57299. * Disables and disposes the physics engine associated with the scene
  57300. */
  57301. disablePhysicsEngine(): void;
  57302. /**
  57303. * Gets a boolean indicating if there is an active physics engine
  57304. * @returns a boolean indicating if there is an active physics engine
  57305. */
  57306. isPhysicsEnabled(): boolean;
  57307. /**
  57308. * Deletes a physics compound impostor
  57309. * @param compound defines the compound to delete
  57310. */
  57311. deleteCompoundImpostor(compound: any): void;
  57312. /**
  57313. * An event triggered when physic simulation is about to be run
  57314. */
  57315. onBeforePhysicsObservable: Observable<Scene>;
  57316. /**
  57317. * An event triggered when physic simulation has been done
  57318. */
  57319. onAfterPhysicsObservable: Observable<Scene>;
  57320. }
  57321. interface AbstractMesh {
  57322. /** @hidden */
  57323. _physicsImpostor: Nullable<PhysicsImpostor>;
  57324. /**
  57325. * Gets or sets impostor used for physic simulation
  57326. * @see http://doc.babylonjs.com/features/physics_engine
  57327. */
  57328. physicsImpostor: Nullable<PhysicsImpostor>;
  57329. /**
  57330. * Gets the current physics impostor
  57331. * @see http://doc.babylonjs.com/features/physics_engine
  57332. * @returns a physics impostor or null
  57333. */
  57334. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57335. /** Apply a physic impulse to the mesh
  57336. * @param force defines the force to apply
  57337. * @param contactPoint defines where to apply the force
  57338. * @returns the current mesh
  57339. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57340. */
  57341. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57342. /**
  57343. * Creates a physic joint between two meshes
  57344. * @param otherMesh defines the other mesh to use
  57345. * @param pivot1 defines the pivot to use on this mesh
  57346. * @param pivot2 defines the pivot to use on the other mesh
  57347. * @param options defines additional options (can be plugin dependent)
  57348. * @returns the current mesh
  57349. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57350. */
  57351. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57352. /** @hidden */
  57353. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57354. }
  57355. /**
  57356. * Defines the physics engine scene component responsible to manage a physics engine
  57357. */
  57358. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57359. /**
  57360. * The component name helpful to identify the component in the list of scene components.
  57361. */
  57362. readonly name: string;
  57363. /**
  57364. * The scene the component belongs to.
  57365. */
  57366. scene: Scene;
  57367. /**
  57368. * Creates a new instance of the component for the given scene
  57369. * @param scene Defines the scene to register the component in
  57370. */
  57371. constructor(scene: Scene);
  57372. /**
  57373. * Registers the component in a given scene
  57374. */
  57375. register(): void;
  57376. /**
  57377. * Rebuilds the elements related to this component in case of
  57378. * context lost for instance.
  57379. */
  57380. rebuild(): void;
  57381. /**
  57382. * Disposes the component and the associated ressources
  57383. */
  57384. dispose(): void;
  57385. }
  57386. }
  57387. declare module BABYLON {
  57388. /**
  57389. * A helper for physics simulations
  57390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57391. */
  57392. export class PhysicsHelper {
  57393. private _scene;
  57394. private _physicsEngine;
  57395. /**
  57396. * Initializes the Physics helper
  57397. * @param scene Babylon.js scene
  57398. */
  57399. constructor(scene: Scene);
  57400. /**
  57401. * Applies a radial explosion impulse
  57402. * @param origin the origin of the explosion
  57403. * @param radiusOrEventOptions the radius or the options of radial explosion
  57404. * @param strength the explosion strength
  57405. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57406. * @returns A physics radial explosion event, or null
  57407. */
  57408. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57409. /**
  57410. * Applies a radial explosion force
  57411. * @param origin the origin of the explosion
  57412. * @param radiusOrEventOptions the radius or the options of radial explosion
  57413. * @param strength the explosion strength
  57414. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57415. * @returns A physics radial explosion event, or null
  57416. */
  57417. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57418. /**
  57419. * Creates a gravitational field
  57420. * @param origin the origin of the explosion
  57421. * @param radiusOrEventOptions the radius or the options of radial explosion
  57422. * @param strength the explosion strength
  57423. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57424. * @returns A physics gravitational field event, or null
  57425. */
  57426. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57427. /**
  57428. * Creates a physics updraft event
  57429. * @param origin the origin of the updraft
  57430. * @param radiusOrEventOptions the radius or the options of the updraft
  57431. * @param strength the strength of the updraft
  57432. * @param height the height of the updraft
  57433. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57434. * @returns A physics updraft event, or null
  57435. */
  57436. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57437. /**
  57438. * Creates a physics vortex event
  57439. * @param origin the of the vortex
  57440. * @param radiusOrEventOptions the radius or the options of the vortex
  57441. * @param strength the strength of the vortex
  57442. * @param height the height of the vortex
  57443. * @returns a Physics vortex event, or null
  57444. * A physics vortex event or null
  57445. */
  57446. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57447. }
  57448. /**
  57449. * Represents a physics radial explosion event
  57450. */
  57451. class PhysicsRadialExplosionEvent {
  57452. private _scene;
  57453. private _options;
  57454. private _sphere;
  57455. private _dataFetched;
  57456. /**
  57457. * Initializes a radial explosioin event
  57458. * @param _scene BabylonJS scene
  57459. * @param _options The options for the vortex event
  57460. */
  57461. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57462. /**
  57463. * Returns the data related to the radial explosion event (sphere).
  57464. * @returns The radial explosion event data
  57465. */
  57466. getData(): PhysicsRadialExplosionEventData;
  57467. /**
  57468. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57469. * @param impostor A physics imposter
  57470. * @param origin the origin of the explosion
  57471. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57472. */
  57473. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57474. /**
  57475. * Triggers affecterd impostors callbacks
  57476. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57477. */
  57478. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57479. /**
  57480. * Disposes the sphere.
  57481. * @param force Specifies if the sphere should be disposed by force
  57482. */
  57483. dispose(force?: boolean): void;
  57484. /*** Helpers ***/
  57485. private _prepareSphere;
  57486. private _intersectsWithSphere;
  57487. }
  57488. /**
  57489. * Represents a gravitational field event
  57490. */
  57491. class PhysicsGravitationalFieldEvent {
  57492. private _physicsHelper;
  57493. private _scene;
  57494. private _origin;
  57495. private _options;
  57496. private _tickCallback;
  57497. private _sphere;
  57498. private _dataFetched;
  57499. /**
  57500. * Initializes the physics gravitational field event
  57501. * @param _physicsHelper A physics helper
  57502. * @param _scene BabylonJS scene
  57503. * @param _origin The origin position of the gravitational field event
  57504. * @param _options The options for the vortex event
  57505. */
  57506. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57507. /**
  57508. * Returns the data related to the gravitational field event (sphere).
  57509. * @returns A gravitational field event
  57510. */
  57511. getData(): PhysicsGravitationalFieldEventData;
  57512. /**
  57513. * Enables the gravitational field.
  57514. */
  57515. enable(): void;
  57516. /**
  57517. * Disables the gravitational field.
  57518. */
  57519. disable(): void;
  57520. /**
  57521. * Disposes the sphere.
  57522. * @param force The force to dispose from the gravitational field event
  57523. */
  57524. dispose(force?: boolean): void;
  57525. private _tick;
  57526. }
  57527. /**
  57528. * Represents a physics updraft event
  57529. */
  57530. class PhysicsUpdraftEvent {
  57531. private _scene;
  57532. private _origin;
  57533. private _options;
  57534. private _physicsEngine;
  57535. private _originTop;
  57536. private _originDirection;
  57537. private _tickCallback;
  57538. private _cylinder;
  57539. private _cylinderPosition;
  57540. private _dataFetched;
  57541. /**
  57542. * Initializes the physics updraft event
  57543. * @param _scene BabylonJS scene
  57544. * @param _origin The origin position of the updraft
  57545. * @param _options The options for the updraft event
  57546. */
  57547. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57548. /**
  57549. * Returns the data related to the updraft event (cylinder).
  57550. * @returns A physics updraft event
  57551. */
  57552. getData(): PhysicsUpdraftEventData;
  57553. /**
  57554. * Enables the updraft.
  57555. */
  57556. enable(): void;
  57557. /**
  57558. * Disables the updraft.
  57559. */
  57560. disable(): void;
  57561. /**
  57562. * Disposes the cylinder.
  57563. * @param force Specifies if the updraft should be disposed by force
  57564. */
  57565. dispose(force?: boolean): void;
  57566. private getImpostorHitData;
  57567. private _tick;
  57568. /*** Helpers ***/
  57569. private _prepareCylinder;
  57570. private _intersectsWithCylinder;
  57571. }
  57572. /**
  57573. * Represents a physics vortex event
  57574. */
  57575. class PhysicsVortexEvent {
  57576. private _scene;
  57577. private _origin;
  57578. private _options;
  57579. private _physicsEngine;
  57580. private _originTop;
  57581. private _tickCallback;
  57582. private _cylinder;
  57583. private _cylinderPosition;
  57584. private _dataFetched;
  57585. /**
  57586. * Initializes the physics vortex event
  57587. * @param _scene The BabylonJS scene
  57588. * @param _origin The origin position of the vortex
  57589. * @param _options The options for the vortex event
  57590. */
  57591. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57592. /**
  57593. * Returns the data related to the vortex event (cylinder).
  57594. * @returns The physics vortex event data
  57595. */
  57596. getData(): PhysicsVortexEventData;
  57597. /**
  57598. * Enables the vortex.
  57599. */
  57600. enable(): void;
  57601. /**
  57602. * Disables the cortex.
  57603. */
  57604. disable(): void;
  57605. /**
  57606. * Disposes the sphere.
  57607. * @param force
  57608. */
  57609. dispose(force?: boolean): void;
  57610. private getImpostorHitData;
  57611. private _tick;
  57612. /*** Helpers ***/
  57613. private _prepareCylinder;
  57614. private _intersectsWithCylinder;
  57615. }
  57616. /**
  57617. * Options fot the radial explosion event
  57618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57619. */
  57620. export class PhysicsRadialExplosionEventOptions {
  57621. /**
  57622. * The radius of the sphere for the radial explosion.
  57623. */
  57624. radius: number;
  57625. /**
  57626. * The strenth of the explosion.
  57627. */
  57628. strength: number;
  57629. /**
  57630. * The strenght of the force in correspondence to the distance of the affected object
  57631. */
  57632. falloff: PhysicsRadialImpulseFalloff;
  57633. /**
  57634. * Sphere options for the radial explosion.
  57635. */
  57636. sphere: {
  57637. segments: number;
  57638. diameter: number;
  57639. };
  57640. /**
  57641. * Sphere options for the radial explosion.
  57642. */
  57643. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57644. }
  57645. /**
  57646. * Options fot the updraft event
  57647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57648. */
  57649. export class PhysicsUpdraftEventOptions {
  57650. /**
  57651. * The radius of the cylinder for the vortex
  57652. */
  57653. radius: number;
  57654. /**
  57655. * The strenth of the updraft.
  57656. */
  57657. strength: number;
  57658. /**
  57659. * The height of the cylinder for the updraft.
  57660. */
  57661. height: number;
  57662. /**
  57663. * The mode for the the updraft.
  57664. */
  57665. updraftMode: PhysicsUpdraftMode;
  57666. }
  57667. /**
  57668. * Options fot the vortex event
  57669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57670. */
  57671. export class PhysicsVortexEventOptions {
  57672. /**
  57673. * The radius of the cylinder for the vortex
  57674. */
  57675. radius: number;
  57676. /**
  57677. * The strenth of the vortex.
  57678. */
  57679. strength: number;
  57680. /**
  57681. * The height of the cylinder for the vortex.
  57682. */
  57683. height: number;
  57684. /**
  57685. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57686. */
  57687. centripetalForceThreshold: number;
  57688. /**
  57689. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57690. */
  57691. centripetalForceMultiplier: number;
  57692. /**
  57693. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57694. */
  57695. centrifugalForceMultiplier: number;
  57696. /**
  57697. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57698. */
  57699. updraftForceMultiplier: number;
  57700. }
  57701. /**
  57702. * The strenght of the force in correspondence to the distance of the affected object
  57703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57704. */
  57705. export enum PhysicsRadialImpulseFalloff {
  57706. /** Defines that impulse is constant in strength across it's whole radius */
  57707. Constant = 0,
  57708. /** Defines that impulse gets weaker if it's further from the origin */
  57709. Linear = 1
  57710. }
  57711. /**
  57712. * The strength of the force in correspondence to the distance of the affected object
  57713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57714. */
  57715. export enum PhysicsUpdraftMode {
  57716. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57717. Center = 0,
  57718. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57719. Perpendicular = 1
  57720. }
  57721. /**
  57722. * Interface for a physics hit data
  57723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57724. */
  57725. export interface PhysicsHitData {
  57726. /**
  57727. * The force applied at the contact point
  57728. */
  57729. force: Vector3;
  57730. /**
  57731. * The contact point
  57732. */
  57733. contactPoint: Vector3;
  57734. /**
  57735. * The distance from the origin to the contact point
  57736. */
  57737. distanceFromOrigin: number;
  57738. }
  57739. /**
  57740. * Interface for radial explosion event data
  57741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57742. */
  57743. export interface PhysicsRadialExplosionEventData {
  57744. /**
  57745. * A sphere used for the radial explosion event
  57746. */
  57747. sphere: Mesh;
  57748. }
  57749. /**
  57750. * Interface for gravitational field event data
  57751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57752. */
  57753. export interface PhysicsGravitationalFieldEventData {
  57754. /**
  57755. * A sphere mesh used for the gravitational field event
  57756. */
  57757. sphere: Mesh;
  57758. }
  57759. /**
  57760. * Interface for updraft event data
  57761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57762. */
  57763. export interface PhysicsUpdraftEventData {
  57764. /**
  57765. * A cylinder used for the updraft event
  57766. */
  57767. cylinder: Mesh;
  57768. }
  57769. /**
  57770. * Interface for vortex event data
  57771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57772. */
  57773. export interface PhysicsVortexEventData {
  57774. /**
  57775. * A cylinder used for the vortex event
  57776. */
  57777. cylinder: Mesh;
  57778. }
  57779. /**
  57780. * Interface for an affected physics impostor
  57781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57782. */
  57783. export interface PhysicsAffectedImpostorWithData {
  57784. /**
  57785. * The impostor affected by the effect
  57786. */
  57787. impostor: PhysicsImpostor;
  57788. /**
  57789. * The data about the hit/horce from the explosion
  57790. */
  57791. hitData: PhysicsHitData;
  57792. }
  57793. }
  57794. declare module BABYLON {
  57795. /** @hidden */
  57796. export var blackAndWhitePixelShader: {
  57797. name: string;
  57798. shader: string;
  57799. };
  57800. }
  57801. declare module BABYLON {
  57802. /**
  57803. * Post process used to render in black and white
  57804. */
  57805. export class BlackAndWhitePostProcess extends PostProcess {
  57806. /**
  57807. * Linear about to convert he result to black and white (default: 1)
  57808. */
  57809. degree: number;
  57810. /**
  57811. * Creates a black and white post process
  57812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57813. * @param name The name of the effect.
  57814. * @param options The required width/height ratio to downsize to before computing the render pass.
  57815. * @param camera The camera to apply the render pass to.
  57816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57817. * @param engine The engine which the post process will be applied. (default: current engine)
  57818. * @param reusable If the post process can be reused on the same frame. (default: false)
  57819. */
  57820. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57821. }
  57822. }
  57823. declare module BABYLON {
  57824. /**
  57825. * This represents a set of one or more post processes in Babylon.
  57826. * A post process can be used to apply a shader to a texture after it is rendered.
  57827. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57828. */
  57829. export class PostProcessRenderEffect {
  57830. private _postProcesses;
  57831. private _getPostProcesses;
  57832. private _singleInstance;
  57833. private _cameras;
  57834. private _indicesForCamera;
  57835. /**
  57836. * Name of the effect
  57837. * @hidden
  57838. */
  57839. _name: string;
  57840. /**
  57841. * Instantiates a post process render effect.
  57842. * A post process can be used to apply a shader to a texture after it is rendered.
  57843. * @param engine The engine the effect is tied to
  57844. * @param name The name of the effect
  57845. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57846. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57847. */
  57848. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57849. /**
  57850. * Checks if all the post processes in the effect are supported.
  57851. */
  57852. readonly isSupported: boolean;
  57853. /**
  57854. * Updates the current state of the effect
  57855. * @hidden
  57856. */
  57857. _update(): void;
  57858. /**
  57859. * Attaches the effect on cameras
  57860. * @param cameras The camera to attach to.
  57861. * @hidden
  57862. */
  57863. _attachCameras(cameras: Camera): void;
  57864. /**
  57865. * Attaches the effect on cameras
  57866. * @param cameras The camera to attach to.
  57867. * @hidden
  57868. */
  57869. _attachCameras(cameras: Camera[]): void;
  57870. /**
  57871. * Detaches the effect on cameras
  57872. * @param cameras The camera to detatch from.
  57873. * @hidden
  57874. */
  57875. _detachCameras(cameras: Camera): void;
  57876. /**
  57877. * Detatches the effect on cameras
  57878. * @param cameras The camera to detatch from.
  57879. * @hidden
  57880. */
  57881. _detachCameras(cameras: Camera[]): void;
  57882. /**
  57883. * Enables the effect on given cameras
  57884. * @param cameras The camera to enable.
  57885. * @hidden
  57886. */
  57887. _enable(cameras: Camera): void;
  57888. /**
  57889. * Enables the effect on given cameras
  57890. * @param cameras The camera to enable.
  57891. * @hidden
  57892. */
  57893. _enable(cameras: Nullable<Camera[]>): void;
  57894. /**
  57895. * Disables the effect on the given cameras
  57896. * @param cameras The camera to disable.
  57897. * @hidden
  57898. */
  57899. _disable(cameras: Camera): void;
  57900. /**
  57901. * Disables the effect on the given cameras
  57902. * @param cameras The camera to disable.
  57903. * @hidden
  57904. */
  57905. _disable(cameras: Nullable<Camera[]>): void;
  57906. /**
  57907. * Gets a list of the post processes contained in the effect.
  57908. * @param camera The camera to get the post processes on.
  57909. * @returns The list of the post processes in the effect.
  57910. */
  57911. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57912. }
  57913. }
  57914. declare module BABYLON {
  57915. /** @hidden */
  57916. export var extractHighlightsPixelShader: {
  57917. name: string;
  57918. shader: string;
  57919. };
  57920. }
  57921. declare module BABYLON {
  57922. /**
  57923. * 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.
  57924. */
  57925. export class ExtractHighlightsPostProcess extends PostProcess {
  57926. /**
  57927. * The luminance threshold, pixels below this value will be set to black.
  57928. */
  57929. threshold: number;
  57930. /** @hidden */
  57931. _exposure: number;
  57932. /**
  57933. * Post process which has the input texture to be used when performing highlight extraction
  57934. * @hidden
  57935. */
  57936. _inputPostProcess: Nullable<PostProcess>;
  57937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57938. }
  57939. }
  57940. declare module BABYLON {
  57941. /** @hidden */
  57942. export var bloomMergePixelShader: {
  57943. name: string;
  57944. shader: string;
  57945. };
  57946. }
  57947. declare module BABYLON {
  57948. /**
  57949. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57950. */
  57951. export class BloomMergePostProcess extends PostProcess {
  57952. /** Weight of the bloom to be added to the original input. */
  57953. weight: number;
  57954. /**
  57955. * Creates a new instance of @see BloomMergePostProcess
  57956. * @param name The name of the effect.
  57957. * @param originalFromInput Post process which's input will be used for the merge.
  57958. * @param blurred Blurred highlights post process which's output will be used.
  57959. * @param weight Weight of the bloom to be added to the original input.
  57960. * @param options The required width/height ratio to downsize to before computing the render pass.
  57961. * @param camera The camera to apply the render pass to.
  57962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57963. * @param engine The engine which the post process will be applied. (default: current engine)
  57964. * @param reusable If the post process can be reused on the same frame. (default: false)
  57965. * @param textureType Type of textures used when performing the post process. (default: 0)
  57966. * @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)
  57967. */
  57968. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57969. /** Weight of the bloom to be added to the original input. */
  57970. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57971. }
  57972. }
  57973. declare module BABYLON {
  57974. /**
  57975. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57976. */
  57977. export class BloomEffect extends PostProcessRenderEffect {
  57978. private bloomScale;
  57979. /**
  57980. * @hidden Internal
  57981. */
  57982. _effects: Array<PostProcess>;
  57983. /**
  57984. * @hidden Internal
  57985. */
  57986. _downscale: ExtractHighlightsPostProcess;
  57987. private _blurX;
  57988. private _blurY;
  57989. private _merge;
  57990. /**
  57991. * The luminance threshold to find bright areas of the image to bloom.
  57992. */
  57993. threshold: number;
  57994. /**
  57995. * The strength of the bloom.
  57996. */
  57997. weight: number;
  57998. /**
  57999. * Specifies the size of the bloom blur kernel, relative to the final output size
  58000. */
  58001. kernel: number;
  58002. /**
  58003. * Creates a new instance of @see BloomEffect
  58004. * @param scene The scene the effect belongs to.
  58005. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58006. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58007. * @param bloomWeight The the strength of bloom.
  58008. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58009. * @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)
  58010. */
  58011. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58012. /**
  58013. * Disposes each of the internal effects for a given camera.
  58014. * @param camera The camera to dispose the effect on.
  58015. */
  58016. disposeEffects(camera: Camera): void;
  58017. /**
  58018. * @hidden Internal
  58019. */
  58020. _updateEffects(): void;
  58021. /**
  58022. * Internal
  58023. * @returns if all the contained post processes are ready.
  58024. * @hidden
  58025. */
  58026. _isReady(): boolean;
  58027. }
  58028. }
  58029. declare module BABYLON {
  58030. /** @hidden */
  58031. export var chromaticAberrationPixelShader: {
  58032. name: string;
  58033. shader: string;
  58034. };
  58035. }
  58036. declare module BABYLON {
  58037. /**
  58038. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58039. */
  58040. export class ChromaticAberrationPostProcess extends PostProcess {
  58041. /**
  58042. * The amount of seperation of rgb channels (default: 30)
  58043. */
  58044. aberrationAmount: number;
  58045. /**
  58046. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58047. */
  58048. radialIntensity: number;
  58049. /**
  58050. * 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))
  58051. */
  58052. direction: Vector2;
  58053. /**
  58054. * 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))
  58055. */
  58056. centerPosition: Vector2;
  58057. /**
  58058. * Creates a new instance ChromaticAberrationPostProcess
  58059. * @param name The name of the effect.
  58060. * @param screenWidth The width of the screen to apply the effect on.
  58061. * @param screenHeight The height of the screen to apply the effect on.
  58062. * @param options The required width/height ratio to downsize to before computing the render pass.
  58063. * @param camera The camera to apply the render pass to.
  58064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58065. * @param engine The engine which the post process will be applied. (default: current engine)
  58066. * @param reusable If the post process can be reused on the same frame. (default: false)
  58067. * @param textureType Type of textures used when performing the post process. (default: 0)
  58068. * @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)
  58069. */
  58070. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58071. }
  58072. }
  58073. declare module BABYLON {
  58074. /** @hidden */
  58075. export var circleOfConfusionPixelShader: {
  58076. name: string;
  58077. shader: string;
  58078. };
  58079. }
  58080. declare module BABYLON {
  58081. /**
  58082. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58083. */
  58084. export class CircleOfConfusionPostProcess extends PostProcess {
  58085. /**
  58086. * 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.
  58087. */
  58088. lensSize: number;
  58089. /**
  58090. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58091. */
  58092. fStop: number;
  58093. /**
  58094. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58095. */
  58096. focusDistance: number;
  58097. /**
  58098. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58099. */
  58100. focalLength: number;
  58101. private _depthTexture;
  58102. /**
  58103. * Creates a new instance CircleOfConfusionPostProcess
  58104. * @param name The name of the effect.
  58105. * @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.
  58106. * @param options The required width/height ratio to downsize to before computing the render pass.
  58107. * @param camera The camera to apply the render pass to.
  58108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58109. * @param engine The engine which the post process will be applied. (default: current engine)
  58110. * @param reusable If the post process can be reused on the same frame. (default: false)
  58111. * @param textureType Type of textures used when performing the post process. (default: 0)
  58112. * @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)
  58113. */
  58114. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58115. /**
  58116. * 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.
  58117. */
  58118. depthTexture: RenderTargetTexture;
  58119. }
  58120. }
  58121. declare module BABYLON {
  58122. /** @hidden */
  58123. export var colorCorrectionPixelShader: {
  58124. name: string;
  58125. shader: string;
  58126. };
  58127. }
  58128. declare module BABYLON {
  58129. /**
  58130. *
  58131. * This post-process allows the modification of rendered colors by using
  58132. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58133. *
  58134. * The object needs to be provided an url to a texture containing the color
  58135. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58136. * Use an image editing software to tweak the LUT to match your needs.
  58137. *
  58138. * For an example of a color LUT, see here:
  58139. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58140. * For explanations on color grading, see here:
  58141. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58142. *
  58143. */
  58144. export class ColorCorrectionPostProcess extends PostProcess {
  58145. private _colorTableTexture;
  58146. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58147. }
  58148. }
  58149. declare module BABYLON {
  58150. /** @hidden */
  58151. export var convolutionPixelShader: {
  58152. name: string;
  58153. shader: string;
  58154. };
  58155. }
  58156. declare module BABYLON {
  58157. /**
  58158. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58159. * input texture to perform effects such as edge detection or sharpening
  58160. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58161. */
  58162. export class ConvolutionPostProcess extends PostProcess {
  58163. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58164. kernel: number[];
  58165. /**
  58166. * Creates a new instance ConvolutionPostProcess
  58167. * @param name The name of the effect.
  58168. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58169. * @param options The required width/height ratio to downsize to before computing the render pass.
  58170. * @param camera The camera to apply the render pass to.
  58171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58172. * @param engine The engine which the post process will be applied. (default: current engine)
  58173. * @param reusable If the post process can be reused on the same frame. (default: false)
  58174. * @param textureType Type of textures used when performing the post process. (default: 0)
  58175. */
  58176. constructor(name: string,
  58177. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58178. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58179. /**
  58180. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58181. */
  58182. static EdgeDetect0Kernel: number[];
  58183. /**
  58184. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58185. */
  58186. static EdgeDetect1Kernel: number[];
  58187. /**
  58188. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58189. */
  58190. static EdgeDetect2Kernel: number[];
  58191. /**
  58192. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58193. */
  58194. static SharpenKernel: number[];
  58195. /**
  58196. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58197. */
  58198. static EmbossKernel: number[];
  58199. /**
  58200. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58201. */
  58202. static GaussianKernel: number[];
  58203. }
  58204. }
  58205. declare module BABYLON {
  58206. /**
  58207. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58208. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58209. * based on samples that have a large difference in distance than the center pixel.
  58210. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58211. */
  58212. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58213. direction: Vector2;
  58214. /**
  58215. * Creates a new instance CircleOfConfusionPostProcess
  58216. * @param name The name of the effect.
  58217. * @param scene The scene the effect belongs to.
  58218. * @param direction The direction the blur should be applied.
  58219. * @param kernel The size of the kernel used to blur.
  58220. * @param options The required width/height ratio to downsize to before computing the render pass.
  58221. * @param camera The camera to apply the render pass to.
  58222. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58223. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58225. * @param engine The engine which the post process will be applied. (default: current engine)
  58226. * @param reusable If the post process can be reused on the same frame. (default: false)
  58227. * @param textureType Type of textures used when performing the post process. (default: 0)
  58228. * @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)
  58229. */
  58230. 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);
  58231. }
  58232. }
  58233. declare module BABYLON {
  58234. /** @hidden */
  58235. export var depthOfFieldMergePixelShader: {
  58236. name: string;
  58237. shader: string;
  58238. };
  58239. }
  58240. declare module BABYLON {
  58241. /**
  58242. * Options to be set when merging outputs from the default pipeline.
  58243. */
  58244. export class DepthOfFieldMergePostProcessOptions {
  58245. /**
  58246. * The original image to merge on top of
  58247. */
  58248. originalFromInput: PostProcess;
  58249. /**
  58250. * Parameters to perform the merge of the depth of field effect
  58251. */
  58252. depthOfField?: {
  58253. circleOfConfusion: PostProcess;
  58254. blurSteps: Array<PostProcess>;
  58255. };
  58256. /**
  58257. * Parameters to perform the merge of bloom effect
  58258. */
  58259. bloom?: {
  58260. blurred: PostProcess;
  58261. weight: number;
  58262. };
  58263. }
  58264. /**
  58265. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58266. */
  58267. export class DepthOfFieldMergePostProcess extends PostProcess {
  58268. private blurSteps;
  58269. /**
  58270. * Creates a new instance of DepthOfFieldMergePostProcess
  58271. * @param name The name of the effect.
  58272. * @param originalFromInput Post process which's input will be used for the merge.
  58273. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58274. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58275. * @param options The required width/height ratio to downsize to before computing the render pass.
  58276. * @param camera The camera to apply the render pass to.
  58277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58278. * @param engine The engine which the post process will be applied. (default: current engine)
  58279. * @param reusable If the post process can be reused on the same frame. (default: false)
  58280. * @param textureType Type of textures used when performing the post process. (default: 0)
  58281. * @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)
  58282. */
  58283. 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);
  58284. /**
  58285. * Updates the effect with the current post process compile time values and recompiles the shader.
  58286. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58287. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58288. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58289. * @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
  58290. * @param onCompiled Called when the shader has been compiled.
  58291. * @param onError Called if there is an error when compiling a shader.
  58292. */
  58293. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58294. }
  58295. }
  58296. declare module BABYLON {
  58297. /**
  58298. * Specifies the level of max blur that should be applied when using the depth of field effect
  58299. */
  58300. export enum DepthOfFieldEffectBlurLevel {
  58301. /**
  58302. * Subtle blur
  58303. */
  58304. Low = 0,
  58305. /**
  58306. * Medium blur
  58307. */
  58308. Medium = 1,
  58309. /**
  58310. * Large blur
  58311. */
  58312. High = 2
  58313. }
  58314. /**
  58315. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58316. */
  58317. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58318. private _circleOfConfusion;
  58319. /**
  58320. * @hidden Internal, blurs from high to low
  58321. */
  58322. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58323. private _depthOfFieldBlurY;
  58324. private _dofMerge;
  58325. /**
  58326. * @hidden Internal post processes in depth of field effect
  58327. */
  58328. _effects: Array<PostProcess>;
  58329. /**
  58330. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58331. */
  58332. focalLength: number;
  58333. /**
  58334. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58335. */
  58336. fStop: number;
  58337. /**
  58338. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58339. */
  58340. focusDistance: number;
  58341. /**
  58342. * 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.
  58343. */
  58344. lensSize: number;
  58345. /**
  58346. * Creates a new instance DepthOfFieldEffect
  58347. * @param scene The scene the effect belongs to.
  58348. * @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.
  58349. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58350. * @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)
  58351. */
  58352. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58353. /**
  58354. * Get the current class name of the current effet
  58355. * @returns "DepthOfFieldEffect"
  58356. */
  58357. getClassName(): string;
  58358. /**
  58359. * 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.
  58360. */
  58361. depthTexture: RenderTargetTexture;
  58362. /**
  58363. * Disposes each of the internal effects for a given camera.
  58364. * @param camera The camera to dispose the effect on.
  58365. */
  58366. disposeEffects(camera: Camera): void;
  58367. /**
  58368. * @hidden Internal
  58369. */
  58370. _updateEffects(): void;
  58371. /**
  58372. * Internal
  58373. * @returns if all the contained post processes are ready.
  58374. * @hidden
  58375. */
  58376. _isReady(): boolean;
  58377. }
  58378. }
  58379. declare module BABYLON {
  58380. /** @hidden */
  58381. export var displayPassPixelShader: {
  58382. name: string;
  58383. shader: string;
  58384. };
  58385. }
  58386. declare module BABYLON {
  58387. /**
  58388. * DisplayPassPostProcess which produces an output the same as it's input
  58389. */
  58390. export class DisplayPassPostProcess extends PostProcess {
  58391. /**
  58392. * Creates the DisplayPassPostProcess
  58393. * @param name The name of the effect.
  58394. * @param options The required width/height ratio to downsize to before computing the render pass.
  58395. * @param camera The camera to apply the render pass to.
  58396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58397. * @param engine The engine which the post process will be applied. (default: current engine)
  58398. * @param reusable If the post process can be reused on the same frame. (default: false)
  58399. */
  58400. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58401. }
  58402. }
  58403. declare module BABYLON {
  58404. /** @hidden */
  58405. export var filterPixelShader: {
  58406. name: string;
  58407. shader: string;
  58408. };
  58409. }
  58410. declare module BABYLON {
  58411. /**
  58412. * Applies a kernel filter to the image
  58413. */
  58414. export class FilterPostProcess extends PostProcess {
  58415. /** The matrix to be applied to the image */
  58416. kernelMatrix: Matrix;
  58417. /**
  58418. *
  58419. * @param name The name of the effect.
  58420. * @param kernelMatrix The matrix to be applied to the image
  58421. * @param options The required width/height ratio to downsize to before computing the render pass.
  58422. * @param camera The camera to apply the render pass to.
  58423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58424. * @param engine The engine which the post process will be applied. (default: current engine)
  58425. * @param reusable If the post process can be reused on the same frame. (default: false)
  58426. */
  58427. constructor(name: string,
  58428. /** The matrix to be applied to the image */
  58429. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58430. }
  58431. }
  58432. declare module BABYLON {
  58433. /** @hidden */
  58434. export var fxaaPixelShader: {
  58435. name: string;
  58436. shader: string;
  58437. };
  58438. }
  58439. declare module BABYLON {
  58440. /** @hidden */
  58441. export var fxaaVertexShader: {
  58442. name: string;
  58443. shader: string;
  58444. };
  58445. }
  58446. declare module BABYLON {
  58447. /**
  58448. * Fxaa post process
  58449. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58450. */
  58451. export class FxaaPostProcess extends PostProcess {
  58452. /** @hidden */
  58453. texelWidth: number;
  58454. /** @hidden */
  58455. texelHeight: number;
  58456. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58457. private _getDefines;
  58458. }
  58459. }
  58460. declare module BABYLON {
  58461. /** @hidden */
  58462. export var grainPixelShader: {
  58463. name: string;
  58464. shader: string;
  58465. };
  58466. }
  58467. declare module BABYLON {
  58468. /**
  58469. * The GrainPostProcess adds noise to the image at mid luminance levels
  58470. */
  58471. export class GrainPostProcess extends PostProcess {
  58472. /**
  58473. * The intensity of the grain added (default: 30)
  58474. */
  58475. intensity: number;
  58476. /**
  58477. * If the grain should be randomized on every frame
  58478. */
  58479. animated: boolean;
  58480. /**
  58481. * Creates a new instance of @see GrainPostProcess
  58482. * @param name The name of the effect.
  58483. * @param options The required width/height ratio to downsize to before computing the render pass.
  58484. * @param camera The camera to apply the render pass to.
  58485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58486. * @param engine The engine which the post process will be applied. (default: current engine)
  58487. * @param reusable If the post process can be reused on the same frame. (default: false)
  58488. * @param textureType Type of textures used when performing the post process. (default: 0)
  58489. * @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)
  58490. */
  58491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58492. }
  58493. }
  58494. declare module BABYLON {
  58495. /** @hidden */
  58496. export var highlightsPixelShader: {
  58497. name: string;
  58498. shader: string;
  58499. };
  58500. }
  58501. declare module BABYLON {
  58502. /**
  58503. * Extracts highlights from the image
  58504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58505. */
  58506. export class HighlightsPostProcess extends PostProcess {
  58507. /**
  58508. * Extracts highlights from the image
  58509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58510. * @param name The name of the effect.
  58511. * @param options The required width/height ratio to downsize to before computing the render pass.
  58512. * @param camera The camera to apply the render pass to.
  58513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58514. * @param engine The engine which the post process will be applied. (default: current engine)
  58515. * @param reusable If the post process can be reused on the same frame. (default: false)
  58516. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58517. */
  58518. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58519. }
  58520. }
  58521. declare module BABYLON {
  58522. /** @hidden */
  58523. export var mrtFragmentDeclaration: {
  58524. name: string;
  58525. shader: string;
  58526. };
  58527. }
  58528. declare module BABYLON {
  58529. /** @hidden */
  58530. export var geometryPixelShader: {
  58531. name: string;
  58532. shader: string;
  58533. };
  58534. }
  58535. declare module BABYLON {
  58536. /** @hidden */
  58537. export var geometryVertexShader: {
  58538. name: string;
  58539. shader: string;
  58540. };
  58541. }
  58542. declare module BABYLON {
  58543. /** @hidden */
  58544. interface ISavedTransformationMatrix {
  58545. world: Matrix;
  58546. viewProjection: Matrix;
  58547. }
  58548. /**
  58549. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58550. */
  58551. export class GeometryBufferRenderer {
  58552. /**
  58553. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58554. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58555. */
  58556. static readonly POSITION_TEXTURE_TYPE: number;
  58557. /**
  58558. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58559. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58560. */
  58561. static readonly VELOCITY_TEXTURE_TYPE: number;
  58562. /**
  58563. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58564. * in order to compute objects velocities when enableVelocity is set to "true"
  58565. * @hidden
  58566. */
  58567. _previousTransformationMatrices: {
  58568. [index: number]: ISavedTransformationMatrix;
  58569. };
  58570. /**
  58571. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58572. * in order to compute objects velocities when enableVelocity is set to "true"
  58573. * @hidden
  58574. */
  58575. _previousBonesTransformationMatrices: {
  58576. [index: number]: Float32Array;
  58577. };
  58578. /**
  58579. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58580. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58581. */
  58582. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58583. private _scene;
  58584. private _multiRenderTarget;
  58585. private _ratio;
  58586. private _enablePosition;
  58587. private _enableVelocity;
  58588. private _positionIndex;
  58589. private _velocityIndex;
  58590. protected _effect: Effect;
  58591. protected _cachedDefines: string;
  58592. /**
  58593. * Set the render list (meshes to be rendered) used in the G buffer.
  58594. */
  58595. renderList: Mesh[];
  58596. /**
  58597. * Gets wether or not G buffer are supported by the running hardware.
  58598. * This requires draw buffer supports
  58599. */
  58600. readonly isSupported: boolean;
  58601. /**
  58602. * Returns the index of the given texture type in the G-Buffer textures array
  58603. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58604. * @returns the index of the given texture type in the G-Buffer textures array
  58605. */
  58606. getTextureIndex(textureType: number): number;
  58607. /**
  58608. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58609. */
  58610. /**
  58611. * Sets whether or not objects positions are enabled for the G buffer.
  58612. */
  58613. enablePosition: boolean;
  58614. /**
  58615. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58616. */
  58617. /**
  58618. * Sets wether or not objects velocities are enabled for the G buffer.
  58619. */
  58620. enableVelocity: boolean;
  58621. /**
  58622. * Gets the scene associated with the buffer.
  58623. */
  58624. readonly scene: Scene;
  58625. /**
  58626. * Gets the ratio used by the buffer during its creation.
  58627. * How big is the buffer related to the main canvas.
  58628. */
  58629. readonly ratio: number;
  58630. /** @hidden */
  58631. static _SceneComponentInitialization: (scene: Scene) => void;
  58632. /**
  58633. * Creates a new G Buffer for the scene
  58634. * @param scene The scene the buffer belongs to
  58635. * @param ratio How big is the buffer related to the main canvas.
  58636. */
  58637. constructor(scene: Scene, ratio?: number);
  58638. /**
  58639. * Checks wether everything is ready to render a submesh to the G buffer.
  58640. * @param subMesh the submesh to check readiness for
  58641. * @param useInstances is the mesh drawn using instance or not
  58642. * @returns true if ready otherwise false
  58643. */
  58644. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58645. /**
  58646. * Gets the current underlying G Buffer.
  58647. * @returns the buffer
  58648. */
  58649. getGBuffer(): MultiRenderTarget;
  58650. /**
  58651. * Gets the number of samples used to render the buffer (anti aliasing).
  58652. */
  58653. /**
  58654. * Sets the number of samples used to render the buffer (anti aliasing).
  58655. */
  58656. samples: number;
  58657. /**
  58658. * Disposes the renderer and frees up associated resources.
  58659. */
  58660. dispose(): void;
  58661. protected _createRenderTargets(): void;
  58662. private _copyBonesTransformationMatrices;
  58663. }
  58664. }
  58665. declare module BABYLON {
  58666. interface Scene {
  58667. /** @hidden (Backing field) */
  58668. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58669. /**
  58670. * Gets or Sets the current geometry buffer associated to the scene.
  58671. */
  58672. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58673. /**
  58674. * Enables a GeometryBufferRender and associates it with the scene
  58675. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58676. * @returns the GeometryBufferRenderer
  58677. */
  58678. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58679. /**
  58680. * Disables the GeometryBufferRender associated with the scene
  58681. */
  58682. disableGeometryBufferRenderer(): void;
  58683. }
  58684. /**
  58685. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58686. * in several rendering techniques.
  58687. */
  58688. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58689. /**
  58690. * The component name helpful to identify the component in the list of scene components.
  58691. */
  58692. readonly name: string;
  58693. /**
  58694. * The scene the component belongs to.
  58695. */
  58696. scene: Scene;
  58697. /**
  58698. * Creates a new instance of the component for the given scene
  58699. * @param scene Defines the scene to register the component in
  58700. */
  58701. constructor(scene: Scene);
  58702. /**
  58703. * Registers the component in a given scene
  58704. */
  58705. register(): void;
  58706. /**
  58707. * Rebuilds the elements related to this component in case of
  58708. * context lost for instance.
  58709. */
  58710. rebuild(): void;
  58711. /**
  58712. * Disposes the component and the associated ressources
  58713. */
  58714. dispose(): void;
  58715. private _gatherRenderTargets;
  58716. }
  58717. }
  58718. declare module BABYLON {
  58719. /** @hidden */
  58720. export var motionBlurPixelShader: {
  58721. name: string;
  58722. shader: string;
  58723. };
  58724. }
  58725. declare module BABYLON {
  58726. /**
  58727. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58728. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58729. * As an example, all you have to do is to create the post-process:
  58730. * var mb = new BABYLON.MotionBlurPostProcess(
  58731. * 'mb', // The name of the effect.
  58732. * scene, // The scene containing the objects to blur according to their velocity.
  58733. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58734. * camera // The camera to apply the render pass to.
  58735. * );
  58736. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58737. */
  58738. export class MotionBlurPostProcess extends PostProcess {
  58739. /**
  58740. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58741. */
  58742. motionStrength: number;
  58743. /**
  58744. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58745. */
  58746. /**
  58747. * Sets the number of iterations to be used for motion blur quality
  58748. */
  58749. motionBlurSamples: number;
  58750. private _motionBlurSamples;
  58751. private _geometryBufferRenderer;
  58752. /**
  58753. * Creates a new instance MotionBlurPostProcess
  58754. * @param name The name of the effect.
  58755. * @param scene The scene containing the objects to blur according to their velocity.
  58756. * @param options The required width/height ratio to downsize to before computing the render pass.
  58757. * @param camera The camera to apply the render pass to.
  58758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58759. * @param engine The engine which the post process will be applied. (default: current engine)
  58760. * @param reusable If the post process can be reused on the same frame. (default: false)
  58761. * @param textureType Type of textures used when performing the post process. (default: 0)
  58762. * @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)
  58763. */
  58764. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58765. /**
  58766. * Excludes the given skinned mesh from computing bones velocities.
  58767. * 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.
  58768. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58769. */
  58770. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58771. /**
  58772. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58773. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58774. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58775. */
  58776. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58777. /**
  58778. * Disposes the post process.
  58779. * @param camera The camera to dispose the post process on.
  58780. */
  58781. dispose(camera?: Camera): void;
  58782. }
  58783. }
  58784. declare module BABYLON {
  58785. /** @hidden */
  58786. export var refractionPixelShader: {
  58787. name: string;
  58788. shader: string;
  58789. };
  58790. }
  58791. declare module BABYLON {
  58792. /**
  58793. * Post process which applies a refractin texture
  58794. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58795. */
  58796. export class RefractionPostProcess extends PostProcess {
  58797. /** the base color of the refraction (used to taint the rendering) */
  58798. color: Color3;
  58799. /** simulated refraction depth */
  58800. depth: number;
  58801. /** the coefficient of the base color (0 to remove base color tainting) */
  58802. colorLevel: number;
  58803. private _refTexture;
  58804. private _ownRefractionTexture;
  58805. /**
  58806. * Gets or sets the refraction texture
  58807. * Please note that you are responsible for disposing the texture if you set it manually
  58808. */
  58809. refractionTexture: Texture;
  58810. /**
  58811. * Initializes the RefractionPostProcess
  58812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58813. * @param name The name of the effect.
  58814. * @param refractionTextureUrl Url of the refraction texture to use
  58815. * @param color the base color of the refraction (used to taint the rendering)
  58816. * @param depth simulated refraction depth
  58817. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58818. * @param camera The camera to apply the render pass to.
  58819. * @param options The required width/height ratio to downsize to before computing the render pass.
  58820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58821. * @param engine The engine which the post process will be applied. (default: current engine)
  58822. * @param reusable If the post process can be reused on the same frame. (default: false)
  58823. */
  58824. constructor(name: string, refractionTextureUrl: string,
  58825. /** the base color of the refraction (used to taint the rendering) */
  58826. color: Color3,
  58827. /** simulated refraction depth */
  58828. depth: number,
  58829. /** the coefficient of the base color (0 to remove base color tainting) */
  58830. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58831. /**
  58832. * Disposes of the post process
  58833. * @param camera Camera to dispose post process on
  58834. */
  58835. dispose(camera: Camera): void;
  58836. }
  58837. }
  58838. declare module BABYLON {
  58839. /** @hidden */
  58840. export var sharpenPixelShader: {
  58841. name: string;
  58842. shader: string;
  58843. };
  58844. }
  58845. declare module BABYLON {
  58846. /**
  58847. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58848. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58849. */
  58850. export class SharpenPostProcess extends PostProcess {
  58851. /**
  58852. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58853. */
  58854. colorAmount: number;
  58855. /**
  58856. * How much sharpness should be applied (default: 0.3)
  58857. */
  58858. edgeAmount: number;
  58859. /**
  58860. * Creates a new instance ConvolutionPostProcess
  58861. * @param name The name of the effect.
  58862. * @param options The required width/height ratio to downsize to before computing the render pass.
  58863. * @param camera The camera to apply the render pass to.
  58864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58865. * @param engine The engine which the post process will be applied. (default: current engine)
  58866. * @param reusable If the post process can be reused on the same frame. (default: false)
  58867. * @param textureType Type of textures used when performing the post process. (default: 0)
  58868. * @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)
  58869. */
  58870. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58871. }
  58872. }
  58873. declare module BABYLON {
  58874. /**
  58875. * PostProcessRenderPipeline
  58876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58877. */
  58878. export class PostProcessRenderPipeline {
  58879. private engine;
  58880. private _renderEffects;
  58881. private _renderEffectsForIsolatedPass;
  58882. /**
  58883. * List of inspectable custom properties (used by the Inspector)
  58884. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58885. */
  58886. inspectableCustomProperties: IInspectable[];
  58887. /**
  58888. * @hidden
  58889. */
  58890. protected _cameras: Camera[];
  58891. /** @hidden */
  58892. _name: string;
  58893. /**
  58894. * Gets pipeline name
  58895. */
  58896. readonly name: string;
  58897. /**
  58898. * Initializes a PostProcessRenderPipeline
  58899. * @param engine engine to add the pipeline to
  58900. * @param name name of the pipeline
  58901. */
  58902. constructor(engine: Engine, name: string);
  58903. /**
  58904. * Gets the class name
  58905. * @returns "PostProcessRenderPipeline"
  58906. */
  58907. getClassName(): string;
  58908. /**
  58909. * If all the render effects in the pipeline are supported
  58910. */
  58911. readonly isSupported: boolean;
  58912. /**
  58913. * Adds an effect to the pipeline
  58914. * @param renderEffect the effect to add
  58915. */
  58916. addEffect(renderEffect: PostProcessRenderEffect): void;
  58917. /** @hidden */
  58918. _rebuild(): void;
  58919. /** @hidden */
  58920. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58921. /** @hidden */
  58922. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58923. /** @hidden */
  58924. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58925. /** @hidden */
  58926. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58927. /** @hidden */
  58928. _attachCameras(cameras: Camera, unique: boolean): void;
  58929. /** @hidden */
  58930. _attachCameras(cameras: Camera[], unique: boolean): void;
  58931. /** @hidden */
  58932. _detachCameras(cameras: Camera): void;
  58933. /** @hidden */
  58934. _detachCameras(cameras: Nullable<Camera[]>): void;
  58935. /** @hidden */
  58936. _update(): void;
  58937. /** @hidden */
  58938. _reset(): void;
  58939. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58940. /**
  58941. * Disposes of the pipeline
  58942. */
  58943. dispose(): void;
  58944. }
  58945. }
  58946. declare module BABYLON {
  58947. /**
  58948. * PostProcessRenderPipelineManager class
  58949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58950. */
  58951. export class PostProcessRenderPipelineManager {
  58952. private _renderPipelines;
  58953. /**
  58954. * Initializes a PostProcessRenderPipelineManager
  58955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58956. */
  58957. constructor();
  58958. /**
  58959. * Gets the list of supported render pipelines
  58960. */
  58961. readonly supportedPipelines: PostProcessRenderPipeline[];
  58962. /**
  58963. * Adds a pipeline to the manager
  58964. * @param renderPipeline The pipeline to add
  58965. */
  58966. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58967. /**
  58968. * Attaches a camera to the pipeline
  58969. * @param renderPipelineName The name of the pipeline to attach to
  58970. * @param cameras the camera to attach
  58971. * @param unique if the camera can be attached multiple times to the pipeline
  58972. */
  58973. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58974. /**
  58975. * Detaches a camera from the pipeline
  58976. * @param renderPipelineName The name of the pipeline to detach from
  58977. * @param cameras the camera to detach
  58978. */
  58979. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58980. /**
  58981. * Enables an effect by name on a pipeline
  58982. * @param renderPipelineName the name of the pipeline to enable the effect in
  58983. * @param renderEffectName the name of the effect to enable
  58984. * @param cameras the cameras that the effect should be enabled on
  58985. */
  58986. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58987. /**
  58988. * Disables an effect by name on a pipeline
  58989. * @param renderPipelineName the name of the pipeline to disable the effect in
  58990. * @param renderEffectName the name of the effect to disable
  58991. * @param cameras the cameras that the effect should be disabled on
  58992. */
  58993. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58994. /**
  58995. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58996. */
  58997. update(): void;
  58998. /** @hidden */
  58999. _rebuild(): void;
  59000. /**
  59001. * Disposes of the manager and pipelines
  59002. */
  59003. dispose(): void;
  59004. }
  59005. }
  59006. declare module BABYLON {
  59007. interface Scene {
  59008. /** @hidden (Backing field) */
  59009. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59010. /**
  59011. * Gets the postprocess render pipeline manager
  59012. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59013. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59014. */
  59015. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59016. }
  59017. /**
  59018. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59019. */
  59020. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59021. /**
  59022. * The component name helpfull to identify the component in the list of scene components.
  59023. */
  59024. readonly name: string;
  59025. /**
  59026. * The scene the component belongs to.
  59027. */
  59028. scene: Scene;
  59029. /**
  59030. * Creates a new instance of the component for the given scene
  59031. * @param scene Defines the scene to register the component in
  59032. */
  59033. constructor(scene: Scene);
  59034. /**
  59035. * Registers the component in a given scene
  59036. */
  59037. register(): void;
  59038. /**
  59039. * Rebuilds the elements related to this component in case of
  59040. * context lost for instance.
  59041. */
  59042. rebuild(): void;
  59043. /**
  59044. * Disposes the component and the associated ressources
  59045. */
  59046. dispose(): void;
  59047. private _gatherRenderTargets;
  59048. }
  59049. }
  59050. declare module BABYLON {
  59051. /**
  59052. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59053. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59054. */
  59055. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59056. private _scene;
  59057. private _camerasToBeAttached;
  59058. /**
  59059. * ID of the sharpen post process,
  59060. */
  59061. private readonly SharpenPostProcessId;
  59062. /**
  59063. * @ignore
  59064. * ID of the image processing post process;
  59065. */
  59066. readonly ImageProcessingPostProcessId: string;
  59067. /**
  59068. * @ignore
  59069. * ID of the Fast Approximate Anti-Aliasing post process;
  59070. */
  59071. readonly FxaaPostProcessId: string;
  59072. /**
  59073. * ID of the chromatic aberration post process,
  59074. */
  59075. private readonly ChromaticAberrationPostProcessId;
  59076. /**
  59077. * ID of the grain post process
  59078. */
  59079. private readonly GrainPostProcessId;
  59080. /**
  59081. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59082. */
  59083. sharpen: SharpenPostProcess;
  59084. private _sharpenEffect;
  59085. private bloom;
  59086. /**
  59087. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59088. */
  59089. depthOfField: DepthOfFieldEffect;
  59090. /**
  59091. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59092. */
  59093. fxaa: FxaaPostProcess;
  59094. /**
  59095. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59096. */
  59097. imageProcessing: ImageProcessingPostProcess;
  59098. /**
  59099. * Chromatic aberration post process which will shift rgb colors in the image
  59100. */
  59101. chromaticAberration: ChromaticAberrationPostProcess;
  59102. private _chromaticAberrationEffect;
  59103. /**
  59104. * Grain post process which add noise to the image
  59105. */
  59106. grain: GrainPostProcess;
  59107. private _grainEffect;
  59108. /**
  59109. * Glow post process which adds a glow to emissive areas of the image
  59110. */
  59111. private _glowLayer;
  59112. /**
  59113. * Animations which can be used to tweak settings over a period of time
  59114. */
  59115. animations: Animation[];
  59116. private _imageProcessingConfigurationObserver;
  59117. private _sharpenEnabled;
  59118. private _bloomEnabled;
  59119. private _depthOfFieldEnabled;
  59120. private _depthOfFieldBlurLevel;
  59121. private _fxaaEnabled;
  59122. private _imageProcessingEnabled;
  59123. private _defaultPipelineTextureType;
  59124. private _bloomScale;
  59125. private _chromaticAberrationEnabled;
  59126. private _grainEnabled;
  59127. private _buildAllowed;
  59128. /**
  59129. * Gets active scene
  59130. */
  59131. readonly scene: Scene;
  59132. /**
  59133. * Enable or disable the sharpen process from the pipeline
  59134. */
  59135. sharpenEnabled: boolean;
  59136. private _resizeObserver;
  59137. private _hardwareScaleLevel;
  59138. private _bloomKernel;
  59139. /**
  59140. * Specifies the size of the bloom blur kernel, relative to the final output size
  59141. */
  59142. bloomKernel: number;
  59143. /**
  59144. * Specifies the weight of the bloom in the final rendering
  59145. */
  59146. private _bloomWeight;
  59147. /**
  59148. * Specifies the luma threshold for the area that will be blurred by the bloom
  59149. */
  59150. private _bloomThreshold;
  59151. private _hdr;
  59152. /**
  59153. * The strength of the bloom.
  59154. */
  59155. bloomWeight: number;
  59156. /**
  59157. * The strength of the bloom.
  59158. */
  59159. bloomThreshold: number;
  59160. /**
  59161. * The scale of the bloom, lower value will provide better performance.
  59162. */
  59163. bloomScale: number;
  59164. /**
  59165. * Enable or disable the bloom from the pipeline
  59166. */
  59167. bloomEnabled: boolean;
  59168. private _rebuildBloom;
  59169. /**
  59170. * If the depth of field is enabled.
  59171. */
  59172. depthOfFieldEnabled: boolean;
  59173. /**
  59174. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59175. */
  59176. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59177. /**
  59178. * If the anti aliasing is enabled.
  59179. */
  59180. fxaaEnabled: boolean;
  59181. private _samples;
  59182. /**
  59183. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59184. */
  59185. samples: number;
  59186. /**
  59187. * If image processing is enabled.
  59188. */
  59189. imageProcessingEnabled: boolean;
  59190. /**
  59191. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59192. */
  59193. glowLayerEnabled: boolean;
  59194. /**
  59195. * Gets the glow layer (or null if not defined)
  59196. */
  59197. readonly glowLayer: Nullable<GlowLayer>;
  59198. /**
  59199. * Enable or disable the chromaticAberration process from the pipeline
  59200. */
  59201. chromaticAberrationEnabled: boolean;
  59202. /**
  59203. * Enable or disable the grain process from the pipeline
  59204. */
  59205. grainEnabled: boolean;
  59206. /**
  59207. * @constructor
  59208. * @param name - The rendering pipeline name (default: "")
  59209. * @param hdr - If high dynamic range textures should be used (default: true)
  59210. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59211. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59212. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59213. */
  59214. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59215. /**
  59216. * Get the class name
  59217. * @returns "DefaultRenderingPipeline"
  59218. */
  59219. getClassName(): string;
  59220. /**
  59221. * Force the compilation of the entire pipeline.
  59222. */
  59223. prepare(): void;
  59224. private _hasCleared;
  59225. private _prevPostProcess;
  59226. private _prevPrevPostProcess;
  59227. private _setAutoClearAndTextureSharing;
  59228. private _depthOfFieldSceneObserver;
  59229. private _buildPipeline;
  59230. private _disposePostProcesses;
  59231. /**
  59232. * Adds a camera to the pipeline
  59233. * @param camera the camera to be added
  59234. */
  59235. addCamera(camera: Camera): void;
  59236. /**
  59237. * Removes a camera from the pipeline
  59238. * @param camera the camera to remove
  59239. */
  59240. removeCamera(camera: Camera): void;
  59241. /**
  59242. * Dispose of the pipeline and stop all post processes
  59243. */
  59244. dispose(): void;
  59245. /**
  59246. * Serialize the rendering pipeline (Used when exporting)
  59247. * @returns the serialized object
  59248. */
  59249. serialize(): any;
  59250. /**
  59251. * Parse the serialized pipeline
  59252. * @param source Source pipeline.
  59253. * @param scene The scene to load the pipeline to.
  59254. * @param rootUrl The URL of the serialized pipeline.
  59255. * @returns An instantiated pipeline from the serialized object.
  59256. */
  59257. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59258. }
  59259. }
  59260. declare module BABYLON {
  59261. /** @hidden */
  59262. export var lensHighlightsPixelShader: {
  59263. name: string;
  59264. shader: string;
  59265. };
  59266. }
  59267. declare module BABYLON {
  59268. /** @hidden */
  59269. export var depthOfFieldPixelShader: {
  59270. name: string;
  59271. shader: string;
  59272. };
  59273. }
  59274. declare module BABYLON {
  59275. /**
  59276. * BABYLON.JS Chromatic Aberration GLSL Shader
  59277. * Author: Olivier Guyot
  59278. * Separates very slightly R, G and B colors on the edges of the screen
  59279. * Inspired by Francois Tarlier & Martins Upitis
  59280. */
  59281. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59282. /**
  59283. * @ignore
  59284. * The chromatic aberration PostProcess id in the pipeline
  59285. */
  59286. LensChromaticAberrationEffect: string;
  59287. /**
  59288. * @ignore
  59289. * The highlights enhancing PostProcess id in the pipeline
  59290. */
  59291. HighlightsEnhancingEffect: string;
  59292. /**
  59293. * @ignore
  59294. * The depth-of-field PostProcess id in the pipeline
  59295. */
  59296. LensDepthOfFieldEffect: string;
  59297. private _scene;
  59298. private _depthTexture;
  59299. private _grainTexture;
  59300. private _chromaticAberrationPostProcess;
  59301. private _highlightsPostProcess;
  59302. private _depthOfFieldPostProcess;
  59303. private _edgeBlur;
  59304. private _grainAmount;
  59305. private _chromaticAberration;
  59306. private _distortion;
  59307. private _highlightsGain;
  59308. private _highlightsThreshold;
  59309. private _dofDistance;
  59310. private _dofAperture;
  59311. private _dofDarken;
  59312. private _dofPentagon;
  59313. private _blurNoise;
  59314. /**
  59315. * @constructor
  59316. *
  59317. * Effect parameters are as follow:
  59318. * {
  59319. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59320. * edge_blur: number; // from 0 to x (1 for realism)
  59321. * distortion: number; // from 0 to x (1 for realism)
  59322. * grain_amount: number; // from 0 to 1
  59323. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59324. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59325. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59326. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59327. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59328. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59329. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59330. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59331. * }
  59332. * Note: if an effect parameter is unset, effect is disabled
  59333. *
  59334. * @param name The rendering pipeline name
  59335. * @param parameters - An object containing all parameters (see above)
  59336. * @param scene The scene linked to this pipeline
  59337. * @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)
  59338. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59339. */
  59340. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59341. /**
  59342. * Get the class name
  59343. * @returns "LensRenderingPipeline"
  59344. */
  59345. getClassName(): string;
  59346. /**
  59347. * Gets associated scene
  59348. */
  59349. readonly scene: Scene;
  59350. /**
  59351. * Gets or sets the edge blur
  59352. */
  59353. edgeBlur: number;
  59354. /**
  59355. * Gets or sets the grain amount
  59356. */
  59357. grainAmount: number;
  59358. /**
  59359. * Gets or sets the chromatic aberration amount
  59360. */
  59361. chromaticAberration: number;
  59362. /**
  59363. * Gets or sets the depth of field aperture
  59364. */
  59365. dofAperture: number;
  59366. /**
  59367. * Gets or sets the edge distortion
  59368. */
  59369. edgeDistortion: number;
  59370. /**
  59371. * Gets or sets the depth of field distortion
  59372. */
  59373. dofDistortion: number;
  59374. /**
  59375. * Gets or sets the darken out of focus amount
  59376. */
  59377. darkenOutOfFocus: number;
  59378. /**
  59379. * Gets or sets a boolean indicating if blur noise is enabled
  59380. */
  59381. blurNoise: boolean;
  59382. /**
  59383. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59384. */
  59385. pentagonBokeh: boolean;
  59386. /**
  59387. * Gets or sets the highlight grain amount
  59388. */
  59389. highlightsGain: number;
  59390. /**
  59391. * Gets or sets the highlight threshold
  59392. */
  59393. highlightsThreshold: number;
  59394. /**
  59395. * Sets the amount of blur at the edges
  59396. * @param amount blur amount
  59397. */
  59398. setEdgeBlur(amount: number): void;
  59399. /**
  59400. * Sets edge blur to 0
  59401. */
  59402. disableEdgeBlur(): void;
  59403. /**
  59404. * Sets the amout of grain
  59405. * @param amount Amount of grain
  59406. */
  59407. setGrainAmount(amount: number): void;
  59408. /**
  59409. * Set grain amount to 0
  59410. */
  59411. disableGrain(): void;
  59412. /**
  59413. * Sets the chromatic aberration amount
  59414. * @param amount amount of chromatic aberration
  59415. */
  59416. setChromaticAberration(amount: number): void;
  59417. /**
  59418. * Sets chromatic aberration amount to 0
  59419. */
  59420. disableChromaticAberration(): void;
  59421. /**
  59422. * Sets the EdgeDistortion amount
  59423. * @param amount amount of EdgeDistortion
  59424. */
  59425. setEdgeDistortion(amount: number): void;
  59426. /**
  59427. * Sets edge distortion to 0
  59428. */
  59429. disableEdgeDistortion(): void;
  59430. /**
  59431. * Sets the FocusDistance amount
  59432. * @param amount amount of FocusDistance
  59433. */
  59434. setFocusDistance(amount: number): void;
  59435. /**
  59436. * Disables depth of field
  59437. */
  59438. disableDepthOfField(): void;
  59439. /**
  59440. * Sets the Aperture amount
  59441. * @param amount amount of Aperture
  59442. */
  59443. setAperture(amount: number): void;
  59444. /**
  59445. * Sets the DarkenOutOfFocus amount
  59446. * @param amount amount of DarkenOutOfFocus
  59447. */
  59448. setDarkenOutOfFocus(amount: number): void;
  59449. private _pentagonBokehIsEnabled;
  59450. /**
  59451. * Creates a pentagon bokeh effect
  59452. */
  59453. enablePentagonBokeh(): void;
  59454. /**
  59455. * Disables the pentagon bokeh effect
  59456. */
  59457. disablePentagonBokeh(): void;
  59458. /**
  59459. * Enables noise blur
  59460. */
  59461. enableNoiseBlur(): void;
  59462. /**
  59463. * Disables noise blur
  59464. */
  59465. disableNoiseBlur(): void;
  59466. /**
  59467. * Sets the HighlightsGain amount
  59468. * @param amount amount of HighlightsGain
  59469. */
  59470. setHighlightsGain(amount: number): void;
  59471. /**
  59472. * Sets the HighlightsThreshold amount
  59473. * @param amount amount of HighlightsThreshold
  59474. */
  59475. setHighlightsThreshold(amount: number): void;
  59476. /**
  59477. * Disables highlights
  59478. */
  59479. disableHighlights(): void;
  59480. /**
  59481. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59482. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59483. */
  59484. dispose(disableDepthRender?: boolean): void;
  59485. private _createChromaticAberrationPostProcess;
  59486. private _createHighlightsPostProcess;
  59487. private _createDepthOfFieldPostProcess;
  59488. private _createGrainTexture;
  59489. }
  59490. }
  59491. declare module BABYLON {
  59492. /** @hidden */
  59493. export var ssao2PixelShader: {
  59494. name: string;
  59495. shader: string;
  59496. };
  59497. }
  59498. declare module BABYLON {
  59499. /** @hidden */
  59500. export var ssaoCombinePixelShader: {
  59501. name: string;
  59502. shader: string;
  59503. };
  59504. }
  59505. declare module BABYLON {
  59506. /**
  59507. * Render pipeline to produce ssao effect
  59508. */
  59509. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59510. /**
  59511. * @ignore
  59512. * The PassPostProcess id in the pipeline that contains the original scene color
  59513. */
  59514. SSAOOriginalSceneColorEffect: string;
  59515. /**
  59516. * @ignore
  59517. * The SSAO PostProcess id in the pipeline
  59518. */
  59519. SSAORenderEffect: string;
  59520. /**
  59521. * @ignore
  59522. * The horizontal blur PostProcess id in the pipeline
  59523. */
  59524. SSAOBlurHRenderEffect: string;
  59525. /**
  59526. * @ignore
  59527. * The vertical blur PostProcess id in the pipeline
  59528. */
  59529. SSAOBlurVRenderEffect: string;
  59530. /**
  59531. * @ignore
  59532. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59533. */
  59534. SSAOCombineRenderEffect: string;
  59535. /**
  59536. * The output strength of the SSAO post-process. Default value is 1.0.
  59537. */
  59538. totalStrength: number;
  59539. /**
  59540. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59541. */
  59542. maxZ: number;
  59543. /**
  59544. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59545. */
  59546. minZAspect: number;
  59547. private _samples;
  59548. /**
  59549. * Number of samples used for the SSAO calculations. Default value is 8
  59550. */
  59551. samples: number;
  59552. private _textureSamples;
  59553. /**
  59554. * Number of samples to use for antialiasing
  59555. */
  59556. textureSamples: number;
  59557. /**
  59558. * Ratio object used for SSAO ratio and blur ratio
  59559. */
  59560. private _ratio;
  59561. /**
  59562. * Dynamically generated sphere sampler.
  59563. */
  59564. private _sampleSphere;
  59565. /**
  59566. * Blur filter offsets
  59567. */
  59568. private _samplerOffsets;
  59569. private _expensiveBlur;
  59570. /**
  59571. * If bilateral blur should be used
  59572. */
  59573. expensiveBlur: boolean;
  59574. /**
  59575. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59576. */
  59577. radius: number;
  59578. /**
  59579. * The base color of the SSAO post-process
  59580. * The final result is "base + ssao" between [0, 1]
  59581. */
  59582. base: number;
  59583. /**
  59584. * Support test.
  59585. */
  59586. static readonly IsSupported: boolean;
  59587. private _scene;
  59588. private _depthTexture;
  59589. private _normalTexture;
  59590. private _randomTexture;
  59591. private _originalColorPostProcess;
  59592. private _ssaoPostProcess;
  59593. private _blurHPostProcess;
  59594. private _blurVPostProcess;
  59595. private _ssaoCombinePostProcess;
  59596. private _firstUpdate;
  59597. /**
  59598. * Gets active scene
  59599. */
  59600. readonly scene: Scene;
  59601. /**
  59602. * @constructor
  59603. * @param name The rendering pipeline name
  59604. * @param scene The scene linked to this pipeline
  59605. * @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 }
  59606. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59607. */
  59608. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59609. /**
  59610. * Get the class name
  59611. * @returns "SSAO2RenderingPipeline"
  59612. */
  59613. getClassName(): string;
  59614. /**
  59615. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59616. */
  59617. dispose(disableGeometryBufferRenderer?: boolean): void;
  59618. private _createBlurPostProcess;
  59619. /** @hidden */
  59620. _rebuild(): void;
  59621. private _bits;
  59622. private _radicalInverse_VdC;
  59623. private _hammersley;
  59624. private _hemisphereSample_uniform;
  59625. private _generateHemisphere;
  59626. private _createSSAOPostProcess;
  59627. private _createSSAOCombinePostProcess;
  59628. private _createRandomTexture;
  59629. /**
  59630. * Serialize the rendering pipeline (Used when exporting)
  59631. * @returns the serialized object
  59632. */
  59633. serialize(): any;
  59634. /**
  59635. * Parse the serialized pipeline
  59636. * @param source Source pipeline.
  59637. * @param scene The scene to load the pipeline to.
  59638. * @param rootUrl The URL of the serialized pipeline.
  59639. * @returns An instantiated pipeline from the serialized object.
  59640. */
  59641. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59642. }
  59643. }
  59644. declare module BABYLON {
  59645. /** @hidden */
  59646. export var ssaoPixelShader: {
  59647. name: string;
  59648. shader: string;
  59649. };
  59650. }
  59651. declare module BABYLON {
  59652. /**
  59653. * Render pipeline to produce ssao effect
  59654. */
  59655. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59656. /**
  59657. * @ignore
  59658. * The PassPostProcess id in the pipeline that contains the original scene color
  59659. */
  59660. SSAOOriginalSceneColorEffect: string;
  59661. /**
  59662. * @ignore
  59663. * The SSAO PostProcess id in the pipeline
  59664. */
  59665. SSAORenderEffect: string;
  59666. /**
  59667. * @ignore
  59668. * The horizontal blur PostProcess id in the pipeline
  59669. */
  59670. SSAOBlurHRenderEffect: string;
  59671. /**
  59672. * @ignore
  59673. * The vertical blur PostProcess id in the pipeline
  59674. */
  59675. SSAOBlurVRenderEffect: string;
  59676. /**
  59677. * @ignore
  59678. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59679. */
  59680. SSAOCombineRenderEffect: string;
  59681. /**
  59682. * The output strength of the SSAO post-process. Default value is 1.0.
  59683. */
  59684. totalStrength: number;
  59685. /**
  59686. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59687. */
  59688. radius: number;
  59689. /**
  59690. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59691. * Must not be equal to fallOff and superior to fallOff.
  59692. * Default value is 0.0075
  59693. */
  59694. area: number;
  59695. /**
  59696. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59697. * Must not be equal to area and inferior to area.
  59698. * Default value is 0.000001
  59699. */
  59700. fallOff: number;
  59701. /**
  59702. * The base color of the SSAO post-process
  59703. * The final result is "base + ssao" between [0, 1]
  59704. */
  59705. base: number;
  59706. private _scene;
  59707. private _depthTexture;
  59708. private _randomTexture;
  59709. private _originalColorPostProcess;
  59710. private _ssaoPostProcess;
  59711. private _blurHPostProcess;
  59712. private _blurVPostProcess;
  59713. private _ssaoCombinePostProcess;
  59714. private _firstUpdate;
  59715. /**
  59716. * Gets active scene
  59717. */
  59718. readonly scene: Scene;
  59719. /**
  59720. * @constructor
  59721. * @param name - The rendering pipeline name
  59722. * @param scene - The scene linked to this pipeline
  59723. * @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 }
  59724. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59725. */
  59726. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59727. /**
  59728. * Get the class name
  59729. * @returns "SSAORenderingPipeline"
  59730. */
  59731. getClassName(): string;
  59732. /**
  59733. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59734. */
  59735. dispose(disableDepthRender?: boolean): void;
  59736. private _createBlurPostProcess;
  59737. /** @hidden */
  59738. _rebuild(): void;
  59739. private _createSSAOPostProcess;
  59740. private _createSSAOCombinePostProcess;
  59741. private _createRandomTexture;
  59742. }
  59743. }
  59744. declare module BABYLON {
  59745. /** @hidden */
  59746. export var standardPixelShader: {
  59747. name: string;
  59748. shader: string;
  59749. };
  59750. }
  59751. declare module BABYLON {
  59752. /**
  59753. * Standard rendering pipeline
  59754. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59755. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59756. */
  59757. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59758. /**
  59759. * Public members
  59760. */
  59761. /**
  59762. * Post-process which contains the original scene color before the pipeline applies all the effects
  59763. */
  59764. originalPostProcess: Nullable<PostProcess>;
  59765. /**
  59766. * Post-process used to down scale an image x4
  59767. */
  59768. downSampleX4PostProcess: Nullable<PostProcess>;
  59769. /**
  59770. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59771. */
  59772. brightPassPostProcess: Nullable<PostProcess>;
  59773. /**
  59774. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59775. */
  59776. blurHPostProcesses: PostProcess[];
  59777. /**
  59778. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59779. */
  59780. blurVPostProcesses: PostProcess[];
  59781. /**
  59782. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59783. */
  59784. textureAdderPostProcess: Nullable<PostProcess>;
  59785. /**
  59786. * Post-process used to create volumetric lighting effect
  59787. */
  59788. volumetricLightPostProcess: Nullable<PostProcess>;
  59789. /**
  59790. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59791. */
  59792. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59793. /**
  59794. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59795. */
  59796. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59797. /**
  59798. * Post-process used to merge the volumetric light effect and the real scene color
  59799. */
  59800. volumetricLightMergePostProces: Nullable<PostProcess>;
  59801. /**
  59802. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59803. */
  59804. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59805. /**
  59806. * Base post-process used to calculate the average luminance of the final image for HDR
  59807. */
  59808. luminancePostProcess: Nullable<PostProcess>;
  59809. /**
  59810. * Post-processes used to create down sample post-processes in order to get
  59811. * the average luminance of the final image for HDR
  59812. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59813. */
  59814. luminanceDownSamplePostProcesses: PostProcess[];
  59815. /**
  59816. * Post-process used to create a HDR effect (light adaptation)
  59817. */
  59818. hdrPostProcess: Nullable<PostProcess>;
  59819. /**
  59820. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59821. */
  59822. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59823. /**
  59824. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59825. */
  59826. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59827. /**
  59828. * Post-process used to merge the final HDR post-process and the real scene color
  59829. */
  59830. hdrFinalPostProcess: Nullable<PostProcess>;
  59831. /**
  59832. * Post-process used to create a lens flare effect
  59833. */
  59834. lensFlarePostProcess: Nullable<PostProcess>;
  59835. /**
  59836. * Post-process that merges the result of the lens flare post-process and the real scene color
  59837. */
  59838. lensFlareComposePostProcess: Nullable<PostProcess>;
  59839. /**
  59840. * Post-process used to create a motion blur effect
  59841. */
  59842. motionBlurPostProcess: Nullable<PostProcess>;
  59843. /**
  59844. * Post-process used to create a depth of field effect
  59845. */
  59846. depthOfFieldPostProcess: Nullable<PostProcess>;
  59847. /**
  59848. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59849. */
  59850. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59851. /**
  59852. * Represents the brightness threshold in order to configure the illuminated surfaces
  59853. */
  59854. brightThreshold: number;
  59855. /**
  59856. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59857. */
  59858. blurWidth: number;
  59859. /**
  59860. * Sets if the blur for highlighted surfaces must be only horizontal
  59861. */
  59862. horizontalBlur: boolean;
  59863. /**
  59864. * Gets the overall exposure used by the pipeline
  59865. */
  59866. /**
  59867. * Sets the overall exposure used by the pipeline
  59868. */
  59869. exposure: number;
  59870. /**
  59871. * Texture used typically to simulate "dirty" on camera lens
  59872. */
  59873. lensTexture: Nullable<Texture>;
  59874. /**
  59875. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59876. */
  59877. volumetricLightCoefficient: number;
  59878. /**
  59879. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59880. */
  59881. volumetricLightPower: number;
  59882. /**
  59883. * Used the set the blur intensity to smooth the volumetric lights
  59884. */
  59885. volumetricLightBlurScale: number;
  59886. /**
  59887. * Light (spot or directional) used to generate the volumetric lights rays
  59888. * The source light must have a shadow generate so the pipeline can get its
  59889. * depth map
  59890. */
  59891. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59892. /**
  59893. * For eye adaptation, represents the minimum luminance the eye can see
  59894. */
  59895. hdrMinimumLuminance: number;
  59896. /**
  59897. * For eye adaptation, represents the decrease luminance speed
  59898. */
  59899. hdrDecreaseRate: number;
  59900. /**
  59901. * For eye adaptation, represents the increase luminance speed
  59902. */
  59903. hdrIncreaseRate: number;
  59904. /**
  59905. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59906. */
  59907. /**
  59908. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59909. */
  59910. hdrAutoExposure: boolean;
  59911. /**
  59912. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59913. */
  59914. lensColorTexture: Nullable<Texture>;
  59915. /**
  59916. * The overall strengh for the lens flare effect
  59917. */
  59918. lensFlareStrength: number;
  59919. /**
  59920. * Dispersion coefficient for lens flare ghosts
  59921. */
  59922. lensFlareGhostDispersal: number;
  59923. /**
  59924. * Main lens flare halo width
  59925. */
  59926. lensFlareHaloWidth: number;
  59927. /**
  59928. * Based on the lens distortion effect, defines how much the lens flare result
  59929. * is distorted
  59930. */
  59931. lensFlareDistortionStrength: number;
  59932. /**
  59933. * Configures the blur intensity used for for lens flare (halo)
  59934. */
  59935. lensFlareBlurWidth: number;
  59936. /**
  59937. * Lens star texture must be used to simulate rays on the flares and is available
  59938. * in the documentation
  59939. */
  59940. lensStarTexture: Nullable<Texture>;
  59941. /**
  59942. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59943. * flare effect by taking account of the dirt texture
  59944. */
  59945. lensFlareDirtTexture: Nullable<Texture>;
  59946. /**
  59947. * Represents the focal length for the depth of field effect
  59948. */
  59949. depthOfFieldDistance: number;
  59950. /**
  59951. * Represents the blur intensity for the blurred part of the depth of field effect
  59952. */
  59953. depthOfFieldBlurWidth: number;
  59954. /**
  59955. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59956. */
  59957. /**
  59958. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59959. */
  59960. motionStrength: number;
  59961. /**
  59962. * Gets wether or not the motion blur post-process is object based or screen based.
  59963. */
  59964. /**
  59965. * Sets wether or not the motion blur post-process should be object based or screen based
  59966. */
  59967. objectBasedMotionBlur: boolean;
  59968. /**
  59969. * List of animations for the pipeline (IAnimatable implementation)
  59970. */
  59971. animations: Animation[];
  59972. /**
  59973. * Private members
  59974. */
  59975. private _scene;
  59976. private _currentDepthOfFieldSource;
  59977. private _basePostProcess;
  59978. private _fixedExposure;
  59979. private _currentExposure;
  59980. private _hdrAutoExposure;
  59981. private _hdrCurrentLuminance;
  59982. private _motionStrength;
  59983. private _isObjectBasedMotionBlur;
  59984. private _floatTextureType;
  59985. private _camerasToBeAttached;
  59986. private _ratio;
  59987. private _bloomEnabled;
  59988. private _depthOfFieldEnabled;
  59989. private _vlsEnabled;
  59990. private _lensFlareEnabled;
  59991. private _hdrEnabled;
  59992. private _motionBlurEnabled;
  59993. private _fxaaEnabled;
  59994. private _motionBlurSamples;
  59995. private _volumetricLightStepsCount;
  59996. private _samples;
  59997. /**
  59998. * @ignore
  59999. * Specifies if the bloom pipeline is enabled
  60000. */
  60001. BloomEnabled: boolean;
  60002. /**
  60003. * @ignore
  60004. * Specifies if the depth of field pipeline is enabed
  60005. */
  60006. DepthOfFieldEnabled: boolean;
  60007. /**
  60008. * @ignore
  60009. * Specifies if the lens flare pipeline is enabed
  60010. */
  60011. LensFlareEnabled: boolean;
  60012. /**
  60013. * @ignore
  60014. * Specifies if the HDR pipeline is enabled
  60015. */
  60016. HDREnabled: boolean;
  60017. /**
  60018. * @ignore
  60019. * Specifies if the volumetric lights scattering effect is enabled
  60020. */
  60021. VLSEnabled: boolean;
  60022. /**
  60023. * @ignore
  60024. * Specifies if the motion blur effect is enabled
  60025. */
  60026. MotionBlurEnabled: boolean;
  60027. /**
  60028. * Specifies if anti-aliasing is enabled
  60029. */
  60030. fxaaEnabled: boolean;
  60031. /**
  60032. * Specifies the number of steps used to calculate the volumetric lights
  60033. * Typically in interval [50, 200]
  60034. */
  60035. volumetricLightStepsCount: number;
  60036. /**
  60037. * Specifies the number of samples used for the motion blur effect
  60038. * Typically in interval [16, 64]
  60039. */
  60040. motionBlurSamples: number;
  60041. /**
  60042. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60043. */
  60044. samples: number;
  60045. /**
  60046. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60047. * @constructor
  60048. * @param name The rendering pipeline name
  60049. * @param scene The scene linked to this pipeline
  60050. * @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)
  60051. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60052. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60053. */
  60054. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60055. private _buildPipeline;
  60056. private _createDownSampleX4PostProcess;
  60057. private _createBrightPassPostProcess;
  60058. private _createBlurPostProcesses;
  60059. private _createTextureAdderPostProcess;
  60060. private _createVolumetricLightPostProcess;
  60061. private _createLuminancePostProcesses;
  60062. private _createHdrPostProcess;
  60063. private _createLensFlarePostProcess;
  60064. private _createDepthOfFieldPostProcess;
  60065. private _createMotionBlurPostProcess;
  60066. private _getDepthTexture;
  60067. private _disposePostProcesses;
  60068. /**
  60069. * Dispose of the pipeline and stop all post processes
  60070. */
  60071. dispose(): void;
  60072. /**
  60073. * Serialize the rendering pipeline (Used when exporting)
  60074. * @returns the serialized object
  60075. */
  60076. serialize(): any;
  60077. /**
  60078. * Parse the serialized pipeline
  60079. * @param source Source pipeline.
  60080. * @param scene The scene to load the pipeline to.
  60081. * @param rootUrl The URL of the serialized pipeline.
  60082. * @returns An instantiated pipeline from the serialized object.
  60083. */
  60084. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60085. /**
  60086. * Luminance steps
  60087. */
  60088. static LuminanceSteps: number;
  60089. }
  60090. }
  60091. declare module BABYLON {
  60092. /** @hidden */
  60093. export var tonemapPixelShader: {
  60094. name: string;
  60095. shader: string;
  60096. };
  60097. }
  60098. declare module BABYLON {
  60099. /** Defines operator used for tonemapping */
  60100. export enum TonemappingOperator {
  60101. /** Hable */
  60102. Hable = 0,
  60103. /** Reinhard */
  60104. Reinhard = 1,
  60105. /** HejiDawson */
  60106. HejiDawson = 2,
  60107. /** Photographic */
  60108. Photographic = 3
  60109. }
  60110. /**
  60111. * Defines a post process to apply tone mapping
  60112. */
  60113. export class TonemapPostProcess extends PostProcess {
  60114. private _operator;
  60115. /** Defines the required exposure adjustement */
  60116. exposureAdjustment: number;
  60117. /**
  60118. * Creates a new TonemapPostProcess
  60119. * @param name defines the name of the postprocess
  60120. * @param _operator defines the operator to use
  60121. * @param exposureAdjustment defines the required exposure adjustement
  60122. * @param camera defines the camera to use (can be null)
  60123. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60124. * @param engine defines the hosting engine (can be ignore if camera is set)
  60125. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60126. */
  60127. constructor(name: string, _operator: TonemappingOperator,
  60128. /** Defines the required exposure adjustement */
  60129. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60130. }
  60131. }
  60132. declare module BABYLON {
  60133. /** @hidden */
  60134. export var depthVertexShader: {
  60135. name: string;
  60136. shader: string;
  60137. };
  60138. }
  60139. declare module BABYLON {
  60140. /** @hidden */
  60141. export var volumetricLightScatteringPixelShader: {
  60142. name: string;
  60143. shader: string;
  60144. };
  60145. }
  60146. declare module BABYLON {
  60147. /** @hidden */
  60148. export var volumetricLightScatteringPassVertexShader: {
  60149. name: string;
  60150. shader: string;
  60151. };
  60152. }
  60153. declare module BABYLON {
  60154. /** @hidden */
  60155. export var volumetricLightScatteringPassPixelShader: {
  60156. name: string;
  60157. shader: string;
  60158. };
  60159. }
  60160. declare module BABYLON {
  60161. /**
  60162. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60163. */
  60164. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60165. private _volumetricLightScatteringPass;
  60166. private _volumetricLightScatteringRTT;
  60167. private _viewPort;
  60168. private _screenCoordinates;
  60169. private _cachedDefines;
  60170. /**
  60171. * If not undefined, the mesh position is computed from the attached node position
  60172. */
  60173. attachedNode: {
  60174. position: Vector3;
  60175. };
  60176. /**
  60177. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60178. */
  60179. customMeshPosition: Vector3;
  60180. /**
  60181. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60182. */
  60183. useCustomMeshPosition: boolean;
  60184. /**
  60185. * If the post-process should inverse the light scattering direction
  60186. */
  60187. invert: boolean;
  60188. /**
  60189. * The internal mesh used by the post-process
  60190. */
  60191. mesh: Mesh;
  60192. /**
  60193. * @hidden
  60194. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60195. */
  60196. useDiffuseColor: boolean;
  60197. /**
  60198. * Array containing the excluded meshes not rendered in the internal pass
  60199. */
  60200. excludedMeshes: AbstractMesh[];
  60201. /**
  60202. * Controls the overall intensity of the post-process
  60203. */
  60204. exposure: number;
  60205. /**
  60206. * Dissipates each sample's contribution in range [0, 1]
  60207. */
  60208. decay: number;
  60209. /**
  60210. * Controls the overall intensity of each sample
  60211. */
  60212. weight: number;
  60213. /**
  60214. * Controls the density of each sample
  60215. */
  60216. density: number;
  60217. /**
  60218. * @constructor
  60219. * @param name The post-process name
  60220. * @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)
  60221. * @param camera The camera that the post-process will be attached to
  60222. * @param mesh The mesh used to create the light scattering
  60223. * @param samples The post-process quality, default 100
  60224. * @param samplingModeThe post-process filtering mode
  60225. * @param engine The babylon engine
  60226. * @param reusable If the post-process is reusable
  60227. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60228. */
  60229. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60230. /**
  60231. * Returns the string "VolumetricLightScatteringPostProcess"
  60232. * @returns "VolumetricLightScatteringPostProcess"
  60233. */
  60234. getClassName(): string;
  60235. private _isReady;
  60236. /**
  60237. * Sets the new light position for light scattering effect
  60238. * @param position The new custom light position
  60239. */
  60240. setCustomMeshPosition(position: Vector3): void;
  60241. /**
  60242. * Returns the light position for light scattering effect
  60243. * @return Vector3 The custom light position
  60244. */
  60245. getCustomMeshPosition(): Vector3;
  60246. /**
  60247. * Disposes the internal assets and detaches the post-process from the camera
  60248. */
  60249. dispose(camera: Camera): void;
  60250. /**
  60251. * Returns the render target texture used by the post-process
  60252. * @return the render target texture used by the post-process
  60253. */
  60254. getPass(): RenderTargetTexture;
  60255. private _meshExcluded;
  60256. private _createPass;
  60257. private _updateMeshScreenCoordinates;
  60258. /**
  60259. * Creates a default mesh for the Volumeric Light Scattering post-process
  60260. * @param name The mesh name
  60261. * @param scene The scene where to create the mesh
  60262. * @return the default mesh
  60263. */
  60264. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60265. }
  60266. }
  60267. declare module BABYLON {
  60268. interface Scene {
  60269. /** @hidden (Backing field) */
  60270. _boundingBoxRenderer: BoundingBoxRenderer;
  60271. /** @hidden (Backing field) */
  60272. _forceShowBoundingBoxes: boolean;
  60273. /**
  60274. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60275. */
  60276. forceShowBoundingBoxes: boolean;
  60277. /**
  60278. * Gets the bounding box renderer associated with the scene
  60279. * @returns a BoundingBoxRenderer
  60280. */
  60281. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60282. }
  60283. interface AbstractMesh {
  60284. /** @hidden (Backing field) */
  60285. _showBoundingBox: boolean;
  60286. /**
  60287. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60288. */
  60289. showBoundingBox: boolean;
  60290. }
  60291. /**
  60292. * Component responsible of rendering the bounding box of the meshes in a scene.
  60293. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60294. */
  60295. export class BoundingBoxRenderer implements ISceneComponent {
  60296. /**
  60297. * The component name helpfull to identify the component in the list of scene components.
  60298. */
  60299. readonly name: string;
  60300. /**
  60301. * The scene the component belongs to.
  60302. */
  60303. scene: Scene;
  60304. /**
  60305. * Color of the bounding box lines placed in front of an object
  60306. */
  60307. frontColor: Color3;
  60308. /**
  60309. * Color of the bounding box lines placed behind an object
  60310. */
  60311. backColor: Color3;
  60312. /**
  60313. * Defines if the renderer should show the back lines or not
  60314. */
  60315. showBackLines: boolean;
  60316. /**
  60317. * @hidden
  60318. */
  60319. renderList: SmartArray<BoundingBox>;
  60320. private _colorShader;
  60321. private _vertexBuffers;
  60322. private _indexBuffer;
  60323. private _fillIndexBuffer;
  60324. private _fillIndexData;
  60325. /**
  60326. * Instantiates a new bounding box renderer in a scene.
  60327. * @param scene the scene the renderer renders in
  60328. */
  60329. constructor(scene: Scene);
  60330. /**
  60331. * Registers the component in a given scene
  60332. */
  60333. register(): void;
  60334. private _evaluateSubMesh;
  60335. private _activeMesh;
  60336. private _prepareRessources;
  60337. private _createIndexBuffer;
  60338. /**
  60339. * Rebuilds the elements related to this component in case of
  60340. * context lost for instance.
  60341. */
  60342. rebuild(): void;
  60343. /**
  60344. * @hidden
  60345. */
  60346. reset(): void;
  60347. /**
  60348. * Render the bounding boxes of a specific rendering group
  60349. * @param renderingGroupId defines the rendering group to render
  60350. */
  60351. render(renderingGroupId: number): void;
  60352. /**
  60353. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60354. * @param mesh Define the mesh to render the occlusion bounding box for
  60355. */
  60356. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60357. /**
  60358. * Dispose and release the resources attached to this renderer.
  60359. */
  60360. dispose(): void;
  60361. }
  60362. }
  60363. declare module BABYLON {
  60364. /** @hidden */
  60365. export var depthPixelShader: {
  60366. name: string;
  60367. shader: string;
  60368. };
  60369. }
  60370. declare module BABYLON {
  60371. /**
  60372. * This represents a depth renderer in Babylon.
  60373. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60374. */
  60375. export class DepthRenderer {
  60376. private _scene;
  60377. private _depthMap;
  60378. private _effect;
  60379. private readonly _storeNonLinearDepth;
  60380. private readonly _clearColor;
  60381. /** Get if the depth renderer is using packed depth or not */
  60382. readonly isPacked: boolean;
  60383. private _cachedDefines;
  60384. private _camera;
  60385. /**
  60386. * Specifiess that the depth renderer will only be used within
  60387. * the camera it is created for.
  60388. * This can help forcing its rendering during the camera processing.
  60389. */
  60390. useOnlyInActiveCamera: boolean;
  60391. /** @hidden */
  60392. static _SceneComponentInitialization: (scene: Scene) => void;
  60393. /**
  60394. * Instantiates a depth renderer
  60395. * @param scene The scene the renderer belongs to
  60396. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60397. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60398. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60399. */
  60400. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60401. /**
  60402. * Creates the depth rendering effect and checks if the effect is ready.
  60403. * @param subMesh The submesh to be used to render the depth map of
  60404. * @param useInstances If multiple world instances should be used
  60405. * @returns if the depth renderer is ready to render the depth map
  60406. */
  60407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60408. /**
  60409. * Gets the texture which the depth map will be written to.
  60410. * @returns The depth map texture
  60411. */
  60412. getDepthMap(): RenderTargetTexture;
  60413. /**
  60414. * Disposes of the depth renderer.
  60415. */
  60416. dispose(): void;
  60417. }
  60418. }
  60419. declare module BABYLON {
  60420. interface Scene {
  60421. /** @hidden (Backing field) */
  60422. _depthRenderer: {
  60423. [id: string]: DepthRenderer;
  60424. };
  60425. /**
  60426. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60427. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60428. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60429. * @returns the created depth renderer
  60430. */
  60431. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60432. /**
  60433. * Disables a depth renderer for a given camera
  60434. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60435. */
  60436. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60437. }
  60438. /**
  60439. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60440. * in several rendering techniques.
  60441. */
  60442. export class DepthRendererSceneComponent implements ISceneComponent {
  60443. /**
  60444. * The component name helpfull to identify the component in the list of scene components.
  60445. */
  60446. readonly name: string;
  60447. /**
  60448. * The scene the component belongs to.
  60449. */
  60450. scene: Scene;
  60451. /**
  60452. * Creates a new instance of the component for the given scene
  60453. * @param scene Defines the scene to register the component in
  60454. */
  60455. constructor(scene: Scene);
  60456. /**
  60457. * Registers the component in a given scene
  60458. */
  60459. register(): void;
  60460. /**
  60461. * Rebuilds the elements related to this component in case of
  60462. * context lost for instance.
  60463. */
  60464. rebuild(): void;
  60465. /**
  60466. * Disposes the component and the associated ressources
  60467. */
  60468. dispose(): void;
  60469. private _gatherRenderTargets;
  60470. private _gatherActiveCameraRenderTargets;
  60471. }
  60472. }
  60473. declare module BABYLON {
  60474. /** @hidden */
  60475. export var outlinePixelShader: {
  60476. name: string;
  60477. shader: string;
  60478. };
  60479. }
  60480. declare module BABYLON {
  60481. /** @hidden */
  60482. export var outlineVertexShader: {
  60483. name: string;
  60484. shader: string;
  60485. };
  60486. }
  60487. declare module BABYLON {
  60488. interface Scene {
  60489. /** @hidden */
  60490. _outlineRenderer: OutlineRenderer;
  60491. /**
  60492. * Gets the outline renderer associated with the scene
  60493. * @returns a OutlineRenderer
  60494. */
  60495. getOutlineRenderer(): OutlineRenderer;
  60496. }
  60497. interface AbstractMesh {
  60498. /** @hidden (Backing field) */
  60499. _renderOutline: boolean;
  60500. /**
  60501. * Gets or sets a boolean indicating if the outline must be rendered as well
  60502. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60503. */
  60504. renderOutline: boolean;
  60505. /** @hidden (Backing field) */
  60506. _renderOverlay: boolean;
  60507. /**
  60508. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60509. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60510. */
  60511. renderOverlay: boolean;
  60512. }
  60513. /**
  60514. * This class is responsible to draw bothe outline/overlay of meshes.
  60515. * It should not be used directly but through the available method on mesh.
  60516. */
  60517. export class OutlineRenderer implements ISceneComponent {
  60518. /**
  60519. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60520. */
  60521. private static _StencilReference;
  60522. /**
  60523. * The name of the component. Each component must have a unique name.
  60524. */
  60525. name: string;
  60526. /**
  60527. * The scene the component belongs to.
  60528. */
  60529. scene: Scene;
  60530. /**
  60531. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60532. */
  60533. zOffset: number;
  60534. private _engine;
  60535. private _effect;
  60536. private _cachedDefines;
  60537. private _savedDepthWrite;
  60538. /**
  60539. * Instantiates a new outline renderer. (There could be only one per scene).
  60540. * @param scene Defines the scene it belongs to
  60541. */
  60542. constructor(scene: Scene);
  60543. /**
  60544. * Register the component to one instance of a scene.
  60545. */
  60546. register(): void;
  60547. /**
  60548. * Rebuilds the elements related to this component in case of
  60549. * context lost for instance.
  60550. */
  60551. rebuild(): void;
  60552. /**
  60553. * Disposes the component and the associated ressources.
  60554. */
  60555. dispose(): void;
  60556. /**
  60557. * Renders the outline in the canvas.
  60558. * @param subMesh Defines the sumesh to render
  60559. * @param batch Defines the batch of meshes in case of instances
  60560. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60561. */
  60562. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60563. /**
  60564. * Returns whether or not the outline renderer is ready for a given submesh.
  60565. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60566. * @param subMesh Defines the submesh to check readyness for
  60567. * @param useInstances Defines wheter wee are trying to render instances or not
  60568. * @returns true if ready otherwise false
  60569. */
  60570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60571. private _beforeRenderingMesh;
  60572. private _afterRenderingMesh;
  60573. }
  60574. }
  60575. declare module BABYLON {
  60576. /**
  60577. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60578. * @see http://doc.babylonjs.com/babylon101/sprites
  60579. */
  60580. export class SpritePackedManager extends SpriteManager {
  60581. /** defines the packed manager's name */
  60582. name: string;
  60583. /**
  60584. * Creates a new sprite manager from a packed sprite sheet
  60585. * @param name defines the manager's name
  60586. * @param imgUrl defines the sprite sheet url
  60587. * @param capacity defines the maximum allowed number of sprites
  60588. * @param scene defines the hosting scene
  60589. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60590. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60591. * @param samplingMode defines the smapling mode to use with spritesheet
  60592. * @param fromPacked set to true; do not alter
  60593. */
  60594. constructor(
  60595. /** defines the packed manager's name */
  60596. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60597. }
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * Defines the list of states available for a task inside a AssetsManager
  60602. */
  60603. export enum AssetTaskState {
  60604. /**
  60605. * Initialization
  60606. */
  60607. INIT = 0,
  60608. /**
  60609. * Running
  60610. */
  60611. RUNNING = 1,
  60612. /**
  60613. * Done
  60614. */
  60615. DONE = 2,
  60616. /**
  60617. * Error
  60618. */
  60619. ERROR = 3
  60620. }
  60621. /**
  60622. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60623. */
  60624. export abstract class AbstractAssetTask {
  60625. /**
  60626. * Task name
  60627. */ name: string;
  60628. /**
  60629. * Callback called when the task is successful
  60630. */
  60631. onSuccess: (task: any) => void;
  60632. /**
  60633. * Callback called when the task is not successful
  60634. */
  60635. onError: (task: any, message?: string, exception?: any) => void;
  60636. /**
  60637. * Creates a new AssetsManager
  60638. * @param name defines the name of the task
  60639. */
  60640. constructor(
  60641. /**
  60642. * Task name
  60643. */ name: string);
  60644. private _isCompleted;
  60645. private _taskState;
  60646. private _errorObject;
  60647. /**
  60648. * Get if the task is completed
  60649. */
  60650. readonly isCompleted: boolean;
  60651. /**
  60652. * Gets the current state of the task
  60653. */
  60654. readonly taskState: AssetTaskState;
  60655. /**
  60656. * Gets the current error object (if task is in error)
  60657. */
  60658. readonly errorObject: {
  60659. message?: string;
  60660. exception?: any;
  60661. };
  60662. /**
  60663. * Internal only
  60664. * @hidden
  60665. */
  60666. _setErrorObject(message?: string, exception?: any): void;
  60667. /**
  60668. * Execute the current task
  60669. * @param scene defines the scene where you want your assets to be loaded
  60670. * @param onSuccess is a callback called when the task is successfully executed
  60671. * @param onError is a callback called if an error occurs
  60672. */
  60673. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60674. /**
  60675. * Execute the current task
  60676. * @param scene defines the scene where you want your assets to be loaded
  60677. * @param onSuccess is a callback called when the task is successfully executed
  60678. * @param onError is a callback called if an error occurs
  60679. */
  60680. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60681. /**
  60682. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60683. * This can be used with failed tasks that have the reason for failure fixed.
  60684. */
  60685. reset(): void;
  60686. private onErrorCallback;
  60687. private onDoneCallback;
  60688. }
  60689. /**
  60690. * Define the interface used by progress events raised during assets loading
  60691. */
  60692. export interface IAssetsProgressEvent {
  60693. /**
  60694. * Defines the number of remaining tasks to process
  60695. */
  60696. remainingCount: number;
  60697. /**
  60698. * Defines the total number of tasks
  60699. */
  60700. totalCount: number;
  60701. /**
  60702. * Defines the task that was just processed
  60703. */
  60704. task: AbstractAssetTask;
  60705. }
  60706. /**
  60707. * Class used to share progress information about assets loading
  60708. */
  60709. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60710. /**
  60711. * Defines the number of remaining tasks to process
  60712. */
  60713. remainingCount: number;
  60714. /**
  60715. * Defines the total number of tasks
  60716. */
  60717. totalCount: number;
  60718. /**
  60719. * Defines the task that was just processed
  60720. */
  60721. task: AbstractAssetTask;
  60722. /**
  60723. * Creates a AssetsProgressEvent
  60724. * @param remainingCount defines the number of remaining tasks to process
  60725. * @param totalCount defines the total number of tasks
  60726. * @param task defines the task that was just processed
  60727. */
  60728. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60729. }
  60730. /**
  60731. * Define a task used by AssetsManager to load meshes
  60732. */
  60733. export class MeshAssetTask extends AbstractAssetTask {
  60734. /**
  60735. * Defines the name of the task
  60736. */
  60737. name: string;
  60738. /**
  60739. * Defines the list of mesh's names you want to load
  60740. */
  60741. meshesNames: any;
  60742. /**
  60743. * Defines the root url to use as a base to load your meshes and associated resources
  60744. */
  60745. rootUrl: string;
  60746. /**
  60747. * Defines the filename of the scene to load from
  60748. */
  60749. sceneFilename: string;
  60750. /**
  60751. * Gets the list of loaded meshes
  60752. */
  60753. loadedMeshes: Array<AbstractMesh>;
  60754. /**
  60755. * Gets the list of loaded particle systems
  60756. */
  60757. loadedParticleSystems: Array<IParticleSystem>;
  60758. /**
  60759. * Gets the list of loaded skeletons
  60760. */
  60761. loadedSkeletons: Array<Skeleton>;
  60762. /**
  60763. * Gets the list of loaded animation groups
  60764. */
  60765. loadedAnimationGroups: Array<AnimationGroup>;
  60766. /**
  60767. * Callback called when the task is successful
  60768. */
  60769. onSuccess: (task: MeshAssetTask) => void;
  60770. /**
  60771. * Callback called when the task is successful
  60772. */
  60773. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60774. /**
  60775. * Creates a new MeshAssetTask
  60776. * @param name defines the name of the task
  60777. * @param meshesNames defines the list of mesh's names you want to load
  60778. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60779. * @param sceneFilename defines the filename of the scene to load from
  60780. */
  60781. constructor(
  60782. /**
  60783. * Defines the name of the task
  60784. */
  60785. name: string,
  60786. /**
  60787. * Defines the list of mesh's names you want to load
  60788. */
  60789. meshesNames: any,
  60790. /**
  60791. * Defines the root url to use as a base to load your meshes and associated resources
  60792. */
  60793. rootUrl: string,
  60794. /**
  60795. * Defines the filename of the scene to load from
  60796. */
  60797. sceneFilename: string);
  60798. /**
  60799. * Execute the current task
  60800. * @param scene defines the scene where you want your assets to be loaded
  60801. * @param onSuccess is a callback called when the task is successfully executed
  60802. * @param onError is a callback called if an error occurs
  60803. */
  60804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60805. }
  60806. /**
  60807. * Define a task used by AssetsManager to load text content
  60808. */
  60809. export class TextFileAssetTask extends AbstractAssetTask {
  60810. /**
  60811. * Defines the name of the task
  60812. */
  60813. name: string;
  60814. /**
  60815. * Defines the location of the file to load
  60816. */
  60817. url: string;
  60818. /**
  60819. * Gets the loaded text string
  60820. */
  60821. text: string;
  60822. /**
  60823. * Callback called when the task is successful
  60824. */
  60825. onSuccess: (task: TextFileAssetTask) => void;
  60826. /**
  60827. * Callback called when the task is successful
  60828. */
  60829. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60830. /**
  60831. * Creates a new TextFileAssetTask object
  60832. * @param name defines the name of the task
  60833. * @param url defines the location of the file to load
  60834. */
  60835. constructor(
  60836. /**
  60837. * Defines the name of the task
  60838. */
  60839. name: string,
  60840. /**
  60841. * Defines the location of the file to load
  60842. */
  60843. url: string);
  60844. /**
  60845. * Execute the current task
  60846. * @param scene defines the scene where you want your assets to be loaded
  60847. * @param onSuccess is a callback called when the task is successfully executed
  60848. * @param onError is a callback called if an error occurs
  60849. */
  60850. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60851. }
  60852. /**
  60853. * Define a task used by AssetsManager to load binary data
  60854. */
  60855. export class BinaryFileAssetTask extends AbstractAssetTask {
  60856. /**
  60857. * Defines the name of the task
  60858. */
  60859. name: string;
  60860. /**
  60861. * Defines the location of the file to load
  60862. */
  60863. url: string;
  60864. /**
  60865. * Gets the lodaded data (as an array buffer)
  60866. */
  60867. data: ArrayBuffer;
  60868. /**
  60869. * Callback called when the task is successful
  60870. */
  60871. onSuccess: (task: BinaryFileAssetTask) => void;
  60872. /**
  60873. * Callback called when the task is successful
  60874. */
  60875. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60876. /**
  60877. * Creates a new BinaryFileAssetTask object
  60878. * @param name defines the name of the new task
  60879. * @param url defines the location of the file to load
  60880. */
  60881. constructor(
  60882. /**
  60883. * Defines the name of the task
  60884. */
  60885. name: string,
  60886. /**
  60887. * Defines the location of the file to load
  60888. */
  60889. url: string);
  60890. /**
  60891. * Execute the current task
  60892. * @param scene defines the scene where you want your assets to be loaded
  60893. * @param onSuccess is a callback called when the task is successfully executed
  60894. * @param onError is a callback called if an error occurs
  60895. */
  60896. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60897. }
  60898. /**
  60899. * Define a task used by AssetsManager to load images
  60900. */
  60901. export class ImageAssetTask extends AbstractAssetTask {
  60902. /**
  60903. * Defines the name of the task
  60904. */
  60905. name: string;
  60906. /**
  60907. * Defines the location of the image to load
  60908. */
  60909. url: string;
  60910. /**
  60911. * Gets the loaded images
  60912. */
  60913. image: HTMLImageElement;
  60914. /**
  60915. * Callback called when the task is successful
  60916. */
  60917. onSuccess: (task: ImageAssetTask) => void;
  60918. /**
  60919. * Callback called when the task is successful
  60920. */
  60921. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60922. /**
  60923. * Creates a new ImageAssetTask
  60924. * @param name defines the name of the task
  60925. * @param url defines the location of the image to load
  60926. */
  60927. constructor(
  60928. /**
  60929. * Defines the name of the task
  60930. */
  60931. name: string,
  60932. /**
  60933. * Defines the location of the image to load
  60934. */
  60935. url: string);
  60936. /**
  60937. * Execute the current task
  60938. * @param scene defines the scene where you want your assets to be loaded
  60939. * @param onSuccess is a callback called when the task is successfully executed
  60940. * @param onError is a callback called if an error occurs
  60941. */
  60942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60943. }
  60944. /**
  60945. * Defines the interface used by texture loading tasks
  60946. */
  60947. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60948. /**
  60949. * Gets the loaded texture
  60950. */
  60951. texture: TEX;
  60952. }
  60953. /**
  60954. * Define a task used by AssetsManager to load 2D textures
  60955. */
  60956. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60957. /**
  60958. * Defines the name of the task
  60959. */
  60960. name: string;
  60961. /**
  60962. * Defines the location of the file to load
  60963. */
  60964. url: string;
  60965. /**
  60966. * Defines if mipmap should not be generated (default is false)
  60967. */
  60968. noMipmap?: boolean | undefined;
  60969. /**
  60970. * Defines if texture must be inverted on Y axis (default is false)
  60971. */
  60972. invertY?: boolean | undefined;
  60973. /**
  60974. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60975. */
  60976. samplingMode: number;
  60977. /**
  60978. * Gets the loaded texture
  60979. */
  60980. texture: Texture;
  60981. /**
  60982. * Callback called when the task is successful
  60983. */
  60984. onSuccess: (task: TextureAssetTask) => void;
  60985. /**
  60986. * Callback called when the task is successful
  60987. */
  60988. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60989. /**
  60990. * Creates a new TextureAssetTask object
  60991. * @param name defines the name of the task
  60992. * @param url defines the location of the file to load
  60993. * @param noMipmap defines if mipmap should not be generated (default is false)
  60994. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60995. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60996. */
  60997. constructor(
  60998. /**
  60999. * Defines the name of the task
  61000. */
  61001. name: string,
  61002. /**
  61003. * Defines the location of the file to load
  61004. */
  61005. url: string,
  61006. /**
  61007. * Defines if mipmap should not be generated (default is false)
  61008. */
  61009. noMipmap?: boolean | undefined,
  61010. /**
  61011. * Defines if texture must be inverted on Y axis (default is false)
  61012. */
  61013. invertY?: boolean | undefined,
  61014. /**
  61015. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61016. */
  61017. samplingMode?: number);
  61018. /**
  61019. * Execute the current task
  61020. * @param scene defines the scene where you want your assets to be loaded
  61021. * @param onSuccess is a callback called when the task is successfully executed
  61022. * @param onError is a callback called if an error occurs
  61023. */
  61024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61025. }
  61026. /**
  61027. * Define a task used by AssetsManager to load cube textures
  61028. */
  61029. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61030. /**
  61031. * Defines the name of the task
  61032. */
  61033. name: string;
  61034. /**
  61035. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61036. */
  61037. url: string;
  61038. /**
  61039. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61040. */
  61041. extensions?: string[] | undefined;
  61042. /**
  61043. * Defines if mipmaps should not be generated (default is false)
  61044. */
  61045. noMipmap?: boolean | undefined;
  61046. /**
  61047. * Defines the explicit list of files (undefined by default)
  61048. */
  61049. files?: string[] | undefined;
  61050. /**
  61051. * Gets the loaded texture
  61052. */
  61053. texture: CubeTexture;
  61054. /**
  61055. * Callback called when the task is successful
  61056. */
  61057. onSuccess: (task: CubeTextureAssetTask) => void;
  61058. /**
  61059. * Callback called when the task is successful
  61060. */
  61061. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61062. /**
  61063. * Creates a new CubeTextureAssetTask
  61064. * @param name defines the name of the task
  61065. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61066. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61067. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61068. * @param files defines the explicit list of files (undefined by default)
  61069. */
  61070. constructor(
  61071. /**
  61072. * Defines the name of the task
  61073. */
  61074. name: string,
  61075. /**
  61076. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61077. */
  61078. url: string,
  61079. /**
  61080. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61081. */
  61082. extensions?: string[] | undefined,
  61083. /**
  61084. * Defines if mipmaps should not be generated (default is false)
  61085. */
  61086. noMipmap?: boolean | undefined,
  61087. /**
  61088. * Defines the explicit list of files (undefined by default)
  61089. */
  61090. files?: string[] | undefined);
  61091. /**
  61092. * Execute the current task
  61093. * @param scene defines the scene where you want your assets to be loaded
  61094. * @param onSuccess is a callback called when the task is successfully executed
  61095. * @param onError is a callback called if an error occurs
  61096. */
  61097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61098. }
  61099. /**
  61100. * Define a task used by AssetsManager to load HDR cube textures
  61101. */
  61102. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61103. /**
  61104. * Defines the name of the task
  61105. */
  61106. name: string;
  61107. /**
  61108. * Defines the location of the file to load
  61109. */
  61110. url: string;
  61111. /**
  61112. * Defines the desired size (the more it increases the longer the generation will be)
  61113. */
  61114. size: number;
  61115. /**
  61116. * Defines if mipmaps should not be generated (default is false)
  61117. */
  61118. noMipmap: boolean;
  61119. /**
  61120. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61121. */
  61122. generateHarmonics: boolean;
  61123. /**
  61124. * 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)
  61125. */
  61126. gammaSpace: boolean;
  61127. /**
  61128. * Internal Use Only
  61129. */
  61130. reserved: boolean;
  61131. /**
  61132. * Gets the loaded texture
  61133. */
  61134. texture: HDRCubeTexture;
  61135. /**
  61136. * Callback called when the task is successful
  61137. */
  61138. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61139. /**
  61140. * Callback called when the task is successful
  61141. */
  61142. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61143. /**
  61144. * Creates a new HDRCubeTextureAssetTask object
  61145. * @param name defines the name of the task
  61146. * @param url defines the location of the file to load
  61147. * @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.
  61148. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61149. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61150. * @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)
  61151. * @param reserved Internal use only
  61152. */
  61153. constructor(
  61154. /**
  61155. * Defines the name of the task
  61156. */
  61157. name: string,
  61158. /**
  61159. * Defines the location of the file to load
  61160. */
  61161. url: string,
  61162. /**
  61163. * Defines the desired size (the more it increases the longer the generation will be)
  61164. */
  61165. size: number,
  61166. /**
  61167. * Defines if mipmaps should not be generated (default is false)
  61168. */
  61169. noMipmap?: boolean,
  61170. /**
  61171. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61172. */
  61173. generateHarmonics?: boolean,
  61174. /**
  61175. * 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)
  61176. */
  61177. gammaSpace?: boolean,
  61178. /**
  61179. * Internal Use Only
  61180. */
  61181. reserved?: boolean);
  61182. /**
  61183. * Execute the current task
  61184. * @param scene defines the scene where you want your assets to be loaded
  61185. * @param onSuccess is a callback called when the task is successfully executed
  61186. * @param onError is a callback called if an error occurs
  61187. */
  61188. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61189. }
  61190. /**
  61191. * Define a task used by AssetsManager to load Equirectangular cube textures
  61192. */
  61193. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61194. /**
  61195. * Defines the name of the task
  61196. */
  61197. name: string;
  61198. /**
  61199. * Defines the location of the file to load
  61200. */
  61201. url: string;
  61202. /**
  61203. * Defines the desired size (the more it increases the longer the generation will be)
  61204. */
  61205. size: number;
  61206. /**
  61207. * Defines if mipmaps should not be generated (default is false)
  61208. */
  61209. noMipmap: boolean;
  61210. /**
  61211. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61212. * but the standard material would require them in Gamma space) (default is true)
  61213. */
  61214. gammaSpace: boolean;
  61215. /**
  61216. * Gets the loaded texture
  61217. */
  61218. texture: EquiRectangularCubeTexture;
  61219. /**
  61220. * Callback called when the task is successful
  61221. */
  61222. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61223. /**
  61224. * Callback called when the task is successful
  61225. */
  61226. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61227. /**
  61228. * Creates a new EquiRectangularCubeTextureAssetTask object
  61229. * @param name defines the name of the task
  61230. * @param url defines the location of the file to load
  61231. * @param size defines the desired size (the more it increases the longer the generation will be)
  61232. * If the size is omitted this implies you are using a preprocessed cubemap.
  61233. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61234. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61235. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61236. * (default is true)
  61237. */
  61238. constructor(
  61239. /**
  61240. * Defines the name of the task
  61241. */
  61242. name: string,
  61243. /**
  61244. * Defines the location of the file to load
  61245. */
  61246. url: string,
  61247. /**
  61248. * Defines the desired size (the more it increases the longer the generation will be)
  61249. */
  61250. size: number,
  61251. /**
  61252. * Defines if mipmaps should not be generated (default is false)
  61253. */
  61254. noMipmap?: boolean,
  61255. /**
  61256. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61257. * but the standard material would require them in Gamma space) (default is true)
  61258. */
  61259. gammaSpace?: boolean);
  61260. /**
  61261. * Execute the current task
  61262. * @param scene defines the scene where you want your assets to be loaded
  61263. * @param onSuccess is a callback called when the task is successfully executed
  61264. * @param onError is a callback called if an error occurs
  61265. */
  61266. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61267. }
  61268. /**
  61269. * This class can be used to easily import assets into a scene
  61270. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61271. */
  61272. export class AssetsManager {
  61273. private _scene;
  61274. private _isLoading;
  61275. protected _tasks: AbstractAssetTask[];
  61276. protected _waitingTasksCount: number;
  61277. protected _totalTasksCount: number;
  61278. /**
  61279. * Callback called when all tasks are processed
  61280. */
  61281. onFinish: (tasks: AbstractAssetTask[]) => void;
  61282. /**
  61283. * Callback called when a task is successful
  61284. */
  61285. onTaskSuccess: (task: AbstractAssetTask) => void;
  61286. /**
  61287. * Callback called when a task had an error
  61288. */
  61289. onTaskError: (task: AbstractAssetTask) => void;
  61290. /**
  61291. * Callback called when a task is done (whatever the result is)
  61292. */
  61293. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61294. /**
  61295. * Observable called when all tasks are processed
  61296. */
  61297. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61298. /**
  61299. * Observable called when a task had an error
  61300. */
  61301. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61302. /**
  61303. * Observable called when all tasks were executed
  61304. */
  61305. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61306. /**
  61307. * Observable called when a task is done (whatever the result is)
  61308. */
  61309. onProgressObservable: Observable<IAssetsProgressEvent>;
  61310. /**
  61311. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61312. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61313. */
  61314. useDefaultLoadingScreen: boolean;
  61315. /**
  61316. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61317. * when all assets have been downloaded.
  61318. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61319. */
  61320. autoHideLoadingUI: boolean;
  61321. /**
  61322. * Creates a new AssetsManager
  61323. * @param scene defines the scene to work on
  61324. */
  61325. constructor(scene: Scene);
  61326. /**
  61327. * Add a MeshAssetTask to the list of active tasks
  61328. * @param taskName defines the name of the new task
  61329. * @param meshesNames defines the name of meshes to load
  61330. * @param rootUrl defines the root url to use to locate files
  61331. * @param sceneFilename defines the filename of the scene file
  61332. * @returns a new MeshAssetTask object
  61333. */
  61334. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61335. /**
  61336. * Add a TextFileAssetTask to the list of active tasks
  61337. * @param taskName defines the name of the new task
  61338. * @param url defines the url of the file to load
  61339. * @returns a new TextFileAssetTask object
  61340. */
  61341. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61342. /**
  61343. * Add a BinaryFileAssetTask to the list of active tasks
  61344. * @param taskName defines the name of the new task
  61345. * @param url defines the url of the file to load
  61346. * @returns a new BinaryFileAssetTask object
  61347. */
  61348. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61349. /**
  61350. * Add a ImageAssetTask to the list of active tasks
  61351. * @param taskName defines the name of the new task
  61352. * @param url defines the url of the file to load
  61353. * @returns a new ImageAssetTask object
  61354. */
  61355. addImageTask(taskName: string, url: string): ImageAssetTask;
  61356. /**
  61357. * Add a TextureAssetTask to the list of active tasks
  61358. * @param taskName defines the name of the new task
  61359. * @param url defines the url of the file to load
  61360. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61361. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61362. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61363. * @returns a new TextureAssetTask object
  61364. */
  61365. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61366. /**
  61367. * Add a CubeTextureAssetTask to the list of active tasks
  61368. * @param taskName defines the name of the new task
  61369. * @param url defines the url of the file to load
  61370. * @param extensions defines the extension to use to load the cube map (can be null)
  61371. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61372. * @param files defines the list of files to load (can be null)
  61373. * @returns a new CubeTextureAssetTask object
  61374. */
  61375. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61376. /**
  61377. *
  61378. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61379. * @param taskName defines the name of the new task
  61380. * @param url defines the url of the file to load
  61381. * @param size defines the size you want for the cubemap (can be null)
  61382. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61383. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61384. * @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)
  61385. * @param reserved Internal use only
  61386. * @returns a new HDRCubeTextureAssetTask object
  61387. */
  61388. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61389. /**
  61390. *
  61391. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61392. * @param taskName defines the name of the new task
  61393. * @param url defines the url of the file to load
  61394. * @param size defines the size you want for the cubemap (can be null)
  61395. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61396. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61397. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61398. * @returns a new EquiRectangularCubeTextureAssetTask object
  61399. */
  61400. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61401. /**
  61402. * Remove a task from the assets manager.
  61403. * @param task the task to remove
  61404. */
  61405. removeTask(task: AbstractAssetTask): void;
  61406. private _decreaseWaitingTasksCount;
  61407. private _runTask;
  61408. /**
  61409. * Reset the AssetsManager and remove all tasks
  61410. * @return the current instance of the AssetsManager
  61411. */
  61412. reset(): AssetsManager;
  61413. /**
  61414. * Start the loading process
  61415. * @return the current instance of the AssetsManager
  61416. */
  61417. load(): AssetsManager;
  61418. /**
  61419. * Start the loading process as an async operation
  61420. * @return a promise returning the list of failed tasks
  61421. */
  61422. loadAsync(): Promise<void>;
  61423. }
  61424. }
  61425. declare module BABYLON {
  61426. /**
  61427. * Wrapper class for promise with external resolve and reject.
  61428. */
  61429. export class Deferred<T> {
  61430. /**
  61431. * The promise associated with this deferred object.
  61432. */
  61433. readonly promise: Promise<T>;
  61434. private _resolve;
  61435. private _reject;
  61436. /**
  61437. * The resolve method of the promise associated with this deferred object.
  61438. */
  61439. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61440. /**
  61441. * The reject method of the promise associated with this deferred object.
  61442. */
  61443. readonly reject: (reason?: any) => void;
  61444. /**
  61445. * Constructor for this deferred object.
  61446. */
  61447. constructor();
  61448. }
  61449. }
  61450. declare module BABYLON {
  61451. /**
  61452. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61453. */
  61454. export class MeshExploder {
  61455. private _centerMesh;
  61456. private _meshes;
  61457. private _meshesOrigins;
  61458. private _toCenterVectors;
  61459. private _scaledDirection;
  61460. private _newPosition;
  61461. private _centerPosition;
  61462. /**
  61463. * Explodes meshes from a center mesh.
  61464. * @param meshes The meshes to explode.
  61465. * @param centerMesh The mesh to be center of explosion.
  61466. */
  61467. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61468. private _setCenterMesh;
  61469. /**
  61470. * Get class name
  61471. * @returns "MeshExploder"
  61472. */
  61473. getClassName(): string;
  61474. /**
  61475. * "Exploded meshes"
  61476. * @returns Array of meshes with the centerMesh at index 0.
  61477. */
  61478. getMeshes(): Array<Mesh>;
  61479. /**
  61480. * Explodes meshes giving a specific direction
  61481. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61482. */
  61483. explode(direction?: number): void;
  61484. }
  61485. }
  61486. declare module BABYLON {
  61487. /**
  61488. * Class used to help managing file picking and drag'n'drop
  61489. */
  61490. export class FilesInput {
  61491. /**
  61492. * List of files ready to be loaded
  61493. */
  61494. static readonly FilesToLoad: {
  61495. [key: string]: File;
  61496. };
  61497. /**
  61498. * Callback called when a file is processed
  61499. */
  61500. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61501. private _engine;
  61502. private _currentScene;
  61503. private _sceneLoadedCallback;
  61504. private _progressCallback;
  61505. private _additionalRenderLoopLogicCallback;
  61506. private _textureLoadingCallback;
  61507. private _startingProcessingFilesCallback;
  61508. private _onReloadCallback;
  61509. private _errorCallback;
  61510. private _elementToMonitor;
  61511. private _sceneFileToLoad;
  61512. private _filesToLoad;
  61513. /**
  61514. * Creates a new FilesInput
  61515. * @param engine defines the rendering engine
  61516. * @param scene defines the hosting scene
  61517. * @param sceneLoadedCallback callback called when scene is loaded
  61518. * @param progressCallback callback called to track progress
  61519. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61520. * @param textureLoadingCallback callback called when a texture is loading
  61521. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61522. * @param onReloadCallback callback called when a reload is requested
  61523. * @param errorCallback callback call if an error occurs
  61524. */
  61525. 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);
  61526. private _dragEnterHandler;
  61527. private _dragOverHandler;
  61528. private _dropHandler;
  61529. /**
  61530. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61531. * @param elementToMonitor defines the DOM element to track
  61532. */
  61533. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61534. /**
  61535. * Release all associated resources
  61536. */
  61537. dispose(): void;
  61538. private renderFunction;
  61539. private drag;
  61540. private drop;
  61541. private _traverseFolder;
  61542. private _processFiles;
  61543. /**
  61544. * Load files from a drop event
  61545. * @param event defines the drop event to use as source
  61546. */
  61547. loadFiles(event: any): void;
  61548. private _processReload;
  61549. /**
  61550. * Reload the current scene from the loaded files
  61551. */
  61552. reload(): void;
  61553. }
  61554. }
  61555. declare module BABYLON {
  61556. /**
  61557. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61558. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61559. */
  61560. export class SceneOptimization {
  61561. /**
  61562. * Defines the priority of this optimization (0 by default which means first in the list)
  61563. */
  61564. priority: number;
  61565. /**
  61566. * Gets a string describing the action executed by the current optimization
  61567. * @returns description string
  61568. */
  61569. getDescription(): string;
  61570. /**
  61571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61572. * @param scene defines the current scene where to apply this optimization
  61573. * @param optimizer defines the current optimizer
  61574. * @returns true if everything that can be done was applied
  61575. */
  61576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61577. /**
  61578. * Creates the SceneOptimization object
  61579. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61580. * @param desc defines the description associated with the optimization
  61581. */
  61582. constructor(
  61583. /**
  61584. * Defines the priority of this optimization (0 by default which means first in the list)
  61585. */
  61586. priority?: number);
  61587. }
  61588. /**
  61589. * Defines an optimization used to reduce the size of render target textures
  61590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61591. */
  61592. export class TextureOptimization extends SceneOptimization {
  61593. /**
  61594. * Defines the priority of this optimization (0 by default which means first in the list)
  61595. */
  61596. priority: number;
  61597. /**
  61598. * 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
  61599. */
  61600. maximumSize: number;
  61601. /**
  61602. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61603. */
  61604. step: number;
  61605. /**
  61606. * Gets a string describing the action executed by the current optimization
  61607. * @returns description string
  61608. */
  61609. getDescription(): string;
  61610. /**
  61611. * Creates the TextureOptimization object
  61612. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61613. * @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
  61614. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61615. */
  61616. constructor(
  61617. /**
  61618. * Defines the priority of this optimization (0 by default which means first in the list)
  61619. */
  61620. priority?: number,
  61621. /**
  61622. * 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
  61623. */
  61624. maximumSize?: number,
  61625. /**
  61626. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61627. */
  61628. step?: number);
  61629. /**
  61630. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61631. * @param scene defines the current scene where to apply this optimization
  61632. * @param optimizer defines the current optimizer
  61633. * @returns true if everything that can be done was applied
  61634. */
  61635. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61636. }
  61637. /**
  61638. * Defines an optimization used to increase or decrease the rendering resolution
  61639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61640. */
  61641. export class HardwareScalingOptimization extends SceneOptimization {
  61642. /**
  61643. * Defines the priority of this optimization (0 by default which means first in the list)
  61644. */
  61645. priority: number;
  61646. /**
  61647. * Defines the maximum scale to use (2 by default)
  61648. */
  61649. maximumScale: number;
  61650. /**
  61651. * Defines the step to use between two passes (0.5 by default)
  61652. */
  61653. step: number;
  61654. private _currentScale;
  61655. private _directionOffset;
  61656. /**
  61657. * Gets a string describing the action executed by the current optimization
  61658. * @return description string
  61659. */
  61660. getDescription(): string;
  61661. /**
  61662. * Creates the HardwareScalingOptimization object
  61663. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61664. * @param maximumScale defines the maximum scale to use (2 by default)
  61665. * @param step defines the step to use between two passes (0.5 by default)
  61666. */
  61667. constructor(
  61668. /**
  61669. * Defines the priority of this optimization (0 by default which means first in the list)
  61670. */
  61671. priority?: number,
  61672. /**
  61673. * Defines the maximum scale to use (2 by default)
  61674. */
  61675. maximumScale?: number,
  61676. /**
  61677. * Defines the step to use between two passes (0.5 by default)
  61678. */
  61679. step?: number);
  61680. /**
  61681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61682. * @param scene defines the current scene where to apply this optimization
  61683. * @param optimizer defines the current optimizer
  61684. * @returns true if everything that can be done was applied
  61685. */
  61686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61687. }
  61688. /**
  61689. * Defines an optimization used to remove shadows
  61690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61691. */
  61692. export class ShadowsOptimization extends SceneOptimization {
  61693. /**
  61694. * Gets a string describing the action executed by the current optimization
  61695. * @return description string
  61696. */
  61697. getDescription(): string;
  61698. /**
  61699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61700. * @param scene defines the current scene where to apply this optimization
  61701. * @param optimizer defines the current optimizer
  61702. * @returns true if everything that can be done was applied
  61703. */
  61704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61705. }
  61706. /**
  61707. * Defines an optimization used to turn post-processes off
  61708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61709. */
  61710. export class PostProcessesOptimization extends SceneOptimization {
  61711. /**
  61712. * Gets a string describing the action executed by the current optimization
  61713. * @return description string
  61714. */
  61715. getDescription(): string;
  61716. /**
  61717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61718. * @param scene defines the current scene where to apply this optimization
  61719. * @param optimizer defines the current optimizer
  61720. * @returns true if everything that can be done was applied
  61721. */
  61722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61723. }
  61724. /**
  61725. * Defines an optimization used to turn lens flares off
  61726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61727. */
  61728. export class LensFlaresOptimization extends SceneOptimization {
  61729. /**
  61730. * Gets a string describing the action executed by the current optimization
  61731. * @return description string
  61732. */
  61733. getDescription(): string;
  61734. /**
  61735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61736. * @param scene defines the current scene where to apply this optimization
  61737. * @param optimizer defines the current optimizer
  61738. * @returns true if everything that can be done was applied
  61739. */
  61740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61741. }
  61742. /**
  61743. * Defines an optimization based on user defined callback.
  61744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61745. */
  61746. export class CustomOptimization extends SceneOptimization {
  61747. /**
  61748. * Callback called to apply the custom optimization.
  61749. */
  61750. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61751. /**
  61752. * Callback called to get custom description
  61753. */
  61754. onGetDescription: () => string;
  61755. /**
  61756. * Gets a string describing the action executed by the current optimization
  61757. * @returns description string
  61758. */
  61759. getDescription(): string;
  61760. /**
  61761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61762. * @param scene defines the current scene where to apply this optimization
  61763. * @param optimizer defines the current optimizer
  61764. * @returns true if everything that can be done was applied
  61765. */
  61766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61767. }
  61768. /**
  61769. * Defines an optimization used to turn particles off
  61770. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61771. */
  61772. export class ParticlesOptimization extends SceneOptimization {
  61773. /**
  61774. * Gets a string describing the action executed by the current optimization
  61775. * @return description string
  61776. */
  61777. getDescription(): string;
  61778. /**
  61779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61780. * @param scene defines the current scene where to apply this optimization
  61781. * @param optimizer defines the current optimizer
  61782. * @returns true if everything that can be done was applied
  61783. */
  61784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61785. }
  61786. /**
  61787. * Defines an optimization used to turn render targets off
  61788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61789. */
  61790. export class RenderTargetsOptimization extends SceneOptimization {
  61791. /**
  61792. * Gets a string describing the action executed by the current optimization
  61793. * @return description string
  61794. */
  61795. getDescription(): string;
  61796. /**
  61797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61798. * @param scene defines the current scene where to apply this optimization
  61799. * @param optimizer defines the current optimizer
  61800. * @returns true if everything that can be done was applied
  61801. */
  61802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61803. }
  61804. /**
  61805. * Defines an optimization used to merge meshes with compatible materials
  61806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61807. */
  61808. export class MergeMeshesOptimization extends SceneOptimization {
  61809. private static _UpdateSelectionTree;
  61810. /**
  61811. * Gets or sets a boolean which defines if optimization octree has to be updated
  61812. */
  61813. /**
  61814. * Gets or sets a boolean which defines if optimization octree has to be updated
  61815. */
  61816. static UpdateSelectionTree: boolean;
  61817. /**
  61818. * Gets a string describing the action executed by the current optimization
  61819. * @return description string
  61820. */
  61821. getDescription(): string;
  61822. private _canBeMerged;
  61823. /**
  61824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61825. * @param scene defines the current scene where to apply this optimization
  61826. * @param optimizer defines the current optimizer
  61827. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61828. * @returns true if everything that can be done was applied
  61829. */
  61830. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61831. }
  61832. /**
  61833. * Defines a list of options used by SceneOptimizer
  61834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61835. */
  61836. export class SceneOptimizerOptions {
  61837. /**
  61838. * Defines the target frame rate to reach (60 by default)
  61839. */
  61840. targetFrameRate: number;
  61841. /**
  61842. * Defines the interval between two checkes (2000ms by default)
  61843. */
  61844. trackerDuration: number;
  61845. /**
  61846. * Gets the list of optimizations to apply
  61847. */
  61848. optimizations: SceneOptimization[];
  61849. /**
  61850. * Creates a new list of options used by SceneOptimizer
  61851. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61852. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61853. */
  61854. constructor(
  61855. /**
  61856. * Defines the target frame rate to reach (60 by default)
  61857. */
  61858. targetFrameRate?: number,
  61859. /**
  61860. * Defines the interval between two checkes (2000ms by default)
  61861. */
  61862. trackerDuration?: number);
  61863. /**
  61864. * Add a new optimization
  61865. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61866. * @returns the current SceneOptimizerOptions
  61867. */
  61868. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61869. /**
  61870. * Add a new custom optimization
  61871. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61872. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61873. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61874. * @returns the current SceneOptimizerOptions
  61875. */
  61876. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61877. /**
  61878. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61879. * @param targetFrameRate defines the target frame rate (60 by default)
  61880. * @returns a SceneOptimizerOptions object
  61881. */
  61882. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61883. /**
  61884. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61885. * @param targetFrameRate defines the target frame rate (60 by default)
  61886. * @returns a SceneOptimizerOptions object
  61887. */
  61888. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61889. /**
  61890. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61891. * @param targetFrameRate defines the target frame rate (60 by default)
  61892. * @returns a SceneOptimizerOptions object
  61893. */
  61894. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61895. }
  61896. /**
  61897. * Class used to run optimizations in order to reach a target frame rate
  61898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61899. */
  61900. export class SceneOptimizer implements IDisposable {
  61901. private _isRunning;
  61902. private _options;
  61903. private _scene;
  61904. private _currentPriorityLevel;
  61905. private _targetFrameRate;
  61906. private _trackerDuration;
  61907. private _currentFrameRate;
  61908. private _sceneDisposeObserver;
  61909. private _improvementMode;
  61910. /**
  61911. * Defines an observable called when the optimizer reaches the target frame rate
  61912. */
  61913. onSuccessObservable: Observable<SceneOptimizer>;
  61914. /**
  61915. * Defines an observable called when the optimizer enables an optimization
  61916. */
  61917. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61918. /**
  61919. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61920. */
  61921. onFailureObservable: Observable<SceneOptimizer>;
  61922. /**
  61923. * Gets a boolean indicating if the optimizer is in improvement mode
  61924. */
  61925. readonly isInImprovementMode: boolean;
  61926. /**
  61927. * Gets the current priority level (0 at start)
  61928. */
  61929. readonly currentPriorityLevel: number;
  61930. /**
  61931. * Gets the current frame rate checked by the SceneOptimizer
  61932. */
  61933. readonly currentFrameRate: number;
  61934. /**
  61935. * Gets or sets the current target frame rate (60 by default)
  61936. */
  61937. /**
  61938. * Gets or sets the current target frame rate (60 by default)
  61939. */
  61940. targetFrameRate: number;
  61941. /**
  61942. * Gets or sets the current interval between two checks (every 2000ms by default)
  61943. */
  61944. /**
  61945. * Gets or sets the current interval between two checks (every 2000ms by default)
  61946. */
  61947. trackerDuration: number;
  61948. /**
  61949. * Gets the list of active optimizations
  61950. */
  61951. readonly optimizations: SceneOptimization[];
  61952. /**
  61953. * Creates a new SceneOptimizer
  61954. * @param scene defines the scene to work on
  61955. * @param options defines the options to use with the SceneOptimizer
  61956. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61957. * @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)
  61958. */
  61959. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61960. /**
  61961. * Stops the current optimizer
  61962. */
  61963. stop(): void;
  61964. /**
  61965. * Reset the optimizer to initial step (current priority level = 0)
  61966. */
  61967. reset(): void;
  61968. /**
  61969. * Start the optimizer. By default it will try to reach a specific framerate
  61970. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61971. */
  61972. start(): void;
  61973. private _checkCurrentState;
  61974. /**
  61975. * Release all resources
  61976. */
  61977. dispose(): void;
  61978. /**
  61979. * Helper function to create a SceneOptimizer with one single line of code
  61980. * @param scene defines the scene to work on
  61981. * @param options defines the options to use with the SceneOptimizer
  61982. * @param onSuccess defines a callback to call on success
  61983. * @param onFailure defines a callback to call on failure
  61984. * @returns the new SceneOptimizer object
  61985. */
  61986. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61987. }
  61988. }
  61989. declare module BABYLON {
  61990. /**
  61991. * Class used to serialize a scene into a string
  61992. */
  61993. export class SceneSerializer {
  61994. /**
  61995. * Clear cache used by a previous serialization
  61996. */
  61997. static ClearCache(): void;
  61998. /**
  61999. * Serialize a scene into a JSON compatible object
  62000. * @param scene defines the scene to serialize
  62001. * @returns a JSON compatible object
  62002. */
  62003. static Serialize(scene: Scene): any;
  62004. /**
  62005. * Serialize a mesh into a JSON compatible object
  62006. * @param toSerialize defines the mesh to serialize
  62007. * @param withParents defines if parents must be serialized as well
  62008. * @param withChildren defines if children must be serialized as well
  62009. * @returns a JSON compatible object
  62010. */
  62011. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62012. }
  62013. }
  62014. declare module BABYLON {
  62015. /**
  62016. * Class used to host texture specific utilities
  62017. */
  62018. export class TextureTools {
  62019. /**
  62020. * Uses the GPU to create a copy texture rescaled at a given size
  62021. * @param texture Texture to copy from
  62022. * @param width defines the desired width
  62023. * @param height defines the desired height
  62024. * @param useBilinearMode defines if bilinear mode has to be used
  62025. * @return the generated texture
  62026. */
  62027. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62028. }
  62029. }
  62030. declare module BABYLON {
  62031. /**
  62032. * This represents the different options available for the video capture.
  62033. */
  62034. export interface VideoRecorderOptions {
  62035. /** Defines the mime type of the video. */
  62036. mimeType: string;
  62037. /** Defines the FPS the video should be recorded at. */
  62038. fps: number;
  62039. /** Defines the chunk size for the recording data. */
  62040. recordChunckSize: number;
  62041. /** The audio tracks to attach to the recording. */
  62042. audioTracks?: MediaStreamTrack[];
  62043. }
  62044. /**
  62045. * This can help with recording videos from BabylonJS.
  62046. * This is based on the available WebRTC functionalities of the browser.
  62047. *
  62048. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62049. */
  62050. export class VideoRecorder {
  62051. private static readonly _defaultOptions;
  62052. /**
  62053. * Returns whether or not the VideoRecorder is available in your browser.
  62054. * @param engine Defines the Babylon Engine.
  62055. * @returns true if supported otherwise false.
  62056. */
  62057. static IsSupported(engine: Engine): boolean;
  62058. private readonly _options;
  62059. private _canvas;
  62060. private _mediaRecorder;
  62061. private _recordedChunks;
  62062. private _fileName;
  62063. private _resolve;
  62064. private _reject;
  62065. /**
  62066. * True when a recording is already in progress.
  62067. */
  62068. readonly isRecording: boolean;
  62069. /**
  62070. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62071. * @param engine Defines the BabylonJS Engine you wish to record.
  62072. * @param options Defines options that can be used to customize the capture.
  62073. */
  62074. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62075. /**
  62076. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62077. */
  62078. stopRecording(): void;
  62079. /**
  62080. * Starts recording the canvas for a max duration specified in parameters.
  62081. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62082. * If null no automatic download will start and you can rely on the promise to get the data back.
  62083. * @param maxDuration Defines the maximum recording time in seconds.
  62084. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62085. * @return A promise callback at the end of the recording with the video data in Blob.
  62086. */
  62087. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62088. /**
  62089. * Releases internal resources used during the recording.
  62090. */
  62091. dispose(): void;
  62092. private _handleDataAvailable;
  62093. private _handleError;
  62094. private _handleStop;
  62095. }
  62096. }
  62097. declare module BABYLON {
  62098. /**
  62099. * Class containing a set of static utilities functions for screenshots
  62100. */
  62101. export class ScreenshotTools {
  62102. /**
  62103. * Captures a screenshot of the current rendering
  62104. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62105. * @param engine defines the rendering engine
  62106. * @param camera defines the source camera
  62107. * @param size This parameter can be set to a single number or to an object with the
  62108. * following (optional) properties: precision, width, height. If a single number is passed,
  62109. * it will be used for both width and height. If an object is passed, the screenshot size
  62110. * will be derived from the parameters. The precision property is a multiplier allowing
  62111. * rendering at a higher or lower resolution
  62112. * @param successCallback defines the callback receives a single parameter which contains the
  62113. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62114. * src parameter of an <img> to display it
  62115. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62116. * Check your browser for supported MIME types
  62117. */
  62118. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62119. /**
  62120. * Captures a screenshot of the current rendering
  62121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62122. * @param engine defines the rendering engine
  62123. * @param camera defines the source camera
  62124. * @param size This parameter can be set to a single number or to an object with the
  62125. * following (optional) properties: precision, width, height. If a single number is passed,
  62126. * it will be used for both width and height. If an object is passed, the screenshot size
  62127. * will be derived from the parameters. The precision property is a multiplier allowing
  62128. * rendering at a higher or lower resolution
  62129. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62130. * Check your browser for supported MIME types
  62131. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62132. * to the src parameter of an <img> to display it
  62133. */
  62134. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62135. /**
  62136. * Generates an image screenshot from the specified camera.
  62137. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62138. * @param engine The engine to use for rendering
  62139. * @param camera The camera to use for rendering
  62140. * @param size This parameter can be set to a single number or to an object with the
  62141. * following (optional) properties: precision, width, height. If a single number is passed,
  62142. * it will be used for both width and height. If an object is passed, the screenshot size
  62143. * will be derived from the parameters. The precision property is a multiplier allowing
  62144. * rendering at a higher or lower resolution
  62145. * @param successCallback The callback receives a single parameter which contains the
  62146. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62147. * src parameter of an <img> to display it
  62148. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62149. * Check your browser for supported MIME types
  62150. * @param samples Texture samples (default: 1)
  62151. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62152. * @param fileName A name for for the downloaded file.
  62153. */
  62154. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62155. /**
  62156. * Generates an image screenshot from the specified camera.
  62157. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62158. * @param engine The engine to use for rendering
  62159. * @param camera The camera to use for rendering
  62160. * @param size This parameter can be set to a single number or to an object with the
  62161. * following (optional) properties: precision, width, height. If a single number is passed,
  62162. * it will be used for both width and height. If an object is passed, the screenshot size
  62163. * will be derived from the parameters. The precision property is a multiplier allowing
  62164. * rendering at a higher or lower resolution
  62165. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62166. * Check your browser for supported MIME types
  62167. * @param samples Texture samples (default: 1)
  62168. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62169. * @param fileName A name for for the downloaded file.
  62170. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62171. * to the src parameter of an <img> to display it
  62172. */
  62173. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62174. /**
  62175. * Gets height and width for screenshot size
  62176. * @private
  62177. */
  62178. private static _getScreenshotSize;
  62179. }
  62180. }
  62181. declare module BABYLON {
  62182. /**
  62183. * A cursor which tracks a point on a path
  62184. */
  62185. export class PathCursor {
  62186. private path;
  62187. /**
  62188. * Stores path cursor callbacks for when an onchange event is triggered
  62189. */
  62190. private _onchange;
  62191. /**
  62192. * The value of the path cursor
  62193. */
  62194. value: number;
  62195. /**
  62196. * The animation array of the path cursor
  62197. */
  62198. animations: Animation[];
  62199. /**
  62200. * Initializes the path cursor
  62201. * @param path The path to track
  62202. */
  62203. constructor(path: Path2);
  62204. /**
  62205. * Gets the cursor point on the path
  62206. * @returns A point on the path cursor at the cursor location
  62207. */
  62208. getPoint(): Vector3;
  62209. /**
  62210. * Moves the cursor ahead by the step amount
  62211. * @param step The amount to move the cursor forward
  62212. * @returns This path cursor
  62213. */
  62214. moveAhead(step?: number): PathCursor;
  62215. /**
  62216. * Moves the cursor behind by the step amount
  62217. * @param step The amount to move the cursor back
  62218. * @returns This path cursor
  62219. */
  62220. moveBack(step?: number): PathCursor;
  62221. /**
  62222. * Moves the cursor by the step amount
  62223. * If the step amount is greater than one, an exception is thrown
  62224. * @param step The amount to move the cursor
  62225. * @returns This path cursor
  62226. */
  62227. move(step: number): PathCursor;
  62228. /**
  62229. * Ensures that the value is limited between zero and one
  62230. * @returns This path cursor
  62231. */
  62232. private ensureLimits;
  62233. /**
  62234. * Runs onchange callbacks on change (used by the animation engine)
  62235. * @returns This path cursor
  62236. */
  62237. private raiseOnChange;
  62238. /**
  62239. * Executes a function on change
  62240. * @param f A path cursor onchange callback
  62241. * @returns This path cursor
  62242. */
  62243. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62244. }
  62245. }
  62246. declare module BABYLON {
  62247. /** @hidden */
  62248. export var blurPixelShader: {
  62249. name: string;
  62250. shader: string;
  62251. };
  62252. }
  62253. declare module BABYLON {
  62254. /** @hidden */
  62255. export var pointCloudVertexDeclaration: {
  62256. name: string;
  62257. shader: string;
  62258. };
  62259. }
  62260. // Mixins
  62261. interface Window {
  62262. mozIndexedDB: IDBFactory;
  62263. webkitIndexedDB: IDBFactory;
  62264. msIndexedDB: IDBFactory;
  62265. webkitURL: typeof URL;
  62266. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62267. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62268. WebGLRenderingContext: WebGLRenderingContext;
  62269. MSGesture: MSGesture;
  62270. CANNON: any;
  62271. AudioContext: AudioContext;
  62272. webkitAudioContext: AudioContext;
  62273. PointerEvent: any;
  62274. Math: Math;
  62275. Uint8Array: Uint8ArrayConstructor;
  62276. Float32Array: Float32ArrayConstructor;
  62277. mozURL: typeof URL;
  62278. msURL: typeof URL;
  62279. VRFrameData: any; // WebVR, from specs 1.1
  62280. DracoDecoderModule: any;
  62281. setImmediate(handler: (...args: any[]) => void): number;
  62282. }
  62283. interface HTMLCanvasElement {
  62284. requestPointerLock(): void;
  62285. msRequestPointerLock?(): void;
  62286. mozRequestPointerLock?(): void;
  62287. webkitRequestPointerLock?(): void;
  62288. /** Track wether a record is in progress */
  62289. isRecording: boolean;
  62290. /** Capture Stream method defined by some browsers */
  62291. captureStream(fps?: number): MediaStream;
  62292. }
  62293. interface CanvasRenderingContext2D {
  62294. msImageSmoothingEnabled: boolean;
  62295. }
  62296. interface MouseEvent {
  62297. mozMovementX: number;
  62298. mozMovementY: number;
  62299. webkitMovementX: number;
  62300. webkitMovementY: number;
  62301. msMovementX: number;
  62302. msMovementY: number;
  62303. }
  62304. interface Navigator {
  62305. mozGetVRDevices: (any: any) => any;
  62306. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62307. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62308. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62309. webkitGetGamepads(): Gamepad[];
  62310. msGetGamepads(): Gamepad[];
  62311. webkitGamepads(): Gamepad[];
  62312. }
  62313. interface HTMLVideoElement {
  62314. mozSrcObject: any;
  62315. }
  62316. interface Math {
  62317. fround(x: number): number;
  62318. imul(a: number, b: number): number;
  62319. }
  62320. interface WebGLRenderingContext {
  62321. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62322. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62323. vertexAttribDivisor(index: number, divisor: number): void;
  62324. createVertexArray(): any;
  62325. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62326. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62327. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62328. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62329. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62330. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62331. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62332. // Queries
  62333. createQuery(): WebGLQuery;
  62334. deleteQuery(query: WebGLQuery): void;
  62335. beginQuery(target: number, query: WebGLQuery): void;
  62336. endQuery(target: number): void;
  62337. getQueryParameter(query: WebGLQuery, pname: number): any;
  62338. getQuery(target: number, pname: number): any;
  62339. MAX_SAMPLES: number;
  62340. RGBA8: number;
  62341. READ_FRAMEBUFFER: number;
  62342. DRAW_FRAMEBUFFER: number;
  62343. UNIFORM_BUFFER: number;
  62344. HALF_FLOAT_OES: number;
  62345. RGBA16F: number;
  62346. RGBA32F: number;
  62347. R32F: number;
  62348. RG32F: number;
  62349. RGB32F: number;
  62350. R16F: number;
  62351. RG16F: number;
  62352. RGB16F: number;
  62353. RED: number;
  62354. RG: number;
  62355. R8: number;
  62356. RG8: number;
  62357. UNSIGNED_INT_24_8: number;
  62358. DEPTH24_STENCIL8: number;
  62359. /* Multiple Render Targets */
  62360. drawBuffers(buffers: number[]): void;
  62361. readBuffer(src: number): void;
  62362. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62363. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62364. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62365. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62366. // Occlusion Query
  62367. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62368. ANY_SAMPLES_PASSED: number;
  62369. QUERY_RESULT_AVAILABLE: number;
  62370. QUERY_RESULT: number;
  62371. }
  62372. interface WebGLProgram {
  62373. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62374. }
  62375. interface EXT_disjoint_timer_query {
  62376. QUERY_COUNTER_BITS_EXT: number;
  62377. TIME_ELAPSED_EXT: number;
  62378. TIMESTAMP_EXT: number;
  62379. GPU_DISJOINT_EXT: number;
  62380. QUERY_RESULT_EXT: number;
  62381. QUERY_RESULT_AVAILABLE_EXT: number;
  62382. queryCounterEXT(query: WebGLQuery, target: number): void;
  62383. createQueryEXT(): WebGLQuery;
  62384. beginQueryEXT(target: number, query: WebGLQuery): void;
  62385. endQueryEXT(target: number): void;
  62386. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62387. deleteQueryEXT(query: WebGLQuery): void;
  62388. }
  62389. interface WebGLUniformLocation {
  62390. _currentState: any;
  62391. }
  62392. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62393. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62394. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62395. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62396. interface WebGLRenderingContext {
  62397. readonly RASTERIZER_DISCARD: number;
  62398. readonly DEPTH_COMPONENT24: number;
  62399. readonly TEXTURE_3D: number;
  62400. readonly TEXTURE_2D_ARRAY: number;
  62401. readonly TEXTURE_COMPARE_FUNC: number;
  62402. readonly TEXTURE_COMPARE_MODE: number;
  62403. readonly COMPARE_REF_TO_TEXTURE: number;
  62404. readonly TEXTURE_WRAP_R: number;
  62405. readonly HALF_FLOAT: number;
  62406. readonly RGB8: number;
  62407. readonly RED_INTEGER: number;
  62408. readonly RG_INTEGER: number;
  62409. readonly RGB_INTEGER: number;
  62410. readonly RGBA_INTEGER: number;
  62411. readonly R8_SNORM: number;
  62412. readonly RG8_SNORM: number;
  62413. readonly RGB8_SNORM: number;
  62414. readonly RGBA8_SNORM: number;
  62415. readonly R8I: number;
  62416. readonly RG8I: number;
  62417. readonly RGB8I: number;
  62418. readonly RGBA8I: number;
  62419. readonly R8UI: number;
  62420. readonly RG8UI: number;
  62421. readonly RGB8UI: number;
  62422. readonly RGBA8UI: number;
  62423. readonly R16I: number;
  62424. readonly RG16I: number;
  62425. readonly RGB16I: number;
  62426. readonly RGBA16I: number;
  62427. readonly R16UI: number;
  62428. readonly RG16UI: number;
  62429. readonly RGB16UI: number;
  62430. readonly RGBA16UI: number;
  62431. readonly R32I: number;
  62432. readonly RG32I: number;
  62433. readonly RGB32I: number;
  62434. readonly RGBA32I: number;
  62435. readonly R32UI: number;
  62436. readonly RG32UI: number;
  62437. readonly RGB32UI: number;
  62438. readonly RGBA32UI: number;
  62439. readonly RGB10_A2UI: number;
  62440. readonly R11F_G11F_B10F: number;
  62441. readonly RGB9_E5: number;
  62442. readonly RGB10_A2: number;
  62443. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62444. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62445. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62446. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62447. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62448. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62449. 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;
  62450. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62451. readonly TRANSFORM_FEEDBACK: number;
  62452. readonly INTERLEAVED_ATTRIBS: number;
  62453. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62454. createTransformFeedback(): WebGLTransformFeedback;
  62455. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62456. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62457. beginTransformFeedback(primitiveMode: number): void;
  62458. endTransformFeedback(): void;
  62459. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62460. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62461. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62462. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62463. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62464. }
  62465. interface ImageBitmap {
  62466. readonly width: number;
  62467. readonly height: number;
  62468. close(): void;
  62469. }
  62470. interface WebGLQuery extends WebGLObject {
  62471. }
  62472. declare var WebGLQuery: {
  62473. prototype: WebGLQuery;
  62474. new(): WebGLQuery;
  62475. };
  62476. interface WebGLSampler extends WebGLObject {
  62477. }
  62478. declare var WebGLSampler: {
  62479. prototype: WebGLSampler;
  62480. new(): WebGLSampler;
  62481. };
  62482. interface WebGLSync extends WebGLObject {
  62483. }
  62484. declare var WebGLSync: {
  62485. prototype: WebGLSync;
  62486. new(): WebGLSync;
  62487. };
  62488. interface WebGLTransformFeedback extends WebGLObject {
  62489. }
  62490. declare var WebGLTransformFeedback: {
  62491. prototype: WebGLTransformFeedback;
  62492. new(): WebGLTransformFeedback;
  62493. };
  62494. interface WebGLVertexArrayObject extends WebGLObject {
  62495. }
  62496. declare var WebGLVertexArrayObject: {
  62497. prototype: WebGLVertexArrayObject;
  62498. new(): WebGLVertexArrayObject;
  62499. };
  62500. // Type definitions for WebVR API
  62501. // Project: https://w3c.github.io/webvr/
  62502. // Definitions by: six a <https://github.com/lostfictions>
  62503. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62504. interface VRDisplay extends EventTarget {
  62505. /**
  62506. * Dictionary of capabilities describing the VRDisplay.
  62507. */
  62508. readonly capabilities: VRDisplayCapabilities;
  62509. /**
  62510. * z-depth defining the far plane of the eye view frustum
  62511. * enables mapping of values in the render target depth
  62512. * attachment to scene coordinates. Initially set to 10000.0.
  62513. */
  62514. depthFar: number;
  62515. /**
  62516. * z-depth defining the near plane of the eye view frustum
  62517. * enables mapping of values in the render target depth
  62518. * attachment to scene coordinates. Initially set to 0.01.
  62519. */
  62520. depthNear: number;
  62521. /**
  62522. * An identifier for this distinct VRDisplay. Used as an
  62523. * association point in the Gamepad API.
  62524. */
  62525. readonly displayId: number;
  62526. /**
  62527. * A display name, a user-readable name identifying it.
  62528. */
  62529. readonly displayName: string;
  62530. readonly isConnected: boolean;
  62531. readonly isPresenting: boolean;
  62532. /**
  62533. * If this VRDisplay supports room-scale experiences, the optional
  62534. * stage attribute contains details on the room-scale parameters.
  62535. */
  62536. readonly stageParameters: VRStageParameters | null;
  62537. /**
  62538. * Passing the value returned by `requestAnimationFrame` to
  62539. * `cancelAnimationFrame` will unregister the callback.
  62540. * @param handle Define the hanle of the request to cancel
  62541. */
  62542. cancelAnimationFrame(handle: number): void;
  62543. /**
  62544. * Stops presenting to the VRDisplay.
  62545. * @returns a promise to know when it stopped
  62546. */
  62547. exitPresent(): Promise<void>;
  62548. /**
  62549. * Return the current VREyeParameters for the given eye.
  62550. * @param whichEye Define the eye we want the parameter for
  62551. * @returns the eye parameters
  62552. */
  62553. getEyeParameters(whichEye: string): VREyeParameters;
  62554. /**
  62555. * Populates the passed VRFrameData with the information required to render
  62556. * the current frame.
  62557. * @param frameData Define the data structure to populate
  62558. * @returns true if ok otherwise false
  62559. */
  62560. getFrameData(frameData: VRFrameData): boolean;
  62561. /**
  62562. * Get the layers currently being presented.
  62563. * @returns the list of VR layers
  62564. */
  62565. getLayers(): VRLayer[];
  62566. /**
  62567. * Return a VRPose containing the future predicted pose of the VRDisplay
  62568. * when the current frame will be presented. The value returned will not
  62569. * change until JavaScript has returned control to the browser.
  62570. *
  62571. * The VRPose will contain the position, orientation, velocity,
  62572. * and acceleration of each of these properties.
  62573. * @returns the pose object
  62574. */
  62575. getPose(): VRPose;
  62576. /**
  62577. * Return the current instantaneous pose of the VRDisplay, with no
  62578. * prediction applied.
  62579. * @returns the current instantaneous pose
  62580. */
  62581. getImmediatePose(): VRPose;
  62582. /**
  62583. * The callback passed to `requestAnimationFrame` will be called
  62584. * any time a new frame should be rendered. When the VRDisplay is
  62585. * presenting the callback will be called at the native refresh
  62586. * rate of the HMD. When not presenting this function acts
  62587. * identically to how window.requestAnimationFrame acts. Content should
  62588. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62589. * asynchronously from other displays and at differing refresh rates.
  62590. * @param callback Define the eaction to run next frame
  62591. * @returns the request handle it
  62592. */
  62593. requestAnimationFrame(callback: FrameRequestCallback): number;
  62594. /**
  62595. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62596. * Repeat calls while already presenting will update the VRLayers being displayed.
  62597. * @param layers Define the list of layer to present
  62598. * @returns a promise to know when the request has been fulfilled
  62599. */
  62600. requestPresent(layers: VRLayer[]): Promise<void>;
  62601. /**
  62602. * Reset the pose for this display, treating its current position and
  62603. * orientation as the "origin/zero" values. VRPose.position,
  62604. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62605. * updated when calling resetPose(). This should be called in only
  62606. * sitting-space experiences.
  62607. */
  62608. resetPose(): void;
  62609. /**
  62610. * The VRLayer provided to the VRDisplay will be captured and presented
  62611. * in the HMD. Calling this function has the same effect on the source
  62612. * canvas as any other operation that uses its source image, and canvases
  62613. * created without preserveDrawingBuffer set to true will be cleared.
  62614. * @param pose Define the pose to submit
  62615. */
  62616. submitFrame(pose?: VRPose): void;
  62617. }
  62618. declare var VRDisplay: {
  62619. prototype: VRDisplay;
  62620. new(): VRDisplay;
  62621. };
  62622. interface VRLayer {
  62623. leftBounds?: number[] | Float32Array | null;
  62624. rightBounds?: number[] | Float32Array | null;
  62625. source?: HTMLCanvasElement | null;
  62626. }
  62627. interface VRDisplayCapabilities {
  62628. readonly canPresent: boolean;
  62629. readonly hasExternalDisplay: boolean;
  62630. readonly hasOrientation: boolean;
  62631. readonly hasPosition: boolean;
  62632. readonly maxLayers: number;
  62633. }
  62634. interface VREyeParameters {
  62635. /** @deprecated */
  62636. readonly fieldOfView: VRFieldOfView;
  62637. readonly offset: Float32Array;
  62638. readonly renderHeight: number;
  62639. readonly renderWidth: number;
  62640. }
  62641. interface VRFieldOfView {
  62642. readonly downDegrees: number;
  62643. readonly leftDegrees: number;
  62644. readonly rightDegrees: number;
  62645. readonly upDegrees: number;
  62646. }
  62647. interface VRFrameData {
  62648. readonly leftProjectionMatrix: Float32Array;
  62649. readonly leftViewMatrix: Float32Array;
  62650. readonly pose: VRPose;
  62651. readonly rightProjectionMatrix: Float32Array;
  62652. readonly rightViewMatrix: Float32Array;
  62653. readonly timestamp: number;
  62654. }
  62655. interface VRPose {
  62656. readonly angularAcceleration: Float32Array | null;
  62657. readonly angularVelocity: Float32Array | null;
  62658. readonly linearAcceleration: Float32Array | null;
  62659. readonly linearVelocity: Float32Array | null;
  62660. readonly orientation: Float32Array | null;
  62661. readonly position: Float32Array | null;
  62662. readonly timestamp: number;
  62663. }
  62664. interface VRStageParameters {
  62665. sittingToStandingTransform?: Float32Array;
  62666. sizeX?: number;
  62667. sizeY?: number;
  62668. }
  62669. interface Navigator {
  62670. getVRDisplays(): Promise<VRDisplay[]>;
  62671. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62672. }
  62673. interface Window {
  62674. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62675. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62676. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62677. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62678. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62679. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62680. }
  62681. interface Gamepad {
  62682. readonly displayId: number;
  62683. }
  62684. type XRSessionMode =
  62685. | "inline"
  62686. | "immersive-vr"
  62687. | "immersive-ar";
  62688. type XRReferenceSpaceType =
  62689. | "viewer"
  62690. | "local"
  62691. | "local-floor"
  62692. | "bounded-floor"
  62693. | "unbounded";
  62694. type XREnvironmentBlendMode =
  62695. | "opaque"
  62696. | "additive"
  62697. | "alpha-blend";
  62698. type XRVisibilityState =
  62699. | "visible"
  62700. | "visible-blurred"
  62701. | "hidden";
  62702. type XRHandedness =
  62703. | "none"
  62704. | "left"
  62705. | "right";
  62706. type XRTargetRayMode =
  62707. | "gaze"
  62708. | "tracked-pointer"
  62709. | "screen";
  62710. type XREye =
  62711. | "none"
  62712. | "left"
  62713. | "right";
  62714. interface XRSpace extends EventTarget {
  62715. }
  62716. interface XRRenderState {
  62717. depthNear?: number;
  62718. depthFar?: number;
  62719. inlineVerticalFieldOfView?: number;
  62720. baseLayer?: XRWebGLLayer;
  62721. }
  62722. interface XRInputSource {
  62723. handedness: XRHandedness;
  62724. targetRayMode: XRTargetRayMode;
  62725. targetRaySpace: XRSpace;
  62726. gripSpace: XRSpace | undefined;
  62727. gamepad: Gamepad | undefined;
  62728. profiles: Array<string>;
  62729. }
  62730. interface XRSession {
  62731. addEventListener: Function;
  62732. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62733. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62734. requestAnimationFrame: Function;
  62735. end(): Promise<void>;
  62736. renderState: XRRenderState;
  62737. inputSources: Array<XRInputSource>;
  62738. }
  62739. interface XRReferenceSpace extends XRSpace {
  62740. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62741. onreset: any;
  62742. }
  62743. interface XRFrame {
  62744. session: XRSession;
  62745. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62746. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62747. }
  62748. interface XRViewerPose extends XRPose {
  62749. views: Array<XRView>;
  62750. }
  62751. interface XRPose {
  62752. transform: XRRigidTransform;
  62753. emulatedPosition: boolean;
  62754. }
  62755. declare var XRWebGLLayer: {
  62756. prototype: XRWebGLLayer;
  62757. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62758. };
  62759. interface XRWebGLLayer {
  62760. framebuffer: WebGLFramebuffer;
  62761. framebufferWidth: number;
  62762. framebufferHeight: number;
  62763. getViewport: Function;
  62764. }
  62765. interface XRRigidTransform {
  62766. position: DOMPointReadOnly;
  62767. orientation: DOMPointReadOnly;
  62768. matrix: Float32Array;
  62769. inverse: XRRigidTransform;
  62770. }
  62771. interface XRView {
  62772. eye: XREye;
  62773. projectionMatrix: Float32Array;
  62774. transform: XRRigidTransform;
  62775. }
  62776. interface XRInputSourceChangeEvent {
  62777. session: XRSession;
  62778. removed: Array<XRInputSource>;
  62779. added: Array<XRInputSource>;
  62780. }
  62781. declare module BABYLON.GUI {
  62782. /**
  62783. * Class used to specific a value and its associated unit
  62784. */
  62785. export class ValueAndUnit {
  62786. /** defines the unit to store */
  62787. unit: number;
  62788. /** defines a boolean indicating if the value can be negative */
  62789. negativeValueAllowed: boolean;
  62790. private _value;
  62791. private _originalUnit;
  62792. /**
  62793. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62794. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62795. */
  62796. ignoreAdaptiveScaling: boolean;
  62797. /**
  62798. * Creates a new ValueAndUnit
  62799. * @param value defines the value to store
  62800. * @param unit defines the unit to store
  62801. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62802. */
  62803. constructor(value: number,
  62804. /** defines the unit to store */
  62805. unit?: number,
  62806. /** defines a boolean indicating if the value can be negative */
  62807. negativeValueAllowed?: boolean);
  62808. /** Gets a boolean indicating if the value is a percentage */
  62809. readonly isPercentage: boolean;
  62810. /** Gets a boolean indicating if the value is store as pixel */
  62811. readonly isPixel: boolean;
  62812. /** Gets direct internal value */
  62813. readonly internalValue: number;
  62814. /**
  62815. * Gets value as pixel
  62816. * @param host defines the root host
  62817. * @param refValue defines the reference value for percentages
  62818. * @returns the value as pixel
  62819. */
  62820. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62821. /**
  62822. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62823. * @param value defines the value to store
  62824. * @param unit defines the unit to store
  62825. * @returns the current ValueAndUnit
  62826. */
  62827. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62828. /**
  62829. * Gets the value accordingly to its unit
  62830. * @param host defines the root host
  62831. * @returns the value
  62832. */
  62833. getValue(host: AdvancedDynamicTexture): number;
  62834. /**
  62835. * Gets a string representation of the value
  62836. * @param host defines the root host
  62837. * @param decimals defines an optional number of decimals to display
  62838. * @returns a string
  62839. */
  62840. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62841. /**
  62842. * Store a value parsed from a string
  62843. * @param source defines the source string
  62844. * @returns true if the value was successfully parsed
  62845. */
  62846. fromString(source: string | number): boolean;
  62847. private static _Regex;
  62848. private static _UNITMODE_PERCENTAGE;
  62849. private static _UNITMODE_PIXEL;
  62850. /** UNITMODE_PERCENTAGE */
  62851. static readonly UNITMODE_PERCENTAGE: number;
  62852. /** UNITMODE_PIXEL */
  62853. static readonly UNITMODE_PIXEL: number;
  62854. }
  62855. }
  62856. declare module BABYLON.GUI {
  62857. /**
  62858. * Define a style used by control to automatically setup properties based on a template.
  62859. * Only support font related properties so far
  62860. */
  62861. export class Style implements BABYLON.IDisposable {
  62862. private _fontFamily;
  62863. private _fontStyle;
  62864. private _fontWeight;
  62865. /** @hidden */
  62866. _host: AdvancedDynamicTexture;
  62867. /** @hidden */
  62868. _fontSize: ValueAndUnit;
  62869. /**
  62870. * BABYLON.Observable raised when the style values are changed
  62871. */
  62872. onChangedObservable: BABYLON.Observable<Style>;
  62873. /**
  62874. * Creates a new style object
  62875. * @param host defines the AdvancedDynamicTexture which hosts this style
  62876. */
  62877. constructor(host: AdvancedDynamicTexture);
  62878. /**
  62879. * Gets or sets the font size
  62880. */
  62881. fontSize: string | number;
  62882. /**
  62883. * Gets or sets the font family
  62884. */
  62885. fontFamily: string;
  62886. /**
  62887. * Gets or sets the font style
  62888. */
  62889. fontStyle: string;
  62890. /** Gets or sets font weight */
  62891. fontWeight: string;
  62892. /** Dispose all associated resources */
  62893. dispose(): void;
  62894. }
  62895. }
  62896. declare module BABYLON.GUI {
  62897. /**
  62898. * Class used to transport BABYLON.Vector2 information for pointer events
  62899. */
  62900. export class Vector2WithInfo extends BABYLON.Vector2 {
  62901. /** defines the current mouse button index */
  62902. buttonIndex: number;
  62903. /**
  62904. * Creates a new Vector2WithInfo
  62905. * @param source defines the vector2 data to transport
  62906. * @param buttonIndex defines the current mouse button index
  62907. */
  62908. constructor(source: BABYLON.Vector2,
  62909. /** defines the current mouse button index */
  62910. buttonIndex?: number);
  62911. }
  62912. /** Class used to provide 2D matrix features */
  62913. export class Matrix2D {
  62914. /** Gets the internal array of 6 floats used to store matrix data */
  62915. m: Float32Array;
  62916. /**
  62917. * Creates a new matrix
  62918. * @param m00 defines value for (0, 0)
  62919. * @param m01 defines value for (0, 1)
  62920. * @param m10 defines value for (1, 0)
  62921. * @param m11 defines value for (1, 1)
  62922. * @param m20 defines value for (2, 0)
  62923. * @param m21 defines value for (2, 1)
  62924. */
  62925. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62926. /**
  62927. * Fills the matrix from direct values
  62928. * @param m00 defines value for (0, 0)
  62929. * @param m01 defines value for (0, 1)
  62930. * @param m10 defines value for (1, 0)
  62931. * @param m11 defines value for (1, 1)
  62932. * @param m20 defines value for (2, 0)
  62933. * @param m21 defines value for (2, 1)
  62934. * @returns the current modified matrix
  62935. */
  62936. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62937. /**
  62938. * Gets matrix determinant
  62939. * @returns the determinant
  62940. */
  62941. determinant(): number;
  62942. /**
  62943. * Inverses the matrix and stores it in a target matrix
  62944. * @param result defines the target matrix
  62945. * @returns the current matrix
  62946. */
  62947. invertToRef(result: Matrix2D): Matrix2D;
  62948. /**
  62949. * Multiplies the current matrix with another one
  62950. * @param other defines the second operand
  62951. * @param result defines the target matrix
  62952. * @returns the current matrix
  62953. */
  62954. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62955. /**
  62956. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62957. * @param x defines the x coordinate to transform
  62958. * @param y defines the x coordinate to transform
  62959. * @param result defines the target vector2
  62960. * @returns the current matrix
  62961. */
  62962. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62963. /**
  62964. * Creates an identity matrix
  62965. * @returns a new matrix
  62966. */
  62967. static Identity(): Matrix2D;
  62968. /**
  62969. * Creates a translation matrix and stores it in a target matrix
  62970. * @param x defines the x coordinate of the translation
  62971. * @param y defines the y coordinate of the translation
  62972. * @param result defines the target matrix
  62973. */
  62974. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62975. /**
  62976. * Creates a scaling matrix and stores it in a target matrix
  62977. * @param x defines the x coordinate of the scaling
  62978. * @param y defines the y coordinate of the scaling
  62979. * @param result defines the target matrix
  62980. */
  62981. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62982. /**
  62983. * Creates a rotation matrix and stores it in a target matrix
  62984. * @param angle defines the rotation angle
  62985. * @param result defines the target matrix
  62986. */
  62987. static RotationToRef(angle: number, result: Matrix2D): void;
  62988. private static _TempPreTranslationMatrix;
  62989. private static _TempPostTranslationMatrix;
  62990. private static _TempRotationMatrix;
  62991. private static _TempScalingMatrix;
  62992. private static _TempCompose0;
  62993. private static _TempCompose1;
  62994. private static _TempCompose2;
  62995. /**
  62996. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62997. * @param tx defines the x coordinate of the translation
  62998. * @param ty defines the y coordinate of the translation
  62999. * @param angle defines the rotation angle
  63000. * @param scaleX defines the x coordinate of the scaling
  63001. * @param scaleY defines the y coordinate of the scaling
  63002. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63003. * @param result defines the target matrix
  63004. */
  63005. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63006. }
  63007. }
  63008. declare module BABYLON.GUI {
  63009. /**
  63010. * Class used to store 2D control sizes
  63011. */
  63012. export class Measure {
  63013. /** defines left coordinate */
  63014. left: number;
  63015. /** defines top coordinate */
  63016. top: number;
  63017. /** defines width dimension */
  63018. width: number;
  63019. /** defines height dimension */
  63020. height: number;
  63021. /**
  63022. * Creates a new measure
  63023. * @param left defines left coordinate
  63024. * @param top defines top coordinate
  63025. * @param width defines width dimension
  63026. * @param height defines height dimension
  63027. */
  63028. constructor(
  63029. /** defines left coordinate */
  63030. left: number,
  63031. /** defines top coordinate */
  63032. top: number,
  63033. /** defines width dimension */
  63034. width: number,
  63035. /** defines height dimension */
  63036. height: number);
  63037. /**
  63038. * Copy from another measure
  63039. * @param other defines the other measure to copy from
  63040. */
  63041. copyFrom(other: Measure): void;
  63042. /**
  63043. * Copy from a group of 4 floats
  63044. * @param left defines left coordinate
  63045. * @param top defines top coordinate
  63046. * @param width defines width dimension
  63047. * @param height defines height dimension
  63048. */
  63049. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63050. /**
  63051. * Computes the axis aligned bounding box measure for two given measures
  63052. * @param a Input measure
  63053. * @param b Input measure
  63054. * @param result the resulting bounding measure
  63055. */
  63056. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63057. /**
  63058. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63059. * @param transform the matrix to transform the measure before computing the AABB
  63060. * @param result the resulting AABB
  63061. */
  63062. transformToRef(transform: Matrix2D, result: Measure): void;
  63063. /**
  63064. * Check equality between this measure and another one
  63065. * @param other defines the other measures
  63066. * @returns true if both measures are equals
  63067. */
  63068. isEqualsTo(other: Measure): boolean;
  63069. /**
  63070. * Creates an empty measure
  63071. * @returns a new measure
  63072. */
  63073. static Empty(): Measure;
  63074. }
  63075. }
  63076. declare module BABYLON.GUI {
  63077. /**
  63078. * Interface used to define a control that can receive focus
  63079. */
  63080. export interface IFocusableControl {
  63081. /**
  63082. * Function called when the control receives the focus
  63083. */
  63084. onFocus(): void;
  63085. /**
  63086. * Function called when the control loses the focus
  63087. */
  63088. onBlur(): void;
  63089. /**
  63090. * Function called to let the control handle keyboard events
  63091. * @param evt defines the current keyboard event
  63092. */
  63093. processKeyboard(evt: KeyboardEvent): void;
  63094. /**
  63095. * Function called to get the list of controls that should not steal the focus from this control
  63096. * @returns an array of controls
  63097. */
  63098. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63099. }
  63100. /**
  63101. * Class used to create texture to support 2D GUI elements
  63102. * @see http://doc.babylonjs.com/how_to/gui
  63103. */
  63104. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63105. private _isDirty;
  63106. private _renderObserver;
  63107. private _resizeObserver;
  63108. private _preKeyboardObserver;
  63109. private _pointerMoveObserver;
  63110. private _pointerObserver;
  63111. private _canvasPointerOutObserver;
  63112. private _background;
  63113. /** @hidden */
  63114. _rootContainer: Container;
  63115. /** @hidden */
  63116. _lastPickedControl: Control;
  63117. /** @hidden */
  63118. _lastControlOver: {
  63119. [pointerId: number]: Control;
  63120. };
  63121. /** @hidden */
  63122. _lastControlDown: {
  63123. [pointerId: number]: Control;
  63124. };
  63125. /** @hidden */
  63126. _capturingControl: {
  63127. [pointerId: number]: Control;
  63128. };
  63129. /** @hidden */
  63130. _shouldBlockPointer: boolean;
  63131. /** @hidden */
  63132. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63133. /** @hidden */
  63134. _linkedControls: Control[];
  63135. private _isFullscreen;
  63136. private _fullscreenViewport;
  63137. private _idealWidth;
  63138. private _idealHeight;
  63139. private _useSmallestIdeal;
  63140. private _renderAtIdealSize;
  63141. private _focusedControl;
  63142. private _blockNextFocusCheck;
  63143. private _renderScale;
  63144. private _rootCanvas;
  63145. private _cursorChanged;
  63146. /**
  63147. * Define type to string to ensure compatibility across browsers
  63148. * Safari doesn't support DataTransfer constructor
  63149. */
  63150. private _clipboardData;
  63151. /**
  63152. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63153. */
  63154. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63155. /**
  63156. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63157. */
  63158. onControlPickedObservable: BABYLON.Observable<Control>;
  63159. /**
  63160. * BABYLON.Observable event triggered before layout is evaluated
  63161. */
  63162. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63163. /**
  63164. * BABYLON.Observable event triggered after the layout was evaluated
  63165. */
  63166. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63167. /**
  63168. * BABYLON.Observable event triggered before the texture is rendered
  63169. */
  63170. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63171. /**
  63172. * BABYLON.Observable event triggered after the texture was rendered
  63173. */
  63174. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63175. /**
  63176. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63177. */
  63178. premulAlpha: boolean;
  63179. /**
  63180. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63181. * Useful when you want more antialiasing
  63182. */
  63183. renderScale: number;
  63184. /** Gets or sets the background color */
  63185. background: string;
  63186. /**
  63187. * Gets or sets the ideal width used to design controls.
  63188. * The GUI will then rescale everything accordingly
  63189. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63190. */
  63191. idealWidth: number;
  63192. /**
  63193. * Gets or sets the ideal height used to design controls.
  63194. * The GUI will then rescale everything accordingly
  63195. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63196. */
  63197. idealHeight: number;
  63198. /**
  63199. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63200. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63201. */
  63202. useSmallestIdeal: boolean;
  63203. /**
  63204. * Gets or sets a boolean indicating if adaptive scaling must be used
  63205. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63206. */
  63207. renderAtIdealSize: boolean;
  63208. /**
  63209. * Gets the underlying layer used to render the texture when in fullscreen mode
  63210. */
  63211. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63212. /**
  63213. * Gets the root container control
  63214. */
  63215. readonly rootContainer: Container;
  63216. /**
  63217. * Returns an array containing the root container.
  63218. * This is mostly used to let the Inspector introspects the ADT
  63219. * @returns an array containing the rootContainer
  63220. */
  63221. getChildren(): Array<Container>;
  63222. /**
  63223. * Will return all controls that are inside this texture
  63224. * @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
  63225. * @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
  63226. * @return all child controls
  63227. */
  63228. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63229. /**
  63230. * Gets or sets the current focused control
  63231. */
  63232. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63233. /**
  63234. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63235. */
  63236. isForeground: boolean;
  63237. /**
  63238. * Gets or set information about clipboardData
  63239. */
  63240. clipboardData: string;
  63241. /**
  63242. * Creates a new AdvancedDynamicTexture
  63243. * @param name defines the name of the texture
  63244. * @param width defines the width of the texture
  63245. * @param height defines the height of the texture
  63246. * @param scene defines the hosting scene
  63247. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63248. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63249. */
  63250. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63251. /**
  63252. * Get the current class name of the texture useful for serialization or dynamic coding.
  63253. * @returns "AdvancedDynamicTexture"
  63254. */
  63255. getClassName(): string;
  63256. /**
  63257. * Function used to execute a function on all controls
  63258. * @param func defines the function to execute
  63259. * @param container defines the container where controls belong. If null the root container will be used
  63260. */
  63261. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63262. private _useInvalidateRectOptimization;
  63263. /**
  63264. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63265. */
  63266. useInvalidateRectOptimization: boolean;
  63267. private _invalidatedRectangle;
  63268. /**
  63269. * Invalidates a rectangle area on the gui texture
  63270. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63271. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63272. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63273. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63274. */
  63275. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63276. /**
  63277. * Marks the texture as dirty forcing a complete update
  63278. */
  63279. markAsDirty(): void;
  63280. /**
  63281. * Helper function used to create a new style
  63282. * @returns a new style
  63283. * @see http://doc.babylonjs.com/how_to/gui#styles
  63284. */
  63285. createStyle(): Style;
  63286. /**
  63287. * Adds a new control to the root container
  63288. * @param control defines the control to add
  63289. * @returns the current texture
  63290. */
  63291. addControl(control: Control): AdvancedDynamicTexture;
  63292. /**
  63293. * Removes a control from the root container
  63294. * @param control defines the control to remove
  63295. * @returns the current texture
  63296. */
  63297. removeControl(control: Control): AdvancedDynamicTexture;
  63298. /**
  63299. * Release all resources
  63300. */
  63301. dispose(): void;
  63302. private _onResize;
  63303. /** @hidden */
  63304. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63305. /**
  63306. * Get screen coordinates for a vector3
  63307. * @param position defines the position to project
  63308. * @param worldMatrix defines the world matrix to use
  63309. * @returns the projected position
  63310. */
  63311. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63312. private _checkUpdate;
  63313. private _clearMeasure;
  63314. private _render;
  63315. /** @hidden */
  63316. _changeCursor(cursor: string): void;
  63317. /** @hidden */
  63318. _registerLastControlDown(control: Control, pointerId: number): void;
  63319. private _doPicking;
  63320. /** @hidden */
  63321. _cleanControlAfterRemovalFromList(list: {
  63322. [pointerId: number]: Control;
  63323. }, control: Control): void;
  63324. /** @hidden */
  63325. _cleanControlAfterRemoval(control: Control): void;
  63326. /** Attach to all scene events required to support pointer events */
  63327. attach(): void;
  63328. /** @hidden */
  63329. private onClipboardCopy;
  63330. /** @hidden */
  63331. private onClipboardCut;
  63332. /** @hidden */
  63333. private onClipboardPaste;
  63334. /**
  63335. * Register the clipboard Events onto the canvas
  63336. */
  63337. registerClipboardEvents(): void;
  63338. /**
  63339. * Unregister the clipboard Events from the canvas
  63340. */
  63341. unRegisterClipboardEvents(): void;
  63342. /**
  63343. * Connect the texture to a hosting mesh to enable interactions
  63344. * @param mesh defines the mesh to attach to
  63345. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63346. */
  63347. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63348. /**
  63349. * Move the focus to a specific control
  63350. * @param control defines the control which will receive the focus
  63351. */
  63352. moveFocusToControl(control: IFocusableControl): void;
  63353. private _manageFocus;
  63354. private _attachToOnPointerOut;
  63355. /**
  63356. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63357. * @param mesh defines the mesh which will receive the texture
  63358. * @param width defines the texture width (1024 by default)
  63359. * @param height defines the texture height (1024 by default)
  63360. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63361. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63362. * @returns a new AdvancedDynamicTexture
  63363. */
  63364. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63365. /**
  63366. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63367. * In this mode the texture will rely on a layer for its rendering.
  63368. * This allows it to be treated like any other layer.
  63369. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63370. * LayerMask is set through advancedTexture.layer.layerMask
  63371. * @param name defines name for the texture
  63372. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63373. * @param scene defines the hsoting scene
  63374. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63375. * @returns a new AdvancedDynamicTexture
  63376. */
  63377. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63378. }
  63379. }
  63380. declare module BABYLON.GUI {
  63381. /**
  63382. * Root class used for all 2D controls
  63383. * @see http://doc.babylonjs.com/how_to/gui#controls
  63384. */
  63385. export class Control {
  63386. /** defines the name of the control */
  63387. name?: string | undefined;
  63388. /**
  63389. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63390. */
  63391. static AllowAlphaInheritance: boolean;
  63392. private _alpha;
  63393. private _alphaSet;
  63394. private _zIndex;
  63395. /** @hidden */
  63396. _host: AdvancedDynamicTexture;
  63397. /** Gets or sets the control parent */
  63398. parent: BABYLON.Nullable<Container>;
  63399. /** @hidden */
  63400. _currentMeasure: Measure;
  63401. private _fontFamily;
  63402. private _fontStyle;
  63403. private _fontWeight;
  63404. private _fontSize;
  63405. private _font;
  63406. /** @hidden */
  63407. _width: ValueAndUnit;
  63408. /** @hidden */
  63409. _height: ValueAndUnit;
  63410. /** @hidden */
  63411. protected _fontOffset: {
  63412. ascent: number;
  63413. height: number;
  63414. descent: number;
  63415. };
  63416. private _color;
  63417. private _style;
  63418. private _styleObserver;
  63419. /** @hidden */
  63420. protected _horizontalAlignment: number;
  63421. /** @hidden */
  63422. protected _verticalAlignment: number;
  63423. /** @hidden */
  63424. protected _isDirty: boolean;
  63425. /** @hidden */
  63426. protected _wasDirty: boolean;
  63427. /** @hidden */
  63428. _tempParentMeasure: Measure;
  63429. /** @hidden */
  63430. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63431. /** @hidden */
  63432. protected _cachedParentMeasure: Measure;
  63433. private _paddingLeft;
  63434. private _paddingRight;
  63435. private _paddingTop;
  63436. private _paddingBottom;
  63437. /** @hidden */
  63438. _left: ValueAndUnit;
  63439. /** @hidden */
  63440. _top: ValueAndUnit;
  63441. private _scaleX;
  63442. private _scaleY;
  63443. private _rotation;
  63444. private _transformCenterX;
  63445. private _transformCenterY;
  63446. /** @hidden */
  63447. _transformMatrix: Matrix2D;
  63448. /** @hidden */
  63449. protected _invertTransformMatrix: Matrix2D;
  63450. /** @hidden */
  63451. protected _transformedPosition: BABYLON.Vector2;
  63452. private _isMatrixDirty;
  63453. private _cachedOffsetX;
  63454. private _cachedOffsetY;
  63455. private _isVisible;
  63456. private _isHighlighted;
  63457. /** @hidden */
  63458. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63459. private _fontSet;
  63460. private _dummyVector2;
  63461. private _downCount;
  63462. private _enterCount;
  63463. private _doNotRender;
  63464. private _downPointerIds;
  63465. protected _isEnabled: boolean;
  63466. protected _disabledColor: string;
  63467. /** @hidden */
  63468. protected _rebuildLayout: boolean;
  63469. /** @hidden */
  63470. _isClipped: boolean;
  63471. /** @hidden */
  63472. _tag: any;
  63473. /**
  63474. * 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
  63475. */
  63476. uniqueId: number;
  63477. /**
  63478. * Gets or sets an object used to store user defined information for the node
  63479. */
  63480. metadata: any;
  63481. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63482. isHitTestVisible: boolean;
  63483. /** Gets or sets a boolean indicating if the control can block pointer events */
  63484. isPointerBlocker: boolean;
  63485. /** Gets or sets a boolean indicating if the control can be focusable */
  63486. isFocusInvisible: boolean;
  63487. /**
  63488. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63489. * 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
  63490. */
  63491. clipChildren: boolean;
  63492. /**
  63493. * Gets or sets a boolean indicating that control content must be clipped
  63494. * 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
  63495. */
  63496. clipContent: boolean;
  63497. /**
  63498. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63499. */
  63500. useBitmapCache: boolean;
  63501. private _cacheData;
  63502. private _shadowOffsetX;
  63503. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63504. shadowOffsetX: number;
  63505. private _shadowOffsetY;
  63506. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63507. shadowOffsetY: number;
  63508. private _shadowBlur;
  63509. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63510. shadowBlur: number;
  63511. private _shadowColor;
  63512. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63513. shadowColor: string;
  63514. /** Gets or sets the cursor to use when the control is hovered */
  63515. hoverCursor: string;
  63516. /** @hidden */
  63517. protected _linkOffsetX: ValueAndUnit;
  63518. /** @hidden */
  63519. protected _linkOffsetY: ValueAndUnit;
  63520. /** Gets the control type name */
  63521. readonly typeName: string;
  63522. /**
  63523. * Get the current class name of the control.
  63524. * @returns current class name
  63525. */
  63526. getClassName(): string;
  63527. /**
  63528. * An event triggered when the pointer move over the control.
  63529. */
  63530. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63531. /**
  63532. * An event triggered when the pointer move out of the control.
  63533. */
  63534. onPointerOutObservable: BABYLON.Observable<Control>;
  63535. /**
  63536. * An event triggered when the pointer taps the control
  63537. */
  63538. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63539. /**
  63540. * An event triggered when pointer up
  63541. */
  63542. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63543. /**
  63544. * An event triggered when a control is clicked on
  63545. */
  63546. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63547. /**
  63548. * An event triggered when pointer enters the control
  63549. */
  63550. onPointerEnterObservable: BABYLON.Observable<Control>;
  63551. /**
  63552. * An event triggered when the control is marked as dirty
  63553. */
  63554. onDirtyObservable: BABYLON.Observable<Control>;
  63555. /**
  63556. * An event triggered before drawing the control
  63557. */
  63558. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63559. /**
  63560. * An event triggered after the control was drawn
  63561. */
  63562. onAfterDrawObservable: BABYLON.Observable<Control>;
  63563. /**
  63564. * Get the hosting AdvancedDynamicTexture
  63565. */
  63566. readonly host: AdvancedDynamicTexture;
  63567. /** Gets or set information about font offsets (used to render and align text) */
  63568. fontOffset: {
  63569. ascent: number;
  63570. height: number;
  63571. descent: number;
  63572. };
  63573. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63574. alpha: number;
  63575. /**
  63576. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63577. */
  63578. isHighlighted: boolean;
  63579. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63580. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63581. */
  63582. scaleX: number;
  63583. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63584. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63585. */
  63586. scaleY: number;
  63587. /** Gets or sets the rotation angle (0 by default)
  63588. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63589. */
  63590. rotation: number;
  63591. /** Gets or sets the transformation center on Y axis (0 by default)
  63592. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63593. */
  63594. transformCenterY: number;
  63595. /** Gets or sets the transformation center on X axis (0 by default)
  63596. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63597. */
  63598. transformCenterX: number;
  63599. /**
  63600. * Gets or sets the horizontal alignment
  63601. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63602. */
  63603. horizontalAlignment: number;
  63604. /**
  63605. * Gets or sets the vertical alignment
  63606. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63607. */
  63608. verticalAlignment: number;
  63609. /**
  63610. * Gets or sets control width
  63611. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63612. */
  63613. width: string | number;
  63614. /**
  63615. * Gets or sets the control width in pixel
  63616. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63617. */
  63618. widthInPixels: number;
  63619. /**
  63620. * Gets or sets control height
  63621. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63622. */
  63623. height: string | number;
  63624. /**
  63625. * Gets or sets control height in pixel
  63626. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63627. */
  63628. heightInPixels: number;
  63629. /** Gets or set font family */
  63630. fontFamily: string;
  63631. /** Gets or sets font style */
  63632. fontStyle: string;
  63633. /** Gets or sets font weight */
  63634. fontWeight: string;
  63635. /**
  63636. * Gets or sets style
  63637. * @see http://doc.babylonjs.com/how_to/gui#styles
  63638. */
  63639. style: BABYLON.Nullable<Style>;
  63640. /** @hidden */
  63641. readonly _isFontSizeInPercentage: boolean;
  63642. /** Gets or sets font size in pixels */
  63643. fontSizeInPixels: number;
  63644. /** Gets or sets font size */
  63645. fontSize: string | number;
  63646. /** Gets or sets foreground color */
  63647. color: string;
  63648. /** Gets or sets z index which is used to reorder controls on the z axis */
  63649. zIndex: number;
  63650. /** Gets or sets a boolean indicating if the control can be rendered */
  63651. notRenderable: boolean;
  63652. /** Gets or sets a boolean indicating if the control is visible */
  63653. isVisible: boolean;
  63654. /** Gets a boolean indicating that the control needs to update its rendering */
  63655. readonly isDirty: boolean;
  63656. /**
  63657. * Gets the current linked mesh (or null if none)
  63658. */
  63659. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63660. /**
  63661. * Gets or sets a value indicating the padding to use on the left of the control
  63662. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63663. */
  63664. paddingLeft: string | number;
  63665. /**
  63666. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63667. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63668. */
  63669. paddingLeftInPixels: number;
  63670. /**
  63671. * Gets or sets a value indicating the padding to use on the right of the control
  63672. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63673. */
  63674. paddingRight: string | number;
  63675. /**
  63676. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63677. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63678. */
  63679. paddingRightInPixels: number;
  63680. /**
  63681. * Gets or sets a value indicating the padding to use on the top of the control
  63682. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63683. */
  63684. paddingTop: string | number;
  63685. /**
  63686. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63687. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63688. */
  63689. paddingTopInPixels: number;
  63690. /**
  63691. * Gets or sets a value indicating the padding to use on the bottom of the control
  63692. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63693. */
  63694. paddingBottom: string | number;
  63695. /**
  63696. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63697. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63698. */
  63699. paddingBottomInPixels: number;
  63700. /**
  63701. * Gets or sets a value indicating the left coordinate of the control
  63702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63703. */
  63704. left: string | number;
  63705. /**
  63706. * Gets or sets a value indicating the left coordinate in pixels of the control
  63707. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63708. */
  63709. leftInPixels: number;
  63710. /**
  63711. * Gets or sets a value indicating the top coordinate of the control
  63712. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63713. */
  63714. top: string | number;
  63715. /**
  63716. * Gets or sets a value indicating the top coordinate in pixels of the control
  63717. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63718. */
  63719. topInPixels: number;
  63720. /**
  63721. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63722. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63723. */
  63724. linkOffsetX: string | number;
  63725. /**
  63726. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63727. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63728. */
  63729. linkOffsetXInPixels: number;
  63730. /**
  63731. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63732. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63733. */
  63734. linkOffsetY: string | number;
  63735. /**
  63736. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63737. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63738. */
  63739. linkOffsetYInPixels: number;
  63740. /** Gets the center coordinate on X axis */
  63741. readonly centerX: number;
  63742. /** Gets the center coordinate on Y axis */
  63743. readonly centerY: number;
  63744. /** Gets or sets if control is Enabled*/
  63745. isEnabled: boolean;
  63746. /** Gets or sets background color of control if it's disabled*/
  63747. disabledColor: string;
  63748. /**
  63749. * Creates a new control
  63750. * @param name defines the name of the control
  63751. */
  63752. constructor(
  63753. /** defines the name of the control */
  63754. name?: string | undefined);
  63755. /** @hidden */
  63756. protected _getTypeName(): string;
  63757. /**
  63758. * Gets the first ascendant in the hierarchy of the given type
  63759. * @param className defines the required type
  63760. * @returns the ascendant or null if not found
  63761. */
  63762. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63763. /** @hidden */
  63764. _resetFontCache(): void;
  63765. /**
  63766. * Determines if a container is an ascendant of the current control
  63767. * @param container defines the container to look for
  63768. * @returns true if the container is one of the ascendant of the control
  63769. */
  63770. isAscendant(container: Control): boolean;
  63771. /**
  63772. * Gets coordinates in local control space
  63773. * @param globalCoordinates defines the coordinates to transform
  63774. * @returns the new coordinates in local space
  63775. */
  63776. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63777. /**
  63778. * Gets coordinates in local control space
  63779. * @param globalCoordinates defines the coordinates to transform
  63780. * @param result defines the target vector2 where to store the result
  63781. * @returns the current control
  63782. */
  63783. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63784. /**
  63785. * Gets coordinates in parent local control space
  63786. * @param globalCoordinates defines the coordinates to transform
  63787. * @returns the new coordinates in parent local space
  63788. */
  63789. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63790. /**
  63791. * Move the current control to a vector3 position projected onto the screen.
  63792. * @param position defines the target position
  63793. * @param scene defines the hosting scene
  63794. */
  63795. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63796. /** @hidden */
  63797. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63798. /**
  63799. * Will return all controls that have this control as ascendant
  63800. * @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
  63801. * @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
  63802. * @return all child controls
  63803. */
  63804. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63805. /**
  63806. * Link current control with a target mesh
  63807. * @param mesh defines the mesh to link with
  63808. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63809. */
  63810. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63811. /** @hidden */
  63812. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63813. /** @hidden */
  63814. _offsetLeft(offset: number): void;
  63815. /** @hidden */
  63816. _offsetTop(offset: number): void;
  63817. /** @hidden */
  63818. _markMatrixAsDirty(): void;
  63819. /** @hidden */
  63820. _flagDescendantsAsMatrixDirty(): void;
  63821. /** @hidden */
  63822. _intersectsRect(rect: Measure): boolean;
  63823. /** @hidden */
  63824. protected invalidateRect(): void;
  63825. /** @hidden */
  63826. _markAsDirty(force?: boolean): void;
  63827. /** @hidden */
  63828. _markAllAsDirty(): void;
  63829. /** @hidden */
  63830. _link(host: AdvancedDynamicTexture): void;
  63831. /** @hidden */
  63832. protected _transform(context?: CanvasRenderingContext2D): void;
  63833. /** @hidden */
  63834. _renderHighlight(context: CanvasRenderingContext2D): void;
  63835. /** @hidden */
  63836. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63837. /** @hidden */
  63838. protected _applyStates(context: CanvasRenderingContext2D): void;
  63839. /** @hidden */
  63840. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63841. /** @hidden */
  63842. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63843. protected _evaluateClippingState(parentMeasure: Measure): void;
  63844. /** @hidden */
  63845. _measure(): void;
  63846. /** @hidden */
  63847. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63848. /** @hidden */
  63849. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63850. /** @hidden */
  63851. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63852. /** @hidden */
  63853. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63854. private static _ClipMeasure;
  63855. private _tmpMeasureA;
  63856. private _clip;
  63857. /** @hidden */
  63858. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63859. /** @hidden */
  63860. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63861. /**
  63862. * Tests if a given coordinates belong to the current control
  63863. * @param x defines x coordinate to test
  63864. * @param y defines y coordinate to test
  63865. * @returns true if the coordinates are inside the control
  63866. */
  63867. contains(x: number, y: number): boolean;
  63868. /** @hidden */
  63869. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63870. /** @hidden */
  63871. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63872. /** @hidden */
  63873. _onPointerEnter(target: Control): boolean;
  63874. /** @hidden */
  63875. _onPointerOut(target: Control, force?: boolean): void;
  63876. /** @hidden */
  63877. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63878. /** @hidden */
  63879. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63880. /** @hidden */
  63881. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63882. /** @hidden */
  63883. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63884. private _prepareFont;
  63885. /** Releases associated resources */
  63886. dispose(): void;
  63887. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63888. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63889. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63890. private static _VERTICAL_ALIGNMENT_TOP;
  63891. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63892. private static _VERTICAL_ALIGNMENT_CENTER;
  63893. /** HORIZONTAL_ALIGNMENT_LEFT */
  63894. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63895. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63896. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63897. /** HORIZONTAL_ALIGNMENT_CENTER */
  63898. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63899. /** VERTICAL_ALIGNMENT_TOP */
  63900. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63901. /** VERTICAL_ALIGNMENT_BOTTOM */
  63902. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63903. /** VERTICAL_ALIGNMENT_CENTER */
  63904. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63905. private static _FontHeightSizes;
  63906. /** @hidden */
  63907. static _GetFontOffset(font: string): {
  63908. ascent: number;
  63909. height: number;
  63910. descent: number;
  63911. };
  63912. /**
  63913. * Creates a stack panel that can be used to render headers
  63914. * @param control defines the control to associate with the header
  63915. * @param text defines the text of the header
  63916. * @param size defines the size of the header
  63917. * @param options defines options used to configure the header
  63918. * @returns a new StackPanel
  63919. * @ignore
  63920. * @hidden
  63921. */
  63922. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63923. isHorizontal: boolean;
  63924. controlFirst: boolean;
  63925. }) => any;
  63926. /** @hidden */
  63927. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63928. }
  63929. }
  63930. declare module BABYLON.GUI {
  63931. /**
  63932. * Root class for 2D containers
  63933. * @see http://doc.babylonjs.com/how_to/gui#containers
  63934. */
  63935. export class Container extends Control {
  63936. name?: string | undefined;
  63937. /** @hidden */
  63938. protected _children: Control[];
  63939. /** @hidden */
  63940. protected _measureForChildren: Measure;
  63941. /** @hidden */
  63942. protected _background: string;
  63943. /** @hidden */
  63944. protected _adaptWidthToChildren: boolean;
  63945. /** @hidden */
  63946. protected _adaptHeightToChildren: boolean;
  63947. /**
  63948. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63949. */
  63950. logLayoutCycleErrors: boolean;
  63951. /**
  63952. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63953. */
  63954. maxLayoutCycle: number;
  63955. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63956. adaptHeightToChildren: boolean;
  63957. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63958. adaptWidthToChildren: boolean;
  63959. /** Gets or sets background color */
  63960. background: string;
  63961. /** Gets the list of children */
  63962. readonly children: Control[];
  63963. /**
  63964. * Creates a new Container
  63965. * @param name defines the name of the container
  63966. */
  63967. constructor(name?: string | undefined);
  63968. protected _getTypeName(): string;
  63969. _flagDescendantsAsMatrixDirty(): void;
  63970. /**
  63971. * Gets a child using its name
  63972. * @param name defines the child name to look for
  63973. * @returns the child control if found
  63974. */
  63975. getChildByName(name: string): BABYLON.Nullable<Control>;
  63976. /**
  63977. * Gets a child using its type and its name
  63978. * @param name defines the child name to look for
  63979. * @param type defines the child type to look for
  63980. * @returns the child control if found
  63981. */
  63982. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63983. /**
  63984. * Search for a specific control in children
  63985. * @param control defines the control to look for
  63986. * @returns true if the control is in child list
  63987. */
  63988. containsControl(control: Control): boolean;
  63989. /**
  63990. * Adds a new control to the current container
  63991. * @param control defines the control to add
  63992. * @returns the current container
  63993. */
  63994. addControl(control: BABYLON.Nullable<Control>): Container;
  63995. /**
  63996. * Removes all controls from the current container
  63997. * @returns the current container
  63998. */
  63999. clearControls(): Container;
  64000. /**
  64001. * Removes a control from the current container
  64002. * @param control defines the control to remove
  64003. * @returns the current container
  64004. */
  64005. removeControl(control: Control): Container;
  64006. /** @hidden */
  64007. _reOrderControl(control: Control): void;
  64008. /** @hidden */
  64009. _offsetLeft(offset: number): void;
  64010. /** @hidden */
  64011. _offsetTop(offset: number): void;
  64012. /** @hidden */
  64013. _markAllAsDirty(): void;
  64014. /** @hidden */
  64015. protected _localDraw(context: CanvasRenderingContext2D): void;
  64016. /** @hidden */
  64017. _link(host: AdvancedDynamicTexture): void;
  64018. /** @hidden */
  64019. protected _beforeLayout(): void;
  64020. /** @hidden */
  64021. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64022. /** @hidden */
  64023. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64024. protected _postMeasure(): void;
  64025. /** @hidden */
  64026. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64027. /** @hidden */
  64028. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64029. /** @hidden */
  64030. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64031. /** @hidden */
  64032. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64033. /** Releases associated resources */
  64034. dispose(): void;
  64035. }
  64036. }
  64037. declare module BABYLON.GUI {
  64038. /** Class used to create rectangle container */
  64039. export class Rectangle extends Container {
  64040. name?: string | undefined;
  64041. private _thickness;
  64042. private _cornerRadius;
  64043. /** Gets or sets border thickness */
  64044. thickness: number;
  64045. /** Gets or sets the corner radius angle */
  64046. cornerRadius: number;
  64047. /**
  64048. * Creates a new Rectangle
  64049. * @param name defines the control name
  64050. */
  64051. constructor(name?: string | undefined);
  64052. protected _getTypeName(): string;
  64053. protected _localDraw(context: CanvasRenderingContext2D): void;
  64054. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64055. private _drawRoundedRect;
  64056. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64057. }
  64058. }
  64059. declare module BABYLON.GUI {
  64060. /**
  64061. * Enum that determines the text-wrapping mode to use.
  64062. */
  64063. export enum TextWrapping {
  64064. /**
  64065. * Clip the text when it's larger than Control.width; this is the default mode.
  64066. */
  64067. Clip = 0,
  64068. /**
  64069. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64070. */
  64071. WordWrap = 1,
  64072. /**
  64073. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64074. */
  64075. Ellipsis = 2
  64076. }
  64077. /**
  64078. * Class used to create text block control
  64079. */
  64080. export class TextBlock extends Control {
  64081. /**
  64082. * Defines the name of the control
  64083. */
  64084. name?: string | undefined;
  64085. private _text;
  64086. private _textWrapping;
  64087. private _textHorizontalAlignment;
  64088. private _textVerticalAlignment;
  64089. private _lines;
  64090. private _resizeToFit;
  64091. private _lineSpacing;
  64092. private _outlineWidth;
  64093. private _outlineColor;
  64094. /**
  64095. * An event triggered after the text is changed
  64096. */
  64097. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64098. /**
  64099. * An event triggered after the text was broken up into lines
  64100. */
  64101. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64102. /**
  64103. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64104. */
  64105. readonly lines: any[];
  64106. /**
  64107. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64108. */
  64109. /**
  64110. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64111. */
  64112. resizeToFit: boolean;
  64113. /**
  64114. * Gets or sets a boolean indicating if text must be wrapped
  64115. */
  64116. /**
  64117. * Gets or sets a boolean indicating if text must be wrapped
  64118. */
  64119. textWrapping: TextWrapping | boolean;
  64120. /**
  64121. * Gets or sets text to display
  64122. */
  64123. /**
  64124. * Gets or sets text to display
  64125. */
  64126. text: string;
  64127. /**
  64128. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64129. */
  64130. /**
  64131. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64132. */
  64133. textHorizontalAlignment: number;
  64134. /**
  64135. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64136. */
  64137. /**
  64138. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64139. */
  64140. textVerticalAlignment: number;
  64141. /**
  64142. * Gets or sets line spacing value
  64143. */
  64144. /**
  64145. * Gets or sets line spacing value
  64146. */
  64147. lineSpacing: string | number;
  64148. /**
  64149. * Gets or sets outlineWidth of the text to display
  64150. */
  64151. /**
  64152. * Gets or sets outlineWidth of the text to display
  64153. */
  64154. outlineWidth: number;
  64155. /**
  64156. * Gets or sets outlineColor of the text to display
  64157. */
  64158. /**
  64159. * Gets or sets outlineColor of the text to display
  64160. */
  64161. outlineColor: string;
  64162. /**
  64163. * Creates a new TextBlock object
  64164. * @param name defines the name of the control
  64165. * @param text defines the text to display (emptry string by default)
  64166. */
  64167. constructor(
  64168. /**
  64169. * Defines the name of the control
  64170. */
  64171. name?: string | undefined, text?: string);
  64172. protected _getTypeName(): string;
  64173. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64174. private _drawText;
  64175. /** @hidden */
  64176. _draw(context: CanvasRenderingContext2D): void;
  64177. protected _applyStates(context: CanvasRenderingContext2D): void;
  64178. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64179. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64180. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64181. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64182. protected _renderLines(context: CanvasRenderingContext2D): void;
  64183. /**
  64184. * Given a width constraint applied on the text block, find the expected height
  64185. * @returns expected height
  64186. */
  64187. computeExpectedHeight(): number;
  64188. dispose(): void;
  64189. }
  64190. }
  64191. declare module BABYLON.GUI {
  64192. /**
  64193. * Class used to create 2D images
  64194. */
  64195. export class Image extends Control {
  64196. name?: string | undefined;
  64197. private static _WorkingCanvas;
  64198. private _domImage;
  64199. private _imageWidth;
  64200. private _imageHeight;
  64201. private _loaded;
  64202. private _stretch;
  64203. private _source;
  64204. private _autoScale;
  64205. private _sourceLeft;
  64206. private _sourceTop;
  64207. private _sourceWidth;
  64208. private _sourceHeight;
  64209. private _cellWidth;
  64210. private _cellHeight;
  64211. private _cellId;
  64212. private _populateNinePatchSlicesFromImage;
  64213. private _sliceLeft;
  64214. private _sliceRight;
  64215. private _sliceTop;
  64216. private _sliceBottom;
  64217. private _detectPointerOnOpaqueOnly;
  64218. /**
  64219. * BABYLON.Observable notified when the content is loaded
  64220. */
  64221. onImageLoadedObservable: BABYLON.Observable<Image>;
  64222. /**
  64223. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64224. */
  64225. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64226. /**
  64227. * Gets a boolean indicating that the content is loaded
  64228. */
  64229. readonly isLoaded: boolean;
  64230. /**
  64231. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64232. */
  64233. populateNinePatchSlicesFromImage: boolean;
  64234. /**
  64235. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64236. * Beware using this as this will comsume more memory as the image has to be stored twice
  64237. */
  64238. detectPointerOnOpaqueOnly: boolean;
  64239. /**
  64240. * Gets or sets the left value for slicing (9-patch)
  64241. */
  64242. sliceLeft: number;
  64243. /**
  64244. * Gets or sets the right value for slicing (9-patch)
  64245. */
  64246. sliceRight: number;
  64247. /**
  64248. * Gets or sets the top value for slicing (9-patch)
  64249. */
  64250. sliceTop: number;
  64251. /**
  64252. * Gets or sets the bottom value for slicing (9-patch)
  64253. */
  64254. sliceBottom: number;
  64255. /**
  64256. * Gets or sets the left coordinate in the source image
  64257. */
  64258. sourceLeft: number;
  64259. /**
  64260. * Gets or sets the top coordinate in the source image
  64261. */
  64262. sourceTop: number;
  64263. /**
  64264. * Gets or sets the width to capture in the source image
  64265. */
  64266. sourceWidth: number;
  64267. /**
  64268. * Gets or sets the height to capture in the source image
  64269. */
  64270. sourceHeight: number;
  64271. /**
  64272. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64273. * @see http://doc.babylonjs.com/how_to/gui#image
  64274. */
  64275. autoScale: boolean;
  64276. /** Gets or sets the streching mode used by the image */
  64277. stretch: number;
  64278. /**
  64279. * Gets or sets the internal DOM image used to render the control
  64280. */
  64281. domImage: HTMLImageElement;
  64282. private _onImageLoaded;
  64283. private _extractNinePatchSliceDataFromImage;
  64284. /**
  64285. * Gets or sets image source url
  64286. */
  64287. source: BABYLON.Nullable<string>;
  64288. /**
  64289. * Checks for svg document with icon id present
  64290. */
  64291. private _svgCheck;
  64292. /**
  64293. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64294. * given external svg file and icon id
  64295. */
  64296. private _getSVGAttribs;
  64297. /**
  64298. * Gets or sets the cell width to use when animation sheet is enabled
  64299. * @see http://doc.babylonjs.com/how_to/gui#image
  64300. */
  64301. cellWidth: number;
  64302. /**
  64303. * Gets or sets the cell height to use when animation sheet is enabled
  64304. * @see http://doc.babylonjs.com/how_to/gui#image
  64305. */
  64306. cellHeight: number;
  64307. /**
  64308. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64309. * @see http://doc.babylonjs.com/how_to/gui#image
  64310. */
  64311. cellId: number;
  64312. /**
  64313. * Creates a new Image
  64314. * @param name defines the control name
  64315. * @param url defines the image url
  64316. */
  64317. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64318. /**
  64319. * Tests if a given coordinates belong to the current control
  64320. * @param x defines x coordinate to test
  64321. * @param y defines y coordinate to test
  64322. * @returns true if the coordinates are inside the control
  64323. */
  64324. contains(x: number, y: number): boolean;
  64325. protected _getTypeName(): string;
  64326. /** Force the control to synchronize with its content */
  64327. synchronizeSizeWithContent(): void;
  64328. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64329. private _prepareWorkingCanvasForOpaqueDetection;
  64330. private _drawImage;
  64331. _draw(context: CanvasRenderingContext2D): void;
  64332. private _renderCornerPatch;
  64333. private _renderNinePatch;
  64334. dispose(): void;
  64335. /** STRETCH_NONE */
  64336. static readonly STRETCH_NONE: number;
  64337. /** STRETCH_FILL */
  64338. static readonly STRETCH_FILL: number;
  64339. /** STRETCH_UNIFORM */
  64340. static readonly STRETCH_UNIFORM: number;
  64341. /** STRETCH_EXTEND */
  64342. static readonly STRETCH_EXTEND: number;
  64343. /** NINE_PATCH */
  64344. static readonly STRETCH_NINE_PATCH: number;
  64345. }
  64346. }
  64347. declare module BABYLON.GUI {
  64348. /**
  64349. * Class used to create 2D buttons
  64350. */
  64351. export class Button extends Rectangle {
  64352. name?: string | undefined;
  64353. /**
  64354. * Function called to generate a pointer enter animation
  64355. */
  64356. pointerEnterAnimation: () => void;
  64357. /**
  64358. * Function called to generate a pointer out animation
  64359. */
  64360. pointerOutAnimation: () => void;
  64361. /**
  64362. * Function called to generate a pointer down animation
  64363. */
  64364. pointerDownAnimation: () => void;
  64365. /**
  64366. * Function called to generate a pointer up animation
  64367. */
  64368. pointerUpAnimation: () => void;
  64369. /**
  64370. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64371. */
  64372. delegatePickingToChildren: boolean;
  64373. private _image;
  64374. /**
  64375. * Returns the image part of the button (if any)
  64376. */
  64377. readonly image: BABYLON.Nullable<Image>;
  64378. private _textBlock;
  64379. /**
  64380. * Returns the image part of the button (if any)
  64381. */
  64382. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64383. /**
  64384. * Creates a new Button
  64385. * @param name defines the name of the button
  64386. */
  64387. constructor(name?: string | undefined);
  64388. protected _getTypeName(): string;
  64389. /** @hidden */
  64390. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64391. /** @hidden */
  64392. _onPointerEnter(target: Control): boolean;
  64393. /** @hidden */
  64394. _onPointerOut(target: Control, force?: boolean): void;
  64395. /** @hidden */
  64396. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64397. /** @hidden */
  64398. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64399. /**
  64400. * Creates a new button made with an image and a text
  64401. * @param name defines the name of the button
  64402. * @param text defines the text of the button
  64403. * @param imageUrl defines the url of the image
  64404. * @returns a new Button
  64405. */
  64406. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64407. /**
  64408. * Creates a new button made with an image
  64409. * @param name defines the name of the button
  64410. * @param imageUrl defines the url of the image
  64411. * @returns a new Button
  64412. */
  64413. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64414. /**
  64415. * Creates a new button made with a text
  64416. * @param name defines the name of the button
  64417. * @param text defines the text of the button
  64418. * @returns a new Button
  64419. */
  64420. static CreateSimpleButton(name: string, text: string): Button;
  64421. /**
  64422. * Creates a new button made with an image and a centered text
  64423. * @param name defines the name of the button
  64424. * @param text defines the text of the button
  64425. * @param imageUrl defines the url of the image
  64426. * @returns a new Button
  64427. */
  64428. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64429. }
  64430. }
  64431. declare module BABYLON.GUI {
  64432. /**
  64433. * Class used to create a 2D stack panel container
  64434. */
  64435. export class StackPanel extends Container {
  64436. name?: string | undefined;
  64437. private _isVertical;
  64438. private _manualWidth;
  64439. private _manualHeight;
  64440. private _doNotTrackManualChanges;
  64441. /**
  64442. * Gets or sets a boolean indicating that layou warnings should be ignored
  64443. */
  64444. ignoreLayoutWarnings: boolean;
  64445. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64446. isVertical: boolean;
  64447. /**
  64448. * Gets or sets panel width.
  64449. * This value should not be set when in horizontal mode as it will be computed automatically
  64450. */
  64451. width: string | number;
  64452. /**
  64453. * Gets or sets panel height.
  64454. * This value should not be set when in vertical mode as it will be computed automatically
  64455. */
  64456. height: string | number;
  64457. /**
  64458. * Creates a new StackPanel
  64459. * @param name defines control name
  64460. */
  64461. constructor(name?: string | undefined);
  64462. protected _getTypeName(): string;
  64463. /** @hidden */
  64464. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64465. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64466. protected _postMeasure(): void;
  64467. }
  64468. }
  64469. declare module BABYLON.GUI {
  64470. /**
  64471. * Class used to represent a 2D checkbox
  64472. */
  64473. export class Checkbox extends Control {
  64474. name?: string | undefined;
  64475. private _isChecked;
  64476. private _background;
  64477. private _checkSizeRatio;
  64478. private _thickness;
  64479. /** Gets or sets border thickness */
  64480. thickness: number;
  64481. /**
  64482. * BABYLON.Observable raised when isChecked property changes
  64483. */
  64484. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64485. /** Gets or sets a value indicating the ratio between overall size and check size */
  64486. checkSizeRatio: number;
  64487. /** Gets or sets background color */
  64488. background: string;
  64489. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64490. isChecked: boolean;
  64491. /**
  64492. * Creates a new CheckBox
  64493. * @param name defines the control name
  64494. */
  64495. constructor(name?: string | undefined);
  64496. protected _getTypeName(): string;
  64497. /** @hidden */
  64498. _draw(context: CanvasRenderingContext2D): void;
  64499. /** @hidden */
  64500. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64501. /**
  64502. * Utility function to easily create a checkbox with a header
  64503. * @param title defines the label to use for the header
  64504. * @param onValueChanged defines the callback to call when value changes
  64505. * @returns a StackPanel containing the checkbox and a textBlock
  64506. */
  64507. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64508. }
  64509. }
  64510. declare module BABYLON.GUI {
  64511. /**
  64512. * Class used to store key control properties
  64513. */
  64514. export class KeyPropertySet {
  64515. /** Width */
  64516. width?: string;
  64517. /** Height */
  64518. height?: string;
  64519. /** Left padding */
  64520. paddingLeft?: string;
  64521. /** Right padding */
  64522. paddingRight?: string;
  64523. /** Top padding */
  64524. paddingTop?: string;
  64525. /** Bottom padding */
  64526. paddingBottom?: string;
  64527. /** Foreground color */
  64528. color?: string;
  64529. /** Background color */
  64530. background?: string;
  64531. }
  64532. /**
  64533. * Class used to create virtual keyboard
  64534. */
  64535. export class VirtualKeyboard extends StackPanel {
  64536. /** BABYLON.Observable raised when a key is pressed */
  64537. onKeyPressObservable: BABYLON.Observable<string>;
  64538. /** Gets or sets default key button width */
  64539. defaultButtonWidth: string;
  64540. /** Gets or sets default key button height */
  64541. defaultButtonHeight: string;
  64542. /** Gets or sets default key button left padding */
  64543. defaultButtonPaddingLeft: string;
  64544. /** Gets or sets default key button right padding */
  64545. defaultButtonPaddingRight: string;
  64546. /** Gets or sets default key button top padding */
  64547. defaultButtonPaddingTop: string;
  64548. /** Gets or sets default key button bottom padding */
  64549. defaultButtonPaddingBottom: string;
  64550. /** Gets or sets default key button foreground color */
  64551. defaultButtonColor: string;
  64552. /** Gets or sets default key button background color */
  64553. defaultButtonBackground: string;
  64554. /** Gets or sets shift button foreground color */
  64555. shiftButtonColor: string;
  64556. /** Gets or sets shift button thickness*/
  64557. selectedShiftThickness: number;
  64558. /** Gets shift key state */
  64559. shiftState: number;
  64560. protected _getTypeName(): string;
  64561. private _createKey;
  64562. /**
  64563. * Adds a new row of keys
  64564. * @param keys defines the list of keys to add
  64565. * @param propertySets defines the associated property sets
  64566. */
  64567. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64568. /**
  64569. * Set the shift key to a specific state
  64570. * @param shiftState defines the new shift state
  64571. */
  64572. applyShiftState(shiftState: number): void;
  64573. private _currentlyConnectedInputText;
  64574. private _connectedInputTexts;
  64575. private _onKeyPressObserver;
  64576. /** Gets the input text control currently attached to the keyboard */
  64577. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64578. /**
  64579. * Connects the keyboard with an input text control
  64580. *
  64581. * @param input defines the target control
  64582. */
  64583. connect(input: InputText): void;
  64584. /**
  64585. * Disconnects the keyboard from connected InputText controls
  64586. *
  64587. * @param input optionally defines a target control, otherwise all are disconnected
  64588. */
  64589. disconnect(input?: InputText): void;
  64590. private _removeConnectedInputObservables;
  64591. /**
  64592. * Release all resources
  64593. */
  64594. dispose(): void;
  64595. /**
  64596. * Creates a new keyboard using a default layout
  64597. *
  64598. * @param name defines control name
  64599. * @returns a new VirtualKeyboard
  64600. */
  64601. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64602. }
  64603. }
  64604. declare module BABYLON.GUI {
  64605. /**
  64606. * Class used to create input text control
  64607. */
  64608. export class InputText extends Control implements IFocusableControl {
  64609. name?: string | undefined;
  64610. private _text;
  64611. private _placeholderText;
  64612. private _background;
  64613. private _focusedBackground;
  64614. private _focusedColor;
  64615. private _placeholderColor;
  64616. private _thickness;
  64617. private _margin;
  64618. private _autoStretchWidth;
  64619. private _maxWidth;
  64620. private _isFocused;
  64621. private _blinkTimeout;
  64622. private _blinkIsEven;
  64623. private _cursorOffset;
  64624. private _scrollLeft;
  64625. private _textWidth;
  64626. private _clickedCoordinate;
  64627. private _deadKey;
  64628. private _addKey;
  64629. private _currentKey;
  64630. private _isTextHighlightOn;
  64631. private _textHighlightColor;
  64632. private _highligherOpacity;
  64633. private _highlightedText;
  64634. private _startHighlightIndex;
  64635. private _endHighlightIndex;
  64636. private _cursorIndex;
  64637. private _onFocusSelectAll;
  64638. private _isPointerDown;
  64639. private _onClipboardObserver;
  64640. private _onPointerDblTapObserver;
  64641. /** @hidden */
  64642. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64643. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64644. promptMessage: string;
  64645. /** Force disable prompt on mobile device */
  64646. disableMobilePrompt: boolean;
  64647. /** BABYLON.Observable raised when the text changes */
  64648. onTextChangedObservable: BABYLON.Observable<InputText>;
  64649. /** BABYLON.Observable raised just before an entered character is to be added */
  64650. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64651. /** BABYLON.Observable raised when the control gets the focus */
  64652. onFocusObservable: BABYLON.Observable<InputText>;
  64653. /** BABYLON.Observable raised when the control loses the focus */
  64654. onBlurObservable: BABYLON.Observable<InputText>;
  64655. /**Observable raised when the text is highlighted */
  64656. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64657. /**Observable raised when copy event is triggered */
  64658. onTextCopyObservable: BABYLON.Observable<InputText>;
  64659. /** BABYLON.Observable raised when cut event is triggered */
  64660. onTextCutObservable: BABYLON.Observable<InputText>;
  64661. /** BABYLON.Observable raised when paste event is triggered */
  64662. onTextPasteObservable: BABYLON.Observable<InputText>;
  64663. /** BABYLON.Observable raised when a key event was processed */
  64664. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64665. /** Gets or sets the maximum width allowed by the control */
  64666. maxWidth: string | number;
  64667. /** Gets the maximum width allowed by the control in pixels */
  64668. readonly maxWidthInPixels: number;
  64669. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64670. highligherOpacity: number;
  64671. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64672. onFocusSelectAll: boolean;
  64673. /** Gets or sets the text hightlight color */
  64674. textHighlightColor: string;
  64675. /** Gets or sets control margin */
  64676. margin: string;
  64677. /** Gets control margin in pixels */
  64678. readonly marginInPixels: number;
  64679. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64680. autoStretchWidth: boolean;
  64681. /** Gets or sets border thickness */
  64682. thickness: number;
  64683. /** Gets or sets the background color when focused */
  64684. focusedBackground: string;
  64685. /** Gets or sets the background color when focused */
  64686. focusedColor: string;
  64687. /** Gets or sets the background color */
  64688. background: string;
  64689. /** Gets or sets the placeholder color */
  64690. placeholderColor: string;
  64691. /** Gets or sets the text displayed when the control is empty */
  64692. placeholderText: string;
  64693. /** Gets or sets the dead key flag */
  64694. deadKey: boolean;
  64695. /** Gets or sets the highlight text */
  64696. highlightedText: string;
  64697. /** Gets or sets if the current key should be added */
  64698. addKey: boolean;
  64699. /** Gets or sets the value of the current key being entered */
  64700. currentKey: string;
  64701. /** Gets or sets the text displayed in the control */
  64702. text: string;
  64703. /** Gets or sets control width */
  64704. width: string | number;
  64705. /**
  64706. * Creates a new InputText
  64707. * @param name defines the control name
  64708. * @param text defines the text of the control
  64709. */
  64710. constructor(name?: string | undefined, text?: string);
  64711. /** @hidden */
  64712. onBlur(): void;
  64713. /** @hidden */
  64714. onFocus(): void;
  64715. protected _getTypeName(): string;
  64716. /**
  64717. * Function called to get the list of controls that should not steal the focus from this control
  64718. * @returns an array of controls
  64719. */
  64720. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64721. /** @hidden */
  64722. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64723. /** @hidden */
  64724. private _updateValueFromCursorIndex;
  64725. /** @hidden */
  64726. private _processDblClick;
  64727. /** @hidden */
  64728. private _selectAllText;
  64729. /**
  64730. * Handles the keyboard event
  64731. * @param evt Defines the KeyboardEvent
  64732. */
  64733. processKeyboard(evt: KeyboardEvent): void;
  64734. /** @hidden */
  64735. private _onCopyText;
  64736. /** @hidden */
  64737. private _onCutText;
  64738. /** @hidden */
  64739. private _onPasteText;
  64740. _draw(context: CanvasRenderingContext2D): void;
  64741. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64742. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64743. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64744. protected _beforeRenderText(text: string): string;
  64745. dispose(): void;
  64746. }
  64747. }
  64748. declare module BABYLON.GUI {
  64749. /**
  64750. * Class used to create a 2D grid container
  64751. */
  64752. export class Grid extends Container {
  64753. name?: string | undefined;
  64754. private _rowDefinitions;
  64755. private _columnDefinitions;
  64756. private _cells;
  64757. private _childControls;
  64758. /**
  64759. * Gets the number of columns
  64760. */
  64761. readonly columnCount: number;
  64762. /**
  64763. * Gets the number of rows
  64764. */
  64765. readonly rowCount: number;
  64766. /** Gets the list of children */
  64767. readonly children: Control[];
  64768. /** Gets the list of cells (e.g. the containers) */
  64769. readonly cells: {
  64770. [key: string]: Container;
  64771. };
  64772. /**
  64773. * Gets the definition of a specific row
  64774. * @param index defines the index of the row
  64775. * @returns the row definition
  64776. */
  64777. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64778. /**
  64779. * Gets the definition of a specific column
  64780. * @param index defines the index of the column
  64781. * @returns the column definition
  64782. */
  64783. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64784. /**
  64785. * Adds a new row to the grid
  64786. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64787. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64788. * @returns the current grid
  64789. */
  64790. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64791. /**
  64792. * Adds a new column to the grid
  64793. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64794. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64795. * @returns the current grid
  64796. */
  64797. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64798. /**
  64799. * Update a row definition
  64800. * @param index defines the index of the row to update
  64801. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64802. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64803. * @returns the current grid
  64804. */
  64805. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64806. /**
  64807. * Update a column definition
  64808. * @param index defines the index of the column to update
  64809. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64810. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64811. * @returns the current grid
  64812. */
  64813. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64814. /**
  64815. * Gets the list of children stored in a specific cell
  64816. * @param row defines the row to check
  64817. * @param column defines the column to check
  64818. * @returns the list of controls
  64819. */
  64820. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64821. /**
  64822. * Gets a string representing the child cell info (row x column)
  64823. * @param child defines the control to get info from
  64824. * @returns a string containing the child cell info (row x column)
  64825. */
  64826. getChildCellInfo(child: Control): string;
  64827. private _removeCell;
  64828. private _offsetCell;
  64829. /**
  64830. * Remove a column definition at specified index
  64831. * @param index defines the index of the column to remove
  64832. * @returns the current grid
  64833. */
  64834. removeColumnDefinition(index: number): Grid;
  64835. /**
  64836. * Remove a row definition at specified index
  64837. * @param index defines the index of the row to remove
  64838. * @returns the current grid
  64839. */
  64840. removeRowDefinition(index: number): Grid;
  64841. /**
  64842. * Adds a new control to the current grid
  64843. * @param control defines the control to add
  64844. * @param row defines the row where to add the control (0 by default)
  64845. * @param column defines the column where to add the control (0 by default)
  64846. * @returns the current grid
  64847. */
  64848. addControl(control: Control, row?: number, column?: number): Grid;
  64849. /**
  64850. * Removes a control from the current container
  64851. * @param control defines the control to remove
  64852. * @returns the current container
  64853. */
  64854. removeControl(control: Control): Container;
  64855. /**
  64856. * Creates a new Grid
  64857. * @param name defines control name
  64858. */
  64859. constructor(name?: string | undefined);
  64860. protected _getTypeName(): string;
  64861. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64862. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64863. _flagDescendantsAsMatrixDirty(): void;
  64864. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64865. /** Releases associated resources */
  64866. dispose(): void;
  64867. }
  64868. }
  64869. declare module BABYLON.GUI {
  64870. /** Class used to create color pickers */
  64871. export class ColorPicker extends Control {
  64872. name?: string | undefined;
  64873. private static _Epsilon;
  64874. private _colorWheelCanvas;
  64875. private _value;
  64876. private _tmpColor;
  64877. private _pointerStartedOnSquare;
  64878. private _pointerStartedOnWheel;
  64879. private _squareLeft;
  64880. private _squareTop;
  64881. private _squareSize;
  64882. private _h;
  64883. private _s;
  64884. private _v;
  64885. private _lastPointerDownID;
  64886. /**
  64887. * BABYLON.Observable raised when the value changes
  64888. */
  64889. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64890. /** Gets or sets the color of the color picker */
  64891. value: BABYLON.Color3;
  64892. /**
  64893. * Gets or sets control width
  64894. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64895. */
  64896. width: string | number;
  64897. /**
  64898. * Gets or sets control height
  64899. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64900. */
  64901. /** Gets or sets control height */
  64902. height: string | number;
  64903. /** Gets or sets control size */
  64904. size: string | number;
  64905. /**
  64906. * Creates a new ColorPicker
  64907. * @param name defines the control name
  64908. */
  64909. constructor(name?: string | undefined);
  64910. protected _getTypeName(): string;
  64911. /** @hidden */
  64912. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64913. private _updateSquareProps;
  64914. private _drawGradientSquare;
  64915. private _drawCircle;
  64916. private _createColorWheelCanvas;
  64917. /** @hidden */
  64918. _draw(context: CanvasRenderingContext2D): void;
  64919. private _pointerIsDown;
  64920. private _updateValueFromPointer;
  64921. private _isPointOnSquare;
  64922. private _isPointOnWheel;
  64923. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64924. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64925. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64926. /**
  64927. * This function expands the color picker by creating a color picker dialog with manual
  64928. * color value input and the ability to save colors into an array to be used later in
  64929. * subsequent launches of the dialogue.
  64930. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64931. * @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.
  64932. * @returns picked color as a hex string and the saved colors array as hex strings.
  64933. */
  64934. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64935. pickerWidth?: string;
  64936. pickerHeight?: string;
  64937. headerHeight?: string;
  64938. lastColor?: string;
  64939. swatchLimit?: number;
  64940. numSwatchesPerLine?: number;
  64941. savedColors?: Array<string>;
  64942. }): Promise<{
  64943. savedColors?: string[];
  64944. pickedColor: string;
  64945. }>;
  64946. }
  64947. }
  64948. declare module BABYLON.GUI {
  64949. /** Class used to create 2D ellipse containers */
  64950. export class Ellipse extends Container {
  64951. name?: string | undefined;
  64952. private _thickness;
  64953. /** Gets or sets border thickness */
  64954. thickness: number;
  64955. /**
  64956. * Creates a new Ellipse
  64957. * @param name defines the control name
  64958. */
  64959. constructor(name?: string | undefined);
  64960. protected _getTypeName(): string;
  64961. protected _localDraw(context: CanvasRenderingContext2D): void;
  64962. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64963. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64964. }
  64965. }
  64966. declare module BABYLON.GUI {
  64967. /**
  64968. * Class used to create a password control
  64969. */
  64970. export class InputPassword extends InputText {
  64971. protected _beforeRenderText(text: string): string;
  64972. }
  64973. }
  64974. declare module BABYLON.GUI {
  64975. /** Class used to render 2D lines */
  64976. export class Line extends Control {
  64977. name?: string | undefined;
  64978. private _lineWidth;
  64979. private _x1;
  64980. private _y1;
  64981. private _x2;
  64982. private _y2;
  64983. private _dash;
  64984. private _connectedControl;
  64985. private _connectedControlDirtyObserver;
  64986. /** Gets or sets the dash pattern */
  64987. dash: Array<number>;
  64988. /** Gets or sets the control connected with the line end */
  64989. connectedControl: Control;
  64990. /** Gets or sets start coordinates on X axis */
  64991. x1: string | number;
  64992. /** Gets or sets start coordinates on Y axis */
  64993. y1: string | number;
  64994. /** Gets or sets end coordinates on X axis */
  64995. x2: string | number;
  64996. /** Gets or sets end coordinates on Y axis */
  64997. y2: string | number;
  64998. /** Gets or sets line width */
  64999. lineWidth: number;
  65000. /** Gets or sets horizontal alignment */
  65001. horizontalAlignment: number;
  65002. /** Gets or sets vertical alignment */
  65003. verticalAlignment: number;
  65004. private readonly _effectiveX2;
  65005. private readonly _effectiveY2;
  65006. /**
  65007. * Creates a new Line
  65008. * @param name defines the control name
  65009. */
  65010. constructor(name?: string | undefined);
  65011. protected _getTypeName(): string;
  65012. _draw(context: CanvasRenderingContext2D): void;
  65013. _measure(): void;
  65014. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65015. /**
  65016. * Move one end of the line given 3D cartesian coordinates.
  65017. * @param position Targeted world position
  65018. * @param scene BABYLON.Scene
  65019. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65020. */
  65021. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65022. /**
  65023. * Move one end of the line to a position in screen absolute space.
  65024. * @param projectedPosition Position in screen absolute space (X, Y)
  65025. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65026. */
  65027. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65028. }
  65029. }
  65030. declare module BABYLON.GUI {
  65031. /**
  65032. * Class used to store a point for a MultiLine object.
  65033. * The point can be pure 2D coordinates, a mesh or a control
  65034. */
  65035. export class MultiLinePoint {
  65036. private _multiLine;
  65037. private _x;
  65038. private _y;
  65039. private _control;
  65040. private _mesh;
  65041. private _controlObserver;
  65042. private _meshObserver;
  65043. /** @hidden */
  65044. _point: BABYLON.Vector2;
  65045. /**
  65046. * Creates a new MultiLinePoint
  65047. * @param multiLine defines the source MultiLine object
  65048. */
  65049. constructor(multiLine: MultiLine);
  65050. /** Gets or sets x coordinate */
  65051. x: string | number;
  65052. /** Gets or sets y coordinate */
  65053. y: string | number;
  65054. /** Gets or sets the control associated with this point */
  65055. control: BABYLON.Nullable<Control>;
  65056. /** Gets or sets the mesh associated with this point */
  65057. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65058. /** Resets links */
  65059. resetLinks(): void;
  65060. /**
  65061. * Gets a translation vector
  65062. * @returns the translation vector
  65063. */
  65064. translate(): BABYLON.Vector2;
  65065. private _translatePoint;
  65066. /** Release associated resources */
  65067. dispose(): void;
  65068. }
  65069. }
  65070. declare module BABYLON.GUI {
  65071. /**
  65072. * Class used to create multi line control
  65073. */
  65074. export class MultiLine extends Control {
  65075. name?: string | undefined;
  65076. private _lineWidth;
  65077. private _dash;
  65078. private _points;
  65079. private _minX;
  65080. private _minY;
  65081. private _maxX;
  65082. private _maxY;
  65083. /**
  65084. * Creates a new MultiLine
  65085. * @param name defines the control name
  65086. */
  65087. constructor(name?: string | undefined);
  65088. /** Gets or sets dash pattern */
  65089. dash: Array<number>;
  65090. /**
  65091. * Gets point stored at specified index
  65092. * @param index defines the index to look for
  65093. * @returns the requested point if found
  65094. */
  65095. getAt(index: number): MultiLinePoint;
  65096. /** Function called when a point is updated */
  65097. onPointUpdate: () => void;
  65098. /**
  65099. * Adds new points to the point collection
  65100. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65101. * @returns the list of created MultiLinePoint
  65102. */
  65103. add(...items: (AbstractMesh | Control | {
  65104. x: string | number;
  65105. y: string | number;
  65106. })[]): MultiLinePoint[];
  65107. /**
  65108. * Adds a new point to the point collection
  65109. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65110. * @returns the created MultiLinePoint
  65111. */
  65112. push(item?: (AbstractMesh | Control | {
  65113. x: string | number;
  65114. y: string | number;
  65115. })): MultiLinePoint;
  65116. /**
  65117. * Remove a specific value or point from the active point collection
  65118. * @param value defines the value or point to remove
  65119. */
  65120. remove(value: number | MultiLinePoint): void;
  65121. /**
  65122. * Resets this object to initial state (no point)
  65123. */
  65124. reset(): void;
  65125. /**
  65126. * Resets all links
  65127. */
  65128. resetLinks(): void;
  65129. /** Gets or sets line width */
  65130. lineWidth: number;
  65131. horizontalAlignment: number;
  65132. verticalAlignment: number;
  65133. protected _getTypeName(): string;
  65134. _draw(context: CanvasRenderingContext2D): void;
  65135. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65136. _measure(): void;
  65137. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65138. dispose(): void;
  65139. }
  65140. }
  65141. declare module BABYLON.GUI {
  65142. /**
  65143. * Class used to create radio button controls
  65144. */
  65145. export class RadioButton extends Control {
  65146. name?: string | undefined;
  65147. private _isChecked;
  65148. private _background;
  65149. private _checkSizeRatio;
  65150. private _thickness;
  65151. /** Gets or sets border thickness */
  65152. thickness: number;
  65153. /** Gets or sets group name */
  65154. group: string;
  65155. /** BABYLON.Observable raised when isChecked is changed */
  65156. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65157. /** Gets or sets a value indicating the ratio between overall size and check size */
  65158. checkSizeRatio: number;
  65159. /** Gets or sets background color */
  65160. background: string;
  65161. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65162. isChecked: boolean;
  65163. /**
  65164. * Creates a new RadioButton
  65165. * @param name defines the control name
  65166. */
  65167. constructor(name?: string | undefined);
  65168. protected _getTypeName(): string;
  65169. _draw(context: CanvasRenderingContext2D): void;
  65170. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65171. /**
  65172. * Utility function to easily create a radio button with a header
  65173. * @param title defines the label to use for the header
  65174. * @param group defines the group to use for the radio button
  65175. * @param isChecked defines the initial state of the radio button
  65176. * @param onValueChanged defines the callback to call when value changes
  65177. * @returns a StackPanel containing the radio button and a textBlock
  65178. */
  65179. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65180. }
  65181. }
  65182. declare module BABYLON.GUI {
  65183. /**
  65184. * Class used to create slider controls
  65185. */
  65186. export class BaseSlider extends Control {
  65187. name?: string | undefined;
  65188. protected _thumbWidth: ValueAndUnit;
  65189. private _minimum;
  65190. private _maximum;
  65191. private _value;
  65192. private _isVertical;
  65193. protected _barOffset: ValueAndUnit;
  65194. private _isThumbClamped;
  65195. protected _displayThumb: boolean;
  65196. private _step;
  65197. private _lastPointerDownID;
  65198. protected _effectiveBarOffset: number;
  65199. protected _renderLeft: number;
  65200. protected _renderTop: number;
  65201. protected _renderWidth: number;
  65202. protected _renderHeight: number;
  65203. protected _backgroundBoxLength: number;
  65204. protected _backgroundBoxThickness: number;
  65205. protected _effectiveThumbThickness: number;
  65206. /** BABYLON.Observable raised when the sldier value changes */
  65207. onValueChangedObservable: BABYLON.Observable<number>;
  65208. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65209. displayThumb: boolean;
  65210. /** Gets or sets a step to apply to values (0 by default) */
  65211. step: number;
  65212. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65213. barOffset: string | number;
  65214. /** Gets main bar offset in pixels*/
  65215. readonly barOffsetInPixels: number;
  65216. /** Gets or sets thumb width */
  65217. thumbWidth: string | number;
  65218. /** Gets thumb width in pixels */
  65219. readonly thumbWidthInPixels: number;
  65220. /** Gets or sets minimum value */
  65221. minimum: number;
  65222. /** Gets or sets maximum value */
  65223. maximum: number;
  65224. /** Gets or sets current value */
  65225. value: number;
  65226. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65227. isVertical: boolean;
  65228. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65229. isThumbClamped: boolean;
  65230. /**
  65231. * Creates a new BaseSlider
  65232. * @param name defines the control name
  65233. */
  65234. constructor(name?: string | undefined);
  65235. protected _getTypeName(): string;
  65236. protected _getThumbPosition(): number;
  65237. protected _getThumbThickness(type: string): number;
  65238. protected _prepareRenderingData(type: string): void;
  65239. private _pointerIsDown;
  65240. /** @hidden */
  65241. protected _updateValueFromPointer(x: number, y: number): void;
  65242. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65243. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65244. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65245. }
  65246. }
  65247. declare module BABYLON.GUI {
  65248. /**
  65249. * Class used to create slider controls
  65250. */
  65251. export class Slider extends BaseSlider {
  65252. name?: string | undefined;
  65253. private _background;
  65254. private _borderColor;
  65255. private _isThumbCircle;
  65256. protected _displayValueBar: boolean;
  65257. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65258. displayValueBar: boolean;
  65259. /** Gets or sets border color */
  65260. borderColor: string;
  65261. /** Gets or sets background color */
  65262. background: string;
  65263. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65264. isThumbCircle: boolean;
  65265. /**
  65266. * Creates a new Slider
  65267. * @param name defines the control name
  65268. */
  65269. constructor(name?: string | undefined);
  65270. protected _getTypeName(): string;
  65271. _draw(context: CanvasRenderingContext2D): void;
  65272. }
  65273. }
  65274. declare module BABYLON.GUI {
  65275. /** Class used to create a RadioGroup
  65276. * which contains groups of radio buttons
  65277. */
  65278. export class SelectorGroup {
  65279. /** name of SelectorGroup */
  65280. name: string;
  65281. private _groupPanel;
  65282. private _selectors;
  65283. private _groupHeader;
  65284. /**
  65285. * Creates a new SelectorGroup
  65286. * @param name of group, used as a group heading
  65287. */
  65288. constructor(
  65289. /** name of SelectorGroup */
  65290. name: string);
  65291. /** Gets the groupPanel of the SelectorGroup */
  65292. readonly groupPanel: StackPanel;
  65293. /** Gets the selectors array */
  65294. readonly selectors: StackPanel[];
  65295. /** Gets and sets the group header */
  65296. header: string;
  65297. /** @hidden */
  65298. private _addGroupHeader;
  65299. /** @hidden*/
  65300. _getSelector(selectorNb: number): StackPanel | undefined;
  65301. /** Removes the selector at the given position
  65302. * @param selectorNb the position of the selector within the group
  65303. */
  65304. removeSelector(selectorNb: number): void;
  65305. }
  65306. /** Class used to create a CheckboxGroup
  65307. * which contains groups of checkbox buttons
  65308. */
  65309. export class CheckboxGroup extends SelectorGroup {
  65310. /** Adds a checkbox as a control
  65311. * @param text is the label for the selector
  65312. * @param func is the function called when the Selector is checked
  65313. * @param checked is true when Selector is checked
  65314. */
  65315. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65316. /** @hidden */
  65317. _setSelectorLabel(selectorNb: number, label: string): void;
  65318. /** @hidden */
  65319. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65320. /** @hidden */
  65321. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65322. /** @hidden */
  65323. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65324. }
  65325. /** Class used to create a RadioGroup
  65326. * which contains groups of radio buttons
  65327. */
  65328. export class RadioGroup extends SelectorGroup {
  65329. private _selectNb;
  65330. /** Adds a radio button as a control
  65331. * @param label is the label for the selector
  65332. * @param func is the function called when the Selector is checked
  65333. * @param checked is true when Selector is checked
  65334. */
  65335. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65336. /** @hidden */
  65337. _setSelectorLabel(selectorNb: number, label: string): void;
  65338. /** @hidden */
  65339. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65340. /** @hidden */
  65341. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65342. /** @hidden */
  65343. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65344. }
  65345. /** Class used to create a SliderGroup
  65346. * which contains groups of slider buttons
  65347. */
  65348. export class SliderGroup extends SelectorGroup {
  65349. /**
  65350. * Adds a slider to the SelectorGroup
  65351. * @param label is the label for the SliderBar
  65352. * @param func is the function called when the Slider moves
  65353. * @param unit is a string describing the units used, eg degrees or metres
  65354. * @param min is the minimum value for the Slider
  65355. * @param max is the maximum value for the Slider
  65356. * @param value is the start value for the Slider between min and max
  65357. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65358. */
  65359. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65360. /** @hidden */
  65361. _setSelectorLabel(selectorNb: number, label: string): void;
  65362. /** @hidden */
  65363. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65364. /** @hidden */
  65365. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65366. /** @hidden */
  65367. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65368. }
  65369. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65370. * @see http://doc.babylonjs.com/how_to/selector
  65371. */
  65372. export class SelectionPanel extends Rectangle {
  65373. /** name of SelectionPanel */
  65374. name: string;
  65375. /** an array of SelectionGroups */
  65376. groups: SelectorGroup[];
  65377. private _panel;
  65378. private _buttonColor;
  65379. private _buttonBackground;
  65380. private _headerColor;
  65381. private _barColor;
  65382. private _barHeight;
  65383. private _spacerHeight;
  65384. private _labelColor;
  65385. private _groups;
  65386. private _bars;
  65387. /**
  65388. * Creates a new SelectionPanel
  65389. * @param name of SelectionPanel
  65390. * @param groups is an array of SelectionGroups
  65391. */
  65392. constructor(
  65393. /** name of SelectionPanel */
  65394. name: string,
  65395. /** an array of SelectionGroups */
  65396. groups?: SelectorGroup[]);
  65397. protected _getTypeName(): string;
  65398. /** Gets or sets the headerColor */
  65399. headerColor: string;
  65400. private _setHeaderColor;
  65401. /** Gets or sets the button color */
  65402. buttonColor: string;
  65403. private _setbuttonColor;
  65404. /** Gets or sets the label color */
  65405. labelColor: string;
  65406. private _setLabelColor;
  65407. /** Gets or sets the button background */
  65408. buttonBackground: string;
  65409. private _setButtonBackground;
  65410. /** Gets or sets the color of separator bar */
  65411. barColor: string;
  65412. private _setBarColor;
  65413. /** Gets or sets the height of separator bar */
  65414. barHeight: string;
  65415. private _setBarHeight;
  65416. /** Gets or sets the height of spacers*/
  65417. spacerHeight: string;
  65418. private _setSpacerHeight;
  65419. /** Adds a bar between groups */
  65420. private _addSpacer;
  65421. /** Add a group to the selection panel
  65422. * @param group is the selector group to add
  65423. */
  65424. addGroup(group: SelectorGroup): void;
  65425. /** Remove the group from the given position
  65426. * @param groupNb is the position of the group in the list
  65427. */
  65428. removeGroup(groupNb: number): void;
  65429. /** Change a group header label
  65430. * @param label is the new group header label
  65431. * @param groupNb is the number of the group to relabel
  65432. * */
  65433. setHeaderName(label: string, groupNb: number): void;
  65434. /** Change selector label to the one given
  65435. * @param label is the new selector label
  65436. * @param groupNb is the number of the groupcontaining the selector
  65437. * @param selectorNb is the number of the selector within a group to relabel
  65438. * */
  65439. relabel(label: string, groupNb: number, selectorNb: number): void;
  65440. /** For a given group position remove the selector at the given position
  65441. * @param groupNb is the number of the group to remove the selector from
  65442. * @param selectorNb is the number of the selector within the group
  65443. */
  65444. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65445. /** For a given group position of correct type add a checkbox button
  65446. * @param groupNb is the number of the group to remove the selector from
  65447. * @param label is the label for the selector
  65448. * @param func is the function called when the Selector is checked
  65449. * @param checked is true when Selector is checked
  65450. */
  65451. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65452. /** For a given group position of correct type add a radio button
  65453. * @param groupNb is the number of the group to remove the selector from
  65454. * @param label is the label for the selector
  65455. * @param func is the function called when the Selector is checked
  65456. * @param checked is true when Selector is checked
  65457. */
  65458. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65459. /**
  65460. * For a given slider group add a slider
  65461. * @param groupNb is the number of the group to add the slider to
  65462. * @param label is the label for the Slider
  65463. * @param func is the function called when the Slider moves
  65464. * @param unit is a string describing the units used, eg degrees or metres
  65465. * @param min is the minimum value for the Slider
  65466. * @param max is the maximum value for the Slider
  65467. * @param value is the start value for the Slider between min and max
  65468. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65469. */
  65470. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65471. }
  65472. }
  65473. declare module BABYLON.GUI {
  65474. /**
  65475. * Class used to hold a the container for ScrollViewer
  65476. * @hidden
  65477. */
  65478. export class _ScrollViewerWindow extends Container {
  65479. parentClientWidth: number;
  65480. parentClientHeight: number;
  65481. /**
  65482. * Creates a new ScrollViewerWindow
  65483. * @param name of ScrollViewerWindow
  65484. */
  65485. constructor(name?: string);
  65486. protected _getTypeName(): string;
  65487. /** @hidden */
  65488. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65489. protected _postMeasure(): void;
  65490. }
  65491. }
  65492. declare module BABYLON.GUI {
  65493. /**
  65494. * Class used to create slider controls
  65495. */
  65496. export class ScrollBar extends BaseSlider {
  65497. name?: string | undefined;
  65498. private _background;
  65499. private _borderColor;
  65500. private _thumbMeasure;
  65501. /** Gets or sets border color */
  65502. borderColor: string;
  65503. /** Gets or sets background color */
  65504. background: string;
  65505. /**
  65506. * Creates a new Slider
  65507. * @param name defines the control name
  65508. */
  65509. constructor(name?: string | undefined);
  65510. protected _getTypeName(): string;
  65511. protected _getThumbThickness(): number;
  65512. _draw(context: CanvasRenderingContext2D): void;
  65513. private _first;
  65514. private _originX;
  65515. private _originY;
  65516. /** @hidden */
  65517. protected _updateValueFromPointer(x: number, y: number): void;
  65518. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65519. }
  65520. }
  65521. declare module BABYLON.GUI {
  65522. /**
  65523. * Class used to hold a viewer window and sliders in a grid
  65524. */
  65525. export class ScrollViewer extends Rectangle {
  65526. private _grid;
  65527. private _horizontalBarSpace;
  65528. private _verticalBarSpace;
  65529. private _dragSpace;
  65530. private _horizontalBar;
  65531. private _verticalBar;
  65532. private _barColor;
  65533. private _barBackground;
  65534. private _barSize;
  65535. private _endLeft;
  65536. private _endTop;
  65537. private _window;
  65538. private _pointerIsOver;
  65539. private _wheelPrecision;
  65540. private _onPointerObserver;
  65541. private _clientWidth;
  65542. private _clientHeight;
  65543. /**
  65544. * Gets the horizontal scrollbar
  65545. */
  65546. readonly horizontalBar: ScrollBar;
  65547. /**
  65548. * Gets the vertical scrollbar
  65549. */
  65550. readonly verticalBar: ScrollBar;
  65551. /**
  65552. * Adds a new control to the current container
  65553. * @param control defines the control to add
  65554. * @returns the current container
  65555. */
  65556. addControl(control: BABYLON.Nullable<Control>): Container;
  65557. /**
  65558. * Removes a control from the current container
  65559. * @param control defines the control to remove
  65560. * @returns the current container
  65561. */
  65562. removeControl(control: Control): Container;
  65563. /** Gets the list of children */
  65564. readonly children: Control[];
  65565. _flagDescendantsAsMatrixDirty(): void;
  65566. /**
  65567. * Creates a new ScrollViewer
  65568. * @param name of ScrollViewer
  65569. */
  65570. constructor(name?: string);
  65571. /** Reset the scroll viewer window to initial size */
  65572. resetWindow(): void;
  65573. protected _getTypeName(): string;
  65574. private _buildClientSizes;
  65575. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65576. protected _postMeasure(): void;
  65577. /**
  65578. * Gets or sets the mouse wheel precision
  65579. * from 0 to 1 with a default value of 0.05
  65580. * */
  65581. wheelPrecision: number;
  65582. /** Gets or sets the bar color */
  65583. barColor: string;
  65584. /** Gets or sets the size of the bar */
  65585. barSize: number;
  65586. /** Gets or sets the bar background */
  65587. barBackground: string;
  65588. /** @hidden */
  65589. private _updateScroller;
  65590. _link(host: AdvancedDynamicTexture): void;
  65591. /** @hidden */
  65592. private _attachWheel;
  65593. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65594. /** Releases associated resources */
  65595. dispose(): void;
  65596. }
  65597. }
  65598. declare module BABYLON.GUI {
  65599. /** Class used to render a grid */
  65600. export class DisplayGrid extends Control {
  65601. name?: string | undefined;
  65602. private _cellWidth;
  65603. private _cellHeight;
  65604. private _minorLineTickness;
  65605. private _minorLineColor;
  65606. private _majorLineTickness;
  65607. private _majorLineColor;
  65608. private _majorLineFrequency;
  65609. private _background;
  65610. private _displayMajorLines;
  65611. private _displayMinorLines;
  65612. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65613. displayMinorLines: boolean;
  65614. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65615. displayMajorLines: boolean;
  65616. /** Gets or sets background color (Black by default) */
  65617. background: string;
  65618. /** Gets or sets the width of each cell (20 by default) */
  65619. cellWidth: number;
  65620. /** Gets or sets the height of each cell (20 by default) */
  65621. cellHeight: number;
  65622. /** Gets or sets the tickness of minor lines (1 by default) */
  65623. minorLineTickness: number;
  65624. /** Gets or sets the color of minor lines (DarkGray by default) */
  65625. minorLineColor: string;
  65626. /** Gets or sets the tickness of major lines (2 by default) */
  65627. majorLineTickness: number;
  65628. /** Gets or sets the color of major lines (White by default) */
  65629. majorLineColor: string;
  65630. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65631. majorLineFrequency: number;
  65632. /**
  65633. * Creates a new GridDisplayRectangle
  65634. * @param name defines the control name
  65635. */
  65636. constructor(name?: string | undefined);
  65637. _draw(context: CanvasRenderingContext2D): void;
  65638. protected _getTypeName(): string;
  65639. }
  65640. }
  65641. declare module BABYLON.GUI {
  65642. /**
  65643. * Class used to create slider controls based on images
  65644. */
  65645. export class ImageBasedSlider extends BaseSlider {
  65646. name?: string | undefined;
  65647. private _backgroundImage;
  65648. private _thumbImage;
  65649. private _valueBarImage;
  65650. private _tempMeasure;
  65651. displayThumb: boolean;
  65652. /**
  65653. * Gets or sets the image used to render the background
  65654. */
  65655. backgroundImage: Image;
  65656. /**
  65657. * Gets or sets the image used to render the value bar
  65658. */
  65659. valueBarImage: Image;
  65660. /**
  65661. * Gets or sets the image used to render the thumb
  65662. */
  65663. thumbImage: Image;
  65664. /**
  65665. * Creates a new ImageBasedSlider
  65666. * @param name defines the control name
  65667. */
  65668. constructor(name?: string | undefined);
  65669. protected _getTypeName(): string;
  65670. _draw(context: CanvasRenderingContext2D): void;
  65671. }
  65672. }
  65673. declare module BABYLON.GUI {
  65674. /**
  65675. * Forcing an export so that this code will execute
  65676. * @hidden
  65677. */
  65678. const name = "Statics";
  65679. }
  65680. declare module BABYLON.GUI {
  65681. /**
  65682. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65683. */
  65684. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65685. /**
  65686. * Define the instrumented AdvancedDynamicTexture.
  65687. */
  65688. texture: AdvancedDynamicTexture;
  65689. private _captureRenderTime;
  65690. private _renderTime;
  65691. private _captureLayoutTime;
  65692. private _layoutTime;
  65693. private _onBeginRenderObserver;
  65694. private _onEndRenderObserver;
  65695. private _onBeginLayoutObserver;
  65696. private _onEndLayoutObserver;
  65697. /**
  65698. * Gets the perf counter used to capture render time
  65699. */
  65700. readonly renderTimeCounter: BABYLON.PerfCounter;
  65701. /**
  65702. * Gets the perf counter used to capture layout time
  65703. */
  65704. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65705. /**
  65706. * Enable or disable the render time capture
  65707. */
  65708. captureRenderTime: boolean;
  65709. /**
  65710. * Enable or disable the layout time capture
  65711. */
  65712. captureLayoutTime: boolean;
  65713. /**
  65714. * Instantiates a new advanced dynamic texture instrumentation.
  65715. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65716. * @param texture Defines the AdvancedDynamicTexture to instrument
  65717. */
  65718. constructor(
  65719. /**
  65720. * Define the instrumented AdvancedDynamicTexture.
  65721. */
  65722. texture: AdvancedDynamicTexture);
  65723. /**
  65724. * Dispose and release associated resources.
  65725. */
  65726. dispose(): void;
  65727. }
  65728. }
  65729. declare module BABYLON.GUI {
  65730. /**
  65731. * Class used to create containers for controls
  65732. */
  65733. export class Container3D extends Control3D {
  65734. private _blockLayout;
  65735. /**
  65736. * Gets the list of child controls
  65737. */
  65738. protected _children: Control3D[];
  65739. /**
  65740. * Gets the list of child controls
  65741. */
  65742. readonly children: Array<Control3D>;
  65743. /**
  65744. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65745. * This is helpful to optimize layout operation when adding multiple children in a row
  65746. */
  65747. blockLayout: boolean;
  65748. /**
  65749. * Creates a new container
  65750. * @param name defines the container name
  65751. */
  65752. constructor(name?: string);
  65753. /**
  65754. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65755. * @returns the current container
  65756. */
  65757. updateLayout(): Container3D;
  65758. /**
  65759. * Gets a boolean indicating if the given control is in the children of this control
  65760. * @param control defines the control to check
  65761. * @returns true if the control is in the child list
  65762. */
  65763. containsControl(control: Control3D): boolean;
  65764. /**
  65765. * Adds a control to the children of this control
  65766. * @param control defines the control to add
  65767. * @returns the current container
  65768. */
  65769. addControl(control: Control3D): Container3D;
  65770. /**
  65771. * This function will be called everytime a new control is added
  65772. */
  65773. protected _arrangeChildren(): void;
  65774. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65775. /**
  65776. * Removes a control from the children of this control
  65777. * @param control defines the control to remove
  65778. * @returns the current container
  65779. */
  65780. removeControl(control: Control3D): Container3D;
  65781. protected _getTypeName(): string;
  65782. /**
  65783. * Releases all associated resources
  65784. */
  65785. dispose(): void;
  65786. /** Control rotation will remain unchanged */
  65787. static readonly UNSET_ORIENTATION: number;
  65788. /** Control will rotate to make it look at sphere central axis */
  65789. static readonly FACEORIGIN_ORIENTATION: number;
  65790. /** Control will rotate to make it look back at sphere central axis */
  65791. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65792. /** Control will rotate to look at z axis (0, 0, 1) */
  65793. static readonly FACEFORWARD_ORIENTATION: number;
  65794. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65795. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65796. }
  65797. }
  65798. declare module BABYLON.GUI {
  65799. /**
  65800. * Class used to manage 3D user interface
  65801. * @see http://doc.babylonjs.com/how_to/gui3d
  65802. */
  65803. export class GUI3DManager implements BABYLON.IDisposable {
  65804. private _scene;
  65805. private _sceneDisposeObserver;
  65806. private _utilityLayer;
  65807. private _rootContainer;
  65808. private _pointerObserver;
  65809. private _pointerOutObserver;
  65810. /** @hidden */
  65811. _lastPickedControl: Control3D;
  65812. /** @hidden */
  65813. _lastControlOver: {
  65814. [pointerId: number]: Control3D;
  65815. };
  65816. /** @hidden */
  65817. _lastControlDown: {
  65818. [pointerId: number]: Control3D;
  65819. };
  65820. /**
  65821. * BABYLON.Observable raised when the point picked by the pointer events changed
  65822. */
  65823. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65824. /** @hidden */
  65825. _sharedMaterials: {
  65826. [key: string]: BABYLON.Material;
  65827. };
  65828. /** Gets the hosting scene */
  65829. readonly scene: BABYLON.Scene;
  65830. /** Gets associated utility layer */
  65831. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65832. /**
  65833. * Creates a new GUI3DManager
  65834. * @param scene
  65835. */
  65836. constructor(scene?: BABYLON.Scene);
  65837. private _handlePointerOut;
  65838. private _doPicking;
  65839. /**
  65840. * Gets the root container
  65841. */
  65842. readonly rootContainer: Container3D;
  65843. /**
  65844. * Gets a boolean indicating if the given control is in the root child list
  65845. * @param control defines the control to check
  65846. * @returns true if the control is in the root child list
  65847. */
  65848. containsControl(control: Control3D): boolean;
  65849. /**
  65850. * Adds a control to the root child list
  65851. * @param control defines the control to add
  65852. * @returns the current manager
  65853. */
  65854. addControl(control: Control3D): GUI3DManager;
  65855. /**
  65856. * Removes a control from the root child list
  65857. * @param control defines the control to remove
  65858. * @returns the current container
  65859. */
  65860. removeControl(control: Control3D): GUI3DManager;
  65861. /**
  65862. * Releases all associated resources
  65863. */
  65864. dispose(): void;
  65865. }
  65866. }
  65867. declare module BABYLON.GUI {
  65868. /**
  65869. * Class used to transport BABYLON.Vector3 information for pointer events
  65870. */
  65871. export class Vector3WithInfo extends BABYLON.Vector3 {
  65872. /** defines the current mouse button index */
  65873. buttonIndex: number;
  65874. /**
  65875. * Creates a new Vector3WithInfo
  65876. * @param source defines the vector3 data to transport
  65877. * @param buttonIndex defines the current mouse button index
  65878. */
  65879. constructor(source: BABYLON.Vector3,
  65880. /** defines the current mouse button index */
  65881. buttonIndex?: number);
  65882. }
  65883. }
  65884. declare module BABYLON.GUI {
  65885. /**
  65886. * Class used as base class for controls
  65887. */
  65888. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65889. /** Defines the control name */
  65890. name?: string | undefined;
  65891. /** @hidden */
  65892. _host: GUI3DManager;
  65893. private _node;
  65894. private _downCount;
  65895. private _enterCount;
  65896. private _downPointerIds;
  65897. private _isVisible;
  65898. /** Gets or sets the control position in world space */
  65899. position: BABYLON.Vector3;
  65900. /** Gets or sets the control scaling in world space */
  65901. scaling: BABYLON.Vector3;
  65902. /** Callback used to start pointer enter animation */
  65903. pointerEnterAnimation: () => void;
  65904. /** Callback used to start pointer out animation */
  65905. pointerOutAnimation: () => void;
  65906. /** Callback used to start pointer down animation */
  65907. pointerDownAnimation: () => void;
  65908. /** Callback used to start pointer up animation */
  65909. pointerUpAnimation: () => void;
  65910. /**
  65911. * An event triggered when the pointer move over the control
  65912. */
  65913. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65914. /**
  65915. * An event triggered when the pointer move out of the control
  65916. */
  65917. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65918. /**
  65919. * An event triggered when the pointer taps the control
  65920. */
  65921. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65922. /**
  65923. * An event triggered when pointer is up
  65924. */
  65925. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65926. /**
  65927. * An event triggered when a control is clicked on (with a mouse)
  65928. */
  65929. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65930. /**
  65931. * An event triggered when pointer enters the control
  65932. */
  65933. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65934. /**
  65935. * Gets or sets the parent container
  65936. */
  65937. parent: BABYLON.Nullable<Container3D>;
  65938. private _behaviors;
  65939. /**
  65940. * Gets the list of attached behaviors
  65941. * @see http://doc.babylonjs.com/features/behaviour
  65942. */
  65943. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65944. /**
  65945. * Attach a behavior to the control
  65946. * @see http://doc.babylonjs.com/features/behaviour
  65947. * @param behavior defines the behavior to attach
  65948. * @returns the current control
  65949. */
  65950. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65951. /**
  65952. * Remove an attached behavior
  65953. * @see http://doc.babylonjs.com/features/behaviour
  65954. * @param behavior defines the behavior to attach
  65955. * @returns the current control
  65956. */
  65957. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65958. /**
  65959. * Gets an attached behavior by name
  65960. * @param name defines the name of the behavior to look for
  65961. * @see http://doc.babylonjs.com/features/behaviour
  65962. * @returns null if behavior was not found else the requested behavior
  65963. */
  65964. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65965. /** Gets or sets a boolean indicating if the control is visible */
  65966. isVisible: boolean;
  65967. /**
  65968. * Creates a new control
  65969. * @param name defines the control name
  65970. */
  65971. constructor(
  65972. /** Defines the control name */
  65973. name?: string | undefined);
  65974. /**
  65975. * Gets a string representing the class name
  65976. */
  65977. readonly typeName: string;
  65978. /**
  65979. * Get the current class name of the control.
  65980. * @returns current class name
  65981. */
  65982. getClassName(): string;
  65983. protected _getTypeName(): string;
  65984. /**
  65985. * Gets the transform node used by this control
  65986. */
  65987. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65988. /**
  65989. * Gets the mesh used to render this control
  65990. */
  65991. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65992. /**
  65993. * Link the control as child of the given node
  65994. * @param node defines the node to link to. Use null to unlink the control
  65995. * @returns the current control
  65996. */
  65997. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65998. /** @hidden **/
  65999. _prepareNode(scene: BABYLON.Scene): void;
  66000. /**
  66001. * Node creation.
  66002. * Can be overriden by children
  66003. * @param scene defines the scene where the node must be attached
  66004. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66005. */
  66006. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66007. /**
  66008. * Affect a material to the given mesh
  66009. * @param mesh defines the mesh which will represent the control
  66010. */
  66011. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66012. /** @hidden */
  66013. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66014. /** @hidden */
  66015. _onPointerEnter(target: Control3D): boolean;
  66016. /** @hidden */
  66017. _onPointerOut(target: Control3D): void;
  66018. /** @hidden */
  66019. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66020. /** @hidden */
  66021. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66022. /** @hidden */
  66023. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66024. /** @hidden */
  66025. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66026. /** @hidden */
  66027. _disposeNode(): void;
  66028. /**
  66029. * Releases all associated resources
  66030. */
  66031. dispose(): void;
  66032. }
  66033. }
  66034. declare module BABYLON.GUI {
  66035. /**
  66036. * Class used as a root to all buttons
  66037. */
  66038. export class AbstractButton3D extends Control3D {
  66039. /**
  66040. * Creates a new button
  66041. * @param name defines the control name
  66042. */
  66043. constructor(name?: string);
  66044. protected _getTypeName(): string;
  66045. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66046. }
  66047. }
  66048. declare module BABYLON.GUI {
  66049. /**
  66050. * Class used to create a button in 3D
  66051. */
  66052. export class Button3D extends AbstractButton3D {
  66053. /** @hidden */
  66054. protected _currentMaterial: BABYLON.Material;
  66055. private _facadeTexture;
  66056. private _content;
  66057. private _contentResolution;
  66058. private _contentScaleRatio;
  66059. /**
  66060. * Gets or sets the texture resolution used to render content (512 by default)
  66061. */
  66062. contentResolution: BABYLON.int;
  66063. /**
  66064. * Gets or sets the texture scale ratio used to render content (2 by default)
  66065. */
  66066. contentScaleRatio: number;
  66067. protected _disposeFacadeTexture(): void;
  66068. protected _resetContent(): void;
  66069. /**
  66070. * Creates a new button
  66071. * @param name defines the control name
  66072. */
  66073. constructor(name?: string);
  66074. /**
  66075. * Gets or sets the GUI 2D content used to display the button's facade
  66076. */
  66077. content: Control;
  66078. /**
  66079. * Apply the facade texture (created from the content property).
  66080. * This function can be overloaded by child classes
  66081. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66082. */
  66083. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66084. protected _getTypeName(): string;
  66085. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66086. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66087. /**
  66088. * Releases all associated resources
  66089. */
  66090. dispose(): void;
  66091. }
  66092. }
  66093. declare module BABYLON.GUI {
  66094. /**
  66095. * Abstract class used to create a container panel deployed on the surface of a volume
  66096. */
  66097. export abstract class VolumeBasedPanel extends Container3D {
  66098. private _columns;
  66099. private _rows;
  66100. private _rowThenColum;
  66101. private _orientation;
  66102. protected _cellWidth: number;
  66103. protected _cellHeight: number;
  66104. /**
  66105. * Gets or sets the distance between elements
  66106. */
  66107. margin: number;
  66108. /**
  66109. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66110. * | Value | Type | Description |
  66111. * | ----- | ----------------------------------- | ----------- |
  66112. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66113. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66114. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66115. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66116. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66117. */
  66118. orientation: number;
  66119. /**
  66120. * Gets or sets the number of columns requested (10 by default).
  66121. * The panel will automatically compute the number of rows based on number of child controls.
  66122. */
  66123. columns: BABYLON.int;
  66124. /**
  66125. * Gets or sets a the number of rows requested.
  66126. * The panel will automatically compute the number of columns based on number of child controls.
  66127. */
  66128. rows: BABYLON.int;
  66129. /**
  66130. * Creates new VolumeBasedPanel
  66131. */
  66132. constructor();
  66133. protected _arrangeChildren(): void;
  66134. /** Child classes must implement this function to provide correct control positioning */
  66135. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66136. /** Child classes can implement this function to provide additional processing */
  66137. protected _finalProcessing(): void;
  66138. }
  66139. }
  66140. declare module BABYLON.GUI {
  66141. /**
  66142. * Class used to create a container panel deployed on the surface of a cylinder
  66143. */
  66144. export class CylinderPanel extends VolumeBasedPanel {
  66145. private _radius;
  66146. /**
  66147. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66148. */
  66149. radius: BABYLON.float;
  66150. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66151. private _cylindricalMapping;
  66152. }
  66153. }
  66154. declare module BABYLON.GUI {
  66155. /** @hidden */
  66156. export var fluentVertexShader: {
  66157. name: string;
  66158. shader: string;
  66159. };
  66160. }
  66161. declare module BABYLON.GUI {
  66162. /** @hidden */
  66163. export var fluentPixelShader: {
  66164. name: string;
  66165. shader: string;
  66166. };
  66167. }
  66168. declare module BABYLON.GUI {
  66169. /** @hidden */
  66170. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66171. INNERGLOW: boolean;
  66172. BORDER: boolean;
  66173. HOVERLIGHT: boolean;
  66174. TEXTURE: boolean;
  66175. constructor();
  66176. }
  66177. /**
  66178. * Class used to render controls with fluent desgin
  66179. */
  66180. export class FluentMaterial extends BABYLON.PushMaterial {
  66181. /**
  66182. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66183. */
  66184. innerGlowColorIntensity: number;
  66185. /**
  66186. * Gets or sets the inner glow color (white by default)
  66187. */
  66188. innerGlowColor: BABYLON.Color3;
  66189. /**
  66190. * Gets or sets alpha value (default is 1.0)
  66191. */
  66192. alpha: number;
  66193. /**
  66194. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66195. */
  66196. albedoColor: BABYLON.Color3;
  66197. /**
  66198. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66199. */
  66200. renderBorders: boolean;
  66201. /**
  66202. * Gets or sets border width (default is 0.5)
  66203. */
  66204. borderWidth: number;
  66205. /**
  66206. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66207. */
  66208. edgeSmoothingValue: number;
  66209. /**
  66210. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66211. */
  66212. borderMinValue: number;
  66213. /**
  66214. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66215. */
  66216. renderHoverLight: boolean;
  66217. /**
  66218. * Gets or sets the radius used to render the hover light (default is 1.0)
  66219. */
  66220. hoverRadius: number;
  66221. /**
  66222. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66223. */
  66224. hoverColor: BABYLON.Color4;
  66225. /**
  66226. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66227. */
  66228. hoverPosition: BABYLON.Vector3;
  66229. private _albedoTexture;
  66230. /** Gets or sets the texture to use for albedo color */
  66231. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66232. /**
  66233. * Creates a new Fluent material
  66234. * @param name defines the name of the material
  66235. * @param scene defines the hosting scene
  66236. */
  66237. constructor(name: string, scene: BABYLON.Scene);
  66238. needAlphaBlending(): boolean;
  66239. needAlphaTesting(): boolean;
  66240. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66241. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66242. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66243. getActiveTextures(): BABYLON.BaseTexture[];
  66244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66245. dispose(forceDisposeEffect?: boolean): void;
  66246. clone(name: string): FluentMaterial;
  66247. serialize(): any;
  66248. getClassName(): string;
  66249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66250. }
  66251. }
  66252. declare module BABYLON.GUI {
  66253. /**
  66254. * Class used to create a holographic button in 3D
  66255. */
  66256. export class HolographicButton extends Button3D {
  66257. private _backPlate;
  66258. private _textPlate;
  66259. private _frontPlate;
  66260. private _text;
  66261. private _imageUrl;
  66262. private _shareMaterials;
  66263. private _frontMaterial;
  66264. private _backMaterial;
  66265. private _plateMaterial;
  66266. private _pickedPointObserver;
  66267. private _tooltipFade;
  66268. private _tooltipTextBlock;
  66269. private _tooltipTexture;
  66270. private _tooltipMesh;
  66271. private _tooltipHoverObserver;
  66272. private _tooltipOutObserver;
  66273. private _disposeTooltip;
  66274. /**
  66275. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66276. */
  66277. tooltipText: BABYLON.Nullable<string>;
  66278. /**
  66279. * Gets or sets text for the button
  66280. */
  66281. text: string;
  66282. /**
  66283. * Gets or sets the image url for the button
  66284. */
  66285. imageUrl: string;
  66286. /**
  66287. * Gets the back material used by this button
  66288. */
  66289. readonly backMaterial: FluentMaterial;
  66290. /**
  66291. * Gets the front material used by this button
  66292. */
  66293. readonly frontMaterial: FluentMaterial;
  66294. /**
  66295. * Gets the plate material used by this button
  66296. */
  66297. readonly plateMaterial: BABYLON.StandardMaterial;
  66298. /**
  66299. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66300. */
  66301. readonly shareMaterials: boolean;
  66302. /**
  66303. * Creates a new button
  66304. * @param name defines the control name
  66305. */
  66306. constructor(name?: string, shareMaterials?: boolean);
  66307. protected _getTypeName(): string;
  66308. private _rebuildContent;
  66309. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66310. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66311. private _createBackMaterial;
  66312. private _createFrontMaterial;
  66313. private _createPlateMaterial;
  66314. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66315. /**
  66316. * Releases all associated resources
  66317. */
  66318. dispose(): void;
  66319. }
  66320. }
  66321. declare module BABYLON.GUI {
  66322. /**
  66323. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66324. */
  66325. export class MeshButton3D extends Button3D {
  66326. /** @hidden */
  66327. protected _currentMesh: BABYLON.Mesh;
  66328. /**
  66329. * Creates a new 3D button based on a mesh
  66330. * @param mesh mesh to become a 3D button
  66331. * @param name defines the control name
  66332. */
  66333. constructor(mesh: BABYLON.Mesh, name?: string);
  66334. protected _getTypeName(): string;
  66335. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66336. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66337. }
  66338. }
  66339. declare module BABYLON.GUI {
  66340. /**
  66341. * Class used to create a container panel deployed on the surface of a plane
  66342. */
  66343. export class PlanePanel extends VolumeBasedPanel {
  66344. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66345. }
  66346. }
  66347. declare module BABYLON.GUI {
  66348. /**
  66349. * Class used to create a container panel where items get randomized planar mapping
  66350. */
  66351. export class ScatterPanel extends VolumeBasedPanel {
  66352. private _iteration;
  66353. /**
  66354. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66355. */
  66356. iteration: BABYLON.float;
  66357. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66358. private _scatterMapping;
  66359. protected _finalProcessing(): void;
  66360. }
  66361. }
  66362. declare module BABYLON.GUI {
  66363. /**
  66364. * Class used to create a container panel deployed on the surface of a sphere
  66365. */
  66366. export class SpherePanel extends VolumeBasedPanel {
  66367. private _radius;
  66368. /**
  66369. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66370. */
  66371. radius: BABYLON.float;
  66372. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66373. private _sphericalMapping;
  66374. }
  66375. }
  66376. declare module BABYLON.GUI {
  66377. /**
  66378. * Class used to create a stack panel in 3D on XY plane
  66379. */
  66380. export class StackPanel3D extends Container3D {
  66381. private _isVertical;
  66382. /**
  66383. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66384. */
  66385. isVertical: boolean;
  66386. /**
  66387. * Gets or sets the distance between elements
  66388. */
  66389. margin: number;
  66390. /**
  66391. * Creates new StackPanel
  66392. * @param isVertical
  66393. */
  66394. constructor(isVertical?: boolean);
  66395. protected _arrangeChildren(): void;
  66396. }
  66397. }
  66398. declare module BABYLON {
  66399. /**
  66400. * Mode that determines the coordinate system to use.
  66401. */
  66402. export enum GLTFLoaderCoordinateSystemMode {
  66403. /**
  66404. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66405. */
  66406. AUTO = 0,
  66407. /**
  66408. * Sets the useRightHandedSystem flag on the scene.
  66409. */
  66410. FORCE_RIGHT_HANDED = 1
  66411. }
  66412. /**
  66413. * Mode that determines what animations will start.
  66414. */
  66415. export enum GLTFLoaderAnimationStartMode {
  66416. /**
  66417. * No animation will start.
  66418. */
  66419. NONE = 0,
  66420. /**
  66421. * The first animation will start.
  66422. */
  66423. FIRST = 1,
  66424. /**
  66425. * All animations will start.
  66426. */
  66427. ALL = 2
  66428. }
  66429. /**
  66430. * Interface that contains the data for the glTF asset.
  66431. */
  66432. export interface IGLTFLoaderData {
  66433. /**
  66434. * Object that represents the glTF JSON.
  66435. */
  66436. json: Object;
  66437. /**
  66438. * The BIN chunk of a binary glTF.
  66439. */
  66440. bin: Nullable<ArrayBufferView>;
  66441. }
  66442. /**
  66443. * Interface for extending the loader.
  66444. */
  66445. export interface IGLTFLoaderExtension {
  66446. /**
  66447. * The name of this extension.
  66448. */
  66449. readonly name: string;
  66450. /**
  66451. * Defines whether this extension is enabled.
  66452. */
  66453. enabled: boolean;
  66454. }
  66455. /**
  66456. * Loader state.
  66457. */
  66458. export enum GLTFLoaderState {
  66459. /**
  66460. * The asset is loading.
  66461. */
  66462. LOADING = 0,
  66463. /**
  66464. * The asset is ready for rendering.
  66465. */
  66466. READY = 1,
  66467. /**
  66468. * The asset is completely loaded.
  66469. */
  66470. COMPLETE = 2
  66471. }
  66472. /** @hidden */
  66473. export interface IGLTFLoader extends IDisposable {
  66474. readonly state: Nullable<GLTFLoaderState>;
  66475. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66476. meshes: AbstractMesh[];
  66477. particleSystems: IParticleSystem[];
  66478. skeletons: Skeleton[];
  66479. animationGroups: AnimationGroup[];
  66480. }>;
  66481. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66482. }
  66483. /**
  66484. * File loader for loading glTF files into a scene.
  66485. */
  66486. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66487. /** @hidden */
  66488. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66489. /** @hidden */
  66490. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66491. /**
  66492. * Raised when the asset has been parsed
  66493. */
  66494. onParsedObservable: Observable<IGLTFLoaderData>;
  66495. private _onParsedObserver;
  66496. /**
  66497. * Raised when the asset has been parsed
  66498. */
  66499. onParsed: (loaderData: IGLTFLoaderData) => void;
  66500. /**
  66501. * 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.
  66502. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66503. * Defaults to true.
  66504. * @hidden
  66505. */
  66506. static IncrementalLoading: boolean;
  66507. /**
  66508. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66509. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66510. * @hidden
  66511. */
  66512. static HomogeneousCoordinates: boolean;
  66513. /**
  66514. * The coordinate system mode. Defaults to AUTO.
  66515. */
  66516. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66517. /**
  66518. * The animation start mode. Defaults to FIRST.
  66519. */
  66520. animationStartMode: GLTFLoaderAnimationStartMode;
  66521. /**
  66522. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66523. */
  66524. compileMaterials: boolean;
  66525. /**
  66526. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66527. */
  66528. useClipPlane: boolean;
  66529. /**
  66530. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66531. */
  66532. compileShadowGenerators: boolean;
  66533. /**
  66534. * Defines if the Alpha blended materials are only applied as coverage.
  66535. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66536. * If true, no extra effects are applied to transparent pixels.
  66537. */
  66538. transparencyAsCoverage: boolean;
  66539. /**
  66540. * Function called before loading a url referenced by the asset.
  66541. */
  66542. preprocessUrlAsync: (url: string) => Promise<string>;
  66543. /**
  66544. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66545. */
  66546. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66547. private _onMeshLoadedObserver;
  66548. /**
  66549. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66550. */
  66551. onMeshLoaded: (mesh: AbstractMesh) => void;
  66552. /**
  66553. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66554. */
  66555. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66556. private _onTextureLoadedObserver;
  66557. /**
  66558. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66559. */
  66560. onTextureLoaded: (texture: BaseTexture) => void;
  66561. /**
  66562. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66563. */
  66564. readonly onMaterialLoadedObservable: Observable<Material>;
  66565. private _onMaterialLoadedObserver;
  66566. /**
  66567. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66568. */
  66569. onMaterialLoaded: (material: Material) => void;
  66570. /**
  66571. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66572. */
  66573. readonly onCameraLoadedObservable: Observable<Camera>;
  66574. private _onCameraLoadedObserver;
  66575. /**
  66576. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66577. */
  66578. onCameraLoaded: (camera: Camera) => void;
  66579. /**
  66580. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66581. * For assets with LODs, raised when all of the LODs are complete.
  66582. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66583. */
  66584. readonly onCompleteObservable: Observable<void>;
  66585. private _onCompleteObserver;
  66586. /**
  66587. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66588. * For assets with LODs, raised when all of the LODs are complete.
  66589. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66590. */
  66591. onComplete: () => void;
  66592. /**
  66593. * Observable raised when an error occurs.
  66594. */
  66595. readonly onErrorObservable: Observable<any>;
  66596. private _onErrorObserver;
  66597. /**
  66598. * Callback raised when an error occurs.
  66599. */
  66600. onError: (reason: any) => void;
  66601. /**
  66602. * Observable raised after the loader is disposed.
  66603. */
  66604. readonly onDisposeObservable: Observable<void>;
  66605. private _onDisposeObserver;
  66606. /**
  66607. * Callback raised after the loader is disposed.
  66608. */
  66609. onDispose: () => void;
  66610. /**
  66611. * Observable raised after a loader extension is created.
  66612. * Set additional options for a loader extension in this event.
  66613. */
  66614. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66615. private _onExtensionLoadedObserver;
  66616. /**
  66617. * Callback raised after a loader extension is created.
  66618. */
  66619. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66620. /**
  66621. * Defines if the loader logging is enabled.
  66622. */
  66623. loggingEnabled: boolean;
  66624. /**
  66625. * Defines if the loader should capture performance counters.
  66626. */
  66627. capturePerformanceCounters: boolean;
  66628. /**
  66629. * Defines if the loader should validate the asset.
  66630. */
  66631. validate: boolean;
  66632. /**
  66633. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66634. */
  66635. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66636. private _onValidatedObserver;
  66637. /**
  66638. * Callback raised after a loader extension is created.
  66639. */
  66640. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66641. private _loader;
  66642. /**
  66643. * Name of the loader ("gltf")
  66644. */
  66645. name: string;
  66646. /**
  66647. * Supported file extensions of the loader (.gltf, .glb)
  66648. */
  66649. extensions: ISceneLoaderPluginExtensions;
  66650. /**
  66651. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66652. */
  66653. dispose(): void;
  66654. /** @hidden */
  66655. _clear(): void;
  66656. /**
  66657. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66658. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66659. * @param scene the scene the meshes should be added to
  66660. * @param data the glTF data to load
  66661. * @param rootUrl root url to load from
  66662. * @param onProgress event that fires when loading progress has occured
  66663. * @param fileName Defines the name of the file to load
  66664. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66665. */
  66666. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66667. meshes: AbstractMesh[];
  66668. particleSystems: IParticleSystem[];
  66669. skeletons: Skeleton[];
  66670. animationGroups: AnimationGroup[];
  66671. }>;
  66672. /**
  66673. * Imports all objects from the loaded glTF data and adds them to the scene
  66674. * @param scene the scene the objects should be added to
  66675. * @param data the glTF data to load
  66676. * @param rootUrl root url to load from
  66677. * @param onProgress event that fires when loading progress has occured
  66678. * @param fileName Defines the name of the file to load
  66679. * @returns a promise which completes when objects have been loaded to the scene
  66680. */
  66681. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66682. /**
  66683. * Load into an asset container.
  66684. * @param scene The scene to load into
  66685. * @param data The data to import
  66686. * @param rootUrl The root url for scene and resources
  66687. * @param onProgress The callback when the load progresses
  66688. * @param fileName Defines the name of the file to load
  66689. * @returns The loaded asset container
  66690. */
  66691. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66692. /**
  66693. * If the data string can be loaded directly.
  66694. * @param data string contianing the file data
  66695. * @returns if the data can be loaded directly
  66696. */
  66697. canDirectLoad(data: string): boolean;
  66698. /**
  66699. * Rewrites a url by combining a root url and response url.
  66700. */
  66701. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66702. /**
  66703. * Instantiates a glTF file loader plugin.
  66704. * @returns the created plugin
  66705. */
  66706. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66707. /**
  66708. * The loader state or null if the loader is not active.
  66709. */
  66710. readonly loaderState: Nullable<GLTFLoaderState>;
  66711. /**
  66712. * Returns a promise that resolves when the asset is completely loaded.
  66713. * @returns a promise that resolves when the asset is completely loaded.
  66714. */
  66715. whenCompleteAsync(): Promise<void>;
  66716. private _parseAsync;
  66717. private _validateAsync;
  66718. private _getLoader;
  66719. private _unpackBinary;
  66720. private _unpackBinaryV1;
  66721. private _unpackBinaryV2;
  66722. private static _parseVersion;
  66723. private static _compareVersion;
  66724. private static _decodeBufferToText;
  66725. private static readonly _logSpaces;
  66726. private _logIndentLevel;
  66727. private _loggingEnabled;
  66728. /** @hidden */
  66729. _log: (message: string) => void;
  66730. /** @hidden */
  66731. _logOpen(message: string): void;
  66732. /** @hidden */
  66733. _logClose(): void;
  66734. private _logEnabled;
  66735. private _logDisabled;
  66736. private _capturePerformanceCounters;
  66737. /** @hidden */
  66738. _startPerformanceCounter: (counterName: string) => void;
  66739. /** @hidden */
  66740. _endPerformanceCounter: (counterName: string) => void;
  66741. private _startPerformanceCounterEnabled;
  66742. private _startPerformanceCounterDisabled;
  66743. private _endPerformanceCounterEnabled;
  66744. private _endPerformanceCounterDisabled;
  66745. }
  66746. }
  66747. declare module BABYLON.GLTF1 {
  66748. /**
  66749. * Enums
  66750. * @hidden
  66751. */
  66752. export enum EComponentType {
  66753. BYTE = 5120,
  66754. UNSIGNED_BYTE = 5121,
  66755. SHORT = 5122,
  66756. UNSIGNED_SHORT = 5123,
  66757. FLOAT = 5126
  66758. }
  66759. /** @hidden */
  66760. export enum EShaderType {
  66761. FRAGMENT = 35632,
  66762. VERTEX = 35633
  66763. }
  66764. /** @hidden */
  66765. export enum EParameterType {
  66766. BYTE = 5120,
  66767. UNSIGNED_BYTE = 5121,
  66768. SHORT = 5122,
  66769. UNSIGNED_SHORT = 5123,
  66770. INT = 5124,
  66771. UNSIGNED_INT = 5125,
  66772. FLOAT = 5126,
  66773. FLOAT_VEC2 = 35664,
  66774. FLOAT_VEC3 = 35665,
  66775. FLOAT_VEC4 = 35666,
  66776. INT_VEC2 = 35667,
  66777. INT_VEC3 = 35668,
  66778. INT_VEC4 = 35669,
  66779. BOOL = 35670,
  66780. BOOL_VEC2 = 35671,
  66781. BOOL_VEC3 = 35672,
  66782. BOOL_VEC4 = 35673,
  66783. FLOAT_MAT2 = 35674,
  66784. FLOAT_MAT3 = 35675,
  66785. FLOAT_MAT4 = 35676,
  66786. SAMPLER_2D = 35678
  66787. }
  66788. /** @hidden */
  66789. export enum ETextureWrapMode {
  66790. CLAMP_TO_EDGE = 33071,
  66791. MIRRORED_REPEAT = 33648,
  66792. REPEAT = 10497
  66793. }
  66794. /** @hidden */
  66795. export enum ETextureFilterType {
  66796. NEAREST = 9728,
  66797. LINEAR = 9728,
  66798. NEAREST_MIPMAP_NEAREST = 9984,
  66799. LINEAR_MIPMAP_NEAREST = 9985,
  66800. NEAREST_MIPMAP_LINEAR = 9986,
  66801. LINEAR_MIPMAP_LINEAR = 9987
  66802. }
  66803. /** @hidden */
  66804. export enum ETextureFormat {
  66805. ALPHA = 6406,
  66806. RGB = 6407,
  66807. RGBA = 6408,
  66808. LUMINANCE = 6409,
  66809. LUMINANCE_ALPHA = 6410
  66810. }
  66811. /** @hidden */
  66812. export enum ECullingType {
  66813. FRONT = 1028,
  66814. BACK = 1029,
  66815. FRONT_AND_BACK = 1032
  66816. }
  66817. /** @hidden */
  66818. export enum EBlendingFunction {
  66819. ZERO = 0,
  66820. ONE = 1,
  66821. SRC_COLOR = 768,
  66822. ONE_MINUS_SRC_COLOR = 769,
  66823. DST_COLOR = 774,
  66824. ONE_MINUS_DST_COLOR = 775,
  66825. SRC_ALPHA = 770,
  66826. ONE_MINUS_SRC_ALPHA = 771,
  66827. DST_ALPHA = 772,
  66828. ONE_MINUS_DST_ALPHA = 773,
  66829. CONSTANT_COLOR = 32769,
  66830. ONE_MINUS_CONSTANT_COLOR = 32770,
  66831. CONSTANT_ALPHA = 32771,
  66832. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66833. SRC_ALPHA_SATURATE = 776
  66834. }
  66835. /** @hidden */
  66836. export interface IGLTFProperty {
  66837. extensions?: {
  66838. [key: string]: any;
  66839. };
  66840. extras?: Object;
  66841. }
  66842. /** @hidden */
  66843. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66844. name?: string;
  66845. }
  66846. /** @hidden */
  66847. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66848. bufferView: string;
  66849. byteOffset: number;
  66850. byteStride: number;
  66851. count: number;
  66852. type: string;
  66853. componentType: EComponentType;
  66854. max?: number[];
  66855. min?: number[];
  66856. name?: string;
  66857. }
  66858. /** @hidden */
  66859. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66860. buffer: string;
  66861. byteOffset: number;
  66862. byteLength: number;
  66863. byteStride: number;
  66864. target?: number;
  66865. }
  66866. /** @hidden */
  66867. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66868. uri: string;
  66869. byteLength?: number;
  66870. type?: string;
  66871. }
  66872. /** @hidden */
  66873. export interface IGLTFShader extends IGLTFChildRootProperty {
  66874. uri: string;
  66875. type: EShaderType;
  66876. }
  66877. /** @hidden */
  66878. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66879. attributes: string[];
  66880. fragmentShader: string;
  66881. vertexShader: string;
  66882. }
  66883. /** @hidden */
  66884. export interface IGLTFTechniqueParameter {
  66885. type: number;
  66886. count?: number;
  66887. semantic?: string;
  66888. node?: string;
  66889. value?: number | boolean | string | Array<any>;
  66890. source?: string;
  66891. babylonValue?: any;
  66892. }
  66893. /** @hidden */
  66894. export interface IGLTFTechniqueCommonProfile {
  66895. lightingModel: string;
  66896. texcoordBindings: Object;
  66897. parameters?: Array<any>;
  66898. }
  66899. /** @hidden */
  66900. export interface IGLTFTechniqueStatesFunctions {
  66901. blendColor?: number[];
  66902. blendEquationSeparate?: number[];
  66903. blendFuncSeparate?: number[];
  66904. colorMask: boolean[];
  66905. cullFace: number[];
  66906. }
  66907. /** @hidden */
  66908. export interface IGLTFTechniqueStates {
  66909. enable: number[];
  66910. functions: IGLTFTechniqueStatesFunctions;
  66911. }
  66912. /** @hidden */
  66913. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66914. parameters: {
  66915. [key: string]: IGLTFTechniqueParameter;
  66916. };
  66917. program: string;
  66918. attributes: {
  66919. [key: string]: string;
  66920. };
  66921. uniforms: {
  66922. [key: string]: string;
  66923. };
  66924. states: IGLTFTechniqueStates;
  66925. }
  66926. /** @hidden */
  66927. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66928. technique?: string;
  66929. values: string[];
  66930. }
  66931. /** @hidden */
  66932. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66933. attributes: {
  66934. [key: string]: string;
  66935. };
  66936. indices: string;
  66937. material: string;
  66938. mode?: number;
  66939. }
  66940. /** @hidden */
  66941. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66942. primitives: IGLTFMeshPrimitive[];
  66943. }
  66944. /** @hidden */
  66945. export interface IGLTFImage extends IGLTFChildRootProperty {
  66946. uri: string;
  66947. }
  66948. /** @hidden */
  66949. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66950. magFilter?: number;
  66951. minFilter?: number;
  66952. wrapS?: number;
  66953. wrapT?: number;
  66954. }
  66955. /** @hidden */
  66956. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66957. sampler: string;
  66958. source: string;
  66959. format?: ETextureFormat;
  66960. internalFormat?: ETextureFormat;
  66961. target?: number;
  66962. type?: number;
  66963. babylonTexture?: Texture;
  66964. }
  66965. /** @hidden */
  66966. export interface IGLTFAmbienLight {
  66967. color?: number[];
  66968. }
  66969. /** @hidden */
  66970. export interface IGLTFDirectionalLight {
  66971. color?: number[];
  66972. }
  66973. /** @hidden */
  66974. export interface IGLTFPointLight {
  66975. color?: number[];
  66976. constantAttenuation?: number;
  66977. linearAttenuation?: number;
  66978. quadraticAttenuation?: number;
  66979. }
  66980. /** @hidden */
  66981. export interface IGLTFSpotLight {
  66982. color?: number[];
  66983. constantAttenuation?: number;
  66984. fallOfAngle?: number;
  66985. fallOffExponent?: number;
  66986. linearAttenuation?: number;
  66987. quadraticAttenuation?: number;
  66988. }
  66989. /** @hidden */
  66990. export interface IGLTFLight extends IGLTFChildRootProperty {
  66991. type: string;
  66992. }
  66993. /** @hidden */
  66994. export interface IGLTFCameraOrthographic {
  66995. xmag: number;
  66996. ymag: number;
  66997. zfar: number;
  66998. znear: number;
  66999. }
  67000. /** @hidden */
  67001. export interface IGLTFCameraPerspective {
  67002. aspectRatio: number;
  67003. yfov: number;
  67004. zfar: number;
  67005. znear: number;
  67006. }
  67007. /** @hidden */
  67008. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67009. type: string;
  67010. }
  67011. /** @hidden */
  67012. export interface IGLTFAnimationChannelTarget {
  67013. id: string;
  67014. path: string;
  67015. }
  67016. /** @hidden */
  67017. export interface IGLTFAnimationChannel {
  67018. sampler: string;
  67019. target: IGLTFAnimationChannelTarget;
  67020. }
  67021. /** @hidden */
  67022. export interface IGLTFAnimationSampler {
  67023. input: string;
  67024. output: string;
  67025. interpolation?: string;
  67026. }
  67027. /** @hidden */
  67028. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67029. channels?: IGLTFAnimationChannel[];
  67030. parameters?: {
  67031. [key: string]: string;
  67032. };
  67033. samplers?: {
  67034. [key: string]: IGLTFAnimationSampler;
  67035. };
  67036. }
  67037. /** @hidden */
  67038. export interface IGLTFNodeInstanceSkin {
  67039. skeletons: string[];
  67040. skin: string;
  67041. meshes: string[];
  67042. }
  67043. /** @hidden */
  67044. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67045. bindShapeMatrix: number[];
  67046. inverseBindMatrices: string;
  67047. jointNames: string[];
  67048. babylonSkeleton?: Skeleton;
  67049. }
  67050. /** @hidden */
  67051. export interface IGLTFNode extends IGLTFChildRootProperty {
  67052. camera?: string;
  67053. children: string[];
  67054. skin?: string;
  67055. jointName?: string;
  67056. light?: string;
  67057. matrix: number[];
  67058. mesh?: string;
  67059. meshes?: string[];
  67060. rotation?: number[];
  67061. scale?: number[];
  67062. translation?: number[];
  67063. babylonNode?: Node;
  67064. }
  67065. /** @hidden */
  67066. export interface IGLTFScene extends IGLTFChildRootProperty {
  67067. nodes: string[];
  67068. }
  67069. /** @hidden */
  67070. export interface IGLTFRuntime {
  67071. extensions: {
  67072. [key: string]: any;
  67073. };
  67074. accessors: {
  67075. [key: string]: IGLTFAccessor;
  67076. };
  67077. buffers: {
  67078. [key: string]: IGLTFBuffer;
  67079. };
  67080. bufferViews: {
  67081. [key: string]: IGLTFBufferView;
  67082. };
  67083. meshes: {
  67084. [key: string]: IGLTFMesh;
  67085. };
  67086. lights: {
  67087. [key: string]: IGLTFLight;
  67088. };
  67089. cameras: {
  67090. [key: string]: IGLTFCamera;
  67091. };
  67092. nodes: {
  67093. [key: string]: IGLTFNode;
  67094. };
  67095. images: {
  67096. [key: string]: IGLTFImage;
  67097. };
  67098. textures: {
  67099. [key: string]: IGLTFTexture;
  67100. };
  67101. shaders: {
  67102. [key: string]: IGLTFShader;
  67103. };
  67104. programs: {
  67105. [key: string]: IGLTFProgram;
  67106. };
  67107. samplers: {
  67108. [key: string]: IGLTFSampler;
  67109. };
  67110. techniques: {
  67111. [key: string]: IGLTFTechnique;
  67112. };
  67113. materials: {
  67114. [key: string]: IGLTFMaterial;
  67115. };
  67116. animations: {
  67117. [key: string]: IGLTFAnimation;
  67118. };
  67119. skins: {
  67120. [key: string]: IGLTFSkins;
  67121. };
  67122. currentScene?: Object;
  67123. scenes: {
  67124. [key: string]: IGLTFScene;
  67125. };
  67126. extensionsUsed: string[];
  67127. extensionsRequired?: string[];
  67128. buffersCount: number;
  67129. shaderscount: number;
  67130. scene: Scene;
  67131. rootUrl: string;
  67132. loadedBufferCount: number;
  67133. loadedBufferViews: {
  67134. [name: string]: ArrayBufferView;
  67135. };
  67136. loadedShaderCount: number;
  67137. importOnlyMeshes: boolean;
  67138. importMeshesNames?: string[];
  67139. dummyNodes: Node[];
  67140. }
  67141. /** @hidden */
  67142. export interface INodeToRoot {
  67143. bone: Bone;
  67144. node: IGLTFNode;
  67145. id: string;
  67146. }
  67147. /** @hidden */
  67148. export interface IJointNode {
  67149. node: IGLTFNode;
  67150. id: string;
  67151. }
  67152. }
  67153. declare module BABYLON.GLTF1 {
  67154. /**
  67155. * Utils functions for GLTF
  67156. * @hidden
  67157. */
  67158. export class GLTFUtils {
  67159. /**
  67160. * Sets the given "parameter" matrix
  67161. * @param scene: the Scene object
  67162. * @param source: the source node where to pick the matrix
  67163. * @param parameter: the GLTF technique parameter
  67164. * @param uniformName: the name of the shader's uniform
  67165. * @param shaderMaterial: the shader material
  67166. */
  67167. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67168. /**
  67169. * Sets the given "parameter" matrix
  67170. * @param shaderMaterial: the shader material
  67171. * @param uniform: the name of the shader's uniform
  67172. * @param value: the value of the uniform
  67173. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67174. */
  67175. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67176. /**
  67177. * Returns the wrap mode of the texture
  67178. * @param mode: the mode value
  67179. */
  67180. static GetWrapMode(mode: number): number;
  67181. /**
  67182. * Returns the byte stride giving an accessor
  67183. * @param accessor: the GLTF accessor objet
  67184. */
  67185. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67186. /**
  67187. * Returns the texture filter mode giving a mode value
  67188. * @param mode: the filter mode value
  67189. */
  67190. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67191. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67192. /**
  67193. * Returns a buffer from its accessor
  67194. * @param gltfRuntime: the GLTF runtime
  67195. * @param accessor: the GLTF accessor
  67196. */
  67197. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67198. /**
  67199. * Decodes a buffer view into a string
  67200. * @param view: the buffer view
  67201. */
  67202. static DecodeBufferToText(view: ArrayBufferView): string;
  67203. /**
  67204. * Returns the default material of gltf. Related to
  67205. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67206. * @param scene: the Babylon.js scene
  67207. */
  67208. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67209. private static _DefaultMaterial;
  67210. }
  67211. }
  67212. declare module BABYLON.GLTF1 {
  67213. /**
  67214. * Implementation of the base glTF spec
  67215. * @hidden
  67216. */
  67217. export class GLTFLoaderBase {
  67218. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67219. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67220. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67221. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67222. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67223. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67224. }
  67225. /**
  67226. * glTF V1 Loader
  67227. * @hidden
  67228. */
  67229. export class GLTFLoader implements IGLTFLoader {
  67230. static Extensions: {
  67231. [name: string]: GLTFLoaderExtension;
  67232. };
  67233. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67234. state: Nullable<GLTFLoaderState>;
  67235. dispose(): void;
  67236. private _importMeshAsync;
  67237. /**
  67238. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67239. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67240. * @param scene the scene the meshes should be added to
  67241. * @param data gltf data containing information of the meshes in a loaded file
  67242. * @param rootUrl root url to load from
  67243. * @param onProgress event that fires when loading progress has occured
  67244. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67245. */
  67246. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67247. meshes: AbstractMesh[];
  67248. particleSystems: IParticleSystem[];
  67249. skeletons: Skeleton[];
  67250. animationGroups: AnimationGroup[];
  67251. }>;
  67252. private _loadAsync;
  67253. /**
  67254. * Imports all objects from a loaded gltf file and adds them to the scene
  67255. * @param scene the scene the objects should be added to
  67256. * @param data gltf data containing information of the meshes in a loaded file
  67257. * @param rootUrl root url to load from
  67258. * @param onProgress event that fires when loading progress has occured
  67259. * @returns a promise which completes when objects have been loaded to the scene
  67260. */
  67261. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67262. private _loadShadersAsync;
  67263. private _loadBuffersAsync;
  67264. private _createNodes;
  67265. }
  67266. /** @hidden */
  67267. export abstract class GLTFLoaderExtension {
  67268. private _name;
  67269. constructor(name: string);
  67270. readonly name: string;
  67271. /**
  67272. * Defines an override for loading the runtime
  67273. * Return true to stop further extensions from loading the runtime
  67274. */
  67275. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67276. /**
  67277. * Defines an onverride for creating gltf runtime
  67278. * Return true to stop further extensions from creating the runtime
  67279. */
  67280. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67281. /**
  67282. * Defines an override for loading buffers
  67283. * Return true to stop further extensions from loading this buffer
  67284. */
  67285. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67286. /**
  67287. * Defines an override for loading texture buffers
  67288. * Return true to stop further extensions from loading this texture data
  67289. */
  67290. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67291. /**
  67292. * Defines an override for creating textures
  67293. * Return true to stop further extensions from loading this texture
  67294. */
  67295. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67296. /**
  67297. * Defines an override for loading shader strings
  67298. * Return true to stop further extensions from loading this shader data
  67299. */
  67300. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67301. /**
  67302. * Defines an override for loading materials
  67303. * Return true to stop further extensions from loading this material
  67304. */
  67305. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67306. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67307. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67308. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67309. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67310. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67311. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67312. private static LoadTextureBufferAsync;
  67313. private static CreateTextureAsync;
  67314. private static ApplyExtensions;
  67315. }
  67316. }
  67317. declare module BABYLON.GLTF1 {
  67318. /** @hidden */
  67319. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67320. private _bin;
  67321. constructor();
  67322. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67323. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67324. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67325. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67326. }
  67327. }
  67328. declare module BABYLON.GLTF1 {
  67329. /** @hidden */
  67330. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67331. constructor();
  67332. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67333. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67334. private _loadTexture;
  67335. }
  67336. }
  67337. declare module BABYLON.GLTF2.Loader {
  67338. /**
  67339. * Loader interface with an index field.
  67340. */
  67341. export interface IArrayItem {
  67342. /**
  67343. * The index of this item in the array.
  67344. */
  67345. index: number;
  67346. }
  67347. /**
  67348. * Loader interface with additional members.
  67349. */
  67350. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67351. /** @hidden */
  67352. _data?: Promise<ArrayBufferView>;
  67353. /** @hidden */
  67354. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67355. }
  67356. /**
  67357. * Loader interface with additional members.
  67358. */
  67359. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67360. }
  67361. /** @hidden */
  67362. export interface _IAnimationSamplerData {
  67363. input: Float32Array;
  67364. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67365. output: Float32Array;
  67366. }
  67367. /**
  67368. * Loader interface with additional members.
  67369. */
  67370. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67371. /** @hidden */
  67372. _data?: Promise<_IAnimationSamplerData>;
  67373. }
  67374. /**
  67375. * Loader interface with additional members.
  67376. */
  67377. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67378. channels: IAnimationChannel[];
  67379. samplers: IAnimationSampler[];
  67380. /** @hidden */
  67381. _babylonAnimationGroup?: AnimationGroup;
  67382. }
  67383. /**
  67384. * Loader interface with additional members.
  67385. */
  67386. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67387. /** @hidden */
  67388. _data?: Promise<ArrayBufferView>;
  67389. }
  67390. /**
  67391. * Loader interface with additional members.
  67392. */
  67393. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67394. /** @hidden */
  67395. _data?: Promise<ArrayBufferView>;
  67396. /** @hidden */
  67397. _babylonBuffer?: Promise<Buffer>;
  67398. }
  67399. /**
  67400. * Loader interface with additional members.
  67401. */
  67402. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67403. }
  67404. /**
  67405. * Loader interface with additional members.
  67406. */
  67407. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67408. /** @hidden */
  67409. _data?: Promise<ArrayBufferView>;
  67410. }
  67411. /**
  67412. * Loader interface with additional members.
  67413. */
  67414. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67415. }
  67416. /**
  67417. * Loader interface with additional members.
  67418. */
  67419. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67420. }
  67421. /**
  67422. * Loader interface with additional members.
  67423. */
  67424. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67425. baseColorTexture?: ITextureInfo;
  67426. metallicRoughnessTexture?: ITextureInfo;
  67427. }
  67428. /**
  67429. * Loader interface with additional members.
  67430. */
  67431. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67432. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67433. normalTexture?: IMaterialNormalTextureInfo;
  67434. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67435. emissiveTexture?: ITextureInfo;
  67436. /** @hidden */
  67437. _data?: {
  67438. [babylonDrawMode: number]: {
  67439. babylonMaterial: Material;
  67440. babylonMeshes: AbstractMesh[];
  67441. promise: Promise<void>;
  67442. };
  67443. };
  67444. }
  67445. /**
  67446. * Loader interface with additional members.
  67447. */
  67448. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67449. primitives: IMeshPrimitive[];
  67450. }
  67451. /**
  67452. * Loader interface with additional members.
  67453. */
  67454. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67455. /** @hidden */
  67456. _instanceData?: {
  67457. babylonSourceMesh: Mesh;
  67458. promise: Promise<any>;
  67459. };
  67460. }
  67461. /**
  67462. * Loader interface with additional members.
  67463. */
  67464. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67465. /**
  67466. * The parent glTF node.
  67467. */
  67468. parent?: INode;
  67469. /** @hidden */
  67470. _babylonTransformNode?: TransformNode;
  67471. /** @hidden */
  67472. _primitiveBabylonMeshes?: AbstractMesh[];
  67473. /** @hidden */
  67474. _babylonBones?: Bone[];
  67475. /** @hidden */
  67476. _numMorphTargets?: number;
  67477. }
  67478. /** @hidden */
  67479. export interface _ISamplerData {
  67480. noMipMaps: boolean;
  67481. samplingMode: number;
  67482. wrapU: number;
  67483. wrapV: number;
  67484. }
  67485. /**
  67486. * Loader interface with additional members.
  67487. */
  67488. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67489. /** @hidden */
  67490. _data?: _ISamplerData;
  67491. }
  67492. /**
  67493. * Loader interface with additional members.
  67494. */
  67495. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67496. }
  67497. /**
  67498. * Loader interface with additional members.
  67499. */
  67500. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67501. /** @hidden */
  67502. _data?: {
  67503. babylonSkeleton: Skeleton;
  67504. promise: Promise<void>;
  67505. };
  67506. }
  67507. /**
  67508. * Loader interface with additional members.
  67509. */
  67510. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67511. }
  67512. /**
  67513. * Loader interface with additional members.
  67514. */
  67515. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67516. }
  67517. /**
  67518. * Loader interface with additional members.
  67519. */
  67520. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67521. accessors?: IAccessor[];
  67522. animations?: IAnimation[];
  67523. buffers?: IBuffer[];
  67524. bufferViews?: IBufferView[];
  67525. cameras?: ICamera[];
  67526. images?: IImage[];
  67527. materials?: IMaterial[];
  67528. meshes?: IMesh[];
  67529. nodes?: INode[];
  67530. samplers?: ISampler[];
  67531. scenes?: IScene[];
  67532. skins?: ISkin[];
  67533. textures?: ITexture[];
  67534. }
  67535. }
  67536. declare module BABYLON.GLTF2 {
  67537. /**
  67538. * Interface for a glTF loader extension.
  67539. */
  67540. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67541. /**
  67542. * Called after the loader state changes to LOADING.
  67543. */
  67544. onLoading?(): void;
  67545. /**
  67546. * Called after the loader state changes to READY.
  67547. */
  67548. onReady?(): void;
  67549. /**
  67550. * Define this method to modify the default behavior when loading scenes.
  67551. * @param context The context when loading the asset
  67552. * @param scene The glTF scene property
  67553. * @returns A promise that resolves when the load is complete or null if not handled
  67554. */
  67555. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67556. /**
  67557. * Define this method to modify the default behavior when loading nodes.
  67558. * @param context The context when loading the asset
  67559. * @param node The glTF node property
  67560. * @param assign A function called synchronously after parsing the glTF properties
  67561. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67562. */
  67563. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67564. /**
  67565. * Define this method to modify the default behavior when loading cameras.
  67566. * @param context The context when loading the asset
  67567. * @param camera The glTF camera property
  67568. * @param assign A function called synchronously after parsing the glTF properties
  67569. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67570. */
  67571. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67572. /**
  67573. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67574. * @param context The context when loading the asset
  67575. * @param primitive The glTF mesh primitive property
  67576. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67577. */
  67578. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67579. /**
  67580. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67581. * @param context The context when loading the asset
  67582. * @param name The mesh name when loading the asset
  67583. * @param node The glTF node when loading the asset
  67584. * @param mesh The glTF mesh when loading the asset
  67585. * @param primitive The glTF mesh primitive property
  67586. * @param assign A function called synchronously after parsing the glTF properties
  67587. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67588. */
  67589. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67590. /**
  67591. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67592. * @param context The context when loading the asset
  67593. * @param material The glTF material property
  67594. * @param assign A function called synchronously after parsing the glTF properties
  67595. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67596. */
  67597. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67598. /**
  67599. * Define this method to modify the default behavior when creating materials.
  67600. * @param context The context when loading the asset
  67601. * @param material The glTF material property
  67602. * @param babylonDrawMode The draw mode for the Babylon material
  67603. * @returns The Babylon material or null if not handled
  67604. */
  67605. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67606. /**
  67607. * Define this method to modify the default behavior when loading material properties.
  67608. * @param context The context when loading the asset
  67609. * @param material The glTF material property
  67610. * @param babylonMaterial The Babylon material
  67611. * @returns A promise that resolves when the load is complete or null if not handled
  67612. */
  67613. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67614. /**
  67615. * Define this method to modify the default behavior when loading texture infos.
  67616. * @param context The context when loading the asset
  67617. * @param textureInfo The glTF texture info property
  67618. * @param assign A function called synchronously after parsing the glTF properties
  67619. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67620. */
  67621. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67622. /**
  67623. * Define this method to modify the default behavior when loading animations.
  67624. * @param context The context when loading the asset
  67625. * @param animation The glTF animation property
  67626. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67627. */
  67628. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67629. /**
  67630. * @hidden Define this method to modify the default behavior when loading skins.
  67631. * @param context The context when loading the asset
  67632. * @param node The glTF node property
  67633. * @param skin The glTF skin property
  67634. * @returns A promise that resolves when the load is complete or null if not handled
  67635. */
  67636. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67637. /**
  67638. * @hidden Define this method to modify the default behavior when loading uris.
  67639. * @param context The context when loading the asset
  67640. * @param property The glTF property associated with the uri
  67641. * @param uri The uri to load
  67642. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67643. */
  67644. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67645. }
  67646. }
  67647. declare module BABYLON.GLTF2 {
  67648. /**
  67649. * Helper class for working with arrays when loading the glTF asset
  67650. */
  67651. export class ArrayItem {
  67652. /**
  67653. * Gets an item from the given array.
  67654. * @param context The context when loading the asset
  67655. * @param array The array to get the item from
  67656. * @param index The index to the array
  67657. * @returns The array item
  67658. */
  67659. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67660. /**
  67661. * Assign an `index` field to each item of the given array.
  67662. * @param array The array of items
  67663. */
  67664. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67665. }
  67666. /**
  67667. * The glTF 2.0 loader
  67668. */
  67669. export class GLTFLoader implements IGLTFLoader {
  67670. /** @hidden */
  67671. _completePromises: Promise<any>[];
  67672. private _disposed;
  67673. private _parent;
  67674. private _state;
  67675. private _extensions;
  67676. private _rootUrl;
  67677. private _fileName;
  67678. private _uniqueRootUrl;
  67679. private _gltf;
  67680. private _babylonScene;
  67681. private _rootBabylonMesh;
  67682. private _defaultBabylonMaterialData;
  67683. private _progressCallback?;
  67684. private _requests;
  67685. private static readonly _DefaultSampler;
  67686. private static _ExtensionNames;
  67687. private static _ExtensionFactories;
  67688. /**
  67689. * Registers a loader extension.
  67690. * @param name The name of the loader extension.
  67691. * @param factory The factory function that creates the loader extension.
  67692. */
  67693. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67694. /**
  67695. * Unregisters a loader extension.
  67696. * @param name The name of the loader extenion.
  67697. * @returns A boolean indicating whether the extension has been unregistered
  67698. */
  67699. static UnregisterExtension(name: string): boolean;
  67700. /**
  67701. * Gets the loader state.
  67702. */
  67703. readonly state: Nullable<GLTFLoaderState>;
  67704. /**
  67705. * The glTF object parsed from the JSON.
  67706. */
  67707. readonly gltf: IGLTF;
  67708. /**
  67709. * The Babylon scene when loading the asset.
  67710. */
  67711. readonly babylonScene: Scene;
  67712. /**
  67713. * The root Babylon mesh when loading the asset.
  67714. */
  67715. readonly rootBabylonMesh: Mesh;
  67716. /** @hidden */
  67717. constructor(parent: GLTFFileLoader);
  67718. /** @hidden */
  67719. dispose(): void;
  67720. /** @hidden */
  67721. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67722. meshes: AbstractMesh[];
  67723. particleSystems: IParticleSystem[];
  67724. skeletons: Skeleton[];
  67725. animationGroups: AnimationGroup[];
  67726. }>;
  67727. /** @hidden */
  67728. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67729. private _loadAsync;
  67730. private _loadData;
  67731. private _setupData;
  67732. private _loadExtensions;
  67733. private _checkExtensions;
  67734. private _setState;
  67735. private _createRootNode;
  67736. /**
  67737. * Loads a glTF scene.
  67738. * @param context The context when loading the asset
  67739. * @param scene The glTF scene property
  67740. * @returns A promise that resolves when the load is complete
  67741. */
  67742. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67743. private _forEachPrimitive;
  67744. private _getMeshes;
  67745. private _getSkeletons;
  67746. private _getAnimationGroups;
  67747. private _startAnimations;
  67748. /**
  67749. * Loads a glTF node.
  67750. * @param context The context when loading the asset
  67751. * @param node The glTF node property
  67752. * @param assign A function called synchronously after parsing the glTF properties
  67753. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67754. */
  67755. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67756. private _loadMeshAsync;
  67757. /**
  67758. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67759. * @param context The context when loading the asset
  67760. * @param name The mesh name when loading the asset
  67761. * @param node The glTF node when loading the asset
  67762. * @param mesh The glTF mesh when loading the asset
  67763. * @param primitive The glTF mesh primitive property
  67764. * @param assign A function called synchronously after parsing the glTF properties
  67765. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67766. */
  67767. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67768. private _loadVertexDataAsync;
  67769. private _createMorphTargets;
  67770. private _loadMorphTargetsAsync;
  67771. private _loadMorphTargetVertexDataAsync;
  67772. private static _LoadTransform;
  67773. private _loadSkinAsync;
  67774. private _loadBones;
  67775. private _loadBone;
  67776. private _loadSkinInverseBindMatricesDataAsync;
  67777. private _updateBoneMatrices;
  67778. private _getNodeMatrix;
  67779. /**
  67780. * Loads a glTF camera.
  67781. * @param context The context when loading the asset
  67782. * @param camera The glTF camera property
  67783. * @param assign A function called synchronously after parsing the glTF properties
  67784. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67785. */
  67786. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67787. private _loadAnimationsAsync;
  67788. /**
  67789. * Loads a glTF animation.
  67790. * @param context The context when loading the asset
  67791. * @param animation The glTF animation property
  67792. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67793. */
  67794. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67795. /**
  67796. * @hidden Loads a glTF animation channel.
  67797. * @param context The context when loading the asset
  67798. * @param animationContext The context of the animation when loading the asset
  67799. * @param animation The glTF animation property
  67800. * @param channel The glTF animation channel property
  67801. * @param babylonAnimationGroup The babylon animation group property
  67802. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67803. * @returns A void promise when the channel load is complete
  67804. */
  67805. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67806. private _loadAnimationSamplerAsync;
  67807. private _loadBufferAsync;
  67808. /**
  67809. * Loads a glTF buffer view.
  67810. * @param context The context when loading the asset
  67811. * @param bufferView The glTF buffer view property
  67812. * @returns A promise that resolves with the loaded data when the load is complete
  67813. */
  67814. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67815. private _loadAccessorAsync;
  67816. private _loadFloatAccessorAsync;
  67817. private _loadIndicesAccessorAsync;
  67818. private _loadVertexBufferViewAsync;
  67819. private _loadVertexAccessorAsync;
  67820. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67821. /** @hidden */
  67822. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67823. private _createDefaultMaterial;
  67824. /**
  67825. * Creates a Babylon material from a glTF material.
  67826. * @param context The context when loading the asset
  67827. * @param material The glTF material property
  67828. * @param babylonDrawMode The draw mode for the Babylon material
  67829. * @returns The Babylon material
  67830. */
  67831. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67832. /**
  67833. * Loads properties from a glTF material into a Babylon material.
  67834. * @param context The context when loading the asset
  67835. * @param material The glTF material property
  67836. * @param babylonMaterial The Babylon material
  67837. * @returns A promise that resolves when the load is complete
  67838. */
  67839. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67840. /**
  67841. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67842. * @param context The context when loading the asset
  67843. * @param material The glTF material property
  67844. * @param babylonMaterial The Babylon material
  67845. * @returns A promise that resolves when the load is complete
  67846. */
  67847. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67848. /**
  67849. * Loads the alpha properties from a glTF material into a Babylon material.
  67850. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67851. * @param context The context when loading the asset
  67852. * @param material The glTF material property
  67853. * @param babylonMaterial The Babylon material
  67854. */
  67855. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67856. /**
  67857. * Loads a glTF texture info.
  67858. * @param context The context when loading the asset
  67859. * @param textureInfo The glTF texture info property
  67860. * @param assign A function called synchronously after parsing the glTF properties
  67861. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67862. */
  67863. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67864. private _loadTextureAsync;
  67865. private _loadSampler;
  67866. /**
  67867. * Loads a glTF image.
  67868. * @param context The context when loading the asset
  67869. * @param image The glTF image property
  67870. * @returns A promise that resolves with the loaded data when the load is complete
  67871. */
  67872. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67873. /**
  67874. * Loads a glTF uri.
  67875. * @param context The context when loading the asset
  67876. * @param property The glTF property associated with the uri
  67877. * @param uri The base64 or relative uri
  67878. * @returns A promise that resolves with the loaded data when the load is complete
  67879. */
  67880. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67881. private _onProgress;
  67882. /**
  67883. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67884. * @param babylonObject the Babylon object with metadata
  67885. * @param pointer the JSON pointer
  67886. */
  67887. static AddPointerMetadata(babylonObject: {
  67888. metadata: any;
  67889. }, pointer: string): void;
  67890. private static _GetTextureWrapMode;
  67891. private static _GetTextureSamplingMode;
  67892. private static _GetTypedArrayConstructor;
  67893. private static _GetTypedArray;
  67894. private static _GetNumComponents;
  67895. private static _ValidateUri;
  67896. private static _GetDrawMode;
  67897. private _compileMaterialsAsync;
  67898. private _compileShadowGeneratorsAsync;
  67899. private _forEachExtensions;
  67900. private _applyExtensions;
  67901. private _extensionsOnLoading;
  67902. private _extensionsOnReady;
  67903. private _extensionsLoadSceneAsync;
  67904. private _extensionsLoadNodeAsync;
  67905. private _extensionsLoadCameraAsync;
  67906. private _extensionsLoadVertexDataAsync;
  67907. private _extensionsLoadMeshPrimitiveAsync;
  67908. private _extensionsLoadMaterialAsync;
  67909. private _extensionsCreateMaterial;
  67910. private _extensionsLoadMaterialPropertiesAsync;
  67911. private _extensionsLoadTextureInfoAsync;
  67912. private _extensionsLoadAnimationAsync;
  67913. private _extensionsLoadSkinAsync;
  67914. private _extensionsLoadUriAsync;
  67915. /**
  67916. * Helper method called by a loader extension to load an glTF extension.
  67917. * @param context The context when loading the asset
  67918. * @param property The glTF property to load the extension from
  67919. * @param extensionName The name of the extension to load
  67920. * @param actionAsync The action to run
  67921. * @returns The promise returned by actionAsync or null if the extension does not exist
  67922. */
  67923. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67924. /**
  67925. * Helper method called by a loader extension to load a glTF extra.
  67926. * @param context The context when loading the asset
  67927. * @param property The glTF property to load the extra from
  67928. * @param extensionName The name of the extension to load
  67929. * @param actionAsync The action to run
  67930. * @returns The promise returned by actionAsync or null if the extra does not exist
  67931. */
  67932. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67933. /**
  67934. * Increments the indentation level and logs a message.
  67935. * @param message The message to log
  67936. */
  67937. logOpen(message: string): void;
  67938. /**
  67939. * Decrements the indentation level.
  67940. */
  67941. logClose(): void;
  67942. /**
  67943. * Logs a message
  67944. * @param message The message to log
  67945. */
  67946. log(message: string): void;
  67947. /**
  67948. * Starts a performance counter.
  67949. * @param counterName The name of the performance counter
  67950. */
  67951. startPerformanceCounter(counterName: string): void;
  67952. /**
  67953. * Ends a performance counter.
  67954. * @param counterName The name of the performance counter
  67955. */
  67956. endPerformanceCounter(counterName: string): void;
  67957. }
  67958. }
  67959. declare module BABYLON.GLTF2.Loader.Extensions {
  67960. /**
  67961. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67962. */
  67963. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67964. /** The name of this extension. */
  67965. readonly name: string;
  67966. /** Defines whether this extension is enabled. */
  67967. enabled: boolean;
  67968. private _loader;
  67969. private _lights?;
  67970. /** @hidden */
  67971. constructor(loader: GLTFLoader);
  67972. /** @hidden */
  67973. dispose(): void;
  67974. /** @hidden */
  67975. onLoading(): void;
  67976. /** @hidden */
  67977. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67978. private _loadLightAsync;
  67979. }
  67980. }
  67981. declare module BABYLON.GLTF2.Loader.Extensions {
  67982. /**
  67983. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67984. */
  67985. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67986. /** The name of this extension. */
  67987. readonly name: string;
  67988. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67989. dracoCompression?: DracoCompression;
  67990. /** Defines whether this extension is enabled. */
  67991. enabled: boolean;
  67992. private _loader;
  67993. /** @hidden */
  67994. constructor(loader: GLTFLoader);
  67995. /** @hidden */
  67996. dispose(): void;
  67997. /** @hidden */
  67998. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67999. }
  68000. }
  68001. declare module BABYLON.GLTF2.Loader.Extensions {
  68002. /**
  68003. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68004. */
  68005. export class KHR_lights implements IGLTFLoaderExtension {
  68006. /** The name of this extension. */
  68007. readonly name: string;
  68008. /** Defines whether this extension is enabled. */
  68009. enabled: boolean;
  68010. private _loader;
  68011. private _lights?;
  68012. /** @hidden */
  68013. constructor(loader: GLTFLoader);
  68014. /** @hidden */
  68015. dispose(): void;
  68016. /** @hidden */
  68017. onLoading(): void;
  68018. /** @hidden */
  68019. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68020. }
  68021. }
  68022. declare module BABYLON.GLTF2.Loader.Extensions {
  68023. /**
  68024. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68025. */
  68026. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68027. /** The name of this extension. */
  68028. readonly name: string;
  68029. /** Defines whether this extension is enabled. */
  68030. enabled: boolean;
  68031. private _loader;
  68032. /** @hidden */
  68033. constructor(loader: GLTFLoader);
  68034. /** @hidden */
  68035. dispose(): void;
  68036. /** @hidden */
  68037. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68038. private _loadSpecularGlossinessPropertiesAsync;
  68039. }
  68040. }
  68041. declare module BABYLON.GLTF2.Loader.Extensions {
  68042. /**
  68043. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68044. */
  68045. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68046. /** The name of this extension. */
  68047. readonly name: string;
  68048. /** Defines whether this extension is enabled. */
  68049. enabled: boolean;
  68050. private _loader;
  68051. /** @hidden */
  68052. constructor(loader: GLTFLoader);
  68053. /** @hidden */
  68054. dispose(): void;
  68055. /** @hidden */
  68056. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68057. private _loadUnlitPropertiesAsync;
  68058. }
  68059. }
  68060. declare module BABYLON.GLTF2.Loader.Extensions {
  68061. /**
  68062. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68063. */
  68064. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68065. /** The name of this extension. */
  68066. readonly name: string;
  68067. /** Defines whether this extension is enabled. */
  68068. enabled: boolean;
  68069. private _loader;
  68070. /** @hidden */
  68071. constructor(loader: GLTFLoader);
  68072. /** @hidden */
  68073. dispose(): void;
  68074. /** @hidden */
  68075. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68076. }
  68077. }
  68078. declare module BABYLON.GLTF2.Loader.Extensions {
  68079. /**
  68080. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68081. */
  68082. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68083. /** The name of this extension. */
  68084. readonly name: string;
  68085. /** Defines whether this extension is enabled. */
  68086. enabled: boolean;
  68087. private _loader;
  68088. private _clips;
  68089. private _emitters;
  68090. /** @hidden */
  68091. constructor(loader: GLTFLoader);
  68092. /** @hidden */
  68093. dispose(): void;
  68094. /** @hidden */
  68095. onLoading(): void;
  68096. /** @hidden */
  68097. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68098. /** @hidden */
  68099. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68100. /** @hidden */
  68101. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68102. private _loadClipAsync;
  68103. private _loadEmitterAsync;
  68104. private _getEventAction;
  68105. private _loadAnimationEventAsync;
  68106. }
  68107. }
  68108. declare module BABYLON.GLTF2.Loader.Extensions {
  68109. /**
  68110. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68111. */
  68112. export class MSFT_lod implements IGLTFLoaderExtension {
  68113. /** The name of this extension. */
  68114. readonly name: string;
  68115. /** Defines whether this extension is enabled. */
  68116. enabled: boolean;
  68117. /**
  68118. * Maximum number of LODs to load, starting from the lowest LOD.
  68119. */
  68120. maxLODsToLoad: number;
  68121. /**
  68122. * Observable raised when all node LODs of one level are loaded.
  68123. * The event data is the index of the loaded LOD starting from zero.
  68124. * Dispose the loader to cancel the loading of the next level of LODs.
  68125. */
  68126. onNodeLODsLoadedObservable: Observable<number>;
  68127. /**
  68128. * Observable raised when all material LODs of one level are loaded.
  68129. * The event data is the index of the loaded LOD starting from zero.
  68130. * Dispose the loader to cancel the loading of the next level of LODs.
  68131. */
  68132. onMaterialLODsLoadedObservable: Observable<number>;
  68133. private _loader;
  68134. private _nodeIndexLOD;
  68135. private _nodeSignalLODs;
  68136. private _nodePromiseLODs;
  68137. private _materialIndexLOD;
  68138. private _materialSignalLODs;
  68139. private _materialPromiseLODs;
  68140. /** @hidden */
  68141. constructor(loader: GLTFLoader);
  68142. /** @hidden */
  68143. dispose(): void;
  68144. /** @hidden */
  68145. onReady(): void;
  68146. /** @hidden */
  68147. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68148. /** @hidden */
  68149. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68150. /** @hidden */
  68151. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68152. /**
  68153. * Gets an array of LOD properties from lowest to highest.
  68154. */
  68155. private _getLODs;
  68156. private _disposeUnusedMaterials;
  68157. }
  68158. }
  68159. declare module BABYLON.GLTF2.Loader.Extensions {
  68160. /** @hidden */
  68161. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68162. readonly name: string;
  68163. enabled: boolean;
  68164. private _loader;
  68165. constructor(loader: GLTFLoader);
  68166. dispose(): void;
  68167. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68168. }
  68169. }
  68170. declare module BABYLON.GLTF2.Loader.Extensions {
  68171. /** @hidden */
  68172. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68173. readonly name: string;
  68174. enabled: boolean;
  68175. private _loader;
  68176. constructor(loader: GLTFLoader);
  68177. dispose(): void;
  68178. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68179. }
  68180. }
  68181. declare module BABYLON.GLTF2.Loader.Extensions {
  68182. /**
  68183. * Store glTF extras (if present) in BJS objects' metadata
  68184. */
  68185. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68186. /** The name of this extension. */
  68187. readonly name: string;
  68188. /** Defines whether this extension is enabled. */
  68189. enabled: boolean;
  68190. private _loader;
  68191. private _assignExtras;
  68192. /** @hidden */
  68193. constructor(loader: GLTFLoader);
  68194. /** @hidden */
  68195. dispose(): void;
  68196. /** @hidden */
  68197. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68198. /** @hidden */
  68199. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68200. /** @hidden */
  68201. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68202. }
  68203. }
  68204. declare module BABYLON {
  68205. /**
  68206. * Class reading and parsing the MTL file bundled with the obj file.
  68207. */
  68208. export class MTLFileLoader {
  68209. /**
  68210. * All material loaded from the mtl will be set here
  68211. */
  68212. materials: StandardMaterial[];
  68213. /**
  68214. * This function will read the mtl file and create each material described inside
  68215. * This function could be improve by adding :
  68216. * -some component missing (Ni, Tf...)
  68217. * -including the specific options available
  68218. *
  68219. * @param scene defines the scene the material will be created in
  68220. * @param data defines the mtl data to parse
  68221. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68222. */
  68223. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68224. /**
  68225. * Gets the texture for the material.
  68226. *
  68227. * If the material is imported from input file,
  68228. * We sanitize the url to ensure it takes the textre from aside the material.
  68229. *
  68230. * @param rootUrl The root url to load from
  68231. * @param value The value stored in the mtl
  68232. * @return The Texture
  68233. */
  68234. private static _getTexture;
  68235. }
  68236. /**
  68237. * Options for loading OBJ/MTL files
  68238. */
  68239. type MeshLoadOptions = {
  68240. /**
  68241. * Defines if UVs are optimized by default during load.
  68242. */
  68243. OptimizeWithUV: boolean;
  68244. /**
  68245. * Defines custom scaling of UV coordinates of loaded meshes.
  68246. */
  68247. UVScaling: Vector2;
  68248. /**
  68249. * Invert model on y-axis (does a model scaling inversion)
  68250. */
  68251. InvertY: boolean;
  68252. /**
  68253. * Invert Y-Axis of referenced textures on load
  68254. */
  68255. InvertTextureY: boolean;
  68256. /**
  68257. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68258. */
  68259. ImportVertexColors: boolean;
  68260. /**
  68261. * Compute the normals for the model, even if normals are present in the file.
  68262. */
  68263. ComputeNormals: boolean;
  68264. /**
  68265. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68266. */
  68267. SkipMaterials: boolean;
  68268. /**
  68269. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68270. */
  68271. MaterialLoadingFailsSilently: boolean;
  68272. };
  68273. /**
  68274. * OBJ file type loader.
  68275. * This is a babylon scene loader plugin.
  68276. */
  68277. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68278. /**
  68279. * Defines if UVs are optimized by default during load.
  68280. */
  68281. static OPTIMIZE_WITH_UV: boolean;
  68282. /**
  68283. * Invert model on y-axis (does a model scaling inversion)
  68284. */
  68285. static INVERT_Y: boolean;
  68286. /**
  68287. * Invert Y-Axis of referenced textures on load
  68288. */
  68289. static INVERT_TEXTURE_Y: boolean;
  68290. /**
  68291. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68292. */
  68293. static IMPORT_VERTEX_COLORS: boolean;
  68294. /**
  68295. * Compute the normals for the model, even if normals are present in the file.
  68296. */
  68297. static COMPUTE_NORMALS: boolean;
  68298. /**
  68299. * Defines custom scaling of UV coordinates of loaded meshes.
  68300. */
  68301. static UV_SCALING: Vector2;
  68302. /**
  68303. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68304. */
  68305. static SKIP_MATERIALS: boolean;
  68306. /**
  68307. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68308. *
  68309. * Defaults to true for backwards compatibility.
  68310. */
  68311. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68312. /**
  68313. * Defines the name of the plugin.
  68314. */
  68315. name: string;
  68316. /**
  68317. * Defines the extension the plugin is able to load.
  68318. */
  68319. extensions: string;
  68320. /** @hidden */
  68321. obj: RegExp;
  68322. /** @hidden */
  68323. group: RegExp;
  68324. /** @hidden */
  68325. mtllib: RegExp;
  68326. /** @hidden */
  68327. usemtl: RegExp;
  68328. /** @hidden */
  68329. smooth: RegExp;
  68330. /** @hidden */
  68331. vertexPattern: RegExp;
  68332. /** @hidden */
  68333. normalPattern: RegExp;
  68334. /** @hidden */
  68335. uvPattern: RegExp;
  68336. /** @hidden */
  68337. facePattern1: RegExp;
  68338. /** @hidden */
  68339. facePattern2: RegExp;
  68340. /** @hidden */
  68341. facePattern3: RegExp;
  68342. /** @hidden */
  68343. facePattern4: RegExp;
  68344. /** @hidden */
  68345. facePattern5: RegExp;
  68346. private _meshLoadOptions;
  68347. /**
  68348. * Creates loader for .OBJ files
  68349. *
  68350. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68351. */
  68352. constructor(meshLoadOptions?: MeshLoadOptions);
  68353. private static readonly currentMeshLoadOptions;
  68354. /**
  68355. * Calls synchronously the MTL file attached to this obj.
  68356. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68357. * Without this function materials are not displayed in the first frame (but displayed after).
  68358. * In consequence it is impossible to get material information in your HTML file
  68359. *
  68360. * @param url The URL of the MTL file
  68361. * @param rootUrl
  68362. * @param onSuccess Callback function to be called when the MTL file is loaded
  68363. * @private
  68364. */
  68365. private _loadMTL;
  68366. /**
  68367. * Instantiates a OBJ file loader plugin.
  68368. * @returns the created plugin
  68369. */
  68370. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68371. /**
  68372. * If the data string can be loaded directly.
  68373. *
  68374. * @param data string containing the file data
  68375. * @returns if the data can be loaded directly
  68376. */
  68377. canDirectLoad(data: string): boolean;
  68378. /**
  68379. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68380. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68381. * @param scene the scene the meshes should be added to
  68382. * @param data the OBJ data to load
  68383. * @param rootUrl root url to load from
  68384. * @param onProgress event that fires when loading progress has occured
  68385. * @param fileName Defines the name of the file to load
  68386. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68387. */
  68388. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68389. meshes: AbstractMesh[];
  68390. particleSystems: IParticleSystem[];
  68391. skeletons: Skeleton[];
  68392. animationGroups: AnimationGroup[];
  68393. }>;
  68394. /**
  68395. * Imports all objects from the loaded OBJ data and adds them to the scene
  68396. * @param scene the scene the objects should be added to
  68397. * @param data the OBJ data to load
  68398. * @param rootUrl root url to load from
  68399. * @param onProgress event that fires when loading progress has occured
  68400. * @param fileName Defines the name of the file to load
  68401. * @returns a promise which completes when objects have been loaded to the scene
  68402. */
  68403. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68404. /**
  68405. * Load into an asset container.
  68406. * @param scene The scene to load into
  68407. * @param data The data to import
  68408. * @param rootUrl The root url for scene and resources
  68409. * @param onProgress The callback when the load progresses
  68410. * @param fileName Defines the name of the file to load
  68411. * @returns The loaded asset container
  68412. */
  68413. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68414. /**
  68415. * Read the OBJ file and create an Array of meshes.
  68416. * Each mesh contains all information given by the OBJ and the MTL file.
  68417. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68418. *
  68419. * @param meshesNames
  68420. * @param scene Scene The scene where are displayed the data
  68421. * @param data String The content of the obj file
  68422. * @param rootUrl String The path to the folder
  68423. * @returns Array<AbstractMesh>
  68424. * @private
  68425. */
  68426. private _parseSolid;
  68427. }
  68428. }
  68429. declare module BABYLON {
  68430. /**
  68431. * STL file type loader.
  68432. * This is a babylon scene loader plugin.
  68433. */
  68434. export class STLFileLoader implements ISceneLoaderPlugin {
  68435. /** @hidden */
  68436. solidPattern: RegExp;
  68437. /** @hidden */
  68438. facetsPattern: RegExp;
  68439. /** @hidden */
  68440. normalPattern: RegExp;
  68441. /** @hidden */
  68442. vertexPattern: RegExp;
  68443. /**
  68444. * Defines the name of the plugin.
  68445. */
  68446. name: string;
  68447. /**
  68448. * Defines the extensions the stl loader is able to load.
  68449. * force data to come in as an ArrayBuffer
  68450. * we'll convert to string if it looks like it's an ASCII .stl
  68451. */
  68452. extensions: ISceneLoaderPluginExtensions;
  68453. /**
  68454. * Import meshes into a scene.
  68455. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68456. * @param scene The scene to import into
  68457. * @param data The data to import
  68458. * @param rootUrl The root url for scene and resources
  68459. * @param meshes The meshes array to import into
  68460. * @param particleSystems The particle systems array to import into
  68461. * @param skeletons The skeletons array to import into
  68462. * @param onError The callback when import fails
  68463. * @returns True if successful or false otherwise
  68464. */
  68465. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68466. /**
  68467. * Load into a scene.
  68468. * @param scene The scene to load into
  68469. * @param data The data to import
  68470. * @param rootUrl The root url for scene and resources
  68471. * @param onError The callback when import fails
  68472. * @returns true if successful or false otherwise
  68473. */
  68474. load(scene: Scene, data: any, rootUrl: string): boolean;
  68475. /**
  68476. * Load into an asset container.
  68477. * @param scene The scene to load into
  68478. * @param data The data to import
  68479. * @param rootUrl The root url for scene and resources
  68480. * @param onError The callback when import fails
  68481. * @returns The loaded asset container
  68482. */
  68483. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68484. private _isBinary;
  68485. private _parseBinary;
  68486. private _parseASCII;
  68487. }
  68488. }
  68489. declare module BABYLON {
  68490. /**
  68491. * Class for generating OBJ data from a Babylon scene.
  68492. */
  68493. export class OBJExport {
  68494. /**
  68495. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68496. * @param mesh defines the list of meshes to serialize
  68497. * @param materials defines if materials should be exported
  68498. * @param matlibname defines the name of the associated mtl file
  68499. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68500. * @returns the OBJ content
  68501. */
  68502. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68503. /**
  68504. * Exports the material(s) of a mesh in .MTL file format (text)
  68505. * @param mesh defines the mesh to extract the material from
  68506. * @returns the mtl content
  68507. */
  68508. static MTL(mesh: Mesh): string;
  68509. }
  68510. }
  68511. declare module BABYLON {
  68512. /** @hidden */
  68513. export var __IGLTFExporterExtension: number;
  68514. /**
  68515. * Interface for extending the exporter
  68516. * @hidden
  68517. */
  68518. export interface IGLTFExporterExtension {
  68519. /**
  68520. * The name of this extension
  68521. */
  68522. readonly name: string;
  68523. /**
  68524. * Defines whether this extension is enabled
  68525. */
  68526. enabled: boolean;
  68527. /**
  68528. * Defines whether this extension is required
  68529. */
  68530. required: boolean;
  68531. }
  68532. }
  68533. declare module BABYLON.GLTF2.Exporter {
  68534. /** @hidden */
  68535. export var __IGLTFExporterExtensionV2: number;
  68536. /**
  68537. * Interface for a glTF exporter extension
  68538. * @hidden
  68539. */
  68540. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68541. /**
  68542. * Define this method to modify the default behavior before exporting a texture
  68543. * @param context The context when loading the asset
  68544. * @param babylonTexture The glTF texture info property
  68545. * @param mimeType The mime-type of the generated image
  68546. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68547. */
  68548. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68549. /**
  68550. * Define this method to modify the default behavior when exporting texture info
  68551. * @param context The context when loading the asset
  68552. * @param meshPrimitive glTF mesh primitive
  68553. * @param babylonSubMesh Babylon submesh
  68554. * @param binaryWriter glTF serializer binary writer instance
  68555. * @returns nullable IMeshPrimitive promise
  68556. */
  68557. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68558. /**
  68559. * Define this method to modify the default behavior when exporting a node
  68560. * @param context The context when exporting the node
  68561. * @param node glTF node
  68562. * @param babylonNode BabylonJS node
  68563. * @returns nullable INode promise
  68564. */
  68565. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68566. /**
  68567. * Called after the exporter state changes to EXPORTING
  68568. */
  68569. onExporting?(): void;
  68570. }
  68571. }
  68572. declare module BABYLON.GLTF2.Exporter {
  68573. /**
  68574. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68575. * @hidden
  68576. */
  68577. export class _GLTFMaterialExporter {
  68578. /**
  68579. * Represents the dielectric specular values for R, G and B
  68580. */
  68581. private static readonly _DielectricSpecular;
  68582. /**
  68583. * Allows the maximum specular power to be defined for material calculations
  68584. */
  68585. private static readonly _MaxSpecularPower;
  68586. /**
  68587. * Mapping to store textures
  68588. */
  68589. private _textureMap;
  68590. /**
  68591. * Numeric tolerance value
  68592. */
  68593. private static readonly _Epsilon;
  68594. /**
  68595. * Reference to the glTF Exporter
  68596. */
  68597. private _exporter;
  68598. constructor(exporter: _Exporter);
  68599. /**
  68600. * Specifies if two colors are approximately equal in value
  68601. * @param color1 first color to compare to
  68602. * @param color2 second color to compare to
  68603. * @param epsilon threshold value
  68604. */
  68605. private static FuzzyEquals;
  68606. /**
  68607. * Gets the materials from a Babylon scene and converts them to glTF materials
  68608. * @param scene babylonjs scene
  68609. * @param mimeType texture mime type
  68610. * @param images array of images
  68611. * @param textures array of textures
  68612. * @param materials array of materials
  68613. * @param imageData mapping of texture names to base64 textures
  68614. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68615. */
  68616. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68617. /**
  68618. * Makes a copy of the glTF material without the texture parameters
  68619. * @param originalMaterial original glTF material
  68620. * @returns glTF material without texture parameters
  68621. */
  68622. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68623. /**
  68624. * Specifies if the material has any texture parameters present
  68625. * @param material glTF Material
  68626. * @returns boolean specifying if texture parameters are present
  68627. */
  68628. _hasTexturesPresent(material: IMaterial): boolean;
  68629. /**
  68630. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68631. * @param babylonStandardMaterial
  68632. * @returns glTF Metallic Roughness Material representation
  68633. */
  68634. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68635. /**
  68636. * Computes the metallic factor
  68637. * @param diffuse diffused value
  68638. * @param specular specular value
  68639. * @param oneMinusSpecularStrength one minus the specular strength
  68640. * @returns metallic value
  68641. */
  68642. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68643. /**
  68644. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68645. * @param glTFMaterial glTF material
  68646. * @param babylonMaterial Babylon material
  68647. */
  68648. private static _SetAlphaMode;
  68649. /**
  68650. * Converts a Babylon Standard Material to a glTF Material
  68651. * @param babylonStandardMaterial BJS Standard Material
  68652. * @param mimeType mime type to use for the textures
  68653. * @param images array of glTF image interfaces
  68654. * @param textures array of glTF texture interfaces
  68655. * @param materials array of glTF material interfaces
  68656. * @param imageData map of image file name to data
  68657. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68658. */
  68659. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68660. /**
  68661. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68662. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68663. * @param mimeType mime type to use for the textures
  68664. * @param images array of glTF image interfaces
  68665. * @param textures array of glTF texture interfaces
  68666. * @param materials array of glTF material interfaces
  68667. * @param imageData map of image file name to data
  68668. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68669. */
  68670. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68671. /**
  68672. * Converts an image typed array buffer to a base64 image
  68673. * @param buffer typed array buffer
  68674. * @param width width of the image
  68675. * @param height height of the image
  68676. * @param mimeType mimetype of the image
  68677. * @returns base64 image string
  68678. */
  68679. private _createBase64FromCanvasAsync;
  68680. /**
  68681. * Generates a white texture based on the specified width and height
  68682. * @param width width of the texture in pixels
  68683. * @param height height of the texture in pixels
  68684. * @param scene babylonjs scene
  68685. * @returns white texture
  68686. */
  68687. private _createWhiteTexture;
  68688. /**
  68689. * 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
  68690. * @param texture1 first texture to resize
  68691. * @param texture2 second texture to resize
  68692. * @param scene babylonjs scene
  68693. * @returns resized textures or null
  68694. */
  68695. private _resizeTexturesToSameDimensions;
  68696. /**
  68697. * Converts an array of pixels to a Float32Array
  68698. * Throws an error if the pixel format is not supported
  68699. * @param pixels - array buffer containing pixel values
  68700. * @returns Float32 of pixels
  68701. */
  68702. private _convertPixelArrayToFloat32;
  68703. /**
  68704. * Convert Specular Glossiness Textures to Metallic Roughness
  68705. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68706. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68707. * @param diffuseTexture texture used to store diffuse information
  68708. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68709. * @param factors specular glossiness material factors
  68710. * @param mimeType the mime type to use for the texture
  68711. * @returns pbr metallic roughness interface or null
  68712. */
  68713. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68714. /**
  68715. * Converts specular glossiness material properties to metallic roughness
  68716. * @param specularGlossiness interface with specular glossiness material properties
  68717. * @returns interface with metallic roughness material properties
  68718. */
  68719. private _convertSpecularGlossinessToMetallicRoughness;
  68720. /**
  68721. * Calculates the surface reflectance, independent of lighting conditions
  68722. * @param color Color source to calculate brightness from
  68723. * @returns number representing the perceived brightness, or zero if color is undefined
  68724. */
  68725. private _getPerceivedBrightness;
  68726. /**
  68727. * Returns the maximum color component value
  68728. * @param color
  68729. * @returns maximum color component value, or zero if color is null or undefined
  68730. */
  68731. private _getMaxComponent;
  68732. /**
  68733. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68734. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68735. * @param mimeType mime type to use for the textures
  68736. * @param images array of glTF image interfaces
  68737. * @param textures array of glTF texture interfaces
  68738. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68739. * @param imageData map of image file name to data
  68740. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68741. * @returns glTF PBR Metallic Roughness factors
  68742. */
  68743. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68744. private _getGLTFTextureSampler;
  68745. private _getGLTFTextureWrapMode;
  68746. private _getGLTFTextureWrapModesSampler;
  68747. /**
  68748. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68749. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68750. * @param mimeType mime type to use for the textures
  68751. * @param images array of glTF image interfaces
  68752. * @param textures array of glTF texture interfaces
  68753. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68754. * @param imageData map of image file name to data
  68755. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68756. * @returns glTF PBR Metallic Roughness factors
  68757. */
  68758. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68759. /**
  68760. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68761. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68762. * @param mimeType mime type to use for the textures
  68763. * @param images array of glTF image interfaces
  68764. * @param textures array of glTF texture interfaces
  68765. * @param materials array of glTF material interfaces
  68766. * @param imageData map of image file name to data
  68767. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68768. */
  68769. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68770. private setMetallicRoughnessPbrMaterial;
  68771. private getPixelsFromTexture;
  68772. /**
  68773. * Extracts a texture from a Babylon texture into file data and glTF data
  68774. * @param babylonTexture Babylon texture to extract
  68775. * @param mimeType Mime Type of the babylonTexture
  68776. * @return glTF texture info, or null if the texture format is not supported
  68777. */
  68778. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68779. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68780. /**
  68781. * Builds a texture from base64 string
  68782. * @param base64Texture base64 texture string
  68783. * @param baseTextureName Name to use for the texture
  68784. * @param mimeType image mime type for the texture
  68785. * @param images array of images
  68786. * @param textures array of textures
  68787. * @param imageData map of image data
  68788. * @returns glTF texture info, or null if the texture format is not supported
  68789. */
  68790. private _getTextureInfoFromBase64;
  68791. }
  68792. }
  68793. declare module BABYLON {
  68794. /**
  68795. * Class for holding and downloading glTF file data
  68796. */
  68797. export class GLTFData {
  68798. /**
  68799. * Object which contains the file name as the key and its data as the value
  68800. */
  68801. glTFFiles: {
  68802. [fileName: string]: string | Blob;
  68803. };
  68804. /**
  68805. * Initializes the glTF file object
  68806. */
  68807. constructor();
  68808. /**
  68809. * Downloads the glTF data as files based on their names and data
  68810. */
  68811. downloadFiles(): void;
  68812. }
  68813. }
  68814. declare module BABYLON {
  68815. /**
  68816. * Holds a collection of exporter options and parameters
  68817. */
  68818. export interface IExportOptions {
  68819. /**
  68820. * Function which indicates whether a babylon node should be exported or not
  68821. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68822. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68823. */
  68824. shouldExportNode?(node: Node): boolean;
  68825. /**
  68826. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68827. * @param metadata source metadata to read from
  68828. * @returns the data to store to glTF node extras
  68829. */
  68830. metadataSelector?(metadata: any): any;
  68831. /**
  68832. * The sample rate to bake animation curves
  68833. */
  68834. animationSampleRate?: number;
  68835. /**
  68836. * Begin serialization without waiting for the scene to be ready
  68837. */
  68838. exportWithoutWaitingForScene?: boolean;
  68839. }
  68840. /**
  68841. * Class for generating glTF data from a Babylon scene.
  68842. */
  68843. export class GLTF2Export {
  68844. /**
  68845. * Exports the geometry of the scene to .gltf file format asynchronously
  68846. * @param scene Babylon scene with scene hierarchy information
  68847. * @param filePrefix File prefix to use when generating the glTF file
  68848. * @param options Exporter options
  68849. * @returns Returns an object with a .gltf file and associates texture names
  68850. * as keys and their data and paths as values
  68851. */
  68852. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68853. private static _PreExportAsync;
  68854. private static _PostExportAsync;
  68855. /**
  68856. * Exports the geometry of the scene to .glb file format asychronously
  68857. * @param scene Babylon scene with scene hierarchy information
  68858. * @param filePrefix File prefix to use when generating glb file
  68859. * @param options Exporter options
  68860. * @returns Returns an object with a .glb filename as key and data as value
  68861. */
  68862. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68863. }
  68864. }
  68865. declare module BABYLON.GLTF2.Exporter {
  68866. /**
  68867. * @hidden
  68868. */
  68869. export class _GLTFUtilities {
  68870. /**
  68871. * Creates a buffer view based on the supplied arguments
  68872. * @param bufferIndex index value of the specified buffer
  68873. * @param byteOffset byte offset value
  68874. * @param byteLength byte length of the bufferView
  68875. * @param byteStride byte distance between conequential elements
  68876. * @param name name of the buffer view
  68877. * @returns bufferView for glTF
  68878. */
  68879. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68880. /**
  68881. * Creates an accessor based on the supplied arguments
  68882. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68883. * @param name The name of the accessor
  68884. * @param type The type of the accessor
  68885. * @param componentType The datatype of components in the attribute
  68886. * @param count The number of attributes referenced by this accessor
  68887. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68888. * @param min Minimum value of each component in this attribute
  68889. * @param max Maximum value of each component in this attribute
  68890. * @returns accessor for glTF
  68891. */
  68892. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68893. /**
  68894. * Calculates the minimum and maximum values of an array of position floats
  68895. * @param positions Positions array of a mesh
  68896. * @param vertexStart Starting vertex offset to calculate min and max values
  68897. * @param vertexCount Number of vertices to check for min and max values
  68898. * @returns min number array and max number array
  68899. */
  68900. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68901. min: number[];
  68902. max: number[];
  68903. };
  68904. /**
  68905. * Converts a new right-handed Vector3
  68906. * @param vector vector3 array
  68907. * @returns right-handed Vector3
  68908. */
  68909. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68910. /**
  68911. * Converts a Vector3 to right-handed
  68912. * @param vector Vector3 to convert to right-handed
  68913. */
  68914. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68915. /**
  68916. * Converts a three element number array to right-handed
  68917. * @param vector number array to convert to right-handed
  68918. */
  68919. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68920. /**
  68921. * Converts a new right-handed Vector3
  68922. * @param vector vector3 array
  68923. * @returns right-handed Vector3
  68924. */
  68925. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68926. /**
  68927. * Converts a Vector3 to right-handed
  68928. * @param vector Vector3 to convert to right-handed
  68929. */
  68930. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68931. /**
  68932. * Converts a three element number array to right-handed
  68933. * @param vector number array to convert to right-handed
  68934. */
  68935. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68936. /**
  68937. * Converts a Vector4 to right-handed
  68938. * @param vector Vector4 to convert to right-handed
  68939. */
  68940. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68941. /**
  68942. * Converts a Vector4 to right-handed
  68943. * @param vector Vector4 to convert to right-handed
  68944. */
  68945. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68946. /**
  68947. * Converts a Quaternion to right-handed
  68948. * @param quaternion Source quaternion to convert to right-handed
  68949. */
  68950. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68951. /**
  68952. * Converts a Quaternion to right-handed
  68953. * @param quaternion Source quaternion to convert to right-handed
  68954. */
  68955. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68956. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68957. }
  68958. }
  68959. declare module BABYLON.GLTF2.Exporter {
  68960. /**
  68961. * Converts Babylon Scene into glTF 2.0.
  68962. * @hidden
  68963. */
  68964. export class _Exporter {
  68965. /**
  68966. * Stores the glTF to export
  68967. */
  68968. _glTF: IGLTF;
  68969. /**
  68970. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68971. */
  68972. _bufferViews: IBufferView[];
  68973. /**
  68974. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68975. */
  68976. _accessors: IAccessor[];
  68977. /**
  68978. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68979. */
  68980. private _nodes;
  68981. /**
  68982. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68983. */
  68984. private _scenes;
  68985. /**
  68986. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68987. */
  68988. private _meshes;
  68989. /**
  68990. * Stores all the generated material information, which represents the appearance of each primitive
  68991. */
  68992. _materials: IMaterial[];
  68993. _materialMap: {
  68994. [materialID: number]: number;
  68995. };
  68996. /**
  68997. * Stores all the generated texture information, which is referenced by glTF materials
  68998. */
  68999. _textures: ITexture[];
  69000. /**
  69001. * Stores all the generated image information, which is referenced by glTF textures
  69002. */
  69003. _images: IImage[];
  69004. /**
  69005. * Stores all the texture samplers
  69006. */
  69007. _samplers: ISampler[];
  69008. /**
  69009. * Stores all the generated animation samplers, which is referenced by glTF animations
  69010. */
  69011. /**
  69012. * Stores the animations for glTF models
  69013. */
  69014. private _animations;
  69015. /**
  69016. * Stores the total amount of bytes stored in the glTF buffer
  69017. */
  69018. private _totalByteLength;
  69019. /**
  69020. * Stores a reference to the Babylon scene containing the source geometry and material information
  69021. */
  69022. _babylonScene: Scene;
  69023. /**
  69024. * Stores a map of the image data, where the key is the file name and the value
  69025. * is the image data
  69026. */
  69027. _imageData: {
  69028. [fileName: string]: {
  69029. data: Uint8Array;
  69030. mimeType: ImageMimeType;
  69031. };
  69032. };
  69033. /**
  69034. * Stores a map of the unique id of a node to its index in the node array
  69035. */
  69036. private _nodeMap;
  69037. /**
  69038. * Specifies if the Babylon scene should be converted to right-handed on export
  69039. */
  69040. _convertToRightHandedSystem: boolean;
  69041. /**
  69042. * Baked animation sample rate
  69043. */
  69044. private _animationSampleRate;
  69045. private _options;
  69046. private _localEngine;
  69047. _glTFMaterialExporter: _GLTFMaterialExporter;
  69048. private _extensions;
  69049. private static _ExtensionNames;
  69050. private static _ExtensionFactories;
  69051. private _applyExtensions;
  69052. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69053. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69054. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69055. private _forEachExtensions;
  69056. private _extensionsOnExporting;
  69057. /**
  69058. * Load glTF serializer extensions
  69059. */
  69060. private _loadExtensions;
  69061. /**
  69062. * Creates a glTF Exporter instance, which can accept optional exporter options
  69063. * @param babylonScene Babylon scene object
  69064. * @param options Options to modify the behavior of the exporter
  69065. */
  69066. constructor(babylonScene: Scene, options?: IExportOptions);
  69067. /**
  69068. * Registers a glTF exporter extension
  69069. * @param name Name of the extension to export
  69070. * @param factory The factory function that creates the exporter extension
  69071. */
  69072. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69073. /**
  69074. * Un-registers an exporter extension
  69075. * @param name The name fo the exporter extension
  69076. * @returns A boolean indicating whether the extension has been un-registered
  69077. */
  69078. static UnregisterExtension(name: string): boolean;
  69079. /**
  69080. * Lazy load a local engine with premultiplied alpha set to false
  69081. */
  69082. _getLocalEngine(): Engine;
  69083. private reorderIndicesBasedOnPrimitiveMode;
  69084. /**
  69085. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69086. * clock-wise during export to glTF
  69087. * @param submesh BabylonJS submesh
  69088. * @param primitiveMode Primitive mode of the mesh
  69089. * @param sideOrientation the winding order of the submesh
  69090. * @param vertexBufferKind The type of vertex attribute
  69091. * @param meshAttributeArray The vertex attribute data
  69092. * @param byteOffset The offset to the binary data
  69093. * @param binaryWriter The binary data for the glTF file
  69094. */
  69095. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69096. /**
  69097. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69098. * clock-wise during export to glTF
  69099. * @param submesh BabylonJS submesh
  69100. * @param primitiveMode Primitive mode of the mesh
  69101. * @param sideOrientation the winding order of the submesh
  69102. * @param vertexBufferKind The type of vertex attribute
  69103. * @param meshAttributeArray The vertex attribute data
  69104. * @param byteOffset The offset to the binary data
  69105. * @param binaryWriter The binary data for the glTF file
  69106. */
  69107. private reorderTriangleFillMode;
  69108. /**
  69109. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69110. * clock-wise during export to glTF
  69111. * @param submesh BabylonJS submesh
  69112. * @param primitiveMode Primitive mode of the mesh
  69113. * @param sideOrientation the winding order of the submesh
  69114. * @param vertexBufferKind The type of vertex attribute
  69115. * @param meshAttributeArray The vertex attribute data
  69116. * @param byteOffset The offset to the binary data
  69117. * @param binaryWriter The binary data for the glTF file
  69118. */
  69119. private reorderTriangleStripDrawMode;
  69120. /**
  69121. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69122. * clock-wise during export to glTF
  69123. * @param submesh BabylonJS submesh
  69124. * @param primitiveMode Primitive mode of the mesh
  69125. * @param sideOrientation the winding order of the submesh
  69126. * @param vertexBufferKind The type of vertex attribute
  69127. * @param meshAttributeArray The vertex attribute data
  69128. * @param byteOffset The offset to the binary data
  69129. * @param binaryWriter The binary data for the glTF file
  69130. */
  69131. private reorderTriangleFanMode;
  69132. /**
  69133. * Writes the vertex attribute data to binary
  69134. * @param vertices The vertices to write to the binary writer
  69135. * @param byteOffset The offset into the binary writer to overwrite binary data
  69136. * @param vertexAttributeKind The vertex attribute type
  69137. * @param meshAttributeArray The vertex attribute data
  69138. * @param binaryWriter The writer containing the binary data
  69139. */
  69140. private writeVertexAttributeData;
  69141. /**
  69142. * Writes mesh attribute data to a data buffer
  69143. * Returns the bytelength of the data
  69144. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69145. * @param meshAttributeArray Array containing the attribute data
  69146. * @param binaryWriter The buffer to write the binary data to
  69147. * @param indices Used to specify the order of the vertex data
  69148. */
  69149. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69150. /**
  69151. * Generates glTF json data
  69152. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69153. * @param glTFPrefix Text to use when prefixing a glTF file
  69154. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69155. * @returns json data as string
  69156. */
  69157. private generateJSON;
  69158. /**
  69159. * Generates data for .gltf and .bin files based on the glTF prefix string
  69160. * @param glTFPrefix Text to use when prefixing a glTF file
  69161. * @returns GLTFData with glTF file data
  69162. */
  69163. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69164. /**
  69165. * Creates a binary buffer for glTF
  69166. * @returns array buffer for binary data
  69167. */
  69168. private _generateBinaryAsync;
  69169. /**
  69170. * Pads the number to a multiple of 4
  69171. * @param num number to pad
  69172. * @returns padded number
  69173. */
  69174. private _getPadding;
  69175. /**
  69176. * Generates a glb file from the json and binary data
  69177. * Returns an object with the glb file name as the key and data as the value
  69178. * @param glTFPrefix
  69179. * @returns object with glb filename as key and data as value
  69180. */
  69181. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69182. /**
  69183. * Sets the TRS for each node
  69184. * @param node glTF Node for storing the transformation data
  69185. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69186. */
  69187. private setNodeTransformation;
  69188. private getVertexBufferFromMesh;
  69189. /**
  69190. * Creates a bufferview based on the vertices type for the Babylon mesh
  69191. * @param kind Indicates the type of vertices data
  69192. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69193. * @param binaryWriter The buffer to write the bufferview data to
  69194. */
  69195. private createBufferViewKind;
  69196. /**
  69197. * The primitive mode of the Babylon mesh
  69198. * @param babylonMesh The BabylonJS mesh
  69199. */
  69200. private getMeshPrimitiveMode;
  69201. /**
  69202. * Sets the primitive mode of the glTF mesh primitive
  69203. * @param meshPrimitive glTF mesh primitive
  69204. * @param primitiveMode The primitive mode
  69205. */
  69206. private setPrimitiveMode;
  69207. /**
  69208. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69209. * @param meshPrimitive glTF mesh primitive
  69210. * @param attributeKind vertex attribute
  69211. * @returns boolean specifying if uv coordinates are present
  69212. */
  69213. private setAttributeKind;
  69214. /**
  69215. * Sets data for the primitive attributes of each submesh
  69216. * @param mesh glTF Mesh object to store the primitive attribute information
  69217. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69218. * @param binaryWriter Buffer to write the attribute data to
  69219. */
  69220. private setPrimitiveAttributesAsync;
  69221. /**
  69222. * Creates a glTF scene based on the array of meshes
  69223. * Returns the the total byte offset
  69224. * @param babylonScene Babylon scene to get the mesh data from
  69225. * @param binaryWriter Buffer to write binary data to
  69226. */
  69227. private createSceneAsync;
  69228. /**
  69229. * Creates a mapping of Node unique id to node index and handles animations
  69230. * @param babylonScene Babylon Scene
  69231. * @param nodes Babylon transform nodes
  69232. * @param binaryWriter Buffer to write binary data to
  69233. * @returns Node mapping of unique id to index
  69234. */
  69235. private createNodeMapAndAnimationsAsync;
  69236. /**
  69237. * Creates a glTF node from a Babylon mesh
  69238. * @param babylonMesh Source Babylon mesh
  69239. * @param binaryWriter Buffer for storing geometry data
  69240. * @returns glTF node
  69241. */
  69242. private createNodeAsync;
  69243. }
  69244. /**
  69245. * @hidden
  69246. *
  69247. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69248. */
  69249. export class _BinaryWriter {
  69250. /**
  69251. * Array buffer which stores all binary data
  69252. */
  69253. private _arrayBuffer;
  69254. /**
  69255. * View of the array buffer
  69256. */
  69257. private _dataView;
  69258. /**
  69259. * byte offset of data in array buffer
  69260. */
  69261. private _byteOffset;
  69262. /**
  69263. * Initialize binary writer with an initial byte length
  69264. * @param byteLength Initial byte length of the array buffer
  69265. */
  69266. constructor(byteLength: number);
  69267. /**
  69268. * Resize the array buffer to the specified byte length
  69269. * @param byteLength
  69270. */
  69271. private resizeBuffer;
  69272. /**
  69273. * Get an array buffer with the length of the byte offset
  69274. * @returns ArrayBuffer resized to the byte offset
  69275. */
  69276. getArrayBuffer(): ArrayBuffer;
  69277. /**
  69278. * Get the byte offset of the array buffer
  69279. * @returns byte offset
  69280. */
  69281. getByteOffset(): number;
  69282. /**
  69283. * Stores an UInt8 in the array buffer
  69284. * @param entry
  69285. * @param byteOffset If defined, specifies where to set the value as an offset.
  69286. */
  69287. setUInt8(entry: number, byteOffset?: number): void;
  69288. /**
  69289. * Gets an UInt32 in the array buffer
  69290. * @param entry
  69291. * @param byteOffset If defined, specifies where to set the value as an offset.
  69292. */
  69293. getUInt32(byteOffset: number): number;
  69294. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69295. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69296. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69297. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69298. /**
  69299. * Stores a Float32 in the array buffer
  69300. * @param entry
  69301. */
  69302. setFloat32(entry: number, byteOffset?: number): void;
  69303. /**
  69304. * Stores an UInt32 in the array buffer
  69305. * @param entry
  69306. * @param byteOffset If defined, specifies where to set the value as an offset.
  69307. */
  69308. setUInt32(entry: number, byteOffset?: number): void;
  69309. }
  69310. }
  69311. declare module BABYLON.GLTF2.Exporter {
  69312. /**
  69313. * @hidden
  69314. * Interface to store animation data.
  69315. */
  69316. export interface _IAnimationData {
  69317. /**
  69318. * Keyframe data.
  69319. */
  69320. inputs: number[];
  69321. /**
  69322. * Value data.
  69323. */
  69324. outputs: number[][];
  69325. /**
  69326. * Animation interpolation data.
  69327. */
  69328. samplerInterpolation: AnimationSamplerInterpolation;
  69329. /**
  69330. * Minimum keyframe value.
  69331. */
  69332. inputsMin: number;
  69333. /**
  69334. * Maximum keyframe value.
  69335. */
  69336. inputsMax: number;
  69337. }
  69338. /**
  69339. * @hidden
  69340. */
  69341. export interface _IAnimationInfo {
  69342. /**
  69343. * The target channel for the animation
  69344. */
  69345. animationChannelTargetPath: AnimationChannelTargetPath;
  69346. /**
  69347. * The glTF accessor type for the data.
  69348. */
  69349. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69350. /**
  69351. * Specifies if quaternions should be used.
  69352. */
  69353. useQuaternion: boolean;
  69354. }
  69355. /**
  69356. * @hidden
  69357. * Utility class for generating glTF animation data from BabylonJS.
  69358. */
  69359. export class _GLTFAnimation {
  69360. /**
  69361. * @ignore
  69362. *
  69363. * Creates glTF channel animation from BabylonJS animation.
  69364. * @param babylonTransformNode - BabylonJS mesh.
  69365. * @param animation - animation.
  69366. * @param animationChannelTargetPath - The target animation channel.
  69367. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69368. * @param useQuaternion - Specifies if quaternions are used.
  69369. * @returns nullable IAnimationData
  69370. */
  69371. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69372. private static _DeduceAnimationInfo;
  69373. /**
  69374. * @ignore
  69375. * Create node animations from the transform node animations
  69376. * @param babylonNode
  69377. * @param runtimeGLTFAnimation
  69378. * @param idleGLTFAnimations
  69379. * @param nodeMap
  69380. * @param nodes
  69381. * @param binaryWriter
  69382. * @param bufferViews
  69383. * @param accessors
  69384. * @param convertToRightHandedSystem
  69385. */
  69386. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69387. [key: number]: number;
  69388. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69389. /**
  69390. * @ignore
  69391. * Create node animations from the animation groups
  69392. * @param babylonScene
  69393. * @param glTFAnimations
  69394. * @param nodeMap
  69395. * @param nodes
  69396. * @param binaryWriter
  69397. * @param bufferViews
  69398. * @param accessors
  69399. * @param convertToRightHandedSystem
  69400. */
  69401. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69402. [key: number]: number;
  69403. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69404. private static AddAnimation;
  69405. /**
  69406. * Create a baked animation
  69407. * @param babylonTransformNode BabylonJS mesh
  69408. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69409. * @param animationChannelTargetPath animation target channel
  69410. * @param minFrame minimum animation frame
  69411. * @param maxFrame maximum animation frame
  69412. * @param fps frames per second of the animation
  69413. * @param inputs input key frames of the animation
  69414. * @param outputs output key frame data of the animation
  69415. * @param convertToRightHandedSystem converts the values to right-handed
  69416. * @param useQuaternion specifies if quaternions should be used
  69417. */
  69418. private static _CreateBakedAnimation;
  69419. private static _ConvertFactorToVector3OrQuaternion;
  69420. private static _SetInterpolatedValue;
  69421. /**
  69422. * Creates linear animation from the animation key frames
  69423. * @param babylonTransformNode BabylonJS mesh
  69424. * @param animation BabylonJS animation
  69425. * @param animationChannelTargetPath The target animation channel
  69426. * @param frameDelta The difference between the last and first frame of the animation
  69427. * @param inputs Array to store the key frame times
  69428. * @param outputs Array to store the key frame data
  69429. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69430. * @param useQuaternion Specifies if quaternions are used in the animation
  69431. */
  69432. private static _CreateLinearOrStepAnimation;
  69433. /**
  69434. * Creates cubic spline animation from the animation key frames
  69435. * @param babylonTransformNode BabylonJS mesh
  69436. * @param animation BabylonJS animation
  69437. * @param animationChannelTargetPath The target animation channel
  69438. * @param frameDelta The difference between the last and first frame of the animation
  69439. * @param inputs Array to store the key frame times
  69440. * @param outputs Array to store the key frame data
  69441. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69442. * @param useQuaternion Specifies if quaternions are used in the animation
  69443. */
  69444. private static _CreateCubicSplineAnimation;
  69445. private static _GetBasePositionRotationOrScale;
  69446. /**
  69447. * Adds a key frame value
  69448. * @param keyFrame
  69449. * @param animation
  69450. * @param outputs
  69451. * @param animationChannelTargetPath
  69452. * @param basePositionRotationOrScale
  69453. * @param convertToRightHandedSystem
  69454. * @param useQuaternion
  69455. */
  69456. private static _AddKeyframeValue;
  69457. /**
  69458. * Determine the interpolation based on the key frames
  69459. * @param keyFrames
  69460. * @param animationChannelTargetPath
  69461. * @param useQuaternion
  69462. */
  69463. private static _DeduceInterpolation;
  69464. /**
  69465. * Adds an input tangent or output tangent to the output data
  69466. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69467. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69468. * @param outputs The animation data by keyframe
  69469. * @param animationChannelTargetPath The target animation channel
  69470. * @param interpolation The interpolation type
  69471. * @param keyFrame The key frame with the animation data
  69472. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69473. * @param useQuaternion Specifies if quaternions are used
  69474. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69475. */
  69476. private static AddSplineTangent;
  69477. /**
  69478. * Get the minimum and maximum key frames' frame values
  69479. * @param keyFrames animation key frames
  69480. * @returns the minimum and maximum key frame value
  69481. */
  69482. private static calculateMinMaxKeyFrames;
  69483. }
  69484. }
  69485. declare module BABYLON.GLTF2.Exporter {
  69486. /** @hidden */
  69487. export var textureTransformPixelShader: {
  69488. name: string;
  69489. shader: string;
  69490. };
  69491. }
  69492. declare module BABYLON.GLTF2.Exporter.Extensions {
  69493. /**
  69494. * @hidden
  69495. */
  69496. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69497. /** Name of this extension */
  69498. readonly name: string;
  69499. /** Defines whether this extension is enabled */
  69500. enabled: boolean;
  69501. /** Defines whether this extension is required */
  69502. required: boolean;
  69503. /** Reference to the glTF exporter */
  69504. private _exporter;
  69505. constructor(exporter: _Exporter);
  69506. dispose(): void;
  69507. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69508. /**
  69509. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69510. * @param babylonTexture
  69511. * @param offset
  69512. * @param rotation
  69513. * @param scale
  69514. * @param scene
  69515. */
  69516. private _textureTransformTextureAsync;
  69517. }
  69518. }
  69519. declare module BABYLON.GLTF2.Exporter.Extensions {
  69520. /**
  69521. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69522. */
  69523. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69524. /** The name of this extension. */
  69525. readonly name: string;
  69526. /** Defines whether this extension is enabled. */
  69527. enabled: boolean;
  69528. /** Defines whether this extension is required */
  69529. required: boolean;
  69530. /** Reference to the glTF exporter */
  69531. private _exporter;
  69532. private _lights;
  69533. /** @hidden */
  69534. constructor(exporter: _Exporter);
  69535. /** @hidden */
  69536. dispose(): void;
  69537. /** @hidden */
  69538. onExporting(): void;
  69539. /**
  69540. * Define this method to modify the default behavior when exporting a node
  69541. * @param context The context when exporting the node
  69542. * @param node glTF node
  69543. * @param babylonNode BabylonJS node
  69544. * @returns nullable INode promise
  69545. */
  69546. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69547. }
  69548. }
  69549. declare module BABYLON {
  69550. /**
  69551. * Class for generating STL data from a Babylon scene.
  69552. */
  69553. export class STLExport {
  69554. /**
  69555. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69556. * @param meshes list defines the mesh to serialize
  69557. * @param download triggers the automatic download of the file.
  69558. * @param fileName changes the downloads fileName.
  69559. * @param binary changes the STL to a binary type.
  69560. * @param isLittleEndian toggle for binary type exporter.
  69561. * @returns the STL as UTF8 string
  69562. */
  69563. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69564. }
  69565. }
  69566. /**
  69567. * @ignoreChildren
  69568. * @ignore
  69569. */
  69570. declare module "babylonjs-gltf2interface" {
  69571. export = BABYLON.GLTF2;
  69572. }
  69573. /**
  69574. * Module for glTF 2.0 Interface
  69575. * @ignoreChildren
  69576. * @ignore
  69577. */
  69578. declare module BABYLON.GLTF2 {
  69579. /**
  69580. * The datatype of the components in the attribute
  69581. */
  69582. const enum AccessorComponentType {
  69583. /**
  69584. * Byte
  69585. */
  69586. BYTE = 5120,
  69587. /**
  69588. * Unsigned Byte
  69589. */
  69590. UNSIGNED_BYTE = 5121,
  69591. /**
  69592. * Short
  69593. */
  69594. SHORT = 5122,
  69595. /**
  69596. * Unsigned Short
  69597. */
  69598. UNSIGNED_SHORT = 5123,
  69599. /**
  69600. * Unsigned Int
  69601. */
  69602. UNSIGNED_INT = 5125,
  69603. /**
  69604. * Float
  69605. */
  69606. FLOAT = 5126,
  69607. }
  69608. /**
  69609. * Specifies if the attirbute is a scalar, vector, or matrix
  69610. */
  69611. const enum AccessorType {
  69612. /**
  69613. * Scalar
  69614. */
  69615. SCALAR = "SCALAR",
  69616. /**
  69617. * Vector2
  69618. */
  69619. VEC2 = "VEC2",
  69620. /**
  69621. * Vector3
  69622. */
  69623. VEC3 = "VEC3",
  69624. /**
  69625. * Vector4
  69626. */
  69627. VEC4 = "VEC4",
  69628. /**
  69629. * Matrix2x2
  69630. */
  69631. MAT2 = "MAT2",
  69632. /**
  69633. * Matrix3x3
  69634. */
  69635. MAT3 = "MAT3",
  69636. /**
  69637. * Matrix4x4
  69638. */
  69639. MAT4 = "MAT4",
  69640. }
  69641. /**
  69642. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69643. */
  69644. const enum AnimationChannelTargetPath {
  69645. /**
  69646. * Translation
  69647. */
  69648. TRANSLATION = "translation",
  69649. /**
  69650. * Rotation
  69651. */
  69652. ROTATION = "rotation",
  69653. /**
  69654. * Scale
  69655. */
  69656. SCALE = "scale",
  69657. /**
  69658. * Weights
  69659. */
  69660. WEIGHTS = "weights",
  69661. }
  69662. /**
  69663. * Interpolation algorithm
  69664. */
  69665. const enum AnimationSamplerInterpolation {
  69666. /**
  69667. * The animated values are linearly interpolated between keyframes
  69668. */
  69669. LINEAR = "LINEAR",
  69670. /**
  69671. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69672. */
  69673. STEP = "STEP",
  69674. /**
  69675. * The animation's interpolation is computed using a cubic spline with specified tangents
  69676. */
  69677. CUBICSPLINE = "CUBICSPLINE",
  69678. }
  69679. /**
  69680. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69681. */
  69682. const enum CameraType {
  69683. /**
  69684. * A perspective camera containing properties to create a perspective projection matrix
  69685. */
  69686. PERSPECTIVE = "perspective",
  69687. /**
  69688. * An orthographic camera containing properties to create an orthographic projection matrix
  69689. */
  69690. ORTHOGRAPHIC = "orthographic",
  69691. }
  69692. /**
  69693. * The mime-type of the image
  69694. */
  69695. const enum ImageMimeType {
  69696. /**
  69697. * JPEG Mime-type
  69698. */
  69699. JPEG = "image/jpeg",
  69700. /**
  69701. * PNG Mime-type
  69702. */
  69703. PNG = "image/png",
  69704. }
  69705. /**
  69706. * The alpha rendering mode of the material
  69707. */
  69708. const enum MaterialAlphaMode {
  69709. /**
  69710. * The alpha value is ignored and the rendered output is fully opaque
  69711. */
  69712. OPAQUE = "OPAQUE",
  69713. /**
  69714. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69715. */
  69716. MASK = "MASK",
  69717. /**
  69718. * 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)
  69719. */
  69720. BLEND = "BLEND",
  69721. }
  69722. /**
  69723. * The type of the primitives to render
  69724. */
  69725. const enum MeshPrimitiveMode {
  69726. /**
  69727. * Points
  69728. */
  69729. POINTS = 0,
  69730. /**
  69731. * Lines
  69732. */
  69733. LINES = 1,
  69734. /**
  69735. * Line Loop
  69736. */
  69737. LINE_LOOP = 2,
  69738. /**
  69739. * Line Strip
  69740. */
  69741. LINE_STRIP = 3,
  69742. /**
  69743. * Triangles
  69744. */
  69745. TRIANGLES = 4,
  69746. /**
  69747. * Triangle Strip
  69748. */
  69749. TRIANGLE_STRIP = 5,
  69750. /**
  69751. * Triangle Fan
  69752. */
  69753. TRIANGLE_FAN = 6,
  69754. }
  69755. /**
  69756. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69757. */
  69758. const enum TextureMagFilter {
  69759. /**
  69760. * Nearest
  69761. */
  69762. NEAREST = 9728,
  69763. /**
  69764. * Linear
  69765. */
  69766. LINEAR = 9729,
  69767. }
  69768. /**
  69769. * Minification filter. All valid values correspond to WebGL enums
  69770. */
  69771. const enum TextureMinFilter {
  69772. /**
  69773. * Nearest
  69774. */
  69775. NEAREST = 9728,
  69776. /**
  69777. * Linear
  69778. */
  69779. LINEAR = 9729,
  69780. /**
  69781. * Nearest Mip-Map Nearest
  69782. */
  69783. NEAREST_MIPMAP_NEAREST = 9984,
  69784. /**
  69785. * Linear Mipmap Nearest
  69786. */
  69787. LINEAR_MIPMAP_NEAREST = 9985,
  69788. /**
  69789. * Nearest Mipmap Linear
  69790. */
  69791. NEAREST_MIPMAP_LINEAR = 9986,
  69792. /**
  69793. * Linear Mipmap Linear
  69794. */
  69795. LINEAR_MIPMAP_LINEAR = 9987,
  69796. }
  69797. /**
  69798. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69799. */
  69800. const enum TextureWrapMode {
  69801. /**
  69802. * Clamp to Edge
  69803. */
  69804. CLAMP_TO_EDGE = 33071,
  69805. /**
  69806. * Mirrored Repeat
  69807. */
  69808. MIRRORED_REPEAT = 33648,
  69809. /**
  69810. * Repeat
  69811. */
  69812. REPEAT = 10497,
  69813. }
  69814. /**
  69815. * glTF Property
  69816. */
  69817. interface IProperty {
  69818. /**
  69819. * Dictionary object with extension-specific objects
  69820. */
  69821. extensions?: {
  69822. [key: string]: any;
  69823. };
  69824. /**
  69825. * Application-Specific data
  69826. */
  69827. extras?: any;
  69828. }
  69829. /**
  69830. * glTF Child of Root Property
  69831. */
  69832. interface IChildRootProperty extends IProperty {
  69833. /**
  69834. * The user-defined name of this object
  69835. */
  69836. name?: string;
  69837. }
  69838. /**
  69839. * Indices of those attributes that deviate from their initialization value
  69840. */
  69841. interface IAccessorSparseIndices extends IProperty {
  69842. /**
  69843. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69844. */
  69845. bufferView: number;
  69846. /**
  69847. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69848. */
  69849. byteOffset?: number;
  69850. /**
  69851. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69852. */
  69853. componentType: AccessorComponentType;
  69854. }
  69855. /**
  69856. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69857. */
  69858. interface IAccessorSparseValues extends IProperty {
  69859. /**
  69860. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69861. */
  69862. bufferView: number;
  69863. /**
  69864. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69865. */
  69866. byteOffset?: number;
  69867. }
  69868. /**
  69869. * Sparse storage of attributes that deviate from their initialization value
  69870. */
  69871. interface IAccessorSparse extends IProperty {
  69872. /**
  69873. * The number of attributes encoded in this sparse accessor
  69874. */
  69875. count: number;
  69876. /**
  69877. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69878. */
  69879. indices: IAccessorSparseIndices;
  69880. /**
  69881. * 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
  69882. */
  69883. values: IAccessorSparseValues;
  69884. }
  69885. /**
  69886. * 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
  69887. */
  69888. interface IAccessor extends IChildRootProperty {
  69889. /**
  69890. * The index of the bufferview
  69891. */
  69892. bufferView?: number;
  69893. /**
  69894. * The offset relative to the start of the bufferView in bytes
  69895. */
  69896. byteOffset?: number;
  69897. /**
  69898. * The datatype of components in the attribute
  69899. */
  69900. componentType: AccessorComponentType;
  69901. /**
  69902. * Specifies whether integer data values should be normalized
  69903. */
  69904. normalized?: boolean;
  69905. /**
  69906. * The number of attributes referenced by this accessor
  69907. */
  69908. count: number;
  69909. /**
  69910. * Specifies if the attribute is a scalar, vector, or matrix
  69911. */
  69912. type: AccessorType;
  69913. /**
  69914. * Maximum value of each component in this attribute
  69915. */
  69916. max?: number[];
  69917. /**
  69918. * Minimum value of each component in this attribute
  69919. */
  69920. min?: number[];
  69921. /**
  69922. * Sparse storage of attributes that deviate from their initialization value
  69923. */
  69924. sparse?: IAccessorSparse;
  69925. }
  69926. /**
  69927. * Targets an animation's sampler at a node's property
  69928. */
  69929. interface IAnimationChannel extends IProperty {
  69930. /**
  69931. * The index of a sampler in this animation used to compute the value for the target
  69932. */
  69933. sampler: number;
  69934. /**
  69935. * The index of the node and TRS property to target
  69936. */
  69937. target: IAnimationChannelTarget;
  69938. }
  69939. /**
  69940. * The index of the node and TRS property that an animation channel targets
  69941. */
  69942. interface IAnimationChannelTarget extends IProperty {
  69943. /**
  69944. * The index of the node to target
  69945. */
  69946. node: number;
  69947. /**
  69948. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69949. */
  69950. path: AnimationChannelTargetPath;
  69951. }
  69952. /**
  69953. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69954. */
  69955. interface IAnimationSampler extends IProperty {
  69956. /**
  69957. * The index of an accessor containing keyframe input values, e.g., time
  69958. */
  69959. input: number;
  69960. /**
  69961. * Interpolation algorithm
  69962. */
  69963. interpolation?: AnimationSamplerInterpolation;
  69964. /**
  69965. * The index of an accessor, containing keyframe output values
  69966. */
  69967. output: number;
  69968. }
  69969. /**
  69970. * A keyframe animation
  69971. */
  69972. interface IAnimation extends IChildRootProperty {
  69973. /**
  69974. * An array of channels, each of which targets an animation's sampler at a node's property
  69975. */
  69976. channels: IAnimationChannel[];
  69977. /**
  69978. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69979. */
  69980. samplers: IAnimationSampler[];
  69981. }
  69982. /**
  69983. * Metadata about the glTF asset
  69984. */
  69985. interface IAsset extends IChildRootProperty {
  69986. /**
  69987. * A copyright message suitable for display to credit the content creator
  69988. */
  69989. copyright?: string;
  69990. /**
  69991. * Tool that generated this glTF model. Useful for debugging
  69992. */
  69993. generator?: string;
  69994. /**
  69995. * The glTF version that this asset targets
  69996. */
  69997. version: string;
  69998. /**
  69999. * The minimum glTF version that this asset targets
  70000. */
  70001. minVersion?: string;
  70002. }
  70003. /**
  70004. * A buffer points to binary geometry, animation, or skins
  70005. */
  70006. interface IBuffer extends IChildRootProperty {
  70007. /**
  70008. * 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
  70009. */
  70010. uri?: string;
  70011. /**
  70012. * The length of the buffer in bytes
  70013. */
  70014. byteLength: number;
  70015. }
  70016. /**
  70017. * A view into a buffer generally representing a subset of the buffer
  70018. */
  70019. interface IBufferView extends IChildRootProperty {
  70020. /**
  70021. * The index of the buffer
  70022. */
  70023. buffer: number;
  70024. /**
  70025. * The offset into the buffer in bytes
  70026. */
  70027. byteOffset?: number;
  70028. /**
  70029. * The lenth of the bufferView in bytes
  70030. */
  70031. byteLength: number;
  70032. /**
  70033. * The stride, in bytes
  70034. */
  70035. byteStride?: number;
  70036. }
  70037. /**
  70038. * An orthographic camera containing properties to create an orthographic projection matrix
  70039. */
  70040. interface ICameraOrthographic extends IProperty {
  70041. /**
  70042. * The floating-point horizontal magnification of the view. Must not be zero
  70043. */
  70044. xmag: number;
  70045. /**
  70046. * The floating-point vertical magnification of the view. Must not be zero
  70047. */
  70048. ymag: number;
  70049. /**
  70050. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70051. */
  70052. zfar: number;
  70053. /**
  70054. * The floating-point distance to the near clipping plane
  70055. */
  70056. znear: number;
  70057. }
  70058. /**
  70059. * A perspective camera containing properties to create a perspective projection matrix
  70060. */
  70061. interface ICameraPerspective extends IProperty {
  70062. /**
  70063. * The floating-point aspect ratio of the field of view
  70064. */
  70065. aspectRatio?: number;
  70066. /**
  70067. * The floating-point vertical field of view in radians
  70068. */
  70069. yfov: number;
  70070. /**
  70071. * The floating-point distance to the far clipping plane
  70072. */
  70073. zfar?: number;
  70074. /**
  70075. * The floating-point distance to the near clipping plane
  70076. */
  70077. znear: number;
  70078. }
  70079. /**
  70080. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70081. */
  70082. interface ICamera extends IChildRootProperty {
  70083. /**
  70084. * An orthographic camera containing properties to create an orthographic projection matrix
  70085. */
  70086. orthographic?: ICameraOrthographic;
  70087. /**
  70088. * A perspective camera containing properties to create a perspective projection matrix
  70089. */
  70090. perspective?: ICameraPerspective;
  70091. /**
  70092. * Specifies if the camera uses a perspective or orthographic projection
  70093. */
  70094. type: CameraType;
  70095. }
  70096. /**
  70097. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70098. */
  70099. interface IImage extends IChildRootProperty {
  70100. /**
  70101. * 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
  70102. */
  70103. uri?: string;
  70104. /**
  70105. * The image's MIME type
  70106. */
  70107. mimeType?: ImageMimeType;
  70108. /**
  70109. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70110. */
  70111. bufferView?: number;
  70112. }
  70113. /**
  70114. * Material Normal Texture Info
  70115. */
  70116. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70117. /**
  70118. * The scalar multiplier applied to each normal vector of the normal texture
  70119. */
  70120. scale?: number;
  70121. }
  70122. /**
  70123. * Material Occlusion Texture Info
  70124. */
  70125. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70126. /**
  70127. * A scalar multiplier controlling the amount of occlusion applied
  70128. */
  70129. strength?: number;
  70130. }
  70131. /**
  70132. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70133. */
  70134. interface IMaterialPbrMetallicRoughness {
  70135. /**
  70136. * The material's base color factor
  70137. */
  70138. baseColorFactor?: number[];
  70139. /**
  70140. * The base color texture
  70141. */
  70142. baseColorTexture?: ITextureInfo;
  70143. /**
  70144. * The metalness of the material
  70145. */
  70146. metallicFactor?: number;
  70147. /**
  70148. * The roughness of the material
  70149. */
  70150. roughnessFactor?: number;
  70151. /**
  70152. * The metallic-roughness texture
  70153. */
  70154. metallicRoughnessTexture?: ITextureInfo;
  70155. }
  70156. /**
  70157. * The material appearance of a primitive
  70158. */
  70159. interface IMaterial extends IChildRootProperty {
  70160. /**
  70161. * 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
  70162. */
  70163. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70164. /**
  70165. * The normal map texture
  70166. */
  70167. normalTexture?: IMaterialNormalTextureInfo;
  70168. /**
  70169. * The occlusion map texture
  70170. */
  70171. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70172. /**
  70173. * The emissive map texture
  70174. */
  70175. emissiveTexture?: ITextureInfo;
  70176. /**
  70177. * 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
  70178. */
  70179. emissiveFactor?: number[];
  70180. /**
  70181. * The alpha rendering mode of the material
  70182. */
  70183. alphaMode?: MaterialAlphaMode;
  70184. /**
  70185. * The alpha cutoff value of the material
  70186. */
  70187. alphaCutoff?: number;
  70188. /**
  70189. * Specifies whether the material is double sided
  70190. */
  70191. doubleSided?: boolean;
  70192. }
  70193. /**
  70194. * Geometry to be rendered with the given material
  70195. */
  70196. interface IMeshPrimitive extends IProperty {
  70197. /**
  70198. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70199. */
  70200. attributes: {
  70201. [name: string]: number;
  70202. };
  70203. /**
  70204. * The index of the accessor that contains the indices
  70205. */
  70206. indices?: number;
  70207. /**
  70208. * The index of the material to apply to this primitive when rendering
  70209. */
  70210. material?: number;
  70211. /**
  70212. * The type of primitives to render. All valid values correspond to WebGL enums
  70213. */
  70214. mode?: MeshPrimitiveMode;
  70215. /**
  70216. * 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
  70217. */
  70218. targets?: {
  70219. [name: string]: number;
  70220. }[];
  70221. }
  70222. /**
  70223. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70224. */
  70225. interface IMesh extends IChildRootProperty {
  70226. /**
  70227. * An array of primitives, each defining geometry to be rendered with a material
  70228. */
  70229. primitives: IMeshPrimitive[];
  70230. /**
  70231. * Array of weights to be applied to the Morph Targets
  70232. */
  70233. weights?: number[];
  70234. }
  70235. /**
  70236. * A node in the node hierarchy
  70237. */
  70238. interface INode extends IChildRootProperty {
  70239. /**
  70240. * The index of the camera referenced by this node
  70241. */
  70242. camera?: number;
  70243. /**
  70244. * The indices of this node's children
  70245. */
  70246. children?: number[];
  70247. /**
  70248. * The index of the skin referenced by this node
  70249. */
  70250. skin?: number;
  70251. /**
  70252. * A floating-point 4x4 transformation matrix stored in column-major order
  70253. */
  70254. matrix?: number[];
  70255. /**
  70256. * The index of the mesh in this node
  70257. */
  70258. mesh?: number;
  70259. /**
  70260. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70261. */
  70262. rotation?: number[];
  70263. /**
  70264. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70265. */
  70266. scale?: number[];
  70267. /**
  70268. * The node's translation along the x, y, and z axes
  70269. */
  70270. translation?: number[];
  70271. /**
  70272. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70273. */
  70274. weights?: number[];
  70275. }
  70276. /**
  70277. * Texture sampler properties for filtering and wrapping modes
  70278. */
  70279. interface ISampler extends IChildRootProperty {
  70280. /**
  70281. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70282. */
  70283. magFilter?: TextureMagFilter;
  70284. /**
  70285. * Minification filter. All valid values correspond to WebGL enums
  70286. */
  70287. minFilter?: TextureMinFilter;
  70288. /**
  70289. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70290. */
  70291. wrapS?: TextureWrapMode;
  70292. /**
  70293. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70294. */
  70295. wrapT?: TextureWrapMode;
  70296. }
  70297. /**
  70298. * The root nodes of a scene
  70299. */
  70300. interface IScene extends IChildRootProperty {
  70301. /**
  70302. * The indices of each root node
  70303. */
  70304. nodes: number[];
  70305. }
  70306. /**
  70307. * Joints and matrices defining a skin
  70308. */
  70309. interface ISkin extends IChildRootProperty {
  70310. /**
  70311. * 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
  70312. */
  70313. inverseBindMatrices?: number;
  70314. /**
  70315. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70316. */
  70317. skeleton?: number;
  70318. /**
  70319. * 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)
  70320. */
  70321. joints: number[];
  70322. }
  70323. /**
  70324. * A texture and its sampler
  70325. */
  70326. interface ITexture extends IChildRootProperty {
  70327. /**
  70328. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70329. */
  70330. sampler?: number;
  70331. /**
  70332. * The index of the image used by this texture
  70333. */
  70334. source: number;
  70335. }
  70336. /**
  70337. * Reference to a texture
  70338. */
  70339. interface ITextureInfo extends IProperty {
  70340. /**
  70341. * The index of the texture
  70342. */
  70343. index: number;
  70344. /**
  70345. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70346. */
  70347. texCoord?: number;
  70348. }
  70349. /**
  70350. * The root object for a glTF asset
  70351. */
  70352. interface IGLTF extends IProperty {
  70353. /**
  70354. * An array of accessors. An accessor is a typed view into a bufferView
  70355. */
  70356. accessors?: IAccessor[];
  70357. /**
  70358. * An array of keyframe animations
  70359. */
  70360. animations?: IAnimation[];
  70361. /**
  70362. * Metadata about the glTF asset
  70363. */
  70364. asset: IAsset;
  70365. /**
  70366. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70367. */
  70368. buffers?: IBuffer[];
  70369. /**
  70370. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70371. */
  70372. bufferViews?: IBufferView[];
  70373. /**
  70374. * An array of cameras
  70375. */
  70376. cameras?: ICamera[];
  70377. /**
  70378. * Names of glTF extensions used somewhere in this asset
  70379. */
  70380. extensionsUsed?: string[];
  70381. /**
  70382. * Names of glTF extensions required to properly load this asset
  70383. */
  70384. extensionsRequired?: string[];
  70385. /**
  70386. * An array of images. An image defines data used to create a texture
  70387. */
  70388. images?: IImage[];
  70389. /**
  70390. * An array of materials. A material defines the appearance of a primitive
  70391. */
  70392. materials?: IMaterial[];
  70393. /**
  70394. * An array of meshes. A mesh is a set of primitives to be rendered
  70395. */
  70396. meshes?: IMesh[];
  70397. /**
  70398. * An array of nodes
  70399. */
  70400. nodes?: INode[];
  70401. /**
  70402. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70403. */
  70404. samplers?: ISampler[];
  70405. /**
  70406. * The index of the default scene
  70407. */
  70408. scene?: number;
  70409. /**
  70410. * An array of scenes
  70411. */
  70412. scenes?: IScene[];
  70413. /**
  70414. * An array of skins. A skin is defined by joints and matrices
  70415. */
  70416. skins?: ISkin[];
  70417. /**
  70418. * An array of textures
  70419. */
  70420. textures?: ITexture[];
  70421. }
  70422. /**
  70423. * The glTF validation results
  70424. */
  70425. interface IGLTFValidationResults {
  70426. info: {
  70427. generator: string;
  70428. hasAnimations: boolean;
  70429. hasDefaultScene: boolean;
  70430. hasMaterials: boolean;
  70431. hasMorphTargets: boolean;
  70432. hasSkins: boolean;
  70433. hasTextures: boolean;
  70434. maxAttributesUsed: number;
  70435. primitivesCount: number
  70436. };
  70437. issues: {
  70438. messages: Array<string>;
  70439. numErrors: number;
  70440. numHints: number;
  70441. numInfos: number;
  70442. numWarnings: number;
  70443. truncated: boolean
  70444. };
  70445. mimeType: string;
  70446. uri: string;
  70447. validatedAt: string;
  70448. validatorVersion: string;
  70449. }
  70450. /**
  70451. * The glTF validation options
  70452. */
  70453. interface IGLTFValidationOptions {
  70454. uri?: string;
  70455. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70456. validateAccessorData?: boolean;
  70457. maxIssues?: number;
  70458. ignoredIssues?: Array<string>;
  70459. severityOverrides?: Object;
  70460. }
  70461. /**
  70462. * The glTF validator object
  70463. */
  70464. interface IGLTFValidator {
  70465. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70466. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /** @hidden */
  70471. export var cellPixelShader: {
  70472. name: string;
  70473. shader: string;
  70474. };
  70475. }
  70476. declare module BABYLON {
  70477. /** @hidden */
  70478. export var cellVertexShader: {
  70479. name: string;
  70480. shader: string;
  70481. };
  70482. }
  70483. declare module BABYLON {
  70484. export class CellMaterial extends BABYLON.PushMaterial {
  70485. private _diffuseTexture;
  70486. diffuseTexture: BABYLON.BaseTexture;
  70487. diffuseColor: BABYLON.Color3;
  70488. _computeHighLevel: boolean;
  70489. computeHighLevel: boolean;
  70490. private _disableLighting;
  70491. disableLighting: boolean;
  70492. private _maxSimultaneousLights;
  70493. maxSimultaneousLights: number;
  70494. private _renderId;
  70495. constructor(name: string, scene: BABYLON.Scene);
  70496. needAlphaBlending(): boolean;
  70497. needAlphaTesting(): boolean;
  70498. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70499. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70500. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70501. getAnimatables(): BABYLON.IAnimatable[];
  70502. getActiveTextures(): BABYLON.BaseTexture[];
  70503. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70504. dispose(forceDisposeEffect?: boolean): void;
  70505. getClassName(): string;
  70506. clone(name: string): CellMaterial;
  70507. serialize(): any;
  70508. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70509. }
  70510. }
  70511. declare module BABYLON {
  70512. export class CustomShaderStructure {
  70513. FragmentStore: string;
  70514. VertexStore: string;
  70515. constructor();
  70516. }
  70517. export class ShaderSpecialParts {
  70518. constructor();
  70519. Fragment_Begin: string;
  70520. Fragment_Definitions: string;
  70521. Fragment_MainBegin: string;
  70522. Fragment_Custom_Diffuse: string;
  70523. Fragment_Before_Lights: string;
  70524. Fragment_Before_Fog: string;
  70525. Fragment_Custom_Alpha: string;
  70526. Fragment_Before_FragColor: string;
  70527. Vertex_Begin: string;
  70528. Vertex_Definitions: string;
  70529. Vertex_MainBegin: string;
  70530. Vertex_Before_PositionUpdated: string;
  70531. Vertex_Before_NormalUpdated: string;
  70532. Vertex_MainEnd: string;
  70533. }
  70534. export class CustomMaterial extends BABYLON.StandardMaterial {
  70535. static ShaderIndexer: number;
  70536. CustomParts: ShaderSpecialParts;
  70537. _isCreatedShader: boolean;
  70538. _createdShaderName: string;
  70539. _customUniform: string[];
  70540. _newUniforms: string[];
  70541. _newUniformInstances: any[];
  70542. _newSamplerInstances: BABYLON.Texture[];
  70543. FragmentShader: string;
  70544. VertexShader: string;
  70545. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70546. ReviewUniform(name: string, arr: string[]): string[];
  70547. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70548. constructor(name: string, scene: BABYLON.Scene);
  70549. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70550. Fragment_Begin(shaderPart: string): CustomMaterial;
  70551. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70552. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70553. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70554. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70555. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70556. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70557. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70558. Vertex_Begin(shaderPart: string): CustomMaterial;
  70559. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70560. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70561. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70562. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70563. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70564. }
  70565. }
  70566. declare module BABYLON {
  70567. export class ShaderAlebdoParts {
  70568. constructor();
  70569. Fragment_Begin: string;
  70570. Fragment_Definitions: string;
  70571. Fragment_MainBegin: string;
  70572. Fragment_Custom_Albedo: string;
  70573. Fragment_Before_Lights: string;
  70574. Fragment_Custom_MetallicRoughness: string;
  70575. Fragment_Custom_MicroSurface: string;
  70576. Fragment_Before_Fog: string;
  70577. Fragment_Custom_Alpha: string;
  70578. Fragment_Before_FragColor: string;
  70579. Vertex_Begin: string;
  70580. Vertex_Definitions: string;
  70581. Vertex_MainBegin: string;
  70582. Vertex_Before_PositionUpdated: string;
  70583. Vertex_Before_NormalUpdated: string;
  70584. Vertex_MainEnd: string;
  70585. }
  70586. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70587. static ShaderIndexer: number;
  70588. CustomParts: ShaderAlebdoParts;
  70589. _isCreatedShader: boolean;
  70590. _createdShaderName: string;
  70591. _customUniform: string[];
  70592. _newUniforms: string[];
  70593. _newUniformInstances: any[];
  70594. _newSamplerInstances: BABYLON.Texture[];
  70595. FragmentShader: string;
  70596. VertexShader: string;
  70597. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70598. ReviewUniform(name: string, arr: string[]): string[];
  70599. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70600. constructor(name: string, scene: BABYLON.Scene);
  70601. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70602. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70603. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70604. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70605. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70606. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70607. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70608. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70609. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70610. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70611. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70612. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70613. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70614. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70615. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70616. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70617. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70618. }
  70619. }
  70620. declare module BABYLON {
  70621. /** @hidden */
  70622. export var firePixelShader: {
  70623. name: string;
  70624. shader: string;
  70625. };
  70626. }
  70627. declare module BABYLON {
  70628. /** @hidden */
  70629. export var fireVertexShader: {
  70630. name: string;
  70631. shader: string;
  70632. };
  70633. }
  70634. declare module BABYLON {
  70635. export class FireMaterial extends BABYLON.PushMaterial {
  70636. private _diffuseTexture;
  70637. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70638. private _distortionTexture;
  70639. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70640. private _opacityTexture;
  70641. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70642. diffuseColor: BABYLON.Color3;
  70643. speed: number;
  70644. private _scaledDiffuse;
  70645. private _renderId;
  70646. private _lastTime;
  70647. constructor(name: string, scene: BABYLON.Scene);
  70648. needAlphaBlending(): boolean;
  70649. needAlphaTesting(): boolean;
  70650. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70651. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70652. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70653. getAnimatables(): BABYLON.IAnimatable[];
  70654. getActiveTextures(): BABYLON.BaseTexture[];
  70655. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70656. getClassName(): string;
  70657. dispose(forceDisposeEffect?: boolean): void;
  70658. clone(name: string): FireMaterial;
  70659. serialize(): any;
  70660. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70661. }
  70662. }
  70663. declare module BABYLON {
  70664. /** @hidden */
  70665. export var furPixelShader: {
  70666. name: string;
  70667. shader: string;
  70668. };
  70669. }
  70670. declare module BABYLON {
  70671. /** @hidden */
  70672. export var furVertexShader: {
  70673. name: string;
  70674. shader: string;
  70675. };
  70676. }
  70677. declare module BABYLON {
  70678. export class FurMaterial extends BABYLON.PushMaterial {
  70679. private _diffuseTexture;
  70680. diffuseTexture: BABYLON.BaseTexture;
  70681. private _heightTexture;
  70682. heightTexture: BABYLON.BaseTexture;
  70683. diffuseColor: BABYLON.Color3;
  70684. furLength: number;
  70685. furAngle: number;
  70686. furColor: BABYLON.Color3;
  70687. furOffset: number;
  70688. furSpacing: number;
  70689. furGravity: BABYLON.Vector3;
  70690. furSpeed: number;
  70691. furDensity: number;
  70692. furOcclusion: number;
  70693. furTexture: BABYLON.DynamicTexture;
  70694. private _disableLighting;
  70695. disableLighting: boolean;
  70696. private _maxSimultaneousLights;
  70697. maxSimultaneousLights: number;
  70698. highLevelFur: boolean;
  70699. _meshes: BABYLON.AbstractMesh[];
  70700. private _renderId;
  70701. private _furTime;
  70702. constructor(name: string, scene: BABYLON.Scene);
  70703. furTime: number;
  70704. needAlphaBlending(): boolean;
  70705. needAlphaTesting(): boolean;
  70706. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70707. updateFur(): void;
  70708. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70709. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70710. getAnimatables(): BABYLON.IAnimatable[];
  70711. getActiveTextures(): BABYLON.BaseTexture[];
  70712. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70713. dispose(forceDisposeEffect?: boolean): void;
  70714. clone(name: string): FurMaterial;
  70715. serialize(): any;
  70716. getClassName(): string;
  70717. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70718. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70719. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70720. }
  70721. }
  70722. declare module BABYLON {
  70723. /** @hidden */
  70724. export var gradientPixelShader: {
  70725. name: string;
  70726. shader: string;
  70727. };
  70728. }
  70729. declare module BABYLON {
  70730. /** @hidden */
  70731. export var gradientVertexShader: {
  70732. name: string;
  70733. shader: string;
  70734. };
  70735. }
  70736. declare module BABYLON {
  70737. export class GradientMaterial extends BABYLON.PushMaterial {
  70738. private _maxSimultaneousLights;
  70739. maxSimultaneousLights: number;
  70740. topColor: BABYLON.Color3;
  70741. topColorAlpha: number;
  70742. bottomColor: BABYLON.Color3;
  70743. bottomColorAlpha: number;
  70744. offset: number;
  70745. scale: number;
  70746. smoothness: number;
  70747. private _disableLighting;
  70748. disableLighting: boolean;
  70749. private _renderId;
  70750. constructor(name: string, scene: BABYLON.Scene);
  70751. needAlphaBlending(): boolean;
  70752. needAlphaTesting(): boolean;
  70753. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70754. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70755. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70756. getAnimatables(): BABYLON.IAnimatable[];
  70757. dispose(forceDisposeEffect?: boolean): void;
  70758. clone(name: string): GradientMaterial;
  70759. serialize(): any;
  70760. getClassName(): string;
  70761. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70762. }
  70763. }
  70764. declare module BABYLON {
  70765. /** @hidden */
  70766. export var gridPixelShader: {
  70767. name: string;
  70768. shader: string;
  70769. };
  70770. }
  70771. declare module BABYLON {
  70772. /** @hidden */
  70773. export var gridVertexShader: {
  70774. name: string;
  70775. shader: string;
  70776. };
  70777. }
  70778. declare module BABYLON {
  70779. /**
  70780. * The grid materials allows you to wrap any shape with a grid.
  70781. * Colors are customizable.
  70782. */
  70783. export class GridMaterial extends BABYLON.PushMaterial {
  70784. /**
  70785. * Main color of the grid (e.g. between lines)
  70786. */
  70787. mainColor: BABYLON.Color3;
  70788. /**
  70789. * Color of the grid lines.
  70790. */
  70791. lineColor: BABYLON.Color3;
  70792. /**
  70793. * The scale of the grid compared to unit.
  70794. */
  70795. gridRatio: number;
  70796. /**
  70797. * Allows setting an offset for the grid lines.
  70798. */
  70799. gridOffset: BABYLON.Vector3;
  70800. /**
  70801. * The frequency of thicker lines.
  70802. */
  70803. majorUnitFrequency: number;
  70804. /**
  70805. * The visibility of minor units in the grid.
  70806. */
  70807. minorUnitVisibility: number;
  70808. /**
  70809. * The grid opacity outside of the lines.
  70810. */
  70811. opacity: number;
  70812. /**
  70813. * Determine RBG output is premultiplied by alpha value.
  70814. */
  70815. preMultiplyAlpha: boolean;
  70816. private _opacityTexture;
  70817. opacityTexture: BABYLON.BaseTexture;
  70818. private _gridControl;
  70819. private _renderId;
  70820. /**
  70821. * constructor
  70822. * @param name The name given to the material in order to identify it afterwards.
  70823. * @param scene The scene the material is used in.
  70824. */
  70825. constructor(name: string, scene: BABYLON.Scene);
  70826. /**
  70827. * Returns wehter or not the grid requires alpha blending.
  70828. */
  70829. needAlphaBlending(): boolean;
  70830. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70831. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70832. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70833. /**
  70834. * Dispose the material and its associated resources.
  70835. * @param forceDisposeEffect will also dispose the used effect when true
  70836. */
  70837. dispose(forceDisposeEffect?: boolean): void;
  70838. clone(name: string): GridMaterial;
  70839. serialize(): any;
  70840. getClassName(): string;
  70841. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70842. }
  70843. }
  70844. declare module BABYLON {
  70845. /** @hidden */
  70846. export var lavaPixelShader: {
  70847. name: string;
  70848. shader: string;
  70849. };
  70850. }
  70851. declare module BABYLON {
  70852. /** @hidden */
  70853. export var lavaVertexShader: {
  70854. name: string;
  70855. shader: string;
  70856. };
  70857. }
  70858. declare module BABYLON {
  70859. export class LavaMaterial extends BABYLON.PushMaterial {
  70860. private _diffuseTexture;
  70861. diffuseTexture: BABYLON.BaseTexture;
  70862. noiseTexture: BABYLON.BaseTexture;
  70863. fogColor: BABYLON.Color3;
  70864. speed: number;
  70865. movingSpeed: number;
  70866. lowFrequencySpeed: number;
  70867. fogDensity: number;
  70868. private _lastTime;
  70869. diffuseColor: BABYLON.Color3;
  70870. private _disableLighting;
  70871. disableLighting: boolean;
  70872. private _unlit;
  70873. unlit: boolean;
  70874. private _maxSimultaneousLights;
  70875. maxSimultaneousLights: number;
  70876. private _scaledDiffuse;
  70877. private _renderId;
  70878. constructor(name: string, scene: BABYLON.Scene);
  70879. needAlphaBlending(): boolean;
  70880. needAlphaTesting(): boolean;
  70881. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70882. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70883. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70884. getAnimatables(): BABYLON.IAnimatable[];
  70885. getActiveTextures(): BABYLON.BaseTexture[];
  70886. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70887. dispose(forceDisposeEffect?: boolean): void;
  70888. clone(name: string): LavaMaterial;
  70889. serialize(): any;
  70890. getClassName(): string;
  70891. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70892. }
  70893. }
  70894. declare module BABYLON {
  70895. /** @hidden */
  70896. export var mixPixelShader: {
  70897. name: string;
  70898. shader: string;
  70899. };
  70900. }
  70901. declare module BABYLON {
  70902. /** @hidden */
  70903. export var mixVertexShader: {
  70904. name: string;
  70905. shader: string;
  70906. };
  70907. }
  70908. declare module BABYLON {
  70909. export class MixMaterial extends BABYLON.PushMaterial {
  70910. /**
  70911. * Mix textures
  70912. */
  70913. private _mixTexture1;
  70914. mixTexture1: BABYLON.BaseTexture;
  70915. private _mixTexture2;
  70916. mixTexture2: BABYLON.BaseTexture;
  70917. /**
  70918. * Diffuse textures
  70919. */
  70920. private _diffuseTexture1;
  70921. diffuseTexture1: BABYLON.Texture;
  70922. private _diffuseTexture2;
  70923. diffuseTexture2: BABYLON.Texture;
  70924. private _diffuseTexture3;
  70925. diffuseTexture3: BABYLON.Texture;
  70926. private _diffuseTexture4;
  70927. diffuseTexture4: BABYLON.Texture;
  70928. private _diffuseTexture5;
  70929. diffuseTexture5: BABYLON.Texture;
  70930. private _diffuseTexture6;
  70931. diffuseTexture6: BABYLON.Texture;
  70932. private _diffuseTexture7;
  70933. diffuseTexture7: BABYLON.Texture;
  70934. private _diffuseTexture8;
  70935. diffuseTexture8: BABYLON.Texture;
  70936. /**
  70937. * Uniforms
  70938. */
  70939. diffuseColor: BABYLON.Color3;
  70940. specularColor: BABYLON.Color3;
  70941. specularPower: number;
  70942. private _disableLighting;
  70943. disableLighting: boolean;
  70944. private _maxSimultaneousLights;
  70945. maxSimultaneousLights: number;
  70946. private _renderId;
  70947. constructor(name: string, scene: BABYLON.Scene);
  70948. needAlphaBlending(): boolean;
  70949. needAlphaTesting(): boolean;
  70950. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70951. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70952. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70953. getAnimatables(): BABYLON.IAnimatable[];
  70954. getActiveTextures(): BABYLON.BaseTexture[];
  70955. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70956. dispose(forceDisposeEffect?: boolean): void;
  70957. clone(name: string): MixMaterial;
  70958. serialize(): any;
  70959. getClassName(): string;
  70960. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70961. }
  70962. }
  70963. declare module BABYLON {
  70964. /** @hidden */
  70965. export var normalPixelShader: {
  70966. name: string;
  70967. shader: string;
  70968. };
  70969. }
  70970. declare module BABYLON {
  70971. /** @hidden */
  70972. export var normalVertexShader: {
  70973. name: string;
  70974. shader: string;
  70975. };
  70976. }
  70977. declare module BABYLON {
  70978. export class NormalMaterial extends BABYLON.PushMaterial {
  70979. private _diffuseTexture;
  70980. diffuseTexture: BABYLON.BaseTexture;
  70981. diffuseColor: BABYLON.Color3;
  70982. private _disableLighting;
  70983. disableLighting: boolean;
  70984. private _maxSimultaneousLights;
  70985. maxSimultaneousLights: number;
  70986. private _renderId;
  70987. constructor(name: string, scene: BABYLON.Scene);
  70988. needAlphaBlending(): boolean;
  70989. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70990. needAlphaTesting(): boolean;
  70991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70994. getAnimatables(): BABYLON.IAnimatable[];
  70995. getActiveTextures(): BABYLON.BaseTexture[];
  70996. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70997. dispose(forceDisposeEffect?: boolean): void;
  70998. clone(name: string): NormalMaterial;
  70999. serialize(): any;
  71000. getClassName(): string;
  71001. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71002. }
  71003. }
  71004. declare module BABYLON {
  71005. /** @hidden */
  71006. export var shadowOnlyPixelShader: {
  71007. name: string;
  71008. shader: string;
  71009. };
  71010. }
  71011. declare module BABYLON {
  71012. /** @hidden */
  71013. export var shadowOnlyVertexShader: {
  71014. name: string;
  71015. shader: string;
  71016. };
  71017. }
  71018. declare module BABYLON {
  71019. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71020. private _renderId;
  71021. private _activeLight;
  71022. constructor(name: string, scene: BABYLON.Scene);
  71023. shadowColor: BABYLON.Color3;
  71024. needAlphaBlending(): boolean;
  71025. needAlphaTesting(): boolean;
  71026. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71027. activeLight: BABYLON.IShadowLight;
  71028. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71029. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71030. clone(name: string): ShadowOnlyMaterial;
  71031. serialize(): any;
  71032. getClassName(): string;
  71033. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71034. }
  71035. }
  71036. declare module BABYLON {
  71037. /** @hidden */
  71038. export var simplePixelShader: {
  71039. name: string;
  71040. shader: string;
  71041. };
  71042. }
  71043. declare module BABYLON {
  71044. /** @hidden */
  71045. export var simpleVertexShader: {
  71046. name: string;
  71047. shader: string;
  71048. };
  71049. }
  71050. declare module BABYLON {
  71051. export class SimpleMaterial extends BABYLON.PushMaterial {
  71052. private _diffuseTexture;
  71053. diffuseTexture: BABYLON.BaseTexture;
  71054. diffuseColor: BABYLON.Color3;
  71055. private _disableLighting;
  71056. disableLighting: boolean;
  71057. private _maxSimultaneousLights;
  71058. maxSimultaneousLights: number;
  71059. private _renderId;
  71060. constructor(name: string, scene: BABYLON.Scene);
  71061. needAlphaBlending(): boolean;
  71062. needAlphaTesting(): boolean;
  71063. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71064. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71065. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71066. getAnimatables(): BABYLON.IAnimatable[];
  71067. getActiveTextures(): BABYLON.BaseTexture[];
  71068. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71069. dispose(forceDisposeEffect?: boolean): void;
  71070. clone(name: string): SimpleMaterial;
  71071. serialize(): any;
  71072. getClassName(): string;
  71073. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71074. }
  71075. }
  71076. declare module BABYLON {
  71077. /** @hidden */
  71078. export var skyPixelShader: {
  71079. name: string;
  71080. shader: string;
  71081. };
  71082. }
  71083. declare module BABYLON {
  71084. /** @hidden */
  71085. export var skyVertexShader: {
  71086. name: string;
  71087. shader: string;
  71088. };
  71089. }
  71090. declare module BABYLON {
  71091. /**
  71092. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71093. * @see https://doc.babylonjs.com/extensions/sky
  71094. */
  71095. export class SkyMaterial extends BABYLON.PushMaterial {
  71096. /**
  71097. * Defines the overall luminance of sky in interval ]0, 1[.
  71098. */
  71099. luminance: number;
  71100. /**
  71101. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71102. */
  71103. turbidity: number;
  71104. /**
  71105. * Defines the sky appearance (light intensity).
  71106. */
  71107. rayleigh: number;
  71108. /**
  71109. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71110. */
  71111. mieCoefficient: number;
  71112. /**
  71113. * Defines the amount of haze particles following the Mie scattering theory.
  71114. */
  71115. mieDirectionalG: number;
  71116. /**
  71117. * Defines the distance of the sun according to the active scene camera.
  71118. */
  71119. distance: number;
  71120. /**
  71121. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71122. * "inclined".
  71123. */
  71124. inclination: number;
  71125. /**
  71126. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71127. * an object direction and a reference direction.
  71128. */
  71129. azimuth: number;
  71130. /**
  71131. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71132. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71133. */
  71134. sunPosition: BABYLON.Vector3;
  71135. /**
  71136. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71137. * .sunPosition property.
  71138. */
  71139. useSunPosition: boolean;
  71140. /**
  71141. * Defines an offset vector used to get a horizon offset.
  71142. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71143. */
  71144. cameraOffset: BABYLON.Vector3;
  71145. private _cameraPosition;
  71146. private _renderId;
  71147. /**
  71148. * Instantiates a new sky material.
  71149. * This material allows to create dynamic and texture free
  71150. * effects for skyboxes by taking care of the atmosphere state.
  71151. * @see https://doc.babylonjs.com/extensions/sky
  71152. * @param name Define the name of the material in the scene
  71153. * @param scene Define the scene the material belong to
  71154. */
  71155. constructor(name: string, scene: BABYLON.Scene);
  71156. /**
  71157. * Specifies if the material will require alpha blending
  71158. * @returns a boolean specifying if alpha blending is needed
  71159. */
  71160. needAlphaBlending(): boolean;
  71161. /**
  71162. * Specifies if this material should be rendered in alpha test mode
  71163. * @returns false as the sky material doesn't need alpha testing.
  71164. */
  71165. needAlphaTesting(): boolean;
  71166. /**
  71167. * Get the texture used for alpha test purpose.
  71168. * @returns null as the sky material has no texture.
  71169. */
  71170. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71171. /**
  71172. * Get if the submesh is ready to be used and all its information available.
  71173. * Child classes can use it to update shaders
  71174. * @param mesh defines the mesh to check
  71175. * @param subMesh defines which submesh to check
  71176. * @param useInstances specifies that instances should be used
  71177. * @returns a boolean indicating that the submesh is ready or not
  71178. */
  71179. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71180. /**
  71181. * Binds the submesh to this material by preparing the effect and shader to draw
  71182. * @param world defines the world transformation matrix
  71183. * @param mesh defines the mesh containing the submesh
  71184. * @param subMesh defines the submesh to bind the material to
  71185. */
  71186. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71187. /**
  71188. * Get the list of animatables in the material.
  71189. * @returns the list of animatables object used in the material
  71190. */
  71191. getAnimatables(): BABYLON.IAnimatable[];
  71192. /**
  71193. * Disposes the material
  71194. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71195. */
  71196. dispose(forceDisposeEffect?: boolean): void;
  71197. /**
  71198. * Makes a duplicate of the material, and gives it a new name
  71199. * @param name defines the new name for the duplicated material
  71200. * @returns the cloned material
  71201. */
  71202. clone(name: string): SkyMaterial;
  71203. /**
  71204. * Serializes this material in a JSON representation
  71205. * @returns the serialized material object
  71206. */
  71207. serialize(): any;
  71208. /**
  71209. * Gets the current class name of the material e.g. "SkyMaterial"
  71210. * Mainly use in serialization.
  71211. * @returns the class name
  71212. */
  71213. getClassName(): string;
  71214. /**
  71215. * Creates a sky material from parsed material data
  71216. * @param source defines the JSON representation of the material
  71217. * @param scene defines the hosting scene
  71218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71219. * @returns a new sky material
  71220. */
  71221. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71222. }
  71223. }
  71224. declare module BABYLON {
  71225. /** @hidden */
  71226. export var terrainPixelShader: {
  71227. name: string;
  71228. shader: string;
  71229. };
  71230. }
  71231. declare module BABYLON {
  71232. /** @hidden */
  71233. export var terrainVertexShader: {
  71234. name: string;
  71235. shader: string;
  71236. };
  71237. }
  71238. declare module BABYLON {
  71239. export class TerrainMaterial extends BABYLON.PushMaterial {
  71240. private _mixTexture;
  71241. mixTexture: BABYLON.BaseTexture;
  71242. private _diffuseTexture1;
  71243. diffuseTexture1: BABYLON.Texture;
  71244. private _diffuseTexture2;
  71245. diffuseTexture2: BABYLON.Texture;
  71246. private _diffuseTexture3;
  71247. diffuseTexture3: BABYLON.Texture;
  71248. private _bumpTexture1;
  71249. bumpTexture1: BABYLON.Texture;
  71250. private _bumpTexture2;
  71251. bumpTexture2: BABYLON.Texture;
  71252. private _bumpTexture3;
  71253. bumpTexture3: BABYLON.Texture;
  71254. diffuseColor: BABYLON.Color3;
  71255. specularColor: BABYLON.Color3;
  71256. specularPower: number;
  71257. private _disableLighting;
  71258. disableLighting: boolean;
  71259. private _maxSimultaneousLights;
  71260. maxSimultaneousLights: number;
  71261. private _renderId;
  71262. constructor(name: string, scene: BABYLON.Scene);
  71263. needAlphaBlending(): boolean;
  71264. needAlphaTesting(): boolean;
  71265. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71266. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71267. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71268. getAnimatables(): BABYLON.IAnimatable[];
  71269. getActiveTextures(): BABYLON.BaseTexture[];
  71270. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71271. dispose(forceDisposeEffect?: boolean): void;
  71272. clone(name: string): TerrainMaterial;
  71273. serialize(): any;
  71274. getClassName(): string;
  71275. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71276. }
  71277. }
  71278. declare module BABYLON {
  71279. /** @hidden */
  71280. export var triplanarPixelShader: {
  71281. name: string;
  71282. shader: string;
  71283. };
  71284. }
  71285. declare module BABYLON {
  71286. /** @hidden */
  71287. export var triplanarVertexShader: {
  71288. name: string;
  71289. shader: string;
  71290. };
  71291. }
  71292. declare module BABYLON {
  71293. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71294. mixTexture: BABYLON.BaseTexture;
  71295. private _diffuseTextureX;
  71296. diffuseTextureX: BABYLON.BaseTexture;
  71297. private _diffuseTextureY;
  71298. diffuseTextureY: BABYLON.BaseTexture;
  71299. private _diffuseTextureZ;
  71300. diffuseTextureZ: BABYLON.BaseTexture;
  71301. private _normalTextureX;
  71302. normalTextureX: BABYLON.BaseTexture;
  71303. private _normalTextureY;
  71304. normalTextureY: BABYLON.BaseTexture;
  71305. private _normalTextureZ;
  71306. normalTextureZ: BABYLON.BaseTexture;
  71307. tileSize: number;
  71308. diffuseColor: BABYLON.Color3;
  71309. specularColor: BABYLON.Color3;
  71310. specularPower: number;
  71311. private _disableLighting;
  71312. disableLighting: boolean;
  71313. private _maxSimultaneousLights;
  71314. maxSimultaneousLights: number;
  71315. private _renderId;
  71316. constructor(name: string, scene: BABYLON.Scene);
  71317. needAlphaBlending(): boolean;
  71318. needAlphaTesting(): boolean;
  71319. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71320. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71321. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71322. getAnimatables(): BABYLON.IAnimatable[];
  71323. getActiveTextures(): BABYLON.BaseTexture[];
  71324. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71325. dispose(forceDisposeEffect?: boolean): void;
  71326. clone(name: string): TriPlanarMaterial;
  71327. serialize(): any;
  71328. getClassName(): string;
  71329. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71330. }
  71331. }
  71332. declare module BABYLON {
  71333. /** @hidden */
  71334. export var waterPixelShader: {
  71335. name: string;
  71336. shader: string;
  71337. };
  71338. }
  71339. declare module BABYLON {
  71340. /** @hidden */
  71341. export var waterVertexShader: {
  71342. name: string;
  71343. shader: string;
  71344. };
  71345. }
  71346. declare module BABYLON {
  71347. export class WaterMaterial extends BABYLON.PushMaterial {
  71348. renderTargetSize: BABYLON.Vector2;
  71349. private _bumpTexture;
  71350. bumpTexture: BABYLON.BaseTexture;
  71351. diffuseColor: BABYLON.Color3;
  71352. specularColor: BABYLON.Color3;
  71353. specularPower: number;
  71354. private _disableLighting;
  71355. disableLighting: boolean;
  71356. private _maxSimultaneousLights;
  71357. maxSimultaneousLights: number;
  71358. /**
  71359. * @param {number}: Represents the wind force
  71360. */
  71361. windForce: number;
  71362. /**
  71363. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71364. */
  71365. windDirection: BABYLON.Vector2;
  71366. /**
  71367. * @param {number}: Wave height, represents the height of the waves
  71368. */
  71369. waveHeight: number;
  71370. /**
  71371. * @param {number}: Bump height, represents the bump height related to the bump map
  71372. */
  71373. bumpHeight: number;
  71374. /**
  71375. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71376. */
  71377. private _bumpSuperimpose;
  71378. bumpSuperimpose: boolean;
  71379. /**
  71380. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71381. */
  71382. private _fresnelSeparate;
  71383. fresnelSeparate: boolean;
  71384. /**
  71385. * @param {boolean}: bump Waves modify the reflection.
  71386. */
  71387. private _bumpAffectsReflection;
  71388. bumpAffectsReflection: boolean;
  71389. /**
  71390. * @param {number}: The water color blended with the refraction (near)
  71391. */
  71392. waterColor: BABYLON.Color3;
  71393. /**
  71394. * @param {number}: The blend factor related to the water color
  71395. */
  71396. colorBlendFactor: number;
  71397. /**
  71398. * @param {number}: The water color blended with the reflection (far)
  71399. */
  71400. waterColor2: BABYLON.Color3;
  71401. /**
  71402. * @param {number}: The blend factor related to the water color (reflection, far)
  71403. */
  71404. colorBlendFactor2: number;
  71405. /**
  71406. * @param {number}: Represents the maximum length of a wave
  71407. */
  71408. waveLength: number;
  71409. /**
  71410. * @param {number}: Defines the waves speed
  71411. */
  71412. waveSpeed: number;
  71413. /**
  71414. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71415. * will avoid calculating useless pixels in the pixel shader of the water material.
  71416. */
  71417. disableClipPlane: boolean;
  71418. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71419. private _mesh;
  71420. private _refractionRTT;
  71421. private _reflectionRTT;
  71422. private _reflectionTransform;
  71423. private _lastTime;
  71424. private _lastDeltaTime;
  71425. private _renderId;
  71426. private _useLogarithmicDepth;
  71427. private _waitingRenderList;
  71428. private _imageProcessingConfiguration;
  71429. private _imageProcessingObserver;
  71430. /**
  71431. * Gets a boolean indicating that current material needs to register RTT
  71432. */
  71433. readonly hasRenderTargetTextures: boolean;
  71434. /**
  71435. * Constructor
  71436. */
  71437. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71438. useLogarithmicDepth: boolean;
  71439. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71440. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71441. addToRenderList(node: any): void;
  71442. enableRenderTargets(enable: boolean): void;
  71443. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71444. readonly renderTargetsEnabled: boolean;
  71445. needAlphaBlending(): boolean;
  71446. needAlphaTesting(): boolean;
  71447. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71449. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71450. private _createRenderTargets;
  71451. getAnimatables(): BABYLON.IAnimatable[];
  71452. getActiveTextures(): BABYLON.BaseTexture[];
  71453. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71454. dispose(forceDisposeEffect?: boolean): void;
  71455. clone(name: string): WaterMaterial;
  71456. serialize(): any;
  71457. getClassName(): string;
  71458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71459. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71460. }
  71461. }
  71462. declare module BABYLON {
  71463. /** @hidden */
  71464. export var asciiartPixelShader: {
  71465. name: string;
  71466. shader: string;
  71467. };
  71468. }
  71469. declare module BABYLON {
  71470. /**
  71471. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71472. *
  71473. * It basically takes care rendering the font front the given font size to a texture.
  71474. * This is used later on in the postprocess.
  71475. */
  71476. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71477. private _font;
  71478. private _text;
  71479. private _charSize;
  71480. /**
  71481. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71482. */
  71483. readonly charSize: number;
  71484. /**
  71485. * Create a new instance of the Ascii Art FontTexture class
  71486. * @param name the name of the texture
  71487. * @param font the font to use, use the W3C CSS notation
  71488. * @param text the caracter set to use in the rendering.
  71489. * @param scene the scene that owns the texture
  71490. */
  71491. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71492. /**
  71493. * Gets the max char width of a font.
  71494. * @param font the font to use, use the W3C CSS notation
  71495. * @return the max char width
  71496. */
  71497. private getFontWidth;
  71498. /**
  71499. * Gets the max char height of a font.
  71500. * @param font the font to use, use the W3C CSS notation
  71501. * @return the max char height
  71502. */
  71503. private getFontHeight;
  71504. /**
  71505. * Clones the current AsciiArtTexture.
  71506. * @return the clone of the texture.
  71507. */
  71508. clone(): AsciiArtFontTexture;
  71509. /**
  71510. * Parses a json object representing the texture and returns an instance of it.
  71511. * @param source the source JSON representation
  71512. * @param scene the scene to create the texture for
  71513. * @return the parsed texture
  71514. */
  71515. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71516. }
  71517. /**
  71518. * Option available in the Ascii Art Post Process.
  71519. */
  71520. export interface IAsciiArtPostProcessOptions {
  71521. /**
  71522. * The font to use following the w3c font definition.
  71523. */
  71524. font?: string;
  71525. /**
  71526. * The character set to use in the postprocess.
  71527. */
  71528. characterSet?: string;
  71529. /**
  71530. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71531. * This number is defined between 0 and 1;
  71532. */
  71533. mixToTile?: number;
  71534. /**
  71535. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71536. * This number is defined between 0 and 1;
  71537. */
  71538. mixToNormal?: number;
  71539. }
  71540. /**
  71541. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71542. *
  71543. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71544. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71545. */
  71546. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71547. /**
  71548. * The font texture used to render the char in the post process.
  71549. */
  71550. private _asciiArtFontTexture;
  71551. /**
  71552. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71553. * This number is defined between 0 and 1;
  71554. */
  71555. mixToTile: number;
  71556. /**
  71557. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71558. * This number is defined between 0 and 1;
  71559. */
  71560. mixToNormal: number;
  71561. /**
  71562. * Instantiates a new Ascii Art Post Process.
  71563. * @param name the name to give to the postprocess
  71564. * @camera the camera to apply the post process to.
  71565. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71566. */
  71567. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71568. }
  71569. }
  71570. declare module BABYLON {
  71571. /** @hidden */
  71572. export var digitalrainPixelShader: {
  71573. name: string;
  71574. shader: string;
  71575. };
  71576. }
  71577. declare module BABYLON {
  71578. /**
  71579. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71580. *
  71581. * It basically takes care rendering the font front the given font size to a texture.
  71582. * This is used later on in the postprocess.
  71583. */
  71584. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71585. private _font;
  71586. private _text;
  71587. private _charSize;
  71588. /**
  71589. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71590. */
  71591. readonly charSize: number;
  71592. /**
  71593. * Create a new instance of the Digital Rain FontTexture class
  71594. * @param name the name of the texture
  71595. * @param font the font to use, use the W3C CSS notation
  71596. * @param text the caracter set to use in the rendering.
  71597. * @param scene the scene that owns the texture
  71598. */
  71599. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71600. /**
  71601. * Gets the max char width of a font.
  71602. * @param font the font to use, use the W3C CSS notation
  71603. * @return the max char width
  71604. */
  71605. private getFontWidth;
  71606. /**
  71607. * Gets the max char height of a font.
  71608. * @param font the font to use, use the W3C CSS notation
  71609. * @return the max char height
  71610. */
  71611. private getFontHeight;
  71612. /**
  71613. * Clones the current DigitalRainFontTexture.
  71614. * @return the clone of the texture.
  71615. */
  71616. clone(): DigitalRainFontTexture;
  71617. /**
  71618. * Parses a json object representing the texture and returns an instance of it.
  71619. * @param source the source JSON representation
  71620. * @param scene the scene to create the texture for
  71621. * @return the parsed texture
  71622. */
  71623. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71624. }
  71625. /**
  71626. * Option available in the Digital Rain Post Process.
  71627. */
  71628. export interface IDigitalRainPostProcessOptions {
  71629. /**
  71630. * The font to use following the w3c font definition.
  71631. */
  71632. font?: string;
  71633. /**
  71634. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71635. * This number is defined between 0 and 1;
  71636. */
  71637. mixToTile?: number;
  71638. /**
  71639. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71640. * This number is defined between 0 and 1;
  71641. */
  71642. mixToNormal?: number;
  71643. }
  71644. /**
  71645. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71646. *
  71647. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71648. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71649. */
  71650. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71651. /**
  71652. * The font texture used to render the char in the post process.
  71653. */
  71654. private _digitalRainFontTexture;
  71655. /**
  71656. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71657. * This number is defined between 0 and 1;
  71658. */
  71659. mixToTile: number;
  71660. /**
  71661. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71662. * This number is defined between 0 and 1;
  71663. */
  71664. mixToNormal: number;
  71665. /**
  71666. * Instantiates a new Digital Rain Post Process.
  71667. * @param name the name to give to the postprocess
  71668. * @camera the camera to apply the post process to.
  71669. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71670. */
  71671. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71672. }
  71673. }
  71674. declare module BABYLON {
  71675. /** @hidden */
  71676. export var oceanPostProcessPixelShader: {
  71677. name: string;
  71678. shader: string;
  71679. };
  71680. }
  71681. declare module BABYLON {
  71682. /**
  71683. * Option available in the Ocean Post Process.
  71684. */
  71685. export interface IOceanPostProcessOptions {
  71686. /**
  71687. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71688. */
  71689. reflectionSize?: number | {
  71690. width: number;
  71691. height: number;
  71692. } | {
  71693. ratio: number;
  71694. };
  71695. /**
  71696. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71697. */
  71698. refractionSize?: number | {
  71699. width: number;
  71700. height: number;
  71701. } | {
  71702. ratio: number;
  71703. };
  71704. }
  71705. /**
  71706. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71707. *
  71708. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71709. * Example usage:
  71710. * var pp = new OceanPostProcess("myOcean", camera);
  71711. * pp.reflectionEnabled = true;
  71712. * pp.refractionEnabled = true;
  71713. */
  71714. export class OceanPostProcess extends BABYLON.PostProcess {
  71715. /**
  71716. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71717. */
  71718. /**
  71719. * Sets weither or not the real-time reflection is enabled on the ocean.
  71720. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71721. */
  71722. reflectionEnabled: boolean;
  71723. /**
  71724. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71725. */
  71726. /**
  71727. * Sets weither or not the real-time refraction is enabled on the ocean.
  71728. * Is set to true, the refraction render target texture will be used as refraction texture.
  71729. */
  71730. refractionEnabled: boolean;
  71731. /**
  71732. * Gets wether or not the post-processes is supported by the running hardware.
  71733. * This requires draw buffer supports.
  71734. */
  71735. readonly isSupported: boolean;
  71736. /**
  71737. * This is the reflection mirror texture used to display reflections on the ocean.
  71738. * By default, render list is empty.
  71739. */
  71740. reflectionTexture: BABYLON.MirrorTexture;
  71741. /**
  71742. * This is the refraction render target texture used to display refraction on the ocean.
  71743. * By default, render list is empty.
  71744. */
  71745. refractionTexture: BABYLON.RenderTargetTexture;
  71746. private _time;
  71747. private _cameraRotation;
  71748. private _cameraViewMatrix;
  71749. private _reflectionEnabled;
  71750. private _refractionEnabled;
  71751. private _geometryRenderer;
  71752. /**
  71753. * Instantiates a new Ocean Post Process.
  71754. * @param name the name to give to the postprocess.
  71755. * @camera the camera to apply the post process to.
  71756. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71757. */
  71758. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71759. /**
  71760. * Returns the appropriate defines according to the current configuration.
  71761. */
  71762. private _getDefines;
  71763. /**
  71764. * Computes the current camera rotation as the shader requires a camera rotation.
  71765. */
  71766. private _computeCameraRotation;
  71767. }
  71768. }
  71769. declare module BABYLON {
  71770. /** @hidden */
  71771. export var brickProceduralTexturePixelShader: {
  71772. name: string;
  71773. shader: string;
  71774. };
  71775. }
  71776. declare module BABYLON {
  71777. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71778. private _numberOfBricksHeight;
  71779. private _numberOfBricksWidth;
  71780. private _jointColor;
  71781. private _brickColor;
  71782. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71783. updateShaderUniforms(): void;
  71784. numberOfBricksHeight: number;
  71785. numberOfBricksWidth: number;
  71786. jointColor: BABYLON.Color3;
  71787. brickColor: BABYLON.Color3;
  71788. /**
  71789. * Serializes this brick procedural texture
  71790. * @returns a serialized brick procedural texture object
  71791. */
  71792. serialize(): any;
  71793. /**
  71794. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71795. * @param parsedTexture defines parsed texture data
  71796. * @param scene defines the current scene
  71797. * @param rootUrl defines the root URL containing brick procedural texture information
  71798. * @returns a parsed Brick Procedural BABYLON.Texture
  71799. */
  71800. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71801. }
  71802. }
  71803. declare module BABYLON {
  71804. /** @hidden */
  71805. export var cloudProceduralTexturePixelShader: {
  71806. name: string;
  71807. shader: string;
  71808. };
  71809. }
  71810. declare module BABYLON {
  71811. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71812. private _skyColor;
  71813. private _cloudColor;
  71814. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71815. updateShaderUniforms(): void;
  71816. skyColor: BABYLON.Color4;
  71817. cloudColor: BABYLON.Color4;
  71818. /**
  71819. * Serializes this cloud procedural texture
  71820. * @returns a serialized cloud procedural texture object
  71821. */
  71822. serialize(): any;
  71823. /**
  71824. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71825. * @param parsedTexture defines parsed texture data
  71826. * @param scene defines the current scene
  71827. * @param rootUrl defines the root URL containing cloud procedural texture information
  71828. * @returns a parsed Cloud Procedural BABYLON.Texture
  71829. */
  71830. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71831. }
  71832. }
  71833. declare module BABYLON {
  71834. /** @hidden */
  71835. export var fireProceduralTexturePixelShader: {
  71836. name: string;
  71837. shader: string;
  71838. };
  71839. }
  71840. declare module BABYLON {
  71841. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71842. private _time;
  71843. private _speed;
  71844. private _autoGenerateTime;
  71845. private _fireColors;
  71846. private _alphaThreshold;
  71847. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71848. updateShaderUniforms(): void;
  71849. render(useCameraPostProcess?: boolean): void;
  71850. static readonly PurpleFireColors: BABYLON.Color3[];
  71851. static readonly GreenFireColors: BABYLON.Color3[];
  71852. static readonly RedFireColors: BABYLON.Color3[];
  71853. static readonly BlueFireColors: BABYLON.Color3[];
  71854. autoGenerateTime: boolean;
  71855. fireColors: BABYLON.Color3[];
  71856. time: number;
  71857. speed: BABYLON.Vector2;
  71858. alphaThreshold: number;
  71859. /**
  71860. * Serializes this fire procedural texture
  71861. * @returns a serialized fire procedural texture object
  71862. */
  71863. serialize(): any;
  71864. /**
  71865. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71866. * @param parsedTexture defines parsed texture data
  71867. * @param scene defines the current scene
  71868. * @param rootUrl defines the root URL containing fire procedural texture information
  71869. * @returns a parsed Fire Procedural BABYLON.Texture
  71870. */
  71871. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71872. }
  71873. }
  71874. declare module BABYLON {
  71875. /** @hidden */
  71876. export var grassProceduralTexturePixelShader: {
  71877. name: string;
  71878. shader: string;
  71879. };
  71880. }
  71881. declare module BABYLON {
  71882. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71883. private _grassColors;
  71884. private _groundColor;
  71885. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71886. updateShaderUniforms(): void;
  71887. grassColors: BABYLON.Color3[];
  71888. groundColor: BABYLON.Color3;
  71889. /**
  71890. * Serializes this grass procedural texture
  71891. * @returns a serialized grass procedural texture object
  71892. */
  71893. serialize(): any;
  71894. /**
  71895. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71896. * @param parsedTexture defines parsed texture data
  71897. * @param scene defines the current scene
  71898. * @param rootUrl defines the root URL containing grass procedural texture information
  71899. * @returns a parsed Grass Procedural BABYLON.Texture
  71900. */
  71901. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /** @hidden */
  71906. export var marbleProceduralTexturePixelShader: {
  71907. name: string;
  71908. shader: string;
  71909. };
  71910. }
  71911. declare module BABYLON {
  71912. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71913. private _numberOfTilesHeight;
  71914. private _numberOfTilesWidth;
  71915. private _amplitude;
  71916. private _jointColor;
  71917. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71918. updateShaderUniforms(): void;
  71919. numberOfTilesHeight: number;
  71920. amplitude: number;
  71921. numberOfTilesWidth: number;
  71922. jointColor: BABYLON.Color3;
  71923. /**
  71924. * Serializes this marble procedural texture
  71925. * @returns a serialized marble procedural texture object
  71926. */
  71927. serialize(): any;
  71928. /**
  71929. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71930. * @param parsedTexture defines parsed texture data
  71931. * @param scene defines the current scene
  71932. * @param rootUrl defines the root URL containing marble procedural texture information
  71933. * @returns a parsed Marble Procedural BABYLON.Texture
  71934. */
  71935. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71936. }
  71937. }
  71938. declare module BABYLON {
  71939. /** @hidden */
  71940. export var normalMapProceduralTexturePixelShader: {
  71941. name: string;
  71942. shader: string;
  71943. };
  71944. }
  71945. declare module BABYLON {
  71946. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71947. private _baseTexture;
  71948. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71949. updateShaderUniforms(): void;
  71950. render(useCameraPostProcess?: boolean): void;
  71951. resize(size: any, generateMipMaps: any): void;
  71952. baseTexture: BABYLON.Texture;
  71953. /**
  71954. * Serializes this normal map procedural texture
  71955. * @returns a serialized normal map procedural texture object
  71956. */
  71957. serialize(): any;
  71958. /**
  71959. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71960. * @param parsedTexture defines parsed texture data
  71961. * @param scene defines the current scene
  71962. * @param rootUrl defines the root URL containing normal map procedural texture information
  71963. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71964. */
  71965. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71966. }
  71967. }
  71968. declare module BABYLON {
  71969. /** @hidden */
  71970. export var perlinNoiseProceduralTexturePixelShader: {
  71971. name: string;
  71972. shader: string;
  71973. };
  71974. }
  71975. declare module BABYLON {
  71976. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71977. time: number;
  71978. timeScale: number;
  71979. translationSpeed: number;
  71980. private _currentTranslation;
  71981. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71982. updateShaderUniforms(): void;
  71983. render(useCameraPostProcess?: boolean): void;
  71984. resize(size: any, generateMipMaps: any): void;
  71985. /**
  71986. * Serializes this perlin noise procedural texture
  71987. * @returns a serialized perlin noise procedural texture object
  71988. */
  71989. serialize(): any;
  71990. /**
  71991. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71992. * @param parsedTexture defines parsed texture data
  71993. * @param scene defines the current scene
  71994. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71995. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71996. */
  71997. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71998. }
  71999. }
  72000. declare module BABYLON {
  72001. /** @hidden */
  72002. export var roadProceduralTexturePixelShader: {
  72003. name: string;
  72004. shader: string;
  72005. };
  72006. }
  72007. declare module BABYLON {
  72008. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72009. private _roadColor;
  72010. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72011. updateShaderUniforms(): void;
  72012. roadColor: BABYLON.Color3;
  72013. /**
  72014. * Serializes this road procedural texture
  72015. * @returns a serialized road procedural texture object
  72016. */
  72017. serialize(): any;
  72018. /**
  72019. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72020. * @param parsedTexture defines parsed texture data
  72021. * @param scene defines the current scene
  72022. * @param rootUrl defines the root URL containing road procedural texture information
  72023. * @returns a parsed Road Procedural BABYLON.Texture
  72024. */
  72025. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72026. }
  72027. }
  72028. declare module BABYLON {
  72029. /** @hidden */
  72030. export var starfieldProceduralTexturePixelShader: {
  72031. name: string;
  72032. shader: string;
  72033. };
  72034. }
  72035. declare module BABYLON {
  72036. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72037. private _time;
  72038. private _alpha;
  72039. private _beta;
  72040. private _zoom;
  72041. private _formuparam;
  72042. private _stepsize;
  72043. private _tile;
  72044. private _brightness;
  72045. private _darkmatter;
  72046. private _distfading;
  72047. private _saturation;
  72048. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72049. updateShaderUniforms(): void;
  72050. time: number;
  72051. alpha: number;
  72052. beta: number;
  72053. formuparam: number;
  72054. stepsize: number;
  72055. zoom: number;
  72056. tile: number;
  72057. brightness: number;
  72058. darkmatter: number;
  72059. distfading: number;
  72060. saturation: number;
  72061. /**
  72062. * Serializes this starfield procedural texture
  72063. * @returns a serialized starfield procedural texture object
  72064. */
  72065. serialize(): any;
  72066. /**
  72067. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72068. * @param parsedTexture defines parsed texture data
  72069. * @param scene defines the current scene
  72070. * @param rootUrl defines the root URL containing startfield procedural texture information
  72071. * @returns a parsed Starfield Procedural BABYLON.Texture
  72072. */
  72073. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72074. }
  72075. }
  72076. declare module BABYLON {
  72077. /** @hidden */
  72078. export var woodProceduralTexturePixelShader: {
  72079. name: string;
  72080. shader: string;
  72081. };
  72082. }
  72083. declare module BABYLON {
  72084. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72085. private _ampScale;
  72086. private _woodColor;
  72087. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72088. updateShaderUniforms(): void;
  72089. ampScale: number;
  72090. woodColor: BABYLON.Color3;
  72091. /**
  72092. * Serializes this wood procedural texture
  72093. * @returns a serialized wood procedural texture object
  72094. */
  72095. serialize(): any;
  72096. /**
  72097. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72098. * @param parsedTexture defines parsed texture data
  72099. * @param scene defines the current scene
  72100. * @param rootUrl defines the root URL containing wood procedural texture information
  72101. * @returns a parsed Wood Procedural BABYLON.Texture
  72102. */
  72103. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72104. }
  72105. }