documentation.d.ts 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113
  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. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * 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)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * 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
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. 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;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * 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"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * 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".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * 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"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * 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".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * 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.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * 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.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * 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).
  4349. * 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.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Creates a new observable
  4357. * @param onObserverAdded defines a callback to call when a new observer is added
  4358. */
  4359. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4360. /**
  4361. * Create a new Observer with the specified callback
  4362. * @param callback the callback that will be executed for that Observer
  4363. * @param mask the mask used to filter observers
  4364. * @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.
  4365. * @param scope optional scope for the callback to be called from
  4366. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4367. * @returns the new observer created for the callback
  4368. */
  4369. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4370. /**
  4371. * Create a new Observer with the specified callback and unregisters after the next notification
  4372. * @param callback the callback that will be executed for that Observer
  4373. * @returns the new observer created for the callback
  4374. */
  4375. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4376. /**
  4377. * Remove an Observer from the Observable object
  4378. * @param observer the instance of the Observer to remove
  4379. * @returns false if it doesn't belong to this Observable
  4380. */
  4381. remove(observer: Nullable<Observer<T>>): boolean;
  4382. /**
  4383. * Remove a callback from the Observable object
  4384. * @param callback the callback to remove
  4385. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4389. private _deferUnregister;
  4390. private _remove;
  4391. /**
  4392. * Moves the observable to the top of the observer list making it get called first when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverTopPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Moves the observable to the bottom of the observer list making it get called last when notified
  4398. * @param observer the observer to move
  4399. */
  4400. makeObserverBottomPriority(observer: Observer<T>): void;
  4401. /**
  4402. * Notify all Observers by calling their respective callback with the given data
  4403. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4404. * @param eventData defines the data to send to all observers
  4405. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4406. * @param target defines the original target of the state
  4407. * @param currentTarget defines the current target of the state
  4408. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4409. */
  4410. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4411. /**
  4412. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4413. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4414. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4415. * and it is crucial that all callbacks will be executed.
  4416. * The order of the callbacks is kept, callbacks are not executed parallel.
  4417. *
  4418. * @param eventData The data to be sent to each callback
  4419. * @param mask is used to filter observers defaults to -1
  4420. * @param target defines the callback target (see EventState)
  4421. * @param currentTarget defines he current object in the bubbling phase
  4422. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4423. */
  4424. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4425. /**
  4426. * Notify a specific observer
  4427. * @param observer defines the observer to notify
  4428. * @param eventData defines the data to be sent to each callback
  4429. * @param mask is used to filter observers defaults to -1
  4430. */
  4431. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4432. /**
  4433. * Gets a boolean indicating if the observable has at least one observer
  4434. * @returns true is the Observable has at least one Observer registered
  4435. */
  4436. hasObservers(): boolean;
  4437. /**
  4438. * Clear the list of observers
  4439. */
  4440. clear(): void;
  4441. /**
  4442. * Clone the current observable
  4443. * @returns a new observable
  4444. */
  4445. clone(): Observable<T>;
  4446. /**
  4447. * Does this observable handles observer registered with a given mask
  4448. * @param mask defines the mask to be tested
  4449. * @return whether or not one observer registered with the given mask is handeled
  4450. **/
  4451. hasSpecificMask(mask?: number): boolean;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Class used to help managing file picking and drag'n'drop
  4457. * File Storage
  4458. */
  4459. export class FilesInputStore {
  4460. /**
  4461. * List of files ready to be loaded
  4462. */
  4463. static FilesToLoad: {
  4464. [key: string]: File;
  4465. };
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** Defines the cross module used constants to avoid circular dependncies */
  4470. export class Constants {
  4471. /** Defines that alpha blending is disabled */
  4472. static readonly ALPHA_DISABLE: number;
  4473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4474. static readonly ALPHA_ADD: number;
  4475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4476. static readonly ALPHA_COMBINE: number;
  4477. /** Defines that alpha blending to DEST - SRC * DEST */
  4478. static readonly ALPHA_SUBTRACT: number;
  4479. /** Defines that alpha blending to SRC * DEST */
  4480. static readonly ALPHA_MULTIPLY: number;
  4481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4482. static readonly ALPHA_MAXIMIZED: number;
  4483. /** Defines that alpha blending to SRC + DEST */
  4484. static readonly ALPHA_ONEONE: number;
  4485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4486. static readonly ALPHA_PREMULTIPLIED: number;
  4487. /**
  4488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4490. */
  4491. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4493. static readonly ALPHA_INTERPOLATE: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_SCREENMODE: number;
  4499. /** Defines that the ressource is not delayed*/
  4500. static readonly DELAYLOADSTATE_NONE: number;
  4501. /** Defines that the ressource was successfully delay loaded */
  4502. static readonly DELAYLOADSTATE_LOADED: number;
  4503. /** Defines that the ressource is currently delay loading */
  4504. static readonly DELAYLOADSTATE_LOADING: number;
  4505. /** Defines that the ressource is delayed and has not started loading */
  4506. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4508. static readonly NEVER: number;
  4509. /** 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 */
  4510. static readonly ALWAYS: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4512. static readonly LESS: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4514. static readonly EQUAL: number;
  4515. /** 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 */
  4516. static readonly LEQUAL: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4518. static readonly GREATER: number;
  4519. /** 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 */
  4520. static readonly GEQUAL: number;
  4521. /** 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 */
  4522. static readonly NOTEQUAL: number;
  4523. /** Passed to stencilOperation to specify that stencil value must be kept */
  4524. static readonly KEEP: number;
  4525. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4526. static readonly REPLACE: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4528. static readonly INCR: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4530. static readonly DECR: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4532. static readonly INVERT: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4534. static readonly INCR_WRAP: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4536. static readonly DECR_WRAP: number;
  4537. /** Texture is not repeating outside of 0..1 UVs */
  4538. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4539. /** Texture is repeating outside of 0..1 UVs */
  4540. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4541. /** Texture is repeating and mirrored */
  4542. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4543. /** ALPHA */
  4544. static readonly TEXTUREFORMAT_ALPHA: number;
  4545. /** LUMINANCE */
  4546. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4547. /** LUMINANCE_ALPHA */
  4548. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4549. /** RGB */
  4550. static readonly TEXTUREFORMAT_RGB: number;
  4551. /** RGBA */
  4552. static readonly TEXTUREFORMAT_RGBA: number;
  4553. /** RED */
  4554. static readonly TEXTUREFORMAT_RED: number;
  4555. /** RED (2nd reference) */
  4556. static readonly TEXTUREFORMAT_R: number;
  4557. /** RG */
  4558. static readonly TEXTUREFORMAT_RG: number;
  4559. /** RED_INTEGER */
  4560. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4561. /** RED_INTEGER (2nd reference) */
  4562. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4563. /** RG_INTEGER */
  4564. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4565. /** RGB_INTEGER */
  4566. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4567. /** RGBA_INTEGER */
  4568. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4569. /** UNSIGNED_BYTE */
  4570. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4571. /** UNSIGNED_BYTE (2nd reference) */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4573. /** FLOAT */
  4574. static readonly TEXTURETYPE_FLOAT: number;
  4575. /** HALF_FLOAT */
  4576. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4577. /** BYTE */
  4578. static readonly TEXTURETYPE_BYTE: number;
  4579. /** SHORT */
  4580. static readonly TEXTURETYPE_SHORT: number;
  4581. /** UNSIGNED_SHORT */
  4582. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4583. /** INT */
  4584. static readonly TEXTURETYPE_INT: number;
  4585. /** UNSIGNED_INT */
  4586. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4587. /** UNSIGNED_SHORT_4_4_4_4 */
  4588. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4589. /** UNSIGNED_SHORT_5_5_5_1 */
  4590. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4591. /** UNSIGNED_SHORT_5_6_5 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4593. /** UNSIGNED_INT_2_10_10_10_REV */
  4594. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4595. /** UNSIGNED_INT_24_8 */
  4596. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4597. /** UNSIGNED_INT_10F_11F_11F_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4599. /** UNSIGNED_INT_5_9_9_9_REV */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4601. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4602. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4603. /** nearest is mag = nearest and min = nearest and mip = linear */
  4604. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4605. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4606. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4607. /** Trilinear is mag = linear and min = linear and mip = linear */
  4608. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4609. /** nearest is mag = nearest and min = nearest and mip = linear */
  4610. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4612. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4613. /** Trilinear is mag = linear and min = linear and mip = linear */
  4614. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4615. /** mag = nearest and min = nearest and mip = nearest */
  4616. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4617. /** mag = nearest and min = linear and mip = nearest */
  4618. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4619. /** mag = nearest and min = linear and mip = linear */
  4620. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4621. /** mag = nearest and min = linear and mip = none */
  4622. static readonly TEXTURE_NEAREST_LINEAR: number;
  4623. /** mag = nearest and min = nearest and mip = none */
  4624. static readonly TEXTURE_NEAREST_NEAREST: number;
  4625. /** mag = linear and min = nearest and mip = nearest */
  4626. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4627. /** mag = linear and min = nearest and mip = linear */
  4628. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4629. /** mag = linear and min = linear and mip = none */
  4630. static readonly TEXTURE_LINEAR_LINEAR: number;
  4631. /** mag = linear and min = nearest and mip = none */
  4632. static readonly TEXTURE_LINEAR_NEAREST: number;
  4633. /** Explicit coordinates mode */
  4634. static readonly TEXTURE_EXPLICIT_MODE: number;
  4635. /** Spherical coordinates mode */
  4636. static readonly TEXTURE_SPHERICAL_MODE: number;
  4637. /** Planar coordinates mode */
  4638. static readonly TEXTURE_PLANAR_MODE: number;
  4639. /** Cubic coordinates mode */
  4640. static readonly TEXTURE_CUBIC_MODE: number;
  4641. /** Projection coordinates mode */
  4642. static readonly TEXTURE_PROJECTION_MODE: number;
  4643. /** Skybox coordinates mode */
  4644. static readonly TEXTURE_SKYBOX_MODE: number;
  4645. /** Inverse Cubic coordinates mode */
  4646. static readonly TEXTURE_INVCUBIC_MODE: number;
  4647. /** Equirectangular coordinates mode */
  4648. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4649. /** Equirectangular Fixed coordinates mode */
  4650. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4651. /** Equirectangular Fixed Mirrored coordinates mode */
  4652. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4653. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4654. static readonly SCALEMODE_FLOOR: number;
  4655. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4656. static readonly SCALEMODE_NEAREST: number;
  4657. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4658. static readonly SCALEMODE_CEILING: number;
  4659. /**
  4660. * The dirty texture flag value
  4661. */
  4662. static readonly MATERIAL_TextureDirtyFlag: number;
  4663. /**
  4664. * The dirty light flag value
  4665. */
  4666. static readonly MATERIAL_LightDirtyFlag: number;
  4667. /**
  4668. * The dirty fresnel flag value
  4669. */
  4670. static readonly MATERIAL_FresnelDirtyFlag: number;
  4671. /**
  4672. * The dirty attribute flag value
  4673. */
  4674. static readonly MATERIAL_AttributesDirtyFlag: number;
  4675. /**
  4676. * The dirty misc flag value
  4677. */
  4678. static readonly MATERIAL_MiscDirtyFlag: number;
  4679. /**
  4680. * The all dirty flag value
  4681. */
  4682. static readonly MATERIAL_AllDirtyFlag: number;
  4683. /**
  4684. * Returns the triangle fill mode
  4685. */
  4686. static readonly MATERIAL_TriangleFillMode: number;
  4687. /**
  4688. * Returns the wireframe mode
  4689. */
  4690. static readonly MATERIAL_WireFrameFillMode: number;
  4691. /**
  4692. * Returns the point fill mode
  4693. */
  4694. static readonly MATERIAL_PointFillMode: number;
  4695. /**
  4696. * Returns the point list draw mode
  4697. */
  4698. static readonly MATERIAL_PointListDrawMode: number;
  4699. /**
  4700. * Returns the line list draw mode
  4701. */
  4702. static readonly MATERIAL_LineListDrawMode: number;
  4703. /**
  4704. * Returns the line loop draw mode
  4705. */
  4706. static readonly MATERIAL_LineLoopDrawMode: number;
  4707. /**
  4708. * Returns the line strip draw mode
  4709. */
  4710. static readonly MATERIAL_LineStripDrawMode: number;
  4711. /**
  4712. * Returns the triangle strip draw mode
  4713. */
  4714. static readonly MATERIAL_TriangleStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle fan draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleFanDrawMode: number;
  4719. /**
  4720. * Stores the clock-wise side orientation
  4721. */
  4722. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4723. /**
  4724. * Stores the counter clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4727. /**
  4728. * Nothing
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_NothingTrigger: number;
  4732. /**
  4733. * On pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickTrigger: number;
  4737. /**
  4738. * On left pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnLeftPickTrigger: number;
  4742. /**
  4743. * On right pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnRightPickTrigger: number;
  4747. /**
  4748. * On center pick
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnCenterPickTrigger: number;
  4752. /**
  4753. * On pick down
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPickDownTrigger: number;
  4757. /**
  4758. * On double pick
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnDoublePickTrigger: number;
  4762. /**
  4763. * On pick up
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnPickUpTrigger: number;
  4767. /**
  4768. * On pick out.
  4769. * This trigger will only be raised if you also declared a OnPickDown
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnPickOutTrigger: number;
  4773. /**
  4774. * On long press
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnLongPressTrigger: number;
  4778. /**
  4779. * On pointer over
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOverTrigger: number;
  4783. /**
  4784. * On pointer out
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnPointerOutTrigger: number;
  4788. /**
  4789. * On every frame
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnEveryFrameTrigger: number;
  4793. /**
  4794. * On intersection enter
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4798. /**
  4799. * On intersection exit
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnIntersectionExitTrigger: number;
  4803. /**
  4804. * On key down
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyDownTrigger: number;
  4808. /**
  4809. * On key up
  4810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4811. */
  4812. static readonly ACTION_OnKeyUpTrigger: number;
  4813. /**
  4814. * Billboard mode will only apply to Y axis
  4815. */
  4816. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4817. /**
  4818. * Billboard mode will apply to all axes
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4821. /**
  4822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4825. /**
  4826. * Gets or sets base Assets URL
  4827. */
  4828. static PARTICLES_BaseAssetsUrl: string;
  4829. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4830. * Test order :
  4831. * Is the bounding sphere outside the frustum ?
  4832. * If not, are the bounding box vertices outside the frustum ?
  4833. * It not, then the cullable object is in the frustum.
  4834. */
  4835. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4836. /** Culling strategy : Bounding Sphere Only.
  4837. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4838. * It's also less accurate than the standard because some not visible objects can still be selected.
  4839. * Test : is the bounding sphere outside the frustum ?
  4840. * If not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4843. /** Culling strategy : Optimistic Inclusion.
  4844. * This in an inclusion test first, then the standard exclusion test.
  4845. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4846. * 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.
  4847. * Anyway, it's as accurate as the standard strategy.
  4848. * Test :
  4849. * Is the cullable object bounding sphere center in the frustum ?
  4850. * If not, apply the default culling strategy.
  4851. */
  4852. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4853. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4854. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4855. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4856. * 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.
  4857. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4858. * Test :
  4859. * Is the cullable object bounding sphere center in the frustum ?
  4860. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4861. */
  4862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4863. /**
  4864. * No logging while loading
  4865. */
  4866. static readonly SCENELOADER_NO_LOGGING: number;
  4867. /**
  4868. * Minimal logging while loading
  4869. */
  4870. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4871. /**
  4872. * Summary logging while loading
  4873. */
  4874. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4875. /**
  4876. * Detailled logging while loading
  4877. */
  4878. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. /**
  4883. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4884. * Babylon.js
  4885. */
  4886. export class DomManagement {
  4887. /**
  4888. * Checks if the window object exists
  4889. * @returns true if the window object exists
  4890. */
  4891. static IsWindowObjectExist(): boolean;
  4892. /**
  4893. * Extracts text content from a DOM element hierarchy
  4894. * @param element defines the root element
  4895. * @returns a string
  4896. */
  4897. static GetDOMTextContent(element: HTMLElement): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /**
  4902. * Logger used througouht the application to allow configuration of
  4903. * the log level required for the messages.
  4904. */
  4905. export class Logger {
  4906. /**
  4907. * No log
  4908. */
  4909. static readonly NoneLogLevel: number;
  4910. /**
  4911. * Only message logs
  4912. */
  4913. static readonly MessageLogLevel: number;
  4914. /**
  4915. * Only warning logs
  4916. */
  4917. static readonly WarningLogLevel: number;
  4918. /**
  4919. * Only error logs
  4920. */
  4921. static readonly ErrorLogLevel: number;
  4922. /**
  4923. * All logs
  4924. */
  4925. static readonly AllLogLevel: number;
  4926. private static _LogCache;
  4927. /**
  4928. * Gets a value indicating the number of loading errors
  4929. * @ignorenaming
  4930. */
  4931. static errorsCount: number;
  4932. /**
  4933. * Callback called when a new log is added
  4934. */
  4935. static OnNewCacheEntry: (entry: string) => void;
  4936. private static _AddLogEntry;
  4937. private static _FormatMessage;
  4938. private static _LogDisabled;
  4939. private static _LogEnabled;
  4940. private static _WarnDisabled;
  4941. private static _WarnEnabled;
  4942. private static _ErrorDisabled;
  4943. private static _ErrorEnabled;
  4944. /**
  4945. * Log a message to the console
  4946. */
  4947. static Log: (message: string) => void;
  4948. /**
  4949. * Write a warning message to the console
  4950. */
  4951. static Warn: (message: string) => void;
  4952. /**
  4953. * Write an error message to the console
  4954. */
  4955. static Error: (message: string) => void;
  4956. /**
  4957. * Gets current log cache (list of logs)
  4958. */
  4959. static readonly LogCache: string;
  4960. /**
  4961. * Clears the log cache
  4962. */
  4963. static ClearLogCache(): void;
  4964. /**
  4965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4966. */
  4967. static LogLevels: number;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /** @hidden */
  4972. export class _TypeStore {
  4973. /** @hidden */
  4974. static RegisteredTypes: {
  4975. [key: string]: Object;
  4976. };
  4977. /** @hidden */
  4978. static GetClass(fqdn: string): any;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * Class containing a set of static utilities functions for deep copy.
  4984. */
  4985. export class DeepCopier {
  4986. /**
  4987. * Tries to copy an object by duplicating every property
  4988. * @param source defines the source object
  4989. * @param destination defines the target object
  4990. * @param doNotCopyList defines a list of properties to avoid
  4991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4992. */
  4993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class containing a set of static utilities functions for precision date
  4999. */
  5000. export class PrecisionDate {
  5001. /**
  5002. * Gets either window.performance.now() if supported or Date.now() else
  5003. */
  5004. static readonly Now: number;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class _DevTools {
  5010. static WarnImport(name: string): string;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5016. */
  5017. export class WebRequest {
  5018. private _xhr;
  5019. /**
  5020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5021. * i.e. when loading files, where the server/service expects an Authorization header
  5022. */
  5023. static CustomRequestHeaders: {
  5024. [key: string]: string;
  5025. };
  5026. /**
  5027. * Add callback functions in this array to update all the requests before they get sent to the network
  5028. */
  5029. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5030. private _injectCustomRequestHeaders;
  5031. /**
  5032. * Gets or sets a function to be called when loading progress changes
  5033. */
  5034. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5035. /**
  5036. * Returns client's state
  5037. */
  5038. readonly readyState: number;
  5039. /**
  5040. * Returns client's status
  5041. */
  5042. readonly status: number;
  5043. /**
  5044. * Returns client's status as a text
  5045. */
  5046. readonly statusText: string;
  5047. /**
  5048. * Returns client's response
  5049. */
  5050. readonly response: any;
  5051. /**
  5052. * Returns client's response url
  5053. */
  5054. readonly responseURL: string;
  5055. /**
  5056. * Returns client's response as text
  5057. */
  5058. readonly responseText: string;
  5059. /**
  5060. * Gets or sets the expected response type
  5061. */
  5062. responseType: XMLHttpRequestResponseType;
  5063. /** @hidden */
  5064. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5065. /** @hidden */
  5066. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5067. /**
  5068. * Cancels any network activity
  5069. */
  5070. abort(): void;
  5071. /**
  5072. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5073. * @param body defines an optional request body
  5074. */
  5075. send(body?: Document | BodyInit | null): void;
  5076. /**
  5077. * Sets the request method, request URL
  5078. * @param method defines the method to use (GET, POST, etc..)
  5079. * @param url defines the url to connect with
  5080. */
  5081. open(method: string, url: string): void;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. /**
  5086. * Class used to evalaute queries containing `and` and `or` operators
  5087. */
  5088. export class AndOrNotEvaluator {
  5089. /**
  5090. * Evaluate a query
  5091. * @param query defines the query to evaluate
  5092. * @param evaluateCallback defines the callback used to filter result
  5093. * @returns true if the query matches
  5094. */
  5095. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5096. private static _HandleParenthesisContent;
  5097. private static _SimplifyNegation;
  5098. }
  5099. }
  5100. declare module BABYLON {
  5101. /**
  5102. * Class used to store custom tags
  5103. */
  5104. export class Tags {
  5105. /**
  5106. * Adds support for tags on the given object
  5107. * @param obj defines the object to use
  5108. */
  5109. static EnableFor(obj: any): void;
  5110. /**
  5111. * Removes tags support
  5112. * @param obj defines the object to use
  5113. */
  5114. static DisableFor(obj: any): void;
  5115. /**
  5116. * Gets a boolean indicating if the given object has tags
  5117. * @param obj defines the object to use
  5118. * @returns a boolean
  5119. */
  5120. static HasTags(obj: any): boolean;
  5121. /**
  5122. * Gets the tags available on a given object
  5123. * @param obj defines the object to use
  5124. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5125. * @returns the tags
  5126. */
  5127. static GetTags(obj: any, asString?: boolean): any;
  5128. /**
  5129. * Adds tags to an object
  5130. * @param obj defines the object to use
  5131. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5132. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5133. */
  5134. static AddTagsTo(obj: any, tagsString: string): void;
  5135. /**
  5136. * @hidden
  5137. */
  5138. static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */
  5148. static _RemoveTagFrom(obj: any, tag: string): void;
  5149. /**
  5150. * Defines if tags hosted on an object match a given query
  5151. * @param obj defines the object to use
  5152. * @param tagsQuery defines the tag query
  5153. * @returns a boolean
  5154. */
  5155. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5156. }
  5157. }
  5158. declare module BABYLON {
  5159. /**
  5160. * Manages the defines for the Material
  5161. */
  5162. export class MaterialDefines {
  5163. /** @hidden */
  5164. protected _keys: string[];
  5165. private _isDirty;
  5166. /** @hidden */
  5167. _renderId: number;
  5168. /** @hidden */
  5169. _areLightsDirty: boolean;
  5170. /** @hidden */
  5171. _areAttributesDirty: boolean;
  5172. /** @hidden */
  5173. _areTexturesDirty: boolean;
  5174. /** @hidden */
  5175. _areFresnelDirty: boolean;
  5176. /** @hidden */
  5177. _areMiscDirty: boolean;
  5178. /** @hidden */
  5179. _areImageProcessingDirty: boolean;
  5180. /** @hidden */
  5181. _normals: boolean;
  5182. /** @hidden */
  5183. _uvs: boolean;
  5184. /** @hidden */
  5185. _needNormals: boolean;
  5186. /** @hidden */
  5187. _needUVs: boolean;
  5188. [id: string]: any;
  5189. /**
  5190. * Specifies if the material needs to be re-calculated
  5191. */
  5192. readonly isDirty: boolean;
  5193. /**
  5194. * Marks the material to indicate that it has been re-calculated
  5195. */
  5196. markAsProcessed(): void;
  5197. /**
  5198. * Marks the material to indicate that it needs to be re-calculated
  5199. */
  5200. markAsUnprocessed(): void;
  5201. /**
  5202. * Marks the material to indicate all of its defines need to be re-calculated
  5203. */
  5204. markAllAsDirty(): void;
  5205. /**
  5206. * Marks the material to indicate that image processing needs to be re-calculated
  5207. */
  5208. markAsImageProcessingDirty(): void;
  5209. /**
  5210. * Marks the material to indicate the lights need to be re-calculated
  5211. */
  5212. markAsLightDirty(): void;
  5213. /**
  5214. * Marks the attribute state as changed
  5215. */
  5216. markAsAttributesDirty(): void;
  5217. /**
  5218. * Marks the texture state as changed
  5219. */
  5220. markAsTexturesDirty(): void;
  5221. /**
  5222. * Marks the fresnel state as changed
  5223. */
  5224. markAsFresnelDirty(): void;
  5225. /**
  5226. * Marks the misc state as changed
  5227. */
  5228. markAsMiscDirty(): void;
  5229. /**
  5230. * Rebuilds the material defines
  5231. */
  5232. rebuild(): void;
  5233. /**
  5234. * Specifies if two material defines are equal
  5235. * @param other - A material define instance to compare to
  5236. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5237. */
  5238. isEqual(other: MaterialDefines): boolean;
  5239. /**
  5240. * Clones this instance's defines to another instance
  5241. * @param other - material defines to clone values to
  5242. */
  5243. cloneTo(other: MaterialDefines): void;
  5244. /**
  5245. * Resets the material define values
  5246. */
  5247. reset(): void;
  5248. /**
  5249. * Converts the material define values to a string
  5250. * @returns - String of material define information
  5251. */
  5252. toString(): string;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store and describe the pipeline context associated with an effect
  5258. */
  5259. export interface IPipelineContext {
  5260. /**
  5261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5262. */
  5263. isAsync: boolean;
  5264. /**
  5265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5266. */
  5267. isReady: boolean;
  5268. /** @hidden */
  5269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to store gfx data (like WebGLBuffer)
  5275. */
  5276. export class DataBuffer {
  5277. /**
  5278. * Gets or sets the number of objects referencing this buffer
  5279. */
  5280. references: number;
  5281. /** Gets or sets the size of the underlying buffer */
  5282. capacity: number;
  5283. /**
  5284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5285. */
  5286. is32Bits: boolean;
  5287. /**
  5288. * Gets the underlying buffer
  5289. */
  5290. readonly underlyingResource: any;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /** @hidden */
  5295. export interface IShaderProcessor {
  5296. attributeProcessor?: (attribute: string) => string;
  5297. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5298. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5299. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5300. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5301. lineProcessor?: (line: string, isFragment: boolean) => string;
  5302. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5303. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5304. }
  5305. }
  5306. declare module BABYLON {
  5307. /** @hidden */
  5308. export interface ProcessingOptions {
  5309. defines: string[];
  5310. indexParameters: any;
  5311. isFragment: boolean;
  5312. shouldUseHighPrecisionShader: boolean;
  5313. supportsUniformBuffers: boolean;
  5314. shadersRepository: string;
  5315. includesShadersStore: {
  5316. [key: string]: string;
  5317. };
  5318. processor?: IShaderProcessor;
  5319. version: string;
  5320. platformName: string;
  5321. lookForClosingBracketForUniformBuffer?: boolean;
  5322. }
  5323. }
  5324. declare module BABYLON {
  5325. /** @hidden */
  5326. export class ShaderCodeNode {
  5327. line: string;
  5328. children: ShaderCodeNode[];
  5329. additionalDefineKey?: string;
  5330. additionalDefineValue?: string;
  5331. isValid(preprocessors: {
  5332. [key: string]: string;
  5333. }): boolean;
  5334. process(preprocessors: {
  5335. [key: string]: string;
  5336. }, options: ProcessingOptions): string;
  5337. }
  5338. }
  5339. declare module BABYLON {
  5340. /** @hidden */
  5341. export class ShaderCodeCursor {
  5342. private _lines;
  5343. lineIndex: number;
  5344. readonly currentLine: string;
  5345. readonly canRead: boolean;
  5346. lines: string[];
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. /** @hidden */
  5351. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5352. process(preprocessors: {
  5353. [key: string]: string;
  5354. }, options: ProcessingOptions): string;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /** @hidden */
  5359. export class ShaderDefineExpression {
  5360. isTrue(preprocessors: {
  5361. [key: string]: string;
  5362. }): boolean;
  5363. }
  5364. }
  5365. declare module BABYLON {
  5366. /** @hidden */
  5367. export class ShaderCodeTestNode extends ShaderCodeNode {
  5368. testExpression: ShaderDefineExpression;
  5369. isValid(preprocessors: {
  5370. [key: string]: string;
  5371. }): boolean;
  5372. }
  5373. }
  5374. declare module BABYLON {
  5375. /** @hidden */
  5376. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5377. define: string;
  5378. not: boolean;
  5379. constructor(define: string, not?: boolean);
  5380. isTrue(preprocessors: {
  5381. [key: string]: string;
  5382. }): boolean;
  5383. }
  5384. }
  5385. declare module BABYLON {
  5386. /** @hidden */
  5387. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5388. leftOperand: ShaderDefineExpression;
  5389. rightOperand: ShaderDefineExpression;
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module BABYLON {
  5396. /** @hidden */
  5397. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5398. leftOperand: ShaderDefineExpression;
  5399. rightOperand: ShaderDefineExpression;
  5400. isTrue(preprocessors: {
  5401. [key: string]: string;
  5402. }): boolean;
  5403. }
  5404. }
  5405. declare module BABYLON {
  5406. /** @hidden */
  5407. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5408. define: string;
  5409. operand: string;
  5410. testValue: string;
  5411. constructor(define: string, operand: string, testValue: string);
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module BABYLON {
  5418. /** @hidden */
  5419. export class ShaderProcessor {
  5420. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5421. private static _ProcessPrecision;
  5422. private static _ExtractOperation;
  5423. private static _BuildSubExpression;
  5424. private static _BuildExpression;
  5425. private static _MoveCursorWithinIf;
  5426. private static _MoveCursor;
  5427. private static _EvaluatePreProcessors;
  5428. private static _PreparePreProcessors;
  5429. private static _ProcessShaderConversion;
  5430. private static _ProcessIncludes;
  5431. }
  5432. }
  5433. declare module BABYLON {
  5434. /**
  5435. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5436. */
  5437. export class PerformanceMonitor {
  5438. private _enabled;
  5439. private _rollingFrameTime;
  5440. private _lastFrameTimeMs;
  5441. /**
  5442. * constructor
  5443. * @param frameSampleSize The number of samples required to saturate the sliding window
  5444. */
  5445. constructor(frameSampleSize?: number);
  5446. /**
  5447. * Samples current frame
  5448. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5449. */
  5450. sampleFrame(timeMs?: number): void;
  5451. /**
  5452. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5453. */
  5454. readonly averageFrameTime: number;
  5455. /**
  5456. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTimeVariance: number;
  5459. /**
  5460. * Returns the frame time of the most recent frame
  5461. */
  5462. readonly instantaneousFrameTime: number;
  5463. /**
  5464. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5465. */
  5466. readonly averageFPS: number;
  5467. /**
  5468. * Returns the average framerate in frames per second using the most recent frame time
  5469. */
  5470. readonly instantaneousFPS: number;
  5471. /**
  5472. * Returns true if enough samples have been taken to completely fill the sliding window
  5473. */
  5474. readonly isSaturated: boolean;
  5475. /**
  5476. * Enables contributions to the sliding window sample set
  5477. */
  5478. enable(): void;
  5479. /**
  5480. * Disables contributions to the sliding window sample set
  5481. * Samples will not be interpolated over the disabled period
  5482. */
  5483. disable(): void;
  5484. /**
  5485. * Returns true if sampling is enabled
  5486. */
  5487. readonly isEnabled: boolean;
  5488. /**
  5489. * Resets performance monitor
  5490. */
  5491. reset(): void;
  5492. }
  5493. /**
  5494. * RollingAverage
  5495. *
  5496. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5497. */
  5498. export class RollingAverage {
  5499. /**
  5500. * Current average
  5501. */
  5502. average: number;
  5503. /**
  5504. * Current variance
  5505. */
  5506. variance: number;
  5507. protected _samples: Array<number>;
  5508. protected _sampleCount: number;
  5509. protected _pos: number;
  5510. protected _m2: number;
  5511. /**
  5512. * constructor
  5513. * @param length The number of samples required to saturate the sliding window
  5514. */
  5515. constructor(length: number);
  5516. /**
  5517. * Adds a sample to the sample set
  5518. * @param v The sample value
  5519. */
  5520. add(v: number): void;
  5521. /**
  5522. * Returns previously added values or null if outside of history or outside the sliding window domain
  5523. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5524. * @return Value previously recorded with add() or null if outside of range
  5525. */
  5526. history(i: number): number;
  5527. /**
  5528. * Returns true if enough samples have been taken to completely fill the sliding window
  5529. * @return true if sample-set saturated
  5530. */
  5531. isSaturated(): boolean;
  5532. /**
  5533. * Resets the rolling average (equivalent to 0 samples taken so far)
  5534. */
  5535. reset(): void;
  5536. /**
  5537. * Wraps a value around the sample range boundaries
  5538. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5539. * @return Wrapped position in sample range
  5540. */
  5541. protected _wrapPosition(i: number): number;
  5542. }
  5543. }
  5544. declare module BABYLON {
  5545. /**
  5546. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5547. * The underlying implementation relies on an associative array to ensure the best performances.
  5548. * The value can be anything including 'null' but except 'undefined'
  5549. */
  5550. export class StringDictionary<T> {
  5551. /**
  5552. * This will clear this dictionary and copy the content from the 'source' one.
  5553. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5554. * @param source the dictionary to take the content from and copy to this dictionary
  5555. */
  5556. copyFrom(source: StringDictionary<T>): void;
  5557. /**
  5558. * Get a value based from its key
  5559. * @param key the given key to get the matching value from
  5560. * @return the value if found, otherwise undefined is returned
  5561. */
  5562. get(key: string): T | undefined;
  5563. /**
  5564. * Get a value from its key or add it if it doesn't exist.
  5565. * This method will ensure you that a given key/data will be present in the dictionary.
  5566. * @param key the given key to get the matching value from
  5567. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5568. * The factory will only be invoked if there's no data for the given key.
  5569. * @return the value corresponding to the key.
  5570. */
  5571. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5572. /**
  5573. * Get a value from its key if present in the dictionary otherwise add it
  5574. * @param key the key to get the value from
  5575. * @param val if there's no such key/value pair in the dictionary add it with this value
  5576. * @return the value corresponding to the key
  5577. */
  5578. getOrAdd(key: string, val: T): T;
  5579. /**
  5580. * Check if there's a given key in the dictionary
  5581. * @param key the key to check for
  5582. * @return true if the key is present, false otherwise
  5583. */
  5584. contains(key: string): boolean;
  5585. /**
  5586. * Add a new key and its corresponding value
  5587. * @param key the key to add
  5588. * @param value the value corresponding to the key
  5589. * @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
  5590. */
  5591. add(key: string, value: T): boolean;
  5592. /**
  5593. * Update a specific value associated to a key
  5594. * @param key defines the key to use
  5595. * @param value defines the value to store
  5596. * @returns true if the value was updated (or false if the key was not found)
  5597. */
  5598. set(key: string, value: T): boolean;
  5599. /**
  5600. * Get the element of the given key and remove it from the dictionary
  5601. * @param key defines the key to search
  5602. * @returns the value associated with the key or null if not found
  5603. */
  5604. getAndRemove(key: string): Nullable<T>;
  5605. /**
  5606. * Remove a key/value from the dictionary.
  5607. * @param key the key to remove
  5608. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5609. */
  5610. remove(key: string): boolean;
  5611. /**
  5612. * Clear the whole content of the dictionary
  5613. */
  5614. clear(): void;
  5615. /**
  5616. * Gets the current count
  5617. */
  5618. readonly count: number;
  5619. /**
  5620. * Execute a callback on each key/val of the dictionary.
  5621. * Note that you can remove any element in this dictionary in the callback implementation
  5622. * @param callback the callback to execute on a given key/value pair
  5623. */
  5624. forEach(callback: (key: string, val: T) => void): void;
  5625. /**
  5626. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5627. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5628. * Note that you can remove any element in this dictionary in the callback implementation
  5629. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5630. * @returns the first item
  5631. */
  5632. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5633. private _count;
  5634. private _data;
  5635. }
  5636. }
  5637. declare module BABYLON {
  5638. /**
  5639. * Helper class that provides a small promise polyfill
  5640. */
  5641. export class PromisePolyfill {
  5642. /**
  5643. * Static function used to check if the polyfill is required
  5644. * If this is the case then the function will inject the polyfill to window.Promise
  5645. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5646. */
  5647. static Apply(force?: boolean): void;
  5648. }
  5649. }
  5650. declare module BABYLON {
  5651. /**
  5652. * Class used to store data that will be store in GPU memory
  5653. */
  5654. export class Buffer {
  5655. private _engine;
  5656. private _buffer;
  5657. /** @hidden */
  5658. _data: Nullable<DataArray>;
  5659. private _updatable;
  5660. private _instanced;
  5661. /**
  5662. * Gets the byte stride.
  5663. */
  5664. readonly byteStride: number;
  5665. /**
  5666. * Constructor
  5667. * @param engine the engine
  5668. * @param data the data to use for this buffer
  5669. * @param updatable whether the data is updatable
  5670. * @param stride the stride (optional)
  5671. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5672. * @param instanced whether the buffer is instanced (optional)
  5673. * @param useBytes set to true if the stride in in bytes (optional)
  5674. */
  5675. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5676. /**
  5677. * Create a new VertexBuffer based on the current buffer
  5678. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5679. * @param offset defines offset in the buffer (0 by default)
  5680. * @param size defines the size in floats of attributes (position is 3 for instance)
  5681. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5682. * @param instanced defines if the vertex buffer contains indexed data
  5683. * @param useBytes defines if the offset and stride are in bytes
  5684. * @returns the new vertex buffer
  5685. */
  5686. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5687. /**
  5688. * Gets a boolean indicating if the Buffer is updatable?
  5689. * @returns true if the buffer is updatable
  5690. */
  5691. isUpdatable(): boolean;
  5692. /**
  5693. * Gets current buffer's data
  5694. * @returns a DataArray or null
  5695. */
  5696. getData(): Nullable<DataArray>;
  5697. /**
  5698. * Gets underlying native buffer
  5699. * @returns underlying native buffer
  5700. */
  5701. getBuffer(): Nullable<DataBuffer>;
  5702. /**
  5703. * Gets the stride in float32 units (i.e. byte stride / 4).
  5704. * May not be an integer if the byte stride is not divisible by 4.
  5705. * DEPRECATED. Use byteStride instead.
  5706. * @returns the stride in float32 units
  5707. */
  5708. getStrideSize(): number;
  5709. /**
  5710. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5711. * @param data defines the data to store
  5712. */
  5713. create(data?: Nullable<DataArray>): void;
  5714. /** @hidden */
  5715. _rebuild(): void;
  5716. /**
  5717. * Update current buffer data
  5718. * @param data defines the data to store
  5719. */
  5720. update(data: DataArray): void;
  5721. /**
  5722. * Updates the data directly.
  5723. * @param data the new data
  5724. * @param offset the new offset
  5725. * @param vertexCount the vertex count (optional)
  5726. * @param useBytes set to true if the offset is in bytes
  5727. */
  5728. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5729. /**
  5730. * Release all resources
  5731. */
  5732. dispose(): void;
  5733. }
  5734. /**
  5735. * Specialized buffer used to store vertex data
  5736. */
  5737. export class VertexBuffer {
  5738. /** @hidden */
  5739. _buffer: Buffer;
  5740. private _kind;
  5741. private _size;
  5742. private _ownsBuffer;
  5743. private _instanced;
  5744. private _instanceDivisor;
  5745. /**
  5746. * The byte type.
  5747. */
  5748. static readonly BYTE: number;
  5749. /**
  5750. * The unsigned byte type.
  5751. */
  5752. static readonly UNSIGNED_BYTE: number;
  5753. /**
  5754. * The short type.
  5755. */
  5756. static readonly SHORT: number;
  5757. /**
  5758. * The unsigned short type.
  5759. */
  5760. static readonly UNSIGNED_SHORT: number;
  5761. /**
  5762. * The integer type.
  5763. */
  5764. static readonly INT: number;
  5765. /**
  5766. * The unsigned integer type.
  5767. */
  5768. static readonly UNSIGNED_INT: number;
  5769. /**
  5770. * The float type.
  5771. */
  5772. static readonly FLOAT: number;
  5773. /**
  5774. * Gets or sets the instance divisor when in instanced mode
  5775. */
  5776. instanceDivisor: number;
  5777. /**
  5778. * Gets the byte stride.
  5779. */
  5780. readonly byteStride: number;
  5781. /**
  5782. * Gets the byte offset.
  5783. */
  5784. readonly byteOffset: number;
  5785. /**
  5786. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5787. */
  5788. readonly normalized: boolean;
  5789. /**
  5790. * Gets the data type of each component in the array.
  5791. */
  5792. readonly type: number;
  5793. /**
  5794. * Constructor
  5795. * @param engine the engine
  5796. * @param data the data to use for this vertex buffer
  5797. * @param kind the vertex buffer kind
  5798. * @param updatable whether the data is updatable
  5799. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5800. * @param stride the stride (optional)
  5801. * @param instanced whether the buffer is instanced (optional)
  5802. * @param offset the offset of the data (optional)
  5803. * @param size the number of components (optional)
  5804. * @param type the type of the component (optional)
  5805. * @param normalized whether the data contains normalized data (optional)
  5806. * @param useBytes set to true if stride and offset are in bytes (optional)
  5807. */
  5808. 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);
  5809. /** @hidden */
  5810. _rebuild(): void;
  5811. /**
  5812. * Returns the kind of the VertexBuffer (string)
  5813. * @returns a string
  5814. */
  5815. getKind(): string;
  5816. /**
  5817. * Gets a boolean indicating if the VertexBuffer is updatable?
  5818. * @returns true if the buffer is updatable
  5819. */
  5820. isUpdatable(): boolean;
  5821. /**
  5822. * Gets current buffer's data
  5823. * @returns a DataArray or null
  5824. */
  5825. getData(): Nullable<DataArray>;
  5826. /**
  5827. * Gets underlying native buffer
  5828. * @returns underlying native buffer
  5829. */
  5830. getBuffer(): Nullable<DataBuffer>;
  5831. /**
  5832. * Gets the stride in float32 units (i.e. byte stride / 4).
  5833. * May not be an integer if the byte stride is not divisible by 4.
  5834. * DEPRECATED. Use byteStride instead.
  5835. * @returns the stride in float32 units
  5836. */
  5837. getStrideSize(): number;
  5838. /**
  5839. * Returns the offset as a multiple of the type byte length.
  5840. * DEPRECATED. Use byteOffset instead.
  5841. * @returns the offset in bytes
  5842. */
  5843. getOffset(): number;
  5844. /**
  5845. * Returns the number of components per vertex attribute (integer)
  5846. * @returns the size in float
  5847. */
  5848. getSize(): number;
  5849. /**
  5850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5851. * @returns true if this buffer is instanced
  5852. */
  5853. getIsInstanced(): boolean;
  5854. /**
  5855. * Returns the instancing divisor, zero for non-instanced (integer).
  5856. * @returns a number
  5857. */
  5858. getInstanceDivisor(): number;
  5859. /**
  5860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5861. * @param data defines the data to store
  5862. */
  5863. create(data?: DataArray): void;
  5864. /**
  5865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5866. * This function will create a new buffer if the current one is not updatable
  5867. * @param data defines the data to store
  5868. */
  5869. update(data: DataArray): void;
  5870. /**
  5871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5872. * Returns the directly updated WebGLBuffer.
  5873. * @param data the new data
  5874. * @param offset the new offset
  5875. * @param useBytes set to true if the offset is in bytes
  5876. */
  5877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5878. /**
  5879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5880. */
  5881. dispose(): void;
  5882. /**
  5883. * Enumerates each value of this vertex buffer as numbers.
  5884. * @param count the number of values to enumerate
  5885. * @param callback the callback function called for each value
  5886. */
  5887. forEach(count: number, callback: (value: number, index: number) => void): void;
  5888. /**
  5889. * Positions
  5890. */
  5891. static readonly PositionKind: string;
  5892. /**
  5893. * Normals
  5894. */
  5895. static readonly NormalKind: string;
  5896. /**
  5897. * Tangents
  5898. */
  5899. static readonly TangentKind: string;
  5900. /**
  5901. * Texture coordinates
  5902. */
  5903. static readonly UVKind: string;
  5904. /**
  5905. * Texture coordinates 2
  5906. */
  5907. static readonly UV2Kind: string;
  5908. /**
  5909. * Texture coordinates 3
  5910. */
  5911. static readonly UV3Kind: string;
  5912. /**
  5913. * Texture coordinates 4
  5914. */
  5915. static readonly UV4Kind: string;
  5916. /**
  5917. * Texture coordinates 5
  5918. */
  5919. static readonly UV5Kind: string;
  5920. /**
  5921. * Texture coordinates 6
  5922. */
  5923. static readonly UV6Kind: string;
  5924. /**
  5925. * Colors
  5926. */
  5927. static readonly ColorKind: string;
  5928. /**
  5929. * Matrix indices (for bones)
  5930. */
  5931. static readonly MatricesIndicesKind: string;
  5932. /**
  5933. * Matrix weights (for bones)
  5934. */
  5935. static readonly MatricesWeightsKind: string;
  5936. /**
  5937. * Additional matrix indices (for bones)
  5938. */
  5939. static readonly MatricesIndicesExtraKind: string;
  5940. /**
  5941. * Additional matrix weights (for bones)
  5942. */
  5943. static readonly MatricesWeightsExtraKind: string;
  5944. /**
  5945. * Deduces the stride given a kind.
  5946. * @param kind The kind string to deduce
  5947. * @returns The deduced stride
  5948. */
  5949. static DeduceStride(kind: string): number;
  5950. /**
  5951. * Gets the byte length of the given type.
  5952. * @param type the type
  5953. * @returns the number of bytes
  5954. */
  5955. static GetTypeByteLength(type: number): number;
  5956. /**
  5957. * Enumerates each value of the given parameters as numbers.
  5958. * @param data the data to enumerate
  5959. * @param byteOffset the byte offset of the data
  5960. * @param byteStride the byte stride of the data
  5961. * @param componentCount the number of components per element
  5962. * @param componentType the type of the component
  5963. * @param count the number of values to enumerate
  5964. * @param normalized whether the data is normalized
  5965. * @param callback the callback function called for each value
  5966. */
  5967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5968. private static _GetFloatValue;
  5969. }
  5970. }
  5971. declare module BABYLON {
  5972. /**
  5973. * Class representing spherical harmonics coefficients to the 3rd degree
  5974. */
  5975. export class SphericalHarmonics {
  5976. /**
  5977. * Defines whether or not the harmonics have been prescaled for rendering.
  5978. */
  5979. preScaled: boolean;
  5980. /**
  5981. * The l0,0 coefficients of the spherical harmonics
  5982. */
  5983. l00: Vector3;
  5984. /**
  5985. * The l1,-1 coefficients of the spherical harmonics
  5986. */
  5987. l1_1: Vector3;
  5988. /**
  5989. * The l1,0 coefficients of the spherical harmonics
  5990. */
  5991. l10: Vector3;
  5992. /**
  5993. * The l1,1 coefficients of the spherical harmonics
  5994. */
  5995. l11: Vector3;
  5996. /**
  5997. * The l2,-2 coefficients of the spherical harmonics
  5998. */
  5999. l2_2: Vector3;
  6000. /**
  6001. * The l2,-1 coefficients of the spherical harmonics
  6002. */
  6003. l2_1: Vector3;
  6004. /**
  6005. * The l2,0 coefficients of the spherical harmonics
  6006. */
  6007. l20: Vector3;
  6008. /**
  6009. * The l2,1 coefficients of the spherical harmonics
  6010. */
  6011. l21: Vector3;
  6012. /**
  6013. * The l2,2 coefficients of the spherical harmonics
  6014. */
  6015. l22: Vector3;
  6016. /**
  6017. * Adds a light to the spherical harmonics
  6018. * @param direction the direction of the light
  6019. * @param color the color of the light
  6020. * @param deltaSolidAngle the delta solid angle of the light
  6021. */
  6022. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6023. /**
  6024. * Scales the spherical harmonics by the given amount
  6025. * @param scale the amount to scale
  6026. */
  6027. scaleInPlace(scale: number): void;
  6028. /**
  6029. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6030. *
  6031. * ```
  6032. * E_lm = A_l * L_lm
  6033. * ```
  6034. *
  6035. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6036. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6037. * the scaling factors are given in equation 9.
  6038. */
  6039. convertIncidentRadianceToIrradiance(): void;
  6040. /**
  6041. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6042. *
  6043. * ```
  6044. * L = (1/pi) * E * rho
  6045. * ```
  6046. *
  6047. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6048. */
  6049. convertIrradianceToLambertianRadiance(): void;
  6050. /**
  6051. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6052. * required operations at run time.
  6053. *
  6054. * This is simply done by scaling back the SH with Ylm constants parameter.
  6055. * The trigonometric part being applied by the shader at run time.
  6056. */
  6057. preScaleForRendering(): void;
  6058. /**
  6059. * Constructs a spherical harmonics from an array.
  6060. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6061. * @returns the spherical harmonics
  6062. */
  6063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6064. /**
  6065. * Gets the spherical harmonics from polynomial
  6066. * @param polynomial the spherical polynomial
  6067. * @returns the spherical harmonics
  6068. */
  6069. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6070. }
  6071. /**
  6072. * Class representing spherical polynomial coefficients to the 3rd degree
  6073. */
  6074. export class SphericalPolynomial {
  6075. private _harmonics;
  6076. /**
  6077. * The spherical harmonics used to create the polynomials.
  6078. */
  6079. readonly preScaledHarmonics: SphericalHarmonics;
  6080. /**
  6081. * The x coefficients of the spherical polynomial
  6082. */
  6083. x: Vector3;
  6084. /**
  6085. * The y coefficients of the spherical polynomial
  6086. */
  6087. y: Vector3;
  6088. /**
  6089. * The z coefficients of the spherical polynomial
  6090. */
  6091. z: Vector3;
  6092. /**
  6093. * The xx coefficients of the spherical polynomial
  6094. */
  6095. xx: Vector3;
  6096. /**
  6097. * The yy coefficients of the spherical polynomial
  6098. */
  6099. yy: Vector3;
  6100. /**
  6101. * The zz coefficients of the spherical polynomial
  6102. */
  6103. zz: Vector3;
  6104. /**
  6105. * The xy coefficients of the spherical polynomial
  6106. */
  6107. xy: Vector3;
  6108. /**
  6109. * The yz coefficients of the spherical polynomial
  6110. */
  6111. yz: Vector3;
  6112. /**
  6113. * The zx coefficients of the spherical polynomial
  6114. */
  6115. zx: Vector3;
  6116. /**
  6117. * Adds an ambient color to the spherical polynomial
  6118. * @param color the color to add
  6119. */
  6120. addAmbient(color: Color3): void;
  6121. /**
  6122. * Scales the spherical polynomial by the given amount
  6123. * @param scale the amount to scale
  6124. */
  6125. scaleInPlace(scale: number): void;
  6126. /**
  6127. * Gets the spherical polynomial from harmonics
  6128. * @param harmonics the spherical harmonics
  6129. * @returns the spherical polynomial
  6130. */
  6131. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6132. /**
  6133. * Constructs a spherical polynomial from an array.
  6134. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6135. * @returns the spherical polynomial
  6136. */
  6137. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6138. }
  6139. }
  6140. declare module BABYLON {
  6141. /**
  6142. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6143. */
  6144. export interface CubeMapInfo {
  6145. /**
  6146. * The pixel array for the front face.
  6147. * This is stored in format, left to right, up to down format.
  6148. */
  6149. front: Nullable<ArrayBufferView>;
  6150. /**
  6151. * The pixel array for the back face.
  6152. * This is stored in format, left to right, up to down format.
  6153. */
  6154. back: Nullable<ArrayBufferView>;
  6155. /**
  6156. * The pixel array for the left face.
  6157. * This is stored in format, left to right, up to down format.
  6158. */
  6159. left: Nullable<ArrayBufferView>;
  6160. /**
  6161. * The pixel array for the right face.
  6162. * This is stored in format, left to right, up to down format.
  6163. */
  6164. right: Nullable<ArrayBufferView>;
  6165. /**
  6166. * The pixel array for the up face.
  6167. * This is stored in format, left to right, up to down format.
  6168. */
  6169. up: Nullable<ArrayBufferView>;
  6170. /**
  6171. * The pixel array for the down face.
  6172. * This is stored in format, left to right, up to down format.
  6173. */
  6174. down: Nullable<ArrayBufferView>;
  6175. /**
  6176. * The size of the cubemap stored.
  6177. *
  6178. * Each faces will be size * size pixels.
  6179. */
  6180. size: number;
  6181. /**
  6182. * The format of the texture.
  6183. *
  6184. * RGBA, RGB.
  6185. */
  6186. format: number;
  6187. /**
  6188. * The type of the texture data.
  6189. *
  6190. * UNSIGNED_INT, FLOAT.
  6191. */
  6192. type: number;
  6193. /**
  6194. * Specifies whether the texture is in gamma space.
  6195. */
  6196. gammaSpace: boolean;
  6197. }
  6198. /**
  6199. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6200. */
  6201. export class PanoramaToCubeMapTools {
  6202. private static FACE_FRONT;
  6203. private static FACE_BACK;
  6204. private static FACE_RIGHT;
  6205. private static FACE_LEFT;
  6206. private static FACE_DOWN;
  6207. private static FACE_UP;
  6208. /**
  6209. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6210. *
  6211. * @param float32Array The source data.
  6212. * @param inputWidth The width of the input panorama.
  6213. * @param inputHeight The height of the input panorama.
  6214. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6215. * @return The cubemap data
  6216. */
  6217. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6218. private static CreateCubemapTexture;
  6219. private static CalcProjectionSpherical;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Helper class dealing with the extraction of spherical polynomial dataArray
  6225. * from a cube map.
  6226. */
  6227. export class CubeMapToSphericalPolynomialTools {
  6228. private static FileFaces;
  6229. /**
  6230. * Converts a texture to the according Spherical Polynomial data.
  6231. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6232. *
  6233. * @param texture The texture to extract the information from.
  6234. * @return The Spherical Polynomial data.
  6235. */
  6236. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6237. /**
  6238. * Converts a cubemap to the according Spherical Polynomial data.
  6239. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6240. *
  6241. * @param cubeInfo The Cube map to extract the information from.
  6242. * @return The Spherical Polynomial data.
  6243. */
  6244. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6250. * during the life time of the application.
  6251. */
  6252. export class EngineStore {
  6253. /** Gets the list of created engines */
  6254. static Instances: Engine[];
  6255. /** @hidden */
  6256. static _LastCreatedScene: Nullable<Scene>;
  6257. /**
  6258. * Gets the latest created engine
  6259. */
  6260. static readonly LastCreatedEngine: Nullable<Engine>;
  6261. /**
  6262. * Gets the latest created scene
  6263. */
  6264. static readonly LastCreatedScene: Nullable<Scene>;
  6265. }
  6266. }
  6267. declare module BABYLON {
  6268. /**
  6269. * Define options used to create a render target texture
  6270. */
  6271. export class RenderTargetCreationOptions {
  6272. /**
  6273. * Specifies is mipmaps must be generated
  6274. */
  6275. generateMipMaps?: boolean;
  6276. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6277. generateDepthBuffer?: boolean;
  6278. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6279. generateStencilBuffer?: boolean;
  6280. /** Defines texture type (int by default) */
  6281. type?: number;
  6282. /** Defines sampling mode (trilinear by default) */
  6283. samplingMode?: number;
  6284. /** Defines format (RGBA by default) */
  6285. format?: number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * @hidden
  6291. **/
  6292. export class _AlphaState {
  6293. private _isAlphaBlendDirty;
  6294. private _isBlendFunctionParametersDirty;
  6295. private _isBlendEquationParametersDirty;
  6296. private _isBlendConstantsDirty;
  6297. private _alphaBlend;
  6298. private _blendFunctionParameters;
  6299. private _blendEquationParameters;
  6300. private _blendConstants;
  6301. /**
  6302. * Initializes the state.
  6303. */
  6304. constructor();
  6305. readonly isDirty: boolean;
  6306. alphaBlend: boolean;
  6307. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6308. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6309. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6310. reset(): void;
  6311. apply(gl: WebGLRenderingContext): void;
  6312. }
  6313. }
  6314. declare module BABYLON {
  6315. /**
  6316. * @hidden
  6317. **/
  6318. export class _DepthCullingState {
  6319. private _isDepthTestDirty;
  6320. private _isDepthMaskDirty;
  6321. private _isDepthFuncDirty;
  6322. private _isCullFaceDirty;
  6323. private _isCullDirty;
  6324. private _isZOffsetDirty;
  6325. private _isFrontFaceDirty;
  6326. private _depthTest;
  6327. private _depthMask;
  6328. private _depthFunc;
  6329. private _cull;
  6330. private _cullFace;
  6331. private _zOffset;
  6332. private _frontFace;
  6333. /**
  6334. * Initializes the state.
  6335. */
  6336. constructor();
  6337. readonly isDirty: boolean;
  6338. zOffset: number;
  6339. cullFace: Nullable<number>;
  6340. cull: Nullable<boolean>;
  6341. depthFunc: Nullable<number>;
  6342. depthMask: boolean;
  6343. depthTest: boolean;
  6344. frontFace: Nullable<number>;
  6345. reset(): void;
  6346. apply(gl: WebGLRenderingContext): void;
  6347. }
  6348. }
  6349. declare module BABYLON {
  6350. /**
  6351. * @hidden
  6352. **/
  6353. export class _StencilState {
  6354. /** 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 */
  6355. static readonly ALWAYS: number;
  6356. /** Passed to stencilOperation to specify that stencil value must be kept */
  6357. static readonly KEEP: number;
  6358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6359. static readonly REPLACE: number;
  6360. private _isStencilTestDirty;
  6361. private _isStencilMaskDirty;
  6362. private _isStencilFuncDirty;
  6363. private _isStencilOpDirty;
  6364. private _stencilTest;
  6365. private _stencilMask;
  6366. private _stencilFunc;
  6367. private _stencilFuncRef;
  6368. private _stencilFuncMask;
  6369. private _stencilOpStencilFail;
  6370. private _stencilOpDepthFail;
  6371. private _stencilOpStencilDepthPass;
  6372. readonly isDirty: boolean;
  6373. stencilFunc: number;
  6374. stencilFuncRef: number;
  6375. stencilFuncMask: number;
  6376. stencilOpStencilFail: number;
  6377. stencilOpDepthFail: number;
  6378. stencilOpStencilDepthPass: number;
  6379. stencilMask: number;
  6380. stencilTest: boolean;
  6381. constructor();
  6382. reset(): void;
  6383. apply(gl: WebGLRenderingContext): void;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * @hidden
  6389. **/
  6390. export class _TimeToken {
  6391. _startTimeQuery: Nullable<WebGLQuery>;
  6392. _endTimeQuery: Nullable<WebGLQuery>;
  6393. _timeElapsedQuery: Nullable<WebGLQuery>;
  6394. _timeElapsedQueryEnded: boolean;
  6395. }
  6396. }
  6397. declare module BABYLON {
  6398. /**
  6399. * Class used to store data associated with WebGL texture data for the engine
  6400. * This class should not be used directly
  6401. */
  6402. export class InternalTexture {
  6403. /** @hidden */
  6404. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6405. /**
  6406. * The source of the texture data is unknown
  6407. */
  6408. static DATASOURCE_UNKNOWN: number;
  6409. /**
  6410. * Texture data comes from an URL
  6411. */
  6412. static DATASOURCE_URL: number;
  6413. /**
  6414. * Texture data is only used for temporary storage
  6415. */
  6416. static DATASOURCE_TEMP: number;
  6417. /**
  6418. * Texture data comes from raw data (ArrayBuffer)
  6419. */
  6420. static DATASOURCE_RAW: number;
  6421. /**
  6422. * Texture content is dynamic (video or dynamic texture)
  6423. */
  6424. static DATASOURCE_DYNAMIC: number;
  6425. /**
  6426. * Texture content is generated by rendering to it
  6427. */
  6428. static DATASOURCE_RENDERTARGET: number;
  6429. /**
  6430. * Texture content is part of a multi render target process
  6431. */
  6432. static DATASOURCE_MULTIRENDERTARGET: number;
  6433. /**
  6434. * Texture data comes from a cube data file
  6435. */
  6436. static DATASOURCE_CUBE: number;
  6437. /**
  6438. * Texture data comes from a raw cube data
  6439. */
  6440. static DATASOURCE_CUBERAW: number;
  6441. /**
  6442. * Texture data come from a prefiltered cube data file
  6443. */
  6444. static DATASOURCE_CUBEPREFILTERED: number;
  6445. /**
  6446. * Texture content is raw 3D data
  6447. */
  6448. static DATASOURCE_RAW3D: number;
  6449. /**
  6450. * Texture content is a depth texture
  6451. */
  6452. static DATASOURCE_DEPTHTEXTURE: number;
  6453. /**
  6454. * Texture data comes from a raw cube data encoded with RGBD
  6455. */
  6456. static DATASOURCE_CUBERAW_RGBD: number;
  6457. /**
  6458. * Defines if the texture is ready
  6459. */
  6460. isReady: boolean;
  6461. /**
  6462. * Defines if the texture is a cube texture
  6463. */
  6464. isCube: boolean;
  6465. /**
  6466. * Defines if the texture contains 3D data
  6467. */
  6468. is3D: boolean;
  6469. /**
  6470. * Defines if the texture contains multiview data
  6471. */
  6472. isMultiview: boolean;
  6473. /**
  6474. * Gets the URL used to load this texture
  6475. */
  6476. url: string;
  6477. /**
  6478. * Gets the sampling mode of the texture
  6479. */
  6480. samplingMode: number;
  6481. /**
  6482. * Gets a boolean indicating if the texture needs mipmaps generation
  6483. */
  6484. generateMipMaps: boolean;
  6485. /**
  6486. * Gets the number of samples used by the texture (WebGL2+ only)
  6487. */
  6488. samples: number;
  6489. /**
  6490. * Gets the type of the texture (int, float...)
  6491. */
  6492. type: number;
  6493. /**
  6494. * Gets the format of the texture (RGB, RGBA...)
  6495. */
  6496. format: number;
  6497. /**
  6498. * Observable called when the texture is loaded
  6499. */
  6500. onLoadedObservable: Observable<InternalTexture>;
  6501. /**
  6502. * Gets the width of the texture
  6503. */
  6504. width: number;
  6505. /**
  6506. * Gets the height of the texture
  6507. */
  6508. height: number;
  6509. /**
  6510. * Gets the depth of the texture
  6511. */
  6512. depth: number;
  6513. /**
  6514. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6515. */
  6516. baseWidth: number;
  6517. /**
  6518. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseHeight: number;
  6521. /**
  6522. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseDepth: number;
  6525. /**
  6526. * Gets a boolean indicating if the texture is inverted on Y axis
  6527. */
  6528. invertY: boolean;
  6529. /** @hidden */
  6530. _invertVScale: boolean;
  6531. /** @hidden */
  6532. _associatedChannel: number;
  6533. /** @hidden */
  6534. _dataSource: number;
  6535. /** @hidden */
  6536. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6537. /** @hidden */
  6538. _bufferView: Nullable<ArrayBufferView>;
  6539. /** @hidden */
  6540. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6541. /** @hidden */
  6542. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6543. /** @hidden */
  6544. _size: number;
  6545. /** @hidden */
  6546. _extension: string;
  6547. /** @hidden */
  6548. _files: Nullable<string[]>;
  6549. /** @hidden */
  6550. _workingCanvas: Nullable<HTMLCanvasElement>;
  6551. /** @hidden */
  6552. _workingContext: Nullable<CanvasRenderingContext2D>;
  6553. /** @hidden */
  6554. _framebuffer: Nullable<WebGLFramebuffer>;
  6555. /** @hidden */
  6556. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6557. /** @hidden */
  6558. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _attachments: Nullable<number[]>;
  6563. /** @hidden */
  6564. _cachedCoordinatesMode: Nullable<number>;
  6565. /** @hidden */
  6566. _cachedWrapU: Nullable<number>;
  6567. /** @hidden */
  6568. _cachedWrapV: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapR: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6573. /** @hidden */
  6574. _isDisabled: boolean;
  6575. /** @hidden */
  6576. _compression: Nullable<string>;
  6577. /** @hidden */
  6578. _generateStencilBuffer: boolean;
  6579. /** @hidden */
  6580. _generateDepthBuffer: boolean;
  6581. /** @hidden */
  6582. _comparisonFunction: number;
  6583. /** @hidden */
  6584. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6585. /** @hidden */
  6586. _lodGenerationScale: number;
  6587. /** @hidden */
  6588. _lodGenerationOffset: number;
  6589. /** @hidden */
  6590. _colorTextureArray: Nullable<WebGLTexture>;
  6591. /** @hidden */
  6592. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6593. /** @hidden */
  6594. _lodTextureHigh: Nullable<BaseTexture>;
  6595. /** @hidden */
  6596. _lodTextureMid: Nullable<BaseTexture>;
  6597. /** @hidden */
  6598. _lodTextureLow: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _isRGBD: boolean;
  6601. /** @hidden */
  6602. _linearSpecularLOD: boolean;
  6603. /** @hidden */
  6604. _irradianceTexture: Nullable<BaseTexture>;
  6605. /** @hidden */
  6606. _webGLTexture: Nullable<WebGLTexture>;
  6607. /** @hidden */
  6608. _references: number;
  6609. private _engine;
  6610. /**
  6611. * Gets the Engine the texture belongs to.
  6612. * @returns The babylon engine
  6613. */
  6614. getEngine(): Engine;
  6615. /**
  6616. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6617. */
  6618. readonly dataSource: number;
  6619. /**
  6620. * Creates a new InternalTexture
  6621. * @param engine defines the engine to use
  6622. * @param dataSource defines the type of data that will be used
  6623. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6624. */
  6625. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6626. /**
  6627. * Increments the number of references (ie. the number of Texture that point to it)
  6628. */
  6629. incrementReferences(): void;
  6630. /**
  6631. * Change the size of the texture (not the size of the content)
  6632. * @param width defines the new width
  6633. * @param height defines the new height
  6634. * @param depth defines the new depth (1 by default)
  6635. */
  6636. updateSize(width: int, height: int, depth?: int): void;
  6637. /** @hidden */
  6638. _rebuild(): void;
  6639. /** @hidden */
  6640. _swapAndDie(target: InternalTexture): void;
  6641. /**
  6642. * Dispose the current allocated resources
  6643. */
  6644. dispose(): void;
  6645. }
  6646. }
  6647. declare module BABYLON {
  6648. /**
  6649. * This represents the main contract an easing function should follow.
  6650. * Easing functions are used throughout the animation system.
  6651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6652. */
  6653. export interface IEasingFunction {
  6654. /**
  6655. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6656. * of the easing function.
  6657. * The link below provides some of the most common examples of easing functions.
  6658. * @see https://easings.net/
  6659. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6660. * @returns the corresponding value on the curve defined by the easing function
  6661. */
  6662. ease(gradient: number): number;
  6663. }
  6664. /**
  6665. * Base class used for every default easing function.
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class EasingFunction implements IEasingFunction {
  6669. /**
  6670. * Interpolation follows the mathematical formula associated with the easing function.
  6671. */
  6672. static readonly EASINGMODE_EASEIN: number;
  6673. /**
  6674. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEOUT: number;
  6677. /**
  6678. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6679. */
  6680. static readonly EASINGMODE_EASEINOUT: number;
  6681. private _easingMode;
  6682. /**
  6683. * Sets the easing mode of the current function.
  6684. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6685. */
  6686. setEasingMode(easingMode: number): void;
  6687. /**
  6688. * Gets the current easing mode.
  6689. * @returns the easing mode
  6690. */
  6691. getEasingMode(): number;
  6692. /**
  6693. * @hidden
  6694. */
  6695. easeInCore(gradient: number): number;
  6696. /**
  6697. * Given an input gradient between 0 and 1, this returns the corresponding value
  6698. * of the easing function.
  6699. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6700. * @returns the corresponding value on the curve defined by the easing function
  6701. */
  6702. ease(gradient: number): number;
  6703. }
  6704. /**
  6705. * Easing function with a circle shape (see link below).
  6706. * @see https://easings.net/#easeInCirc
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class CircleEase extends EasingFunction implements IEasingFunction {
  6710. /** @hidden */
  6711. easeInCore(gradient: number): number;
  6712. }
  6713. /**
  6714. * Easing function with a ease back shape (see link below).
  6715. * @see https://easings.net/#easeInBack
  6716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6717. */
  6718. export class BackEase extends EasingFunction implements IEasingFunction {
  6719. /** Defines the amplitude of the function */
  6720. amplitude: number;
  6721. /**
  6722. * Instantiates a back ease easing
  6723. * @see https://easings.net/#easeInBack
  6724. * @param amplitude Defines the amplitude of the function
  6725. */
  6726. constructor(
  6727. /** Defines the amplitude of the function */
  6728. amplitude?: number);
  6729. /** @hidden */
  6730. easeInCore(gradient: number): number;
  6731. }
  6732. /**
  6733. * Easing function with a bouncing shape (see link below).
  6734. * @see https://easings.net/#easeInBounce
  6735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6736. */
  6737. export class BounceEase extends EasingFunction implements IEasingFunction {
  6738. /** Defines the number of bounces */
  6739. bounces: number;
  6740. /** Defines the amplitude of the bounce */
  6741. bounciness: number;
  6742. /**
  6743. * Instantiates a bounce easing
  6744. * @see https://easings.net/#easeInBounce
  6745. * @param bounces Defines the number of bounces
  6746. * @param bounciness Defines the amplitude of the bounce
  6747. */
  6748. constructor(
  6749. /** Defines the number of bounces */
  6750. bounces?: number,
  6751. /** Defines the amplitude of the bounce */
  6752. bounciness?: number);
  6753. /** @hidden */
  6754. easeInCore(gradient: number): number;
  6755. }
  6756. /**
  6757. * Easing function with a power of 3 shape (see link below).
  6758. * @see https://easings.net/#easeInCubic
  6759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6760. */
  6761. export class CubicEase extends EasingFunction implements IEasingFunction {
  6762. /** @hidden */
  6763. easeInCore(gradient: number): number;
  6764. }
  6765. /**
  6766. * Easing function with an elastic shape (see link below).
  6767. * @see https://easings.net/#easeInElastic
  6768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6769. */
  6770. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6771. /** Defines the number of oscillations*/
  6772. oscillations: number;
  6773. /** Defines the amplitude of the oscillations*/
  6774. springiness: number;
  6775. /**
  6776. * Instantiates an elastic easing function
  6777. * @see https://easings.net/#easeInElastic
  6778. * @param oscillations Defines the number of oscillations
  6779. * @param springiness Defines the amplitude of the oscillations
  6780. */
  6781. constructor(
  6782. /** Defines the number of oscillations*/
  6783. oscillations?: number,
  6784. /** Defines the amplitude of the oscillations*/
  6785. springiness?: number);
  6786. /** @hidden */
  6787. easeInCore(gradient: number): number;
  6788. }
  6789. /**
  6790. * Easing function with an exponential shape (see link below).
  6791. * @see https://easings.net/#easeInExpo
  6792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6793. */
  6794. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6795. /** Defines the exponent of the function */
  6796. exponent: number;
  6797. /**
  6798. * Instantiates an exponential easing function
  6799. * @see https://easings.net/#easeInExpo
  6800. * @param exponent Defines the exponent of the function
  6801. */
  6802. constructor(
  6803. /** Defines the exponent of the function */
  6804. exponent?: number);
  6805. /** @hidden */
  6806. easeInCore(gradient: number): number;
  6807. }
  6808. /**
  6809. * Easing function with a power shape (see link below).
  6810. * @see https://easings.net/#easeInQuad
  6811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6812. */
  6813. export class PowerEase extends EasingFunction implements IEasingFunction {
  6814. /** Defines the power of the function */
  6815. power: number;
  6816. /**
  6817. * Instantiates an power base easing function
  6818. * @see https://easings.net/#easeInQuad
  6819. * @param power Defines the power of the function
  6820. */
  6821. constructor(
  6822. /** Defines the power of the function */
  6823. power?: number);
  6824. /** @hidden */
  6825. easeInCore(gradient: number): number;
  6826. }
  6827. /**
  6828. * Easing function with a power of 2 shape (see link below).
  6829. * @see https://easings.net/#easeInQuad
  6830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6831. */
  6832. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6833. /** @hidden */
  6834. easeInCore(gradient: number): number;
  6835. }
  6836. /**
  6837. * Easing function with a power of 4 shape (see link below).
  6838. * @see https://easings.net/#easeInQuart
  6839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6840. */
  6841. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power of 5 shape (see link below).
  6847. * @see https://easings.net/#easeInQuint
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6851. /** @hidden */
  6852. easeInCore(gradient: number): number;
  6853. }
  6854. /**
  6855. * Easing function with a sin shape (see link below).
  6856. * @see https://easings.net/#easeInSine
  6857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6858. */
  6859. export class SineEase extends EasingFunction implements IEasingFunction {
  6860. /** @hidden */
  6861. easeInCore(gradient: number): number;
  6862. }
  6863. /**
  6864. * Easing function with a bezier shape (see link below).
  6865. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6867. */
  6868. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6869. /** Defines the x component of the start tangent in the bezier curve */
  6870. x1: number;
  6871. /** Defines the y component of the start tangent in the bezier curve */
  6872. y1: number;
  6873. /** Defines the x component of the end tangent in the bezier curve */
  6874. x2: number;
  6875. /** Defines the y component of the end tangent in the bezier curve */
  6876. y2: number;
  6877. /**
  6878. * Instantiates a bezier function
  6879. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6880. * @param x1 Defines the x component of the start tangent in the bezier curve
  6881. * @param y1 Defines the y component of the start tangent in the bezier curve
  6882. * @param x2 Defines the x component of the end tangent in the bezier curve
  6883. * @param y2 Defines the y component of the end tangent in the bezier curve
  6884. */
  6885. constructor(
  6886. /** Defines the x component of the start tangent in the bezier curve */
  6887. x1?: number,
  6888. /** Defines the y component of the start tangent in the bezier curve */
  6889. y1?: number,
  6890. /** Defines the x component of the end tangent in the bezier curve */
  6891. x2?: number,
  6892. /** Defines the y component of the end tangent in the bezier curve */
  6893. y2?: number);
  6894. /** @hidden */
  6895. easeInCore(gradient: number): number;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * Defines an interface which represents an animation key frame
  6901. */
  6902. export interface IAnimationKey {
  6903. /**
  6904. * Frame of the key frame
  6905. */
  6906. frame: number;
  6907. /**
  6908. * Value at the specifies key frame
  6909. */
  6910. value: any;
  6911. /**
  6912. * The input tangent for the cubic hermite spline
  6913. */
  6914. inTangent?: any;
  6915. /**
  6916. * The output tangent for the cubic hermite spline
  6917. */
  6918. outTangent?: any;
  6919. /**
  6920. * The animation interpolation type
  6921. */
  6922. interpolation?: AnimationKeyInterpolation;
  6923. }
  6924. /**
  6925. * Enum for the animation key frame interpolation type
  6926. */
  6927. export enum AnimationKeyInterpolation {
  6928. /**
  6929. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6930. */
  6931. STEP = 1
  6932. }
  6933. }
  6934. declare module BABYLON {
  6935. /**
  6936. * Represents the range of an animation
  6937. */
  6938. export class AnimationRange {
  6939. /**The name of the animation range**/
  6940. name: string;
  6941. /**The starting frame of the animation */
  6942. from: number;
  6943. /**The ending frame of the animation*/
  6944. to: number;
  6945. /**
  6946. * Initializes the range of an animation
  6947. * @param name The name of the animation range
  6948. * @param from The starting frame of the animation
  6949. * @param to The ending frame of the animation
  6950. */
  6951. constructor(
  6952. /**The name of the animation range**/
  6953. name: string,
  6954. /**The starting frame of the animation */
  6955. from: number,
  6956. /**The ending frame of the animation*/
  6957. to: number);
  6958. /**
  6959. * Makes a copy of the animation range
  6960. * @returns A copy of the animation range
  6961. */
  6962. clone(): AnimationRange;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Composed of a frame, and an action function
  6968. */
  6969. export class AnimationEvent {
  6970. /** The frame for which the event is triggered **/
  6971. frame: number;
  6972. /** The event to perform when triggered **/
  6973. action: (currentFrame: number) => void;
  6974. /** Specifies if the event should be triggered only once**/
  6975. onlyOnce?: boolean | undefined;
  6976. /**
  6977. * Specifies if the animation event is done
  6978. */
  6979. isDone: boolean;
  6980. /**
  6981. * Initializes the animation event
  6982. * @param frame The frame for which the event is triggered
  6983. * @param action The event to perform when triggered
  6984. * @param onlyOnce Specifies if the event should be triggered only once
  6985. */
  6986. constructor(
  6987. /** The frame for which the event is triggered **/
  6988. frame: number,
  6989. /** The event to perform when triggered **/
  6990. action: (currentFrame: number) => void,
  6991. /** Specifies if the event should be triggered only once**/
  6992. onlyOnce?: boolean | undefined);
  6993. /** @hidden */
  6994. _clone(): AnimationEvent;
  6995. }
  6996. }
  6997. declare module BABYLON {
  6998. /**
  6999. * Interface used to define a behavior
  7000. */
  7001. export interface Behavior<T> {
  7002. /** gets or sets behavior's name */
  7003. name: string;
  7004. /**
  7005. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7006. */
  7007. init(): void;
  7008. /**
  7009. * Called when the behavior is attached to a target
  7010. * @param target defines the target where the behavior is attached to
  7011. */
  7012. attach(target: T): void;
  7013. /**
  7014. * Called when the behavior is detached from its target
  7015. */
  7016. detach(): void;
  7017. }
  7018. /**
  7019. * Interface implemented by classes supporting behaviors
  7020. */
  7021. export interface IBehaviorAware<T> {
  7022. /**
  7023. * Attach a behavior
  7024. * @param behavior defines the behavior to attach
  7025. * @returns the current host
  7026. */
  7027. addBehavior(behavior: Behavior<T>): T;
  7028. /**
  7029. * Remove a behavior from the current object
  7030. * @param behavior defines the behavior to detach
  7031. * @returns the current host
  7032. */
  7033. removeBehavior(behavior: Behavior<T>): T;
  7034. /**
  7035. * Gets a behavior using its name to search
  7036. * @param name defines the name to search
  7037. * @returns the behavior or null if not found
  7038. */
  7039. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7040. }
  7041. }
  7042. declare module BABYLON {
  7043. /**
  7044. * @hidden
  7045. */
  7046. export class IntersectionInfo {
  7047. bu: Nullable<number>;
  7048. bv: Nullable<number>;
  7049. distance: number;
  7050. faceId: number;
  7051. subMeshId: number;
  7052. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7053. }
  7054. }
  7055. declare module BABYLON {
  7056. /**
  7057. * Class used to store bounding sphere information
  7058. */
  7059. export class BoundingSphere {
  7060. /**
  7061. * Gets the center of the bounding sphere in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Radius of the bounding sphere in local space
  7066. */
  7067. radius: number;
  7068. /**
  7069. * Gets the center of the bounding sphere in world space
  7070. */
  7071. readonly centerWorld: Vector3;
  7072. /**
  7073. * Radius of the bounding sphere in world space
  7074. */
  7075. radiusWorld: number;
  7076. /**
  7077. * Gets the minimum vector in local space
  7078. */
  7079. readonly minimum: Vector3;
  7080. /**
  7081. * Gets the maximum vector in local space
  7082. */
  7083. readonly maximum: Vector3;
  7084. private _worldMatrix;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Creates a new bounding sphere
  7088. * @param min defines the minimum vector (in local space)
  7089. * @param max defines the maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * Scale the current bounding sphere by applying a scale factor
  7102. * @param factor defines the scale factor to apply
  7103. * @returns the current bounding box
  7104. */
  7105. scale(factor: number): BoundingSphere;
  7106. /**
  7107. * Gets the world matrix of the bounding box
  7108. * @returns a matrix
  7109. */
  7110. getWorldMatrix(): DeepImmutable<Matrix>;
  7111. /** @hidden */
  7112. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7113. /**
  7114. * Tests if the bounding sphere is intersecting the frustum planes
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if there is an intersection
  7117. */
  7118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if the bounding sphere center is in between the frustum planes.
  7121. * Used for optimistic fast inclusion.
  7122. * @param frustumPlanes defines the frustum planes to test
  7123. * @returns true if the sphere center is in between the frustum planes
  7124. */
  7125. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7126. /**
  7127. * Tests if a point is inside the bounding sphere
  7128. * @param point defines the point to test
  7129. * @returns true if the point is inside the bounding sphere
  7130. */
  7131. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7132. /**
  7133. * Checks if two sphere intersct
  7134. * @param sphere0 sphere 0
  7135. * @param sphere1 sphere 1
  7136. * @returns true if the speres intersect
  7137. */
  7138. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /**
  7143. * Class used to store bounding box information
  7144. */
  7145. export class BoundingBox implements ICullable {
  7146. /**
  7147. * Gets the 8 vectors representing the bounding box in local space
  7148. */
  7149. readonly vectors: Vector3[];
  7150. /**
  7151. * Gets the center of the bounding box in local space
  7152. */
  7153. readonly center: Vector3;
  7154. /**
  7155. * Gets the center of the bounding box in world space
  7156. */
  7157. readonly centerWorld: Vector3;
  7158. /**
  7159. * Gets the extend size in local space
  7160. */
  7161. readonly extendSize: Vector3;
  7162. /**
  7163. * Gets the extend size in world space
  7164. */
  7165. readonly extendSizeWorld: Vector3;
  7166. /**
  7167. * Gets the OBB (object bounding box) directions
  7168. */
  7169. readonly directions: Vector3[];
  7170. /**
  7171. * Gets the 8 vectors representing the bounding box in world space
  7172. */
  7173. readonly vectorsWorld: Vector3[];
  7174. /**
  7175. * Gets the minimum vector in world space
  7176. */
  7177. readonly minimumWorld: Vector3;
  7178. /**
  7179. * Gets the maximum vector in world space
  7180. */
  7181. readonly maximumWorld: Vector3;
  7182. /**
  7183. * Gets the minimum vector in local space
  7184. */
  7185. readonly minimum: Vector3;
  7186. /**
  7187. * Gets the maximum vector in local space
  7188. */
  7189. readonly maximum: Vector3;
  7190. private _worldMatrix;
  7191. private static readonly TmpVector3;
  7192. /**
  7193. * @hidden
  7194. */
  7195. _tag: number;
  7196. /**
  7197. * Creates a new bounding box
  7198. * @param min defines the minimum vector (in local space)
  7199. * @param max defines the maximum vector (in local space)
  7200. * @param worldMatrix defines the new world matrix
  7201. */
  7202. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7203. /**
  7204. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7205. * @param min defines the new minimum vector (in local space)
  7206. * @param max defines the new maximum vector (in local space)
  7207. * @param worldMatrix defines the new world matrix
  7208. */
  7209. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7210. /**
  7211. * Scale the current bounding box by applying a scale factor
  7212. * @param factor defines the scale factor to apply
  7213. * @returns the current bounding box
  7214. */
  7215. scale(factor: number): BoundingBox;
  7216. /**
  7217. * Gets the world matrix of the bounding box
  7218. * @returns a matrix
  7219. */
  7220. getWorldMatrix(): DeepImmutable<Matrix>;
  7221. /** @hidden */
  7222. _update(world: DeepImmutable<Matrix>): void;
  7223. /**
  7224. * Tests if the bounding box is intersecting the frustum planes
  7225. * @param frustumPlanes defines the frustum planes to test
  7226. * @returns true if there is an intersection
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7229. /**
  7230. * Tests if the bounding box is entirely inside the frustum planes
  7231. * @param frustumPlanes defines the frustum planes to test
  7232. * @returns true if there is an inclusion
  7233. */
  7234. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7235. /**
  7236. * Tests if a point is inside the bounding box
  7237. * @param point defines the point to test
  7238. * @returns true if the point is inside the bounding box
  7239. */
  7240. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7241. /**
  7242. * Tests if the bounding box intersects with a bounding sphere
  7243. * @param sphere defines the sphere to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7247. /**
  7248. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7249. * @param min defines the min vector to use
  7250. * @param max defines the max vector to use
  7251. * @returns true if there is an intersection
  7252. */
  7253. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7254. /**
  7255. * Tests if two bounding boxes are intersections
  7256. * @param box0 defines the first box to test
  7257. * @param box1 defines the second box to test
  7258. * @returns true if there is an intersection
  7259. */
  7260. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7261. /**
  7262. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7263. * @param minPoint defines the minimum vector of the bounding box
  7264. * @param maxPoint defines the maximum vector of the bounding box
  7265. * @param sphereCenter defines the sphere center
  7266. * @param sphereRadius defines the sphere radius
  7267. * @returns true if there is an intersection
  7268. */
  7269. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7270. /**
  7271. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7272. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7273. * @param frustumPlanes defines the frustum planes to test
  7274. * @return true if there is an inclusion
  7275. */
  7276. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7277. /**
  7278. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7279. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @return true if there is an intersection
  7282. */
  7283. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /** @hidden */
  7288. export class Collider {
  7289. /** Define if a collision was found */
  7290. collisionFound: boolean;
  7291. /**
  7292. * Define last intersection point in local space
  7293. */
  7294. intersectionPoint: Vector3;
  7295. /**
  7296. * Define last collided mesh
  7297. */
  7298. collidedMesh: Nullable<AbstractMesh>;
  7299. private _collisionPoint;
  7300. private _planeIntersectionPoint;
  7301. private _tempVector;
  7302. private _tempVector2;
  7303. private _tempVector3;
  7304. private _tempVector4;
  7305. private _edge;
  7306. private _baseToVertex;
  7307. private _destinationPoint;
  7308. private _slidePlaneNormal;
  7309. private _displacementVector;
  7310. /** @hidden */
  7311. _radius: Vector3;
  7312. /** @hidden */
  7313. _retry: number;
  7314. private _velocity;
  7315. private _basePoint;
  7316. private _epsilon;
  7317. /** @hidden */
  7318. _velocityWorldLength: number;
  7319. /** @hidden */
  7320. _basePointWorld: Vector3;
  7321. private _velocityWorld;
  7322. private _normalizedVelocity;
  7323. /** @hidden */
  7324. _initialVelocity: Vector3;
  7325. /** @hidden */
  7326. _initialPosition: Vector3;
  7327. private _nearestDistance;
  7328. private _collisionMask;
  7329. collisionMask: number;
  7330. /**
  7331. * Gets the plane normal used to compute the sliding response (in local space)
  7332. */
  7333. readonly slidePlaneNormal: Vector3;
  7334. /** @hidden */
  7335. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7336. /** @hidden */
  7337. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7338. /** @hidden */
  7339. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7340. /** @hidden */
  7341. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7342. /** @hidden */
  7343. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7344. /** @hidden */
  7345. _getResponse(pos: Vector3, vel: Vector3): void;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Interface for cullable objects
  7351. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7352. */
  7353. export interface ICullable {
  7354. /**
  7355. * Checks if the object or part of the object is in the frustum
  7356. * @param frustumPlanes Camera near/planes
  7357. * @returns true if the object is in frustum otherwise false
  7358. */
  7359. isInFrustum(frustumPlanes: Plane[]): boolean;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7367. }
  7368. /**
  7369. * Info for a bounding data of a mesh
  7370. */
  7371. export class BoundingInfo implements ICullable {
  7372. /**
  7373. * Bounding box for the mesh
  7374. */
  7375. readonly boundingBox: BoundingBox;
  7376. /**
  7377. * Bounding sphere for the mesh
  7378. */
  7379. readonly boundingSphere: BoundingSphere;
  7380. private _isLocked;
  7381. private static readonly TmpVector3;
  7382. /**
  7383. * Constructs bounding info
  7384. * @param minimum min vector of the bounding box/sphere
  7385. * @param maximum max vector of the bounding box/sphere
  7386. * @param worldMatrix defines the new world matrix
  7387. */
  7388. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7389. /**
  7390. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7391. * @param min defines the new minimum vector (in local space)
  7392. * @param max defines the new maximum vector (in local space)
  7393. * @param worldMatrix defines the new world matrix
  7394. */
  7395. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7396. /**
  7397. * min vector of the bounding box/sphere
  7398. */
  7399. readonly minimum: Vector3;
  7400. /**
  7401. * max vector of the bounding box/sphere
  7402. */
  7403. readonly maximum: Vector3;
  7404. /**
  7405. * If the info is locked and won't be updated to avoid perf overhead
  7406. */
  7407. isLocked: boolean;
  7408. /**
  7409. * Updates the bounding sphere and box
  7410. * @param world world matrix to be used to update
  7411. */
  7412. update(world: DeepImmutable<Matrix>): void;
  7413. /**
  7414. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7415. * @param center New center of the bounding info
  7416. * @param extend New extend of the bounding info
  7417. * @returns the current bounding info
  7418. */
  7419. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7420. /**
  7421. * Scale the current bounding info by applying a scale factor
  7422. * @param factor defines the scale factor to apply
  7423. * @returns the current bounding info
  7424. */
  7425. scale(factor: number): BoundingInfo;
  7426. /**
  7427. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7428. * @param frustumPlanes defines the frustum to test
  7429. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7430. * @returns true if the bounding info is in the frustum planes
  7431. */
  7432. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7433. /**
  7434. * Gets the world distance between the min and max points of the bounding box
  7435. */
  7436. readonly diagonalLength: number;
  7437. /**
  7438. * Checks if a cullable object (mesh...) is in the camera frustum
  7439. * Unlike isInFrustum this cheks the full bounding box
  7440. * @param frustumPlanes Camera near/planes
  7441. * @returns true if the object is in frustum otherwise false
  7442. */
  7443. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7444. /** @hidden */
  7445. _checkCollision(collider: Collider): boolean;
  7446. /**
  7447. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7448. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7449. * @param point the point to check intersection with
  7450. * @returns if the point intersects
  7451. */
  7452. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7453. /**
  7454. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7455. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7456. * @param boundingInfo the bounding info to check intersection with
  7457. * @param precise if the intersection should be done using OBB
  7458. * @returns if the bounding info intersects
  7459. */
  7460. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7461. }
  7462. }
  7463. declare module BABYLON {
  7464. /**
  7465. * Defines an array and its length.
  7466. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7467. */
  7468. export interface ISmartArrayLike<T> {
  7469. /**
  7470. * The data of the array.
  7471. */
  7472. data: Array<T>;
  7473. /**
  7474. * The active length of the array.
  7475. */
  7476. length: number;
  7477. }
  7478. /**
  7479. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7480. */
  7481. export class SmartArray<T> implements ISmartArrayLike<T> {
  7482. /**
  7483. * The full set of data from the array.
  7484. */
  7485. data: Array<T>;
  7486. /**
  7487. * The active length of the array.
  7488. */
  7489. length: number;
  7490. protected _id: number;
  7491. /**
  7492. * Instantiates a Smart Array.
  7493. * @param capacity defines the default capacity of the array.
  7494. */
  7495. constructor(capacity: number);
  7496. /**
  7497. * Pushes a value at the end of the active data.
  7498. * @param value defines the object to push in the array.
  7499. */
  7500. push(value: T): void;
  7501. /**
  7502. * Iterates over the active data and apply the lambda to them.
  7503. * @param func defines the action to apply on each value.
  7504. */
  7505. forEach(func: (content: T) => void): void;
  7506. /**
  7507. * Sorts the full sets of data.
  7508. * @param compareFn defines the comparison function to apply.
  7509. */
  7510. sort(compareFn: (a: T, b: T) => number): void;
  7511. /**
  7512. * Resets the active data to an empty array.
  7513. */
  7514. reset(): void;
  7515. /**
  7516. * Releases all the data from the array as well as the array.
  7517. */
  7518. dispose(): void;
  7519. /**
  7520. * Concats the active data with a given array.
  7521. * @param array defines the data to concatenate with.
  7522. */
  7523. concat(array: any): void;
  7524. /**
  7525. * Returns the position of a value in the active data.
  7526. * @param value defines the value to find the index for
  7527. * @returns the index if found in the active data otherwise -1
  7528. */
  7529. indexOf(value: T): number;
  7530. /**
  7531. * Returns whether an element is part of the active data.
  7532. * @param value defines the value to look for
  7533. * @returns true if found in the active data otherwise false
  7534. */
  7535. contains(value: T): boolean;
  7536. private static _GlobalId;
  7537. }
  7538. /**
  7539. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7540. * The data in this array can only be present once
  7541. */
  7542. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7543. private _duplicateId;
  7544. /**
  7545. * Pushes a value at the end of the active data.
  7546. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7547. * @param value defines the object to push in the array.
  7548. */
  7549. push(value: T): void;
  7550. /**
  7551. * Pushes a value at the end of the active data.
  7552. * If the data is already present, it won t be added again
  7553. * @param value defines the object to push in the array.
  7554. * @returns true if added false if it was already present
  7555. */
  7556. pushNoDuplicate(value: T): boolean;
  7557. /**
  7558. * Resets the active data to an empty array.
  7559. */
  7560. reset(): void;
  7561. /**
  7562. * Concats the active data with a given array.
  7563. * This ensures no dupplicate will be present in the result.
  7564. * @param array defines the data to concatenate with.
  7565. */
  7566. concatWithNoDuplicate(array: any): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4
  7594. }
  7595. /**
  7596. * Interface used to define custom inspectable properties.
  7597. * This interface is used by the inspector to display custom property grids
  7598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7599. */
  7600. export interface IInspectable {
  7601. /**
  7602. * Gets the label to display
  7603. */
  7604. label: string;
  7605. /**
  7606. * Gets the name of the property to edit
  7607. */
  7608. propertyName: string;
  7609. /**
  7610. * Gets the type of the editor to use
  7611. */
  7612. type: InspectableType;
  7613. /**
  7614. * Gets the minimum value of the property when using in "slider" mode
  7615. */
  7616. min?: number;
  7617. /**
  7618. * Gets the maximum value of the property when using in "slider" mode
  7619. */
  7620. max?: number;
  7621. /**
  7622. * Gets the setp to use when using in "slider" mode
  7623. */
  7624. step?: number;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * This represents the required contract to create a new type of texture loader.
  7630. */
  7631. export interface IInternalTextureLoader {
  7632. /**
  7633. * Defines wether the loader supports cascade loading the different faces.
  7634. */
  7635. supportCascades: boolean;
  7636. /**
  7637. * This returns if the loader support the current file information.
  7638. * @param extension defines the file extension of the file being loaded
  7639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7640. * @param fallback defines the fallback internal texture if any
  7641. * @param isBase64 defines whether the texture is encoded as a base64
  7642. * @param isBuffer defines whether the texture data are stored as a buffer
  7643. * @returns true if the loader can load the specified file
  7644. */
  7645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7646. /**
  7647. * Transform the url before loading if required.
  7648. * @param rootUrl the url of the texture
  7649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7650. * @returns the transformed texture
  7651. */
  7652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7653. /**
  7654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7655. * @param rootUrl the url of the texture
  7656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7657. * @returns the fallback texture
  7658. */
  7659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7660. /**
  7661. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7662. * @param data contains the texture data
  7663. * @param texture defines the BabylonJS internal texture
  7664. * @param createPolynomials will be true if polynomials have been requested
  7665. * @param onLoad defines the callback to trigger once the texture is ready
  7666. * @param onError defines the callback to trigger in case of error
  7667. */
  7668. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /**
  7670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7671. * @param data contains the texture data
  7672. * @param texture defines the BabylonJS internal texture
  7673. * @param callback defines the method to call once ready to upload
  7674. */
  7675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7676. }
  7677. }
  7678. declare module BABYLON {
  7679. interface Engine {
  7680. /**
  7681. * Creates a depth stencil cube texture.
  7682. * This is only available in WebGL 2.
  7683. * @param size The size of face edge in the cube texture.
  7684. * @param options The options defining the cube texture.
  7685. * @returns The cube texture
  7686. */
  7687. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7688. /**
  7689. * Creates a cube texture
  7690. * @param rootUrl defines the url where the files to load is located
  7691. * @param scene defines the current scene
  7692. * @param files defines the list of files to load (1 per face)
  7693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7694. * @param onLoad defines an optional callback raised when the texture is loaded
  7695. * @param onError defines an optional callback raised if there is an issue to load the texture
  7696. * @param format defines the format of the data
  7697. * @param forcedExtension defines the extension to use to pick the right loader
  7698. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7699. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7700. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7701. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7702. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7703. * @returns the cube texture as an InternalTexture
  7704. */
  7705. 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;
  7706. /**
  7707. * Creates a cube texture
  7708. * @param rootUrl defines the url where the files to load is located
  7709. * @param scene defines the current scene
  7710. * @param files defines the list of files to load (1 per face)
  7711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7712. * @param onLoad defines an optional callback raised when the texture is loaded
  7713. * @param onError defines an optional callback raised if there is an issue to load the texture
  7714. * @param format defines the format of the data
  7715. * @param forcedExtension defines the extension to use to pick the right loader
  7716. * @returns the cube texture as an InternalTexture
  7717. */
  7718. 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;
  7719. /**
  7720. * Creates a cube texture
  7721. * @param rootUrl defines the url where the files to load is located
  7722. * @param scene defines the current scene
  7723. * @param files defines the list of files to load (1 per face)
  7724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7725. * @param onLoad defines an optional callback raised when the texture is loaded
  7726. * @param onError defines an optional callback raised if there is an issue to load the texture
  7727. * @param format defines the format of the data
  7728. * @param forcedExtension defines the extension to use to pick the right loader
  7729. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @returns the cube texture as an InternalTexture
  7733. */
  7734. 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;
  7735. /** @hidden */
  7736. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7737. /** @hidden */
  7738. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7739. /** @hidden */
  7740. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7741. /** @hidden */
  7742. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. }
  7744. }
  7745. declare module BABYLON {
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. /**
  7769. * Returns the bounding box size
  7770. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7771. */
  7772. boundingBoxSize: Vector3;
  7773. protected _rotationY: number;
  7774. /**
  7775. * Sets texture matrix rotation angle around Y axis in radians.
  7776. */
  7777. /**
  7778. * Gets texture matrix rotation angle around Y axis radians.
  7779. */
  7780. rotationY: number;
  7781. /**
  7782. * Are mip maps generated for this texture or not.
  7783. */
  7784. readonly noMipmap: boolean;
  7785. private _noMipmap;
  7786. private _files;
  7787. private _extensions;
  7788. private _textureMatrix;
  7789. private _format;
  7790. private _createPolynomials;
  7791. /** @hidden */
  7792. _prefiltered: boolean;
  7793. /**
  7794. * Creates a cube texture from an array of image urls
  7795. * @param files defines an array of image urls
  7796. * @param scene defines the hosting scene
  7797. * @param noMipmap specifies if mip maps are not used
  7798. * @returns a cube texture
  7799. */
  7800. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7801. /**
  7802. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7803. * @param url defines the url of the prefiltered texture
  7804. * @param scene defines the scene the texture is attached to
  7805. * @param forcedExtension defines the extension of the file if different from the url
  7806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7807. * @return the prefiltered texture
  7808. */
  7809. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7810. /**
  7811. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7812. * as prefiltered data.
  7813. * @param rootUrl defines the url of the texture or the root name of the six images
  7814. * @param scene defines the scene the texture is attached to
  7815. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7816. * @param noMipmap defines if mipmaps should be created or not
  7817. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7818. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7819. * @param onError defines a callback triggered in case of error during load
  7820. * @param format defines the internal format to use for the texture once loaded
  7821. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7822. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7823. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7826. * @return the cube texture
  7827. */
  7828. 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);
  7829. /**
  7830. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7831. */
  7832. readonly isPrefiltered: boolean;
  7833. /**
  7834. * Get the current class name of the texture useful for serialization or dynamic coding.
  7835. * @returns "CubeTexture"
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Update the url (and optional buffer) of this texture if url was null during construction.
  7840. * @param url the url of the texture
  7841. * @param forcedExtension defines the extension to use
  7842. * @param onLoad callback called when the texture is loaded (defaults to null)
  7843. */
  7844. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7845. /**
  7846. * Delays loading of the cube texture
  7847. * @param forcedExtension defines the extension to use
  7848. */
  7849. delayLoad(forcedExtension?: string): void;
  7850. /**
  7851. * Returns the reflection texture matrix
  7852. * @returns the reflection texture matrix
  7853. */
  7854. getReflectionTextureMatrix(): Matrix;
  7855. /**
  7856. * Sets the reflection texture matrix
  7857. * @param value Reflection texture matrix
  7858. */
  7859. setReflectionTextureMatrix(value: Matrix): void;
  7860. /**
  7861. * Parses text to create a cube texture
  7862. * @param parsedTexture define the serialized text to read from
  7863. * @param scene defines the hosting scene
  7864. * @param rootUrl defines the root url of the cube texture
  7865. * @returns a cube texture
  7866. */
  7867. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7868. /**
  7869. * Makes a clone, or deep copy, of the cube texture
  7870. * @returns a new cube texture
  7871. */
  7872. clone(): CubeTexture;
  7873. }
  7874. }
  7875. declare module BABYLON {
  7876. /** @hidden */
  7877. export var postprocessVertexShader: {
  7878. name: string;
  7879. shader: string;
  7880. };
  7881. }
  7882. declare module BABYLON {
  7883. /**
  7884. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7885. * This is the base of the follow, arc rotate cameras and Free camera
  7886. * @see http://doc.babylonjs.com/features/cameras
  7887. */
  7888. export class TargetCamera extends Camera {
  7889. private static _RigCamTransformMatrix;
  7890. private static _TargetTransformMatrix;
  7891. private static _TargetFocalPoint;
  7892. /**
  7893. * Define the current direction the camera is moving to
  7894. */
  7895. cameraDirection: Vector3;
  7896. /**
  7897. * Define the current rotation the camera is rotating to
  7898. */
  7899. cameraRotation: Vector2;
  7900. /**
  7901. * When set, the up vector of the camera will be updated by the rotation of the camera
  7902. */
  7903. updateUpVectorFromRotation: boolean;
  7904. private _tmpQuaternion;
  7905. /**
  7906. * Define the current rotation of the camera
  7907. */
  7908. rotation: Vector3;
  7909. /**
  7910. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7911. */
  7912. rotationQuaternion: Quaternion;
  7913. /**
  7914. * Define the current speed of the camera
  7915. */
  7916. speed: number;
  7917. /**
  7918. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7919. * around all axis.
  7920. */
  7921. noRotationConstraint: boolean;
  7922. /**
  7923. * Define the current target of the camera as an object or a position.
  7924. */
  7925. lockedTarget: any;
  7926. /** @hidden */
  7927. _currentTarget: Vector3;
  7928. /** @hidden */
  7929. _initialFocalDistance: number;
  7930. /** @hidden */
  7931. _viewMatrix: Matrix;
  7932. /** @hidden */
  7933. _camMatrix: Matrix;
  7934. /** @hidden */
  7935. _cameraTransformMatrix: Matrix;
  7936. /** @hidden */
  7937. _cameraRotationMatrix: Matrix;
  7938. /** @hidden */
  7939. _referencePoint: Vector3;
  7940. /** @hidden */
  7941. _transformedReferencePoint: Vector3;
  7942. protected _globalCurrentTarget: Vector3;
  7943. protected _globalCurrentUpVector: Vector3;
  7944. /** @hidden */
  7945. _reset: () => void;
  7946. private _defaultUp;
  7947. /**
  7948. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7949. * This is the base of the follow, arc rotate cameras and Free camera
  7950. * @see http://doc.babylonjs.com/features/cameras
  7951. * @param name Defines the name of the camera in the scene
  7952. * @param position Defines the start position of the camera in the scene
  7953. * @param scene Defines the scene the camera belongs to
  7954. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7955. */
  7956. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7957. /**
  7958. * Gets the position in front of the camera at a given distance.
  7959. * @param distance The distance from the camera we want the position to be
  7960. * @returns the position
  7961. */
  7962. getFrontPosition(distance: number): Vector3;
  7963. /** @hidden */
  7964. _getLockedTargetPosition(): Nullable<Vector3>;
  7965. private _storedPosition;
  7966. private _storedRotation;
  7967. private _storedRotationQuaternion;
  7968. /**
  7969. * Store current camera state of the camera (fov, position, rotation, etc..)
  7970. * @returns the camera
  7971. */
  7972. storeState(): Camera;
  7973. /**
  7974. * Restored camera state. You must call storeState() first
  7975. * @returns whether it was successful or not
  7976. * @hidden
  7977. */
  7978. _restoreStateValues(): boolean;
  7979. /** @hidden */
  7980. _initCache(): void;
  7981. /** @hidden */
  7982. _updateCache(ignoreParentClass?: boolean): void;
  7983. /** @hidden */
  7984. _isSynchronizedViewMatrix(): boolean;
  7985. /** @hidden */
  7986. _computeLocalCameraSpeed(): number;
  7987. /**
  7988. * Defines the target the camera should look at.
  7989. * @param target Defines the new target as a Vector or a mesh
  7990. */
  7991. setTarget(target: Vector3): void;
  7992. /**
  7993. * Return the current target position of the camera. This value is expressed in local space.
  7994. * @returns the target position
  7995. */
  7996. getTarget(): Vector3;
  7997. /** @hidden */
  7998. _decideIfNeedsToMove(): boolean;
  7999. /** @hidden */
  8000. _updatePosition(): void;
  8001. /** @hidden */
  8002. _checkInputs(): void;
  8003. protected _updateCameraRotationMatrix(): void;
  8004. /**
  8005. * 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)
  8006. * @returns the current camera
  8007. */
  8008. private _rotateUpVectorWithCameraRotationMatrix;
  8009. private _cachedRotationZ;
  8010. private _cachedQuaternionRotationZ;
  8011. /** @hidden */
  8012. _getViewMatrix(): Matrix;
  8013. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8014. /**
  8015. * @hidden
  8016. */
  8017. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8018. /**
  8019. * @hidden
  8020. */
  8021. _updateRigCameras(): void;
  8022. private _getRigCamPositionAndTarget;
  8023. /**
  8024. * Gets the current object class name.
  8025. * @return the class name
  8026. */
  8027. getClassName(): string;
  8028. }
  8029. }
  8030. declare module BABYLON {
  8031. /**
  8032. * @ignore
  8033. * This is a list of all the different input types that are available in the application.
  8034. * Fo instance: ArcRotateCameraGamepadInput...
  8035. */
  8036. export var CameraInputTypes: {};
  8037. /**
  8038. * This is the contract to implement in order to create a new input class.
  8039. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8040. */
  8041. export interface ICameraInput<TCamera extends Camera> {
  8042. /**
  8043. * Defines the camera the input is attached to.
  8044. */
  8045. camera: Nullable<TCamera>;
  8046. /**
  8047. * Gets the class name of the current intput.
  8048. * @returns the class name
  8049. */
  8050. getClassName(): string;
  8051. /**
  8052. * Get the friendly name associated with the input class.
  8053. * @returns the input friendly name
  8054. */
  8055. getSimpleName(): string;
  8056. /**
  8057. * Attach the input controls to a specific dom element to get the input from.
  8058. * @param element Defines the element the controls should be listened from
  8059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8060. */
  8061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8062. /**
  8063. * Detach the current controls from the specified dom element.
  8064. * @param element Defines the element to stop listening the inputs from
  8065. */
  8066. detachControl(element: Nullable<HTMLElement>): void;
  8067. /**
  8068. * Update the current camera state depending on the inputs that have been used this frame.
  8069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8070. */
  8071. checkInputs?: () => void;
  8072. }
  8073. /**
  8074. * Represents a map of input types to input instance or input index to input instance.
  8075. */
  8076. export interface CameraInputsMap<TCamera extends Camera> {
  8077. /**
  8078. * Accessor to the input by input type.
  8079. */
  8080. [name: string]: ICameraInput<TCamera>;
  8081. /**
  8082. * Accessor to the input by input index.
  8083. */
  8084. [idx: number]: ICameraInput<TCamera>;
  8085. }
  8086. /**
  8087. * This represents the input manager used within a camera.
  8088. * It helps dealing with all the different kind of input attached to a camera.
  8089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8090. */
  8091. export class CameraInputsManager<TCamera extends Camera> {
  8092. /**
  8093. * Defines the list of inputs attahed to the camera.
  8094. */
  8095. attached: CameraInputsMap<TCamera>;
  8096. /**
  8097. * Defines the dom element the camera is collecting inputs from.
  8098. * This is null if the controls have not been attached.
  8099. */
  8100. attachedElement: Nullable<HTMLElement>;
  8101. /**
  8102. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8103. */
  8104. noPreventDefault: boolean;
  8105. /**
  8106. * Defined the camera the input manager belongs to.
  8107. */
  8108. camera: TCamera;
  8109. /**
  8110. * Update the current camera state depending on the inputs that have been used this frame.
  8111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8112. */
  8113. checkInputs: () => void;
  8114. /**
  8115. * Instantiate a new Camera Input Manager.
  8116. * @param camera Defines the camera the input manager blongs to
  8117. */
  8118. constructor(camera: TCamera);
  8119. /**
  8120. * Add an input method to a camera
  8121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8122. * @param input camera input method
  8123. */
  8124. add(input: ICameraInput<TCamera>): void;
  8125. /**
  8126. * Remove a specific input method from a camera
  8127. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8128. * @param inputToRemove camera input method
  8129. */
  8130. remove(inputToRemove: ICameraInput<TCamera>): void;
  8131. /**
  8132. * Remove a specific input type from a camera
  8133. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8134. * @param inputType the type of the input to remove
  8135. */
  8136. removeByType(inputType: string): void;
  8137. private _addCheckInputs;
  8138. /**
  8139. * Attach the input controls to the currently attached dom element to listen the events from.
  8140. * @param input Defines the input to attach
  8141. */
  8142. attachInput(input: ICameraInput<TCamera>): void;
  8143. /**
  8144. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8145. * @param element Defines the dom element to collect the events from
  8146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8147. */
  8148. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8149. /**
  8150. * Detach the current manager inputs controls from a specific dom element.
  8151. * @param element Defines the dom element to collect the events from
  8152. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8153. */
  8154. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8155. /**
  8156. * Rebuild the dynamic inputCheck function from the current list of
  8157. * defined inputs in the manager.
  8158. */
  8159. rebuildInputCheck(): void;
  8160. /**
  8161. * Remove all attached input methods from a camera
  8162. */
  8163. clear(): void;
  8164. /**
  8165. * Serialize the current input manager attached to a camera.
  8166. * This ensures than once parsed,
  8167. * the input associated to the camera will be identical to the current ones
  8168. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8169. */
  8170. serialize(serializedCamera: any): void;
  8171. /**
  8172. * Parses an input manager serialized JSON to restore the previous list of inputs
  8173. * and states associated to a camera.
  8174. * @param parsedCamera Defines the JSON to parse
  8175. */
  8176. parse(parsedCamera: any): void;
  8177. }
  8178. }
  8179. declare module BABYLON {
  8180. /**
  8181. * Gather the list of keyboard event types as constants.
  8182. */
  8183. export class KeyboardEventTypes {
  8184. /**
  8185. * The keydown event is fired when a key becomes active (pressed).
  8186. */
  8187. static readonly KEYDOWN: number;
  8188. /**
  8189. * The keyup event is fired when a key has been released.
  8190. */
  8191. static readonly KEYUP: number;
  8192. }
  8193. /**
  8194. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8195. */
  8196. export class KeyboardInfo {
  8197. /**
  8198. * Defines the type of event (KeyboardEventTypes)
  8199. */
  8200. type: number;
  8201. /**
  8202. * Defines the related dom event
  8203. */
  8204. event: KeyboardEvent;
  8205. /**
  8206. * Instantiates a new keyboard info.
  8207. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8208. * @param type Defines the type of event (KeyboardEventTypes)
  8209. * @param event Defines the related dom event
  8210. */
  8211. constructor(
  8212. /**
  8213. * Defines the type of event (KeyboardEventTypes)
  8214. */
  8215. type: number,
  8216. /**
  8217. * Defines the related dom event
  8218. */
  8219. event: KeyboardEvent);
  8220. }
  8221. /**
  8222. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8223. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8224. */
  8225. export class KeyboardInfoPre extends KeyboardInfo {
  8226. /**
  8227. * Defines the type of event (KeyboardEventTypes)
  8228. */
  8229. type: number;
  8230. /**
  8231. * Defines the related dom event
  8232. */
  8233. event: KeyboardEvent;
  8234. /**
  8235. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8236. */
  8237. skipOnPointerObservable: boolean;
  8238. /**
  8239. * Instantiates a new keyboard pre info.
  8240. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8241. * @param type Defines the type of event (KeyboardEventTypes)
  8242. * @param event Defines the related dom event
  8243. */
  8244. constructor(
  8245. /**
  8246. * Defines the type of event (KeyboardEventTypes)
  8247. */
  8248. type: number,
  8249. /**
  8250. * Defines the related dom event
  8251. */
  8252. event: KeyboardEvent);
  8253. }
  8254. }
  8255. declare module BABYLON {
  8256. /**
  8257. * Manage the keyboard inputs to control the movement of a free camera.
  8258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8259. */
  8260. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8261. /**
  8262. * Defines the camera the input is attached to.
  8263. */
  8264. camera: FreeCamera;
  8265. /**
  8266. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8267. */
  8268. keysUp: number[];
  8269. /**
  8270. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8271. */
  8272. keysDown: number[];
  8273. /**
  8274. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8275. */
  8276. keysLeft: number[];
  8277. /**
  8278. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8279. */
  8280. keysRight: number[];
  8281. private _keys;
  8282. private _onCanvasBlurObserver;
  8283. private _onKeyboardObserver;
  8284. private _engine;
  8285. private _scene;
  8286. /**
  8287. * Attach the input controls to a specific dom element to get the input from.
  8288. * @param element Defines the element the controls should be listened from
  8289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8290. */
  8291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8292. /**
  8293. * Detach the current controls from the specified dom element.
  8294. * @param element Defines the element to stop listening the inputs from
  8295. */
  8296. detachControl(element: Nullable<HTMLElement>): void;
  8297. /**
  8298. * Update the current camera state depending on the inputs that have been used this frame.
  8299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8300. */
  8301. checkInputs(): void;
  8302. /**
  8303. * Gets the class name of the current intput.
  8304. * @returns the class name
  8305. */
  8306. getClassName(): string;
  8307. /** @hidden */
  8308. _onLostFocus(): void;
  8309. /**
  8310. * Get the friendly name associated with the input class.
  8311. * @returns the input friendly name
  8312. */
  8313. getSimpleName(): string;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8319. * separate meshes. This can be use to improve performances.
  8320. * @see http://doc.babylonjs.com/how_to/multi_materials
  8321. */
  8322. export class MultiMaterial extends Material {
  8323. private _subMaterials;
  8324. /**
  8325. * Gets or Sets the list of Materials used within the multi material.
  8326. * They need to be ordered according to the submeshes order in the associated mesh
  8327. */
  8328. subMaterials: Nullable<Material>[];
  8329. /**
  8330. * Function used to align with Node.getChildren()
  8331. * @returns the list of Materials used within the multi material
  8332. */
  8333. getChildren(): Nullable<Material>[];
  8334. /**
  8335. * Instantiates a new Multi Material
  8336. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8337. * separate meshes. This can be use to improve performances.
  8338. * @see http://doc.babylonjs.com/how_to/multi_materials
  8339. * @param name Define the name in the scene
  8340. * @param scene Define the scene the material belongs to
  8341. */
  8342. constructor(name: string, scene: Scene);
  8343. private _hookArray;
  8344. /**
  8345. * Get one of the submaterial by its index in the submaterials array
  8346. * @param index The index to look the sub material at
  8347. * @returns The Material if the index has been defined
  8348. */
  8349. getSubMaterial(index: number): Nullable<Material>;
  8350. /**
  8351. * Get the list of active textures for the whole sub materials list.
  8352. * @returns All the textures that will be used during the rendering
  8353. */
  8354. getActiveTextures(): BaseTexture[];
  8355. /**
  8356. * Gets the current class name of the material e.g. "MultiMaterial"
  8357. * Mainly use in serialization.
  8358. * @returns the class name
  8359. */
  8360. getClassName(): string;
  8361. /**
  8362. * Checks if the material is ready to render the requested sub mesh
  8363. * @param mesh Define the mesh the submesh belongs to
  8364. * @param subMesh Define the sub mesh to look readyness for
  8365. * @param useInstances Define whether or not the material is used with instances
  8366. * @returns true if ready, otherwise false
  8367. */
  8368. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8369. /**
  8370. * Clones the current material and its related sub materials
  8371. * @param name Define the name of the newly cloned material
  8372. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8373. * @returns the cloned material
  8374. */
  8375. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8376. /**
  8377. * Serializes the materials into a JSON representation.
  8378. * @returns the JSON representation
  8379. */
  8380. serialize(): any;
  8381. /**
  8382. * Dispose the material and release its associated resources
  8383. * @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)
  8384. * @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)
  8385. * @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)
  8386. */
  8387. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8388. /**
  8389. * Creates a MultiMaterial from parsed MultiMaterial data.
  8390. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8391. * @param scene defines the hosting scene
  8392. * @returns a new MultiMaterial
  8393. */
  8394. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8395. }
  8396. }
  8397. declare module BABYLON {
  8398. /**
  8399. * Class used to represent data loading progression
  8400. */
  8401. export class SceneLoaderFlags {
  8402. private static _ForceFullSceneLoadingForIncremental;
  8403. private static _ShowLoadingScreen;
  8404. private static _CleanBoneMatrixWeights;
  8405. private static _loggingLevel;
  8406. /**
  8407. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8408. */
  8409. static ForceFullSceneLoadingForIncremental: boolean;
  8410. /**
  8411. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8412. */
  8413. static ShowLoadingScreen: boolean;
  8414. /**
  8415. * Defines the current logging level (while loading the scene)
  8416. * @ignorenaming
  8417. */
  8418. static loggingLevel: number;
  8419. /**
  8420. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8421. */
  8422. static CleanBoneMatrixWeights: boolean;
  8423. }
  8424. }
  8425. declare module BABYLON {
  8426. /**
  8427. * 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.
  8428. * @see https://doc.babylonjs.com/how_to/transformnode
  8429. */
  8430. export class TransformNode extends Node {
  8431. /**
  8432. * Object will not rotate to face the camera
  8433. */
  8434. static BILLBOARDMODE_NONE: number;
  8435. /**
  8436. * Object will rotate to face the camera but only on the x axis
  8437. */
  8438. static BILLBOARDMODE_X: number;
  8439. /**
  8440. * Object will rotate to face the camera but only on the y axis
  8441. */
  8442. static BILLBOARDMODE_Y: number;
  8443. /**
  8444. * Object will rotate to face the camera but only on the z axis
  8445. */
  8446. static BILLBOARDMODE_Z: number;
  8447. /**
  8448. * Object will rotate to face the camera
  8449. */
  8450. static BILLBOARDMODE_ALL: number;
  8451. private _forward;
  8452. private _forwardInverted;
  8453. private _up;
  8454. private _right;
  8455. private _rightInverted;
  8456. private _position;
  8457. private _rotation;
  8458. private _rotationQuaternion;
  8459. protected _scaling: Vector3;
  8460. protected _isDirty: boolean;
  8461. private _transformToBoneReferal;
  8462. private _billboardMode;
  8463. /**
  8464. * Gets or sets the billboard mode. Default is 0.
  8465. *
  8466. * | Value | Type | Description |
  8467. * | --- | --- | --- |
  8468. * | 0 | BILLBOARDMODE_NONE | |
  8469. * | 1 | BILLBOARDMODE_X | |
  8470. * | 2 | BILLBOARDMODE_Y | |
  8471. * | 4 | BILLBOARDMODE_Z | |
  8472. * | 7 | BILLBOARDMODE_ALL | |
  8473. *
  8474. */
  8475. billboardMode: number;
  8476. private _preserveParentRotationForBillboard;
  8477. /**
  8478. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8479. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8480. */
  8481. preserveParentRotationForBillboard: boolean;
  8482. /**
  8483. * 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
  8484. */
  8485. scalingDeterminant: number;
  8486. private _infiniteDistance;
  8487. /**
  8488. * Gets or sets the distance of the object to max, often used by skybox
  8489. */
  8490. infiniteDistance: boolean;
  8491. /**
  8492. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8493. * By default the system will update normals to compensate
  8494. */
  8495. ignoreNonUniformScaling: boolean;
  8496. /**
  8497. * 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
  8498. */
  8499. reIntegrateRotationIntoRotationQuaternion: boolean;
  8500. /** @hidden */
  8501. _poseMatrix: Nullable<Matrix>;
  8502. /** @hidden */
  8503. _localMatrix: Matrix;
  8504. private _usePivotMatrix;
  8505. private _absolutePosition;
  8506. private _pivotMatrix;
  8507. private _pivotMatrixInverse;
  8508. protected _postMultiplyPivotMatrix: boolean;
  8509. protected _isWorldMatrixFrozen: boolean;
  8510. /** @hidden */
  8511. _indexInSceneTransformNodesArray: number;
  8512. /**
  8513. * An event triggered after the world matrix is updated
  8514. */
  8515. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8516. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8517. /**
  8518. * Gets a string identifying the name of the class
  8519. * @returns "TransformNode" string
  8520. */
  8521. getClassName(): string;
  8522. /**
  8523. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8524. */
  8525. position: Vector3;
  8526. /**
  8527. * 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)).
  8528. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8529. */
  8530. rotation: Vector3;
  8531. /**
  8532. * 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)).
  8533. */
  8534. scaling: Vector3;
  8535. /**
  8536. * 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).
  8537. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8538. */
  8539. rotationQuaternion: Nullable<Quaternion>;
  8540. /**
  8541. * The forward direction of that transform in world space.
  8542. */
  8543. readonly forward: Vector3;
  8544. /**
  8545. * The up direction of that transform in world space.
  8546. */
  8547. readonly up: Vector3;
  8548. /**
  8549. * The right direction of that transform in world space.
  8550. */
  8551. readonly right: Vector3;
  8552. /**
  8553. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8554. * @param matrix the matrix to copy the pose from
  8555. * @returns this TransformNode.
  8556. */
  8557. updatePoseMatrix(matrix: Matrix): TransformNode;
  8558. /**
  8559. * Returns the mesh Pose matrix.
  8560. * @returns the pose matrix
  8561. */
  8562. getPoseMatrix(): Matrix;
  8563. /** @hidden */
  8564. _isSynchronized(): boolean;
  8565. /** @hidden */
  8566. _initCache(): void;
  8567. /**
  8568. * Flag the transform node as dirty (Forcing it to update everything)
  8569. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8570. * @returns this transform node
  8571. */
  8572. markAsDirty(property: string): TransformNode;
  8573. /**
  8574. * Returns the current mesh absolute position.
  8575. * Returns a Vector3.
  8576. */
  8577. readonly absolutePosition: Vector3;
  8578. /**
  8579. * Sets a new matrix to apply before all other transformation
  8580. * @param matrix defines the transform matrix
  8581. * @returns the current TransformNode
  8582. */
  8583. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8584. /**
  8585. * Sets a new pivot matrix to the current node
  8586. * @param matrix defines the new pivot matrix to use
  8587. * @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
  8588. * @returns the current TransformNode
  8589. */
  8590. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8591. /**
  8592. * Returns the mesh pivot matrix.
  8593. * Default : Identity.
  8594. * @returns the matrix
  8595. */
  8596. getPivotMatrix(): Matrix;
  8597. /**
  8598. * Prevents the World matrix to be computed any longer.
  8599. * @returns the TransformNode.
  8600. */
  8601. freezeWorldMatrix(): TransformNode;
  8602. /**
  8603. * Allows back the World matrix computation.
  8604. * @returns the TransformNode.
  8605. */
  8606. unfreezeWorldMatrix(): this;
  8607. /**
  8608. * True if the World matrix has been frozen.
  8609. */
  8610. readonly isWorldMatrixFrozen: boolean;
  8611. /**
  8612. * Retuns the mesh absolute position in the World.
  8613. * @returns a Vector3.
  8614. */
  8615. getAbsolutePosition(): Vector3;
  8616. /**
  8617. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8618. * @param absolutePosition the absolute position to set
  8619. * @returns the TransformNode.
  8620. */
  8621. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8622. /**
  8623. * Sets the mesh position in its local space.
  8624. * @param vector3 the position to set in localspace
  8625. * @returns the TransformNode.
  8626. */
  8627. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8628. /**
  8629. * Returns the mesh position in the local space from the current World matrix values.
  8630. * @returns a new Vector3.
  8631. */
  8632. getPositionExpressedInLocalSpace(): Vector3;
  8633. /**
  8634. * Translates the mesh along the passed Vector3 in its local space.
  8635. * @param vector3 the distance to translate in localspace
  8636. * @returns the TransformNode.
  8637. */
  8638. locallyTranslate(vector3: Vector3): TransformNode;
  8639. private static _lookAtVectorCache;
  8640. /**
  8641. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8642. * @param targetPoint the position (must be in same space as current mesh) to look at
  8643. * @param yawCor optional yaw (y-axis) correction in radians
  8644. * @param pitchCor optional pitch (x-axis) correction in radians
  8645. * @param rollCor optional roll (z-axis) correction in radians
  8646. * @param space the choosen space of the target
  8647. * @returns the TransformNode.
  8648. */
  8649. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8650. /**
  8651. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8652. * This Vector3 is expressed in the World space.
  8653. * @param localAxis axis to rotate
  8654. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8655. */
  8656. getDirection(localAxis: Vector3): Vector3;
  8657. /**
  8658. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8659. * localAxis is expressed in the mesh local space.
  8660. * result is computed in the Wordl space from the mesh World matrix.
  8661. * @param localAxis axis to rotate
  8662. * @param result the resulting transformnode
  8663. * @returns this TransformNode.
  8664. */
  8665. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8666. /**
  8667. * Sets this transform node rotation to the given local axis.
  8668. * @param localAxis the axis in local space
  8669. * @param yawCor optional yaw (y-axis) correction in radians
  8670. * @param pitchCor optional pitch (x-axis) correction in radians
  8671. * @param rollCor optional roll (z-axis) correction in radians
  8672. * @returns this TransformNode
  8673. */
  8674. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8675. /**
  8676. * Sets a new pivot point to the current node
  8677. * @param point defines the new pivot point to use
  8678. * @param space defines if the point is in world or local space (local by default)
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8682. /**
  8683. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8684. * @returns the pivot point
  8685. */
  8686. getPivotPoint(): Vector3;
  8687. /**
  8688. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8689. * @param result the vector3 to store the result
  8690. * @returns this TransformNode.
  8691. */
  8692. getPivotPointToRef(result: Vector3): TransformNode;
  8693. /**
  8694. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8695. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8696. */
  8697. getAbsolutePivotPoint(): Vector3;
  8698. /**
  8699. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8700. * @param result vector3 to store the result
  8701. * @returns this TransformNode.
  8702. */
  8703. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8704. /**
  8705. * Defines the passed node as the parent of the current node.
  8706. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8707. * @see https://doc.babylonjs.com/how_to/parenting
  8708. * @param node the node ot set as the parent
  8709. * @returns this TransformNode.
  8710. */
  8711. setParent(node: Nullable<Node>): TransformNode;
  8712. private _nonUniformScaling;
  8713. /**
  8714. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8715. */
  8716. readonly nonUniformScaling: boolean;
  8717. /** @hidden */
  8718. _updateNonUniformScalingState(value: boolean): boolean;
  8719. /**
  8720. * Attach the current TransformNode to another TransformNode associated with a bone
  8721. * @param bone Bone affecting the TransformNode
  8722. * @param affectedTransformNode TransformNode associated with the bone
  8723. * @returns this object
  8724. */
  8725. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8726. /**
  8727. * Detach the transform node if its associated with a bone
  8728. * @returns this object
  8729. */
  8730. detachFromBone(): TransformNode;
  8731. private static _rotationAxisCache;
  8732. /**
  8733. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8734. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8735. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8736. * The passed axis is also normalized.
  8737. * @param axis the axis to rotate around
  8738. * @param amount the amount to rotate in radians
  8739. * @param space Space to rotate in (Default: local)
  8740. * @returns the TransformNode.
  8741. */
  8742. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8743. /**
  8744. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8745. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8746. * The passed axis is also normalized. .
  8747. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8748. * @param point the point to rotate around
  8749. * @param axis the axis to rotate around
  8750. * @param amount the amount to rotate in radians
  8751. * @returns the TransformNode
  8752. */
  8753. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8754. /**
  8755. * Translates the mesh along the axis vector for the passed distance in the given space.
  8756. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8757. * @param axis the axis to translate in
  8758. * @param distance the distance to translate
  8759. * @param space Space to rotate in (Default: local)
  8760. * @returns the TransformNode.
  8761. */
  8762. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8763. /**
  8764. * Adds a rotation step to the mesh current rotation.
  8765. * x, y, z are Euler angles expressed in radians.
  8766. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8767. * This means this rotation is made in the mesh local space only.
  8768. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8769. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8770. * ```javascript
  8771. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8772. * ```
  8773. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8774. * 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.
  8775. * @param x Rotation to add
  8776. * @param y Rotation to add
  8777. * @param z Rotation to add
  8778. * @returns the TransformNode.
  8779. */
  8780. addRotation(x: number, y: number, z: number): TransformNode;
  8781. /**
  8782. * @hidden
  8783. */
  8784. protected _getEffectiveParent(): Nullable<Node>;
  8785. /**
  8786. * Computes the world matrix of the node
  8787. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8788. * @returns the world matrix
  8789. */
  8790. computeWorldMatrix(force?: boolean): Matrix;
  8791. protected _afterComputeWorldMatrix(): void;
  8792. /**
  8793. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8794. * @param func callback function to add
  8795. *
  8796. * @returns the TransformNode.
  8797. */
  8798. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8799. /**
  8800. * Removes a registered callback function.
  8801. * @param func callback function to remove
  8802. * @returns the TransformNode.
  8803. */
  8804. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8805. /**
  8806. * Gets the position of the current mesh in camera space
  8807. * @param camera defines the camera to use
  8808. * @returns a position
  8809. */
  8810. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8811. /**
  8812. * Returns the distance from the mesh to the active camera
  8813. * @param camera defines the camera to use
  8814. * @returns the distance
  8815. */
  8816. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8817. /**
  8818. * Clone the current transform node
  8819. * @param name Name of the new clone
  8820. * @param newParent New parent for the clone
  8821. * @param doNotCloneChildren Do not clone children hierarchy
  8822. * @returns the new transform node
  8823. */
  8824. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8825. /**
  8826. * Serializes the objects information.
  8827. * @param currentSerializationObject defines the object to serialize in
  8828. * @returns the serialized object
  8829. */
  8830. serialize(currentSerializationObject?: any): any;
  8831. /**
  8832. * Returns a new TransformNode object parsed from the source provided.
  8833. * @param parsedTransformNode is the source.
  8834. * @param scene the scne the object belongs to
  8835. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8836. * @returns a new TransformNode object parsed from the source provided.
  8837. */
  8838. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8839. /**
  8840. * Get all child-transformNodes of this node
  8841. * @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
  8842. * @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
  8843. * @returns an array of TransformNode
  8844. */
  8845. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8846. /**
  8847. * Releases resources associated with this transform node.
  8848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8850. */
  8851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8852. /**
  8853. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8854. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8855. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8856. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8857. * @returns the current mesh
  8858. */
  8859. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8860. }
  8861. }
  8862. declare module BABYLON {
  8863. /**
  8864. * Class used to override all child animations of a given target
  8865. */
  8866. export class AnimationPropertiesOverride {
  8867. /**
  8868. * Gets or sets a value indicating if animation blending must be used
  8869. */
  8870. enableBlending: boolean;
  8871. /**
  8872. * Gets or sets the blending speed to use when enableBlending is true
  8873. */
  8874. blendingSpeed: number;
  8875. /**
  8876. * Gets or sets the default loop mode to use
  8877. */
  8878. loopMode: number;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. /**
  8883. * Class used to store bone information
  8884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8885. */
  8886. export class Bone extends Node {
  8887. /**
  8888. * defines the bone name
  8889. */
  8890. name: string;
  8891. private static _tmpVecs;
  8892. private static _tmpQuat;
  8893. private static _tmpMats;
  8894. /**
  8895. * Gets the list of child bones
  8896. */
  8897. children: Bone[];
  8898. /** Gets the animations associated with this bone */
  8899. animations: Animation[];
  8900. /**
  8901. * Gets or sets bone length
  8902. */
  8903. length: number;
  8904. /**
  8905. * @hidden Internal only
  8906. * Set this value to map this bone to a different index in the transform matrices
  8907. * Set this value to -1 to exclude the bone from the transform matrices
  8908. */
  8909. _index: Nullable<number>;
  8910. private _skeleton;
  8911. private _localMatrix;
  8912. private _restPose;
  8913. private _baseMatrix;
  8914. private _absoluteTransform;
  8915. private _invertedAbsoluteTransform;
  8916. private _parent;
  8917. private _scalingDeterminant;
  8918. private _worldTransform;
  8919. private _localScaling;
  8920. private _localRotation;
  8921. private _localPosition;
  8922. private _needToDecompose;
  8923. private _needToCompose;
  8924. /** @hidden */
  8925. _linkedTransformNode: Nullable<TransformNode>;
  8926. /** @hidden */
  8927. _waitingTransformNodeId: Nullable<string>;
  8928. /** @hidden */
  8929. /** @hidden */
  8930. _matrix: Matrix;
  8931. /**
  8932. * Create a new bone
  8933. * @param name defines the bone name
  8934. * @param skeleton defines the parent skeleton
  8935. * @param parentBone defines the parent (can be null if the bone is the root)
  8936. * @param localMatrix defines the local matrix
  8937. * @param restPose defines the rest pose matrix
  8938. * @param baseMatrix defines the base matrix
  8939. * @param index defines index of the bone in the hiearchy
  8940. */
  8941. constructor(
  8942. /**
  8943. * defines the bone name
  8944. */
  8945. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8946. /**
  8947. * Gets the current object class name.
  8948. * @return the class name
  8949. */
  8950. getClassName(): string;
  8951. /**
  8952. * Gets the parent skeleton
  8953. * @returns a skeleton
  8954. */
  8955. getSkeleton(): Skeleton;
  8956. /**
  8957. * Gets parent bone
  8958. * @returns a bone or null if the bone is the root of the bone hierarchy
  8959. */
  8960. getParent(): Nullable<Bone>;
  8961. /**
  8962. * Returns an array containing the root bones
  8963. * @returns an array containing the root bones
  8964. */
  8965. getChildren(): Array<Bone>;
  8966. /**
  8967. * Sets the parent bone
  8968. * @param parent defines the parent (can be null if the bone is the root)
  8969. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8970. */
  8971. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8972. /**
  8973. * Gets the local matrix
  8974. * @returns a matrix
  8975. */
  8976. getLocalMatrix(): Matrix;
  8977. /**
  8978. * Gets the base matrix (initial matrix which remains unchanged)
  8979. * @returns a matrix
  8980. */
  8981. getBaseMatrix(): Matrix;
  8982. /**
  8983. * Gets the rest pose matrix
  8984. * @returns a matrix
  8985. */
  8986. getRestPose(): Matrix;
  8987. /**
  8988. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8989. */
  8990. getWorldMatrix(): Matrix;
  8991. /**
  8992. * Sets the local matrix to rest pose matrix
  8993. */
  8994. returnToRest(): void;
  8995. /**
  8996. * Gets the inverse of the absolute transform matrix.
  8997. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8998. * @returns a matrix
  8999. */
  9000. getInvertedAbsoluteTransform(): Matrix;
  9001. /**
  9002. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9003. * @returns a matrix
  9004. */
  9005. getAbsoluteTransform(): Matrix;
  9006. /**
  9007. * Links with the given transform node.
  9008. * The local matrix of this bone is copied from the transform node every frame.
  9009. * @param transformNode defines the transform node to link to
  9010. */
  9011. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9012. /** Gets or sets current position (in local space) */
  9013. position: Vector3;
  9014. /** Gets or sets current rotation (in local space) */
  9015. rotation: Vector3;
  9016. /** Gets or sets current rotation quaternion (in local space) */
  9017. rotationQuaternion: Quaternion;
  9018. /** Gets or sets current scaling (in local space) */
  9019. scaling: Vector3;
  9020. /**
  9021. * Gets the animation properties override
  9022. */
  9023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9024. private _decompose;
  9025. private _compose;
  9026. /**
  9027. * Update the base and local matrices
  9028. * @param matrix defines the new base or local matrix
  9029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9030. * @param updateLocalMatrix defines if the local matrix should be updated
  9031. */
  9032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9033. /** @hidden */
  9034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9035. /**
  9036. * Flag the bone as dirty (Forcing it to update everything)
  9037. */
  9038. markAsDirty(): void;
  9039. /** @hidden */
  9040. _markAsDirtyAndCompose(): void;
  9041. private _markAsDirtyAndDecompose;
  9042. /**
  9043. * Translate the bone in local or world space
  9044. * @param vec The amount to translate the bone
  9045. * @param space The space that the translation is in
  9046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9047. */
  9048. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9049. /**
  9050. * Set the postion of the bone in local or world space
  9051. * @param position The position to set the bone
  9052. * @param space The space that the position is in
  9053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9054. */
  9055. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9056. /**
  9057. * Set the absolute position of the bone (world space)
  9058. * @param position The position to set the bone
  9059. * @param mesh The mesh that this bone is attached to
  9060. */
  9061. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9062. /**
  9063. * Scale the bone on the x, y and z axes (in local space)
  9064. * @param x The amount to scale the bone on the x axis
  9065. * @param y The amount to scale the bone on the y axis
  9066. * @param z The amount to scale the bone on the z axis
  9067. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9068. */
  9069. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9070. /**
  9071. * Set the bone scaling in local space
  9072. * @param scale defines the scaling vector
  9073. */
  9074. setScale(scale: Vector3): void;
  9075. /**
  9076. * Gets the current scaling in local space
  9077. * @returns the current scaling vector
  9078. */
  9079. getScale(): Vector3;
  9080. /**
  9081. * Gets the current scaling in local space and stores it in a target vector
  9082. * @param result defines the target vector
  9083. */
  9084. getScaleToRef(result: Vector3): void;
  9085. /**
  9086. * Set the yaw, pitch, and roll of the bone in local or world space
  9087. * @param yaw The rotation of the bone on the y axis
  9088. * @param pitch The rotation of the bone on the x axis
  9089. * @param roll The rotation of the bone on the z axis
  9090. * @param space The space that the axes of rotation are in
  9091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9092. */
  9093. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9094. /**
  9095. * Add a rotation to the bone on an axis in local or world space
  9096. * @param axis The axis to rotate the bone on
  9097. * @param amount The amount to rotate the bone
  9098. * @param space The space that the axis is in
  9099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9100. */
  9101. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9102. /**
  9103. * Set the rotation of the bone to a particular axis angle in local or world space
  9104. * @param axis The axis to rotate the bone on
  9105. * @param angle The angle that the bone should be rotated to
  9106. * @param space The space that the axis is in
  9107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9108. */
  9109. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9110. /**
  9111. * Set the euler rotation of the bone in local of world space
  9112. * @param rotation The euler rotation that the bone should be set to
  9113. * @param space The space that the rotation is in
  9114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9115. */
  9116. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9117. /**
  9118. * Set the quaternion rotation of the bone in local of world space
  9119. * @param quat The quaternion rotation that the bone should be set to
  9120. * @param space The space that the rotation is in
  9121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9122. */
  9123. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9124. /**
  9125. * Set the rotation matrix of the bone in local of world space
  9126. * @param rotMat The rotation matrix that the bone should be set to
  9127. * @param space The space that the rotation is in
  9128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9129. */
  9130. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9131. private _rotateWithMatrix;
  9132. private _getNegativeRotationToRef;
  9133. /**
  9134. * Get the position of the bone in local or world space
  9135. * @param space The space that the returned position is in
  9136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9137. * @returns The position of the bone
  9138. */
  9139. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9140. /**
  9141. * Copy the position of the bone to a vector3 in local or world space
  9142. * @param space The space that the returned position is in
  9143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9144. * @param result The vector3 to copy the position to
  9145. */
  9146. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9147. /**
  9148. * Get the absolute position of the bone (world space)
  9149. * @param mesh The mesh that this bone is attached to
  9150. * @returns The absolute position of the bone
  9151. */
  9152. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9153. /**
  9154. * Copy the absolute position of the bone (world space) to the result param
  9155. * @param mesh The mesh that this bone is attached to
  9156. * @param result The vector3 to copy the absolute position to
  9157. */
  9158. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9159. /**
  9160. * Compute the absolute transforms of this bone and its children
  9161. */
  9162. computeAbsoluteTransforms(): void;
  9163. /**
  9164. * Get the world direction from an axis that is in the local space of the bone
  9165. * @param localAxis The local direction that is used to compute the world direction
  9166. * @param mesh The mesh that this bone is attached to
  9167. * @returns The world direction
  9168. */
  9169. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9170. /**
  9171. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9172. * @param localAxis The local direction that is used to compute the world direction
  9173. * @param mesh The mesh that this bone is attached to
  9174. * @param result The vector3 that the world direction will be copied to
  9175. */
  9176. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9177. /**
  9178. * Get the euler rotation of the bone in local or world space
  9179. * @param space The space that the rotation should be in
  9180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9181. * @returns The euler rotation
  9182. */
  9183. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9184. /**
  9185. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9186. * @param space The space that the rotation should be in
  9187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9188. * @param result The vector3 that the rotation should be copied to
  9189. */
  9190. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9191. /**
  9192. * Get the quaternion rotation of the bone in either local or world space
  9193. * @param space The space that the rotation should be in
  9194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9195. * @returns The quaternion rotation
  9196. */
  9197. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9198. /**
  9199. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9200. * @param space The space that the rotation should be in
  9201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9202. * @param result The quaternion that the rotation should be copied to
  9203. */
  9204. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9205. /**
  9206. * Get the rotation matrix of the bone in local or world space
  9207. * @param space The space that the rotation should be in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. * @returns The rotation matrix
  9210. */
  9211. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9212. /**
  9213. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9214. * @param space The space that the rotation should be in
  9215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9216. * @param result The quaternion that the rotation should be copied to
  9217. */
  9218. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9219. /**
  9220. * Get the world position of a point that is in the local space of the bone
  9221. * @param position The local position
  9222. * @param mesh The mesh that this bone is attached to
  9223. * @returns The world position
  9224. */
  9225. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9226. /**
  9227. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9228. * @param position The local position
  9229. * @param mesh The mesh that this bone is attached to
  9230. * @param result The vector3 that the world position should be copied to
  9231. */
  9232. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9233. /**
  9234. * Get the local position of a point that is in world space
  9235. * @param position The world position
  9236. * @param mesh The mesh that this bone is attached to
  9237. * @returns The local position
  9238. */
  9239. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9240. /**
  9241. * Get the local position of a point that is in world space and copy it to the result param
  9242. * @param position The world position
  9243. * @param mesh The mesh that this bone is attached to
  9244. * @param result The vector3 that the local position should be copied to
  9245. */
  9246. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9247. }
  9248. }
  9249. declare module BABYLON {
  9250. interface Engine {
  9251. /**
  9252. * Creates a raw texture
  9253. * @param data defines the data to store in the texture
  9254. * @param width defines the width of the texture
  9255. * @param height defines the height of the texture
  9256. * @param format defines the format of the data
  9257. * @param generateMipMaps defines if the engine should generate the mip levels
  9258. * @param invertY defines if data must be stored with Y axis inverted
  9259. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9260. * @param compression defines the compression used (null by default)
  9261. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9262. * @returns the raw texture inside an InternalTexture
  9263. */
  9264. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9265. /**
  9266. * Update a raw texture
  9267. * @param texture defines the texture to update
  9268. * @param data defines the data to store in the texture
  9269. * @param format defines the format of the data
  9270. * @param invertY defines if data must be stored with Y axis inverted
  9271. */
  9272. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9273. /**
  9274. * Update a raw texture
  9275. * @param texture defines the texture to update
  9276. * @param data defines the data to store in the texture
  9277. * @param format defines the format of the data
  9278. * @param invertY defines if data must be stored with Y axis inverted
  9279. * @param compression defines the compression used (null by default)
  9280. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9281. */
  9282. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9283. /**
  9284. * Creates a new raw cube texture
  9285. * @param data defines the array of data to use to create each face
  9286. * @param size defines the size of the textures
  9287. * @param format defines the format of the data
  9288. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9289. * @param generateMipMaps defines if the engine should generate the mip levels
  9290. * @param invertY defines if data must be stored with Y axis inverted
  9291. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9292. * @param compression defines the compression used (null by default)
  9293. * @returns the cube texture as an InternalTexture
  9294. */
  9295. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9296. /**
  9297. * Update a raw cube texture
  9298. * @param texture defines the texture to udpdate
  9299. * @param data defines the data to store
  9300. * @param format defines the data format
  9301. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9302. * @param invertY defines if data must be stored with Y axis inverted
  9303. */
  9304. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9305. /**
  9306. * Update a raw cube texture
  9307. * @param texture defines the texture to udpdate
  9308. * @param data defines the data to store
  9309. * @param format defines the data format
  9310. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9311. * @param invertY defines if data must be stored with Y axis inverted
  9312. * @param compression defines the compression used (null by default)
  9313. */
  9314. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9315. /**
  9316. * Update a raw cube texture
  9317. * @param texture defines the texture to udpdate
  9318. * @param data defines the data to store
  9319. * @param format defines the data format
  9320. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9321. * @param invertY defines if data must be stored with Y axis inverted
  9322. * @param compression defines the compression used (null by default)
  9323. * @param level defines which level of the texture to update
  9324. */
  9325. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9326. /**
  9327. * Creates a new raw cube texture from a specified url
  9328. * @param url defines the url where the data is located
  9329. * @param scene defines the current scene
  9330. * @param size defines the size of the textures
  9331. * @param format defines the format of the data
  9332. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9333. * @param noMipmap defines if the engine should avoid generating the mip levels
  9334. * @param callback defines a callback used to extract texture data from loaded data
  9335. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9336. * @param onLoad defines a callback called when texture is loaded
  9337. * @param onError defines a callback called if there is an error
  9338. * @returns the cube texture as an InternalTexture
  9339. */
  9340. 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;
  9341. /**
  9342. * Creates a new raw cube texture from a specified url
  9343. * @param url defines the url where the data is located
  9344. * @param scene defines the current scene
  9345. * @param size defines the size of the textures
  9346. * @param format defines the format of the data
  9347. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9348. * @param noMipmap defines if the engine should avoid generating the mip levels
  9349. * @param callback defines a callback used to extract texture data from loaded data
  9350. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9351. * @param onLoad defines a callback called when texture is loaded
  9352. * @param onError defines a callback called if there is an error
  9353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9354. * @param invertY defines if data must be stored with Y axis inverted
  9355. * @returns the cube texture as an InternalTexture
  9356. */
  9357. 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;
  9358. /**
  9359. * Creates a new raw 3D texture
  9360. * @param data defines the data used to create the texture
  9361. * @param width defines the width of the texture
  9362. * @param height defines the height of the texture
  9363. * @param depth defines the depth of the texture
  9364. * @param format defines the format of the texture
  9365. * @param generateMipMaps defines if the engine must generate mip levels
  9366. * @param invertY defines if data must be stored with Y axis inverted
  9367. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9368. * @param compression defines the compressed used (can be null)
  9369. * @param textureType defines the compressed used (can be null)
  9370. * @returns a new raw 3D texture (stored in an InternalTexture)
  9371. */
  9372. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9373. /**
  9374. * Update a raw 3D texture
  9375. * @param texture defines the texture to update
  9376. * @param data defines the data to store
  9377. * @param format defines the data format
  9378. * @param invertY defines if data must be stored with Y axis inverted
  9379. */
  9380. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9381. /**
  9382. * Update a raw 3D texture
  9383. * @param texture defines the texture to update
  9384. * @param data defines the data to store
  9385. * @param format defines the data format
  9386. * @param invertY defines if data must be stored with Y axis inverted
  9387. * @param compression defines the used compression (can be null)
  9388. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9389. */
  9390. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9391. }
  9392. }
  9393. declare module BABYLON {
  9394. /**
  9395. * Raw texture can help creating a texture directly from an array of data.
  9396. * This can be super useful if you either get the data from an uncompressed source or
  9397. * if you wish to create your texture pixel by pixel.
  9398. */
  9399. export class RawTexture extends Texture {
  9400. /**
  9401. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9402. */
  9403. format: number;
  9404. private _engine;
  9405. /**
  9406. * Instantiates a new RawTexture.
  9407. * Raw texture can help creating a texture directly from an array of data.
  9408. * This can be super useful if you either get the data from an uncompressed source or
  9409. * if you wish to create your texture pixel by pixel.
  9410. * @param data define the array of data to use to create the texture
  9411. * @param width define the width of the texture
  9412. * @param height define the height of the texture
  9413. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9414. * @param scene define the scene the texture belongs to
  9415. * @param generateMipMaps define whether mip maps should be generated or not
  9416. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9417. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9418. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9419. */
  9420. constructor(data: ArrayBufferView, width: number, height: number,
  9421. /**
  9422. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9423. */
  9424. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9425. /**
  9426. * Updates the texture underlying data.
  9427. * @param data Define the new data of the texture
  9428. */
  9429. update(data: ArrayBufferView): void;
  9430. /**
  9431. * Creates a luminance texture from some data.
  9432. * @param data Define the texture data
  9433. * @param width Define the width of the texture
  9434. * @param height Define the height of the texture
  9435. * @param scene Define the scene the texture belongs to
  9436. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9437. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9438. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9439. * @returns the luminance texture
  9440. */
  9441. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9442. /**
  9443. * Creates a luminance alpha texture from some data.
  9444. * @param data Define the texture data
  9445. * @param width Define the width of the texture
  9446. * @param height Define the height of the texture
  9447. * @param scene Define the scene the texture belongs to
  9448. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9449. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9450. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9451. * @returns the luminance alpha texture
  9452. */
  9453. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9454. /**
  9455. * Creates an alpha texture from some data.
  9456. * @param data Define the texture data
  9457. * @param width Define the width of the texture
  9458. * @param height Define the height of the texture
  9459. * @param scene Define the scene the texture belongs to
  9460. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9461. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9462. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9463. * @returns the alpha texture
  9464. */
  9465. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9466. /**
  9467. * Creates a RGB texture from some data.
  9468. * @param data Define the texture data
  9469. * @param width Define the width of the texture
  9470. * @param height Define the height of the texture
  9471. * @param scene Define the scene the texture belongs to
  9472. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9473. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9474. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9475. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9476. * @returns the RGB alpha texture
  9477. */
  9478. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9479. /**
  9480. * Creates a RGBA texture from some data.
  9481. * @param data Define the texture data
  9482. * @param width Define the width of the texture
  9483. * @param height Define the height of the texture
  9484. * @param scene Define the scene the texture belongs to
  9485. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9488. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9489. * @returns the RGBA texture
  9490. */
  9491. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9492. /**
  9493. * Creates a R texture from some data.
  9494. * @param data Define the texture data
  9495. * @param width Define the width of the texture
  9496. * @param height Define the height of the texture
  9497. * @param scene Define the scene the texture belongs to
  9498. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9501. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9502. * @returns the R texture
  9503. */
  9504. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9505. }
  9506. }
  9507. declare module BABYLON {
  9508. /**
  9509. * Defines a runtime animation
  9510. */
  9511. export class RuntimeAnimation {
  9512. private _events;
  9513. /**
  9514. * The current frame of the runtime animation
  9515. */
  9516. private _currentFrame;
  9517. /**
  9518. * The animation used by the runtime animation
  9519. */
  9520. private _animation;
  9521. /**
  9522. * The target of the runtime animation
  9523. */
  9524. private _target;
  9525. /**
  9526. * The initiating animatable
  9527. */
  9528. private _host;
  9529. /**
  9530. * The original value of the runtime animation
  9531. */
  9532. private _originalValue;
  9533. /**
  9534. * The original blend value of the runtime animation
  9535. */
  9536. private _originalBlendValue;
  9537. /**
  9538. * The offsets cache of the runtime animation
  9539. */
  9540. private _offsetsCache;
  9541. /**
  9542. * The high limits cache of the runtime animation
  9543. */
  9544. private _highLimitsCache;
  9545. /**
  9546. * Specifies if the runtime animation has been stopped
  9547. */
  9548. private _stopped;
  9549. /**
  9550. * The blending factor of the runtime animation
  9551. */
  9552. private _blendingFactor;
  9553. /**
  9554. * The BabylonJS scene
  9555. */
  9556. private _scene;
  9557. /**
  9558. * The current value of the runtime animation
  9559. */
  9560. private _currentValue;
  9561. /** @hidden */
  9562. _animationState: _IAnimationState;
  9563. /**
  9564. * The active target of the runtime animation
  9565. */
  9566. private _activeTargets;
  9567. private _currentActiveTarget;
  9568. private _directTarget;
  9569. /**
  9570. * The target path of the runtime animation
  9571. */
  9572. private _targetPath;
  9573. /**
  9574. * The weight of the runtime animation
  9575. */
  9576. private _weight;
  9577. /**
  9578. * The ratio offset of the runtime animation
  9579. */
  9580. private _ratioOffset;
  9581. /**
  9582. * The previous delay of the runtime animation
  9583. */
  9584. private _previousDelay;
  9585. /**
  9586. * The previous ratio of the runtime animation
  9587. */
  9588. private _previousRatio;
  9589. private _enableBlending;
  9590. private _keys;
  9591. private _minFrame;
  9592. private _maxFrame;
  9593. private _minValue;
  9594. private _maxValue;
  9595. private _targetIsArray;
  9596. /**
  9597. * Gets the current frame of the runtime animation
  9598. */
  9599. readonly currentFrame: number;
  9600. /**
  9601. * Gets the weight of the runtime animation
  9602. */
  9603. readonly weight: number;
  9604. /**
  9605. * Gets the current value of the runtime animation
  9606. */
  9607. readonly currentValue: any;
  9608. /**
  9609. * Gets the target path of the runtime animation
  9610. */
  9611. readonly targetPath: string;
  9612. /**
  9613. * Gets the actual target of the runtime animation
  9614. */
  9615. readonly target: any;
  9616. /** @hidden */
  9617. _onLoop: () => void;
  9618. /**
  9619. * Create a new RuntimeAnimation object
  9620. * @param target defines the target of the animation
  9621. * @param animation defines the source animation object
  9622. * @param scene defines the hosting scene
  9623. * @param host defines the initiating Animatable
  9624. */
  9625. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9626. private _preparePath;
  9627. /**
  9628. * Gets the animation from the runtime animation
  9629. */
  9630. readonly animation: Animation;
  9631. /**
  9632. * Resets the runtime animation to the beginning
  9633. * @param restoreOriginal defines whether to restore the target property to the original value
  9634. */
  9635. reset(restoreOriginal?: boolean): void;
  9636. /**
  9637. * Specifies if the runtime animation is stopped
  9638. * @returns Boolean specifying if the runtime animation is stopped
  9639. */
  9640. isStopped(): boolean;
  9641. /**
  9642. * Disposes of the runtime animation
  9643. */
  9644. dispose(): void;
  9645. /**
  9646. * Apply the interpolated value to the target
  9647. * @param currentValue defines the value computed by the animation
  9648. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9649. */
  9650. setValue(currentValue: any, weight: number): void;
  9651. private _getOriginalValues;
  9652. private _setValue;
  9653. /**
  9654. * Gets the loop pmode of the runtime animation
  9655. * @returns Loop Mode
  9656. */
  9657. private _getCorrectLoopMode;
  9658. /**
  9659. * Move the current animation to a given frame
  9660. * @param frame defines the frame to move to
  9661. */
  9662. goToFrame(frame: number): void;
  9663. /**
  9664. * @hidden Internal use only
  9665. */
  9666. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9667. /**
  9668. * Execute the current animation
  9669. * @param delay defines the delay to add to the current frame
  9670. * @param from defines the lower bound of the animation range
  9671. * @param to defines the upper bound of the animation range
  9672. * @param loop defines if the current animation must loop
  9673. * @param speedRatio defines the current speed ratio
  9674. * @param weight defines the weight of the animation (default is -1 so no weight)
  9675. * @param onLoop optional callback called when animation loops
  9676. * @returns a boolean indicating if the animation is running
  9677. */
  9678. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9679. }
  9680. }
  9681. declare module BABYLON {
  9682. /**
  9683. * Class used to store an actual running animation
  9684. */
  9685. export class Animatable {
  9686. /** defines the target object */
  9687. target: any;
  9688. /** defines the starting frame number (default is 0) */
  9689. fromFrame: number;
  9690. /** defines the ending frame number (default is 100) */
  9691. toFrame: number;
  9692. /** defines if the animation must loop (default is false) */
  9693. loopAnimation: boolean;
  9694. /** defines a callback to call when animation ends if it is not looping */
  9695. onAnimationEnd?: (() => void) | null | undefined;
  9696. /** defines a callback to call when animation loops */
  9697. onAnimationLoop?: (() => void) | null | undefined;
  9698. private _localDelayOffset;
  9699. private _pausedDelay;
  9700. private _runtimeAnimations;
  9701. private _paused;
  9702. private _scene;
  9703. private _speedRatio;
  9704. private _weight;
  9705. private _syncRoot;
  9706. /**
  9707. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9708. * This will only apply for non looping animation (default is true)
  9709. */
  9710. disposeOnEnd: boolean;
  9711. /**
  9712. * Gets a boolean indicating if the animation has started
  9713. */
  9714. animationStarted: boolean;
  9715. /**
  9716. * Observer raised when the animation ends
  9717. */
  9718. onAnimationEndObservable: Observable<Animatable>;
  9719. /**
  9720. * Observer raised when the animation loops
  9721. */
  9722. onAnimationLoopObservable: Observable<Animatable>;
  9723. /**
  9724. * Gets the root Animatable used to synchronize and normalize animations
  9725. */
  9726. readonly syncRoot: Nullable<Animatable>;
  9727. /**
  9728. * Gets the current frame of the first RuntimeAnimation
  9729. * Used to synchronize Animatables
  9730. */
  9731. readonly masterFrame: number;
  9732. /**
  9733. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9734. */
  9735. weight: number;
  9736. /**
  9737. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9738. */
  9739. speedRatio: number;
  9740. /**
  9741. * Creates a new Animatable
  9742. * @param scene defines the hosting scene
  9743. * @param target defines the target object
  9744. * @param fromFrame defines the starting frame number (default is 0)
  9745. * @param toFrame defines the ending frame number (default is 100)
  9746. * @param loopAnimation defines if the animation must loop (default is false)
  9747. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9748. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9749. * @param animations defines a group of animation to add to the new Animatable
  9750. * @param onAnimationLoop defines a callback to call when animation loops
  9751. */
  9752. constructor(scene: Scene,
  9753. /** defines the target object */
  9754. target: any,
  9755. /** defines the starting frame number (default is 0) */
  9756. fromFrame?: number,
  9757. /** defines the ending frame number (default is 100) */
  9758. toFrame?: number,
  9759. /** defines if the animation must loop (default is false) */
  9760. loopAnimation?: boolean, speedRatio?: number,
  9761. /** defines a callback to call when animation ends if it is not looping */
  9762. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9763. /** defines a callback to call when animation loops */
  9764. onAnimationLoop?: (() => void) | null | undefined);
  9765. /**
  9766. * Synchronize and normalize current Animatable with a source Animatable
  9767. * This is useful when using animation weights and when animations are not of the same length
  9768. * @param root defines the root Animatable to synchronize with
  9769. * @returns the current Animatable
  9770. */
  9771. syncWith(root: Animatable): Animatable;
  9772. /**
  9773. * Gets the list of runtime animations
  9774. * @returns an array of RuntimeAnimation
  9775. */
  9776. getAnimations(): RuntimeAnimation[];
  9777. /**
  9778. * Adds more animations to the current animatable
  9779. * @param target defines the target of the animations
  9780. * @param animations defines the new animations to add
  9781. */
  9782. appendAnimations(target: any, animations: Animation[]): void;
  9783. /**
  9784. * Gets the source animation for a specific property
  9785. * @param property defines the propertyu to look for
  9786. * @returns null or the source animation for the given property
  9787. */
  9788. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9789. /**
  9790. * Gets the runtime animation for a specific property
  9791. * @param property defines the propertyu to look for
  9792. * @returns null or the runtime animation for the given property
  9793. */
  9794. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9795. /**
  9796. * Resets the animatable to its original state
  9797. */
  9798. reset(): void;
  9799. /**
  9800. * Allows the animatable to blend with current running animations
  9801. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9802. * @param blendingSpeed defines the blending speed to use
  9803. */
  9804. enableBlending(blendingSpeed: number): void;
  9805. /**
  9806. * Disable animation blending
  9807. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9808. */
  9809. disableBlending(): void;
  9810. /**
  9811. * Jump directly to a given frame
  9812. * @param frame defines the frame to jump to
  9813. */
  9814. goToFrame(frame: number): void;
  9815. /**
  9816. * Pause the animation
  9817. */
  9818. pause(): void;
  9819. /**
  9820. * Restart the animation
  9821. */
  9822. restart(): void;
  9823. private _raiseOnAnimationEnd;
  9824. /**
  9825. * Stop and delete the current animation
  9826. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9827. * @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)
  9828. */
  9829. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9830. /**
  9831. * Wait asynchronously for the animation to end
  9832. * @returns a promise which will be fullfilled when the animation ends
  9833. */
  9834. waitAsync(): Promise<Animatable>;
  9835. /** @hidden */
  9836. _animate(delay: number): boolean;
  9837. }
  9838. interface Scene {
  9839. /** @hidden */
  9840. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9841. /** @hidden */
  9842. _processLateAnimationBindingsForMatrices(holder: {
  9843. totalWeight: number;
  9844. animations: RuntimeAnimation[];
  9845. originalValue: Matrix;
  9846. }): any;
  9847. /** @hidden */
  9848. _processLateAnimationBindingsForQuaternions(holder: {
  9849. totalWeight: number;
  9850. animations: RuntimeAnimation[];
  9851. originalValue: Quaternion;
  9852. }, refQuaternion: Quaternion): Quaternion;
  9853. /** @hidden */
  9854. _processLateAnimationBindings(): void;
  9855. /**
  9856. * Will start the animation sequence of a given target
  9857. * @param target defines the target
  9858. * @param from defines from which frame should animation start
  9859. * @param to defines until which frame should animation run.
  9860. * @param weight defines the weight to apply to the animation (1.0 by default)
  9861. * @param loop defines if the animation loops
  9862. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9863. * @param onAnimationEnd defines the function to be executed when the animation ends
  9864. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9865. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9866. * @param onAnimationLoop defines the callback to call when an animation loops
  9867. * @returns the animatable object created for this animation
  9868. */
  9869. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9870. /**
  9871. * Will start the animation sequence of a given target
  9872. * @param target defines the target
  9873. * @param from defines from which frame should animation start
  9874. * @param to defines until which frame should animation run.
  9875. * @param loop defines if the animation loops
  9876. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9877. * @param onAnimationEnd defines the function to be executed when the animation ends
  9878. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9879. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9880. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9881. * @param onAnimationLoop defines the callback to call when an animation loops
  9882. * @returns the animatable object created for this animation
  9883. */
  9884. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9885. /**
  9886. * Will start the animation sequence of a given target and its hierarchy
  9887. * @param target defines the target
  9888. * @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.
  9889. * @param from defines from which frame should animation start
  9890. * @param to defines until which frame should animation run.
  9891. * @param loop defines if the animation loops
  9892. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9893. * @param onAnimationEnd defines the function to be executed when the animation ends
  9894. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9895. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9896. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9897. * @param onAnimationLoop defines the callback to call when an animation loops
  9898. * @returns the list of created animatables
  9899. */
  9900. 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[];
  9901. /**
  9902. * Begin a new animation on a given node
  9903. * @param target defines the target where the animation will take place
  9904. * @param animations defines the list of animations to start
  9905. * @param from defines the initial value
  9906. * @param to defines the final value
  9907. * @param loop defines if you want animation to loop (off by default)
  9908. * @param speedRatio defines the speed ratio to apply to all animations
  9909. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9910. * @param onAnimationLoop defines the callback to call when an animation loops
  9911. * @returns the list of created animatables
  9912. */
  9913. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9914. /**
  9915. * Begin a new animation on a given node and its hierarchy
  9916. * @param target defines the root node where the animation will take place
  9917. * @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.
  9918. * @param animations defines the list of animations to start
  9919. * @param from defines the initial value
  9920. * @param to defines the final value
  9921. * @param loop defines if you want animation to loop (off by default)
  9922. * @param speedRatio defines the speed ratio to apply to all animations
  9923. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9924. * @param onAnimationLoop defines the callback to call when an animation loops
  9925. * @returns the list of animatables created for all nodes
  9926. */
  9927. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9928. /**
  9929. * Gets the animatable associated with a specific target
  9930. * @param target defines the target of the animatable
  9931. * @returns the required animatable if found
  9932. */
  9933. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9934. /**
  9935. * Gets all animatables associated with a given target
  9936. * @param target defines the target to look animatables for
  9937. * @returns an array of Animatables
  9938. */
  9939. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9940. /**
  9941. * Stops and removes all animations that have been applied to the scene
  9942. */
  9943. stopAllAnimations(): void;
  9944. }
  9945. interface Bone {
  9946. /**
  9947. * Copy an animation range from another bone
  9948. * @param source defines the source bone
  9949. * @param rangeName defines the range name to copy
  9950. * @param frameOffset defines the frame offset
  9951. * @param rescaleAsRequired defines if rescaling must be applied if required
  9952. * @param skelDimensionsRatio defines the scaling ratio
  9953. * @returns true if operation was successful
  9954. */
  9955. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9956. }
  9957. }
  9958. declare module BABYLON {
  9959. /**
  9960. * Class used to handle skinning animations
  9961. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9962. */
  9963. export class Skeleton implements IAnimatable {
  9964. /** defines the skeleton name */
  9965. name: string;
  9966. /** defines the skeleton Id */
  9967. id: string;
  9968. /**
  9969. * Defines the list of child bones
  9970. */
  9971. bones: Bone[];
  9972. /**
  9973. * Defines an estimate of the dimension of the skeleton at rest
  9974. */
  9975. dimensionsAtRest: Vector3;
  9976. /**
  9977. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9978. */
  9979. needInitialSkinMatrix: boolean;
  9980. /**
  9981. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9982. */
  9983. overrideMesh: Nullable<AbstractMesh>;
  9984. /**
  9985. * Gets the list of animations attached to this skeleton
  9986. */
  9987. animations: Array<Animation>;
  9988. private _scene;
  9989. private _isDirty;
  9990. private _transformMatrices;
  9991. private _transformMatrixTexture;
  9992. private _meshesWithPoseMatrix;
  9993. private _animatables;
  9994. private _identity;
  9995. private _synchronizedWithMesh;
  9996. private _ranges;
  9997. private _lastAbsoluteTransformsUpdateId;
  9998. private _canUseTextureForBones;
  9999. private _uniqueId;
  10000. /** @hidden */
  10001. _numBonesWithLinkedTransformNode: number;
  10002. /** @hidden */
  10003. _hasWaitingData: Nullable<boolean>;
  10004. /**
  10005. * Specifies if the skeleton should be serialized
  10006. */
  10007. doNotSerialize: boolean;
  10008. private _useTextureToStoreBoneMatrices;
  10009. /**
  10010. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10011. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10012. */
  10013. useTextureToStoreBoneMatrices: boolean;
  10014. private _animationPropertiesOverride;
  10015. /**
  10016. * Gets or sets the animation properties override
  10017. */
  10018. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10019. /**
  10020. * List of inspectable custom properties (used by the Inspector)
  10021. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10022. */
  10023. inspectableCustomProperties: IInspectable[];
  10024. /**
  10025. * An observable triggered before computing the skeleton's matrices
  10026. */
  10027. onBeforeComputeObservable: Observable<Skeleton>;
  10028. /**
  10029. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10030. */
  10031. readonly isUsingTextureForMatrices: boolean;
  10032. /**
  10033. * Gets the unique ID of this skeleton
  10034. */
  10035. readonly uniqueId: number;
  10036. /**
  10037. * Creates a new skeleton
  10038. * @param name defines the skeleton name
  10039. * @param id defines the skeleton Id
  10040. * @param scene defines the hosting scene
  10041. */
  10042. constructor(
  10043. /** defines the skeleton name */
  10044. name: string,
  10045. /** defines the skeleton Id */
  10046. id: string, scene: Scene);
  10047. /**
  10048. * Gets the current object class name.
  10049. * @return the class name
  10050. */
  10051. getClassName(): string;
  10052. /**
  10053. * Returns an array containing the root bones
  10054. * @returns an array containing the root bones
  10055. */
  10056. getChildren(): Array<Bone>;
  10057. /**
  10058. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10059. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10060. * @returns a Float32Array containing matrices data
  10061. */
  10062. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10063. /**
  10064. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10065. * @returns a raw texture containing the data
  10066. */
  10067. getTransformMatrixTexture(): Nullable<RawTexture>;
  10068. /**
  10069. * Gets the current hosting scene
  10070. * @returns a scene object
  10071. */
  10072. getScene(): Scene;
  10073. /**
  10074. * Gets a string representing the current skeleton data
  10075. * @param fullDetails defines a boolean indicating if we want a verbose version
  10076. * @returns a string representing the current skeleton data
  10077. */
  10078. toString(fullDetails?: boolean): string;
  10079. /**
  10080. * Get bone's index searching by name
  10081. * @param name defines bone's name to search for
  10082. * @return the indice of the bone. Returns -1 if not found
  10083. */
  10084. getBoneIndexByName(name: string): number;
  10085. /**
  10086. * Creater a new animation range
  10087. * @param name defines the name of the range
  10088. * @param from defines the start key
  10089. * @param to defines the end key
  10090. */
  10091. createAnimationRange(name: string, from: number, to: number): void;
  10092. /**
  10093. * Delete a specific animation range
  10094. * @param name defines the name of the range
  10095. * @param deleteFrames defines if frames must be removed as well
  10096. */
  10097. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10098. /**
  10099. * Gets a specific animation range
  10100. * @param name defines the name of the range to look for
  10101. * @returns the requested animation range or null if not found
  10102. */
  10103. getAnimationRange(name: string): Nullable<AnimationRange>;
  10104. /**
  10105. * Gets the list of all animation ranges defined on this skeleton
  10106. * @returns an array
  10107. */
  10108. getAnimationRanges(): Nullable<AnimationRange>[];
  10109. /**
  10110. * Copy animation range from a source skeleton.
  10111. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10112. * @param source defines the source skeleton
  10113. * @param name defines the name of the range to copy
  10114. * @param rescaleAsRequired defines if rescaling must be applied if required
  10115. * @returns true if operation was successful
  10116. */
  10117. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10118. /**
  10119. * Forces the skeleton to go to rest pose
  10120. */
  10121. returnToRest(): void;
  10122. private _getHighestAnimationFrame;
  10123. /**
  10124. * Begin a specific animation range
  10125. * @param name defines the name of the range to start
  10126. * @param loop defines if looping must be turned on (false by default)
  10127. * @param speedRatio defines the speed ratio to apply (1 by default)
  10128. * @param onAnimationEnd defines a callback which will be called when animation will end
  10129. * @returns a new animatable
  10130. */
  10131. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10132. /** @hidden */
  10133. _markAsDirty(): void;
  10134. /** @hidden */
  10135. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10136. /** @hidden */
  10137. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10138. private _computeTransformMatrices;
  10139. /**
  10140. * Build all resources required to render a skeleton
  10141. */
  10142. prepare(): void;
  10143. /**
  10144. * Gets the list of animatables currently running for this skeleton
  10145. * @returns an array of animatables
  10146. */
  10147. getAnimatables(): IAnimatable[];
  10148. /**
  10149. * Clone the current skeleton
  10150. * @param name defines the name of the new skeleton
  10151. * @param id defines the id of the new skeleton
  10152. * @returns the new skeleton
  10153. */
  10154. clone(name: string, id: string): Skeleton;
  10155. /**
  10156. * Enable animation blending for this skeleton
  10157. * @param blendingSpeed defines the blending speed to apply
  10158. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10159. */
  10160. enableBlending(blendingSpeed?: number): void;
  10161. /**
  10162. * Releases all resources associated with the current skeleton
  10163. */
  10164. dispose(): void;
  10165. /**
  10166. * Serialize the skeleton in a JSON object
  10167. * @returns a JSON object
  10168. */
  10169. serialize(): any;
  10170. /**
  10171. * Creates a new skeleton from serialized data
  10172. * @param parsedSkeleton defines the serialized data
  10173. * @param scene defines the hosting scene
  10174. * @returns a new skeleton
  10175. */
  10176. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10177. /**
  10178. * Compute all node absolute transforms
  10179. * @param forceUpdate defines if computation must be done even if cache is up to date
  10180. */
  10181. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10182. /**
  10183. * Gets the root pose matrix
  10184. * @returns a matrix
  10185. */
  10186. getPoseMatrix(): Nullable<Matrix>;
  10187. /**
  10188. * Sorts bones per internal index
  10189. */
  10190. sortBones(): void;
  10191. private _sortBones;
  10192. }
  10193. }
  10194. declare module BABYLON {
  10195. /**
  10196. * Defines a target to use with MorphTargetManager
  10197. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10198. */
  10199. export class MorphTarget implements IAnimatable {
  10200. /** defines the name of the target */
  10201. name: string;
  10202. /**
  10203. * Gets or sets the list of animations
  10204. */
  10205. animations: Animation[];
  10206. private _scene;
  10207. private _positions;
  10208. private _normals;
  10209. private _tangents;
  10210. private _uvs;
  10211. private _influence;
  10212. /**
  10213. * Observable raised when the influence changes
  10214. */
  10215. onInfluenceChanged: Observable<boolean>;
  10216. /** @hidden */
  10217. _onDataLayoutChanged: Observable<void>;
  10218. /**
  10219. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10220. */
  10221. influence: number;
  10222. /**
  10223. * Gets or sets the id of the morph Target
  10224. */
  10225. id: string;
  10226. private _animationPropertiesOverride;
  10227. /**
  10228. * Gets or sets the animation properties override
  10229. */
  10230. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10231. /**
  10232. * Creates a new MorphTarget
  10233. * @param name defines the name of the target
  10234. * @param influence defines the influence to use
  10235. * @param scene defines the scene the morphtarget belongs to
  10236. */
  10237. constructor(
  10238. /** defines the name of the target */
  10239. name: string, influence?: number, scene?: Nullable<Scene>);
  10240. /**
  10241. * Gets a boolean defining if the target contains position data
  10242. */
  10243. readonly hasPositions: boolean;
  10244. /**
  10245. * Gets a boolean defining if the target contains normal data
  10246. */
  10247. readonly hasNormals: boolean;
  10248. /**
  10249. * Gets a boolean defining if the target contains tangent data
  10250. */
  10251. readonly hasTangents: boolean;
  10252. /**
  10253. * Gets a boolean defining if the target contains texture coordinates data
  10254. */
  10255. readonly hasUVs: boolean;
  10256. /**
  10257. * Affects position data to this target
  10258. * @param data defines the position data to use
  10259. */
  10260. setPositions(data: Nullable<FloatArray>): void;
  10261. /**
  10262. * Gets the position data stored in this target
  10263. * @returns a FloatArray containing the position data (or null if not present)
  10264. */
  10265. getPositions(): Nullable<FloatArray>;
  10266. /**
  10267. * Affects normal data to this target
  10268. * @param data defines the normal data to use
  10269. */
  10270. setNormals(data: Nullable<FloatArray>): void;
  10271. /**
  10272. * Gets the normal data stored in this target
  10273. * @returns a FloatArray containing the normal data (or null if not present)
  10274. */
  10275. getNormals(): Nullable<FloatArray>;
  10276. /**
  10277. * Affects tangent data to this target
  10278. * @param data defines the tangent data to use
  10279. */
  10280. setTangents(data: Nullable<FloatArray>): void;
  10281. /**
  10282. * Gets the tangent data stored in this target
  10283. * @returns a FloatArray containing the tangent data (or null if not present)
  10284. */
  10285. getTangents(): Nullable<FloatArray>;
  10286. /**
  10287. * Affects texture coordinates data to this target
  10288. * @param data defines the texture coordinates data to use
  10289. */
  10290. setUVs(data: Nullable<FloatArray>): void;
  10291. /**
  10292. * Gets the texture coordinates data stored in this target
  10293. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10294. */
  10295. getUVs(): Nullable<FloatArray>;
  10296. /**
  10297. * Serializes the current target into a Serialization object
  10298. * @returns the serialized object
  10299. */
  10300. serialize(): any;
  10301. /**
  10302. * Returns the string "MorphTarget"
  10303. * @returns "MorphTarget"
  10304. */
  10305. getClassName(): string;
  10306. /**
  10307. * Creates a new target from serialized data
  10308. * @param serializationObject defines the serialized data to use
  10309. * @returns a new MorphTarget
  10310. */
  10311. static Parse(serializationObject: any): MorphTarget;
  10312. /**
  10313. * Creates a MorphTarget from mesh data
  10314. * @param mesh defines the source mesh
  10315. * @param name defines the name to use for the new target
  10316. * @param influence defines the influence to attach to the target
  10317. * @returns a new MorphTarget
  10318. */
  10319. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10320. }
  10321. }
  10322. declare module BABYLON {
  10323. /**
  10324. * This class is used to deform meshes using morphing between different targets
  10325. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10326. */
  10327. export class MorphTargetManager {
  10328. private _targets;
  10329. private _targetInfluenceChangedObservers;
  10330. private _targetDataLayoutChangedObservers;
  10331. private _activeTargets;
  10332. private _scene;
  10333. private _influences;
  10334. private _supportsNormals;
  10335. private _supportsTangents;
  10336. private _supportsUVs;
  10337. private _vertexCount;
  10338. private _uniqueId;
  10339. private _tempInfluences;
  10340. /**
  10341. * Creates a new MorphTargetManager
  10342. * @param scene defines the current scene
  10343. */
  10344. constructor(scene?: Nullable<Scene>);
  10345. /**
  10346. * Gets the unique ID of this manager
  10347. */
  10348. readonly uniqueId: number;
  10349. /**
  10350. * Gets the number of vertices handled by this manager
  10351. */
  10352. readonly vertexCount: number;
  10353. /**
  10354. * Gets a boolean indicating if this manager supports morphing of normals
  10355. */
  10356. readonly supportsNormals: boolean;
  10357. /**
  10358. * Gets a boolean indicating if this manager supports morphing of tangents
  10359. */
  10360. readonly supportsTangents: boolean;
  10361. /**
  10362. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10363. */
  10364. readonly supportsUVs: boolean;
  10365. /**
  10366. * Gets the number of targets stored in this manager
  10367. */
  10368. readonly numTargets: number;
  10369. /**
  10370. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10371. */
  10372. readonly numInfluencers: number;
  10373. /**
  10374. * Gets the list of influences (one per target)
  10375. */
  10376. readonly influences: Float32Array;
  10377. /**
  10378. * Gets the active target at specified index. An active target is a target with an influence > 0
  10379. * @param index defines the index to check
  10380. * @returns the requested target
  10381. */
  10382. getActiveTarget(index: number): MorphTarget;
  10383. /**
  10384. * Gets the target at specified index
  10385. * @param index defines the index to check
  10386. * @returns the requested target
  10387. */
  10388. getTarget(index: number): MorphTarget;
  10389. /**
  10390. * Add a new target to this manager
  10391. * @param target defines the target to add
  10392. */
  10393. addTarget(target: MorphTarget): void;
  10394. /**
  10395. * Removes a target from the manager
  10396. * @param target defines the target to remove
  10397. */
  10398. removeTarget(target: MorphTarget): void;
  10399. /**
  10400. * Serializes the current manager into a Serialization object
  10401. * @returns the serialized object
  10402. */
  10403. serialize(): any;
  10404. private _syncActiveTargets;
  10405. /**
  10406. * Syncrhonize the targets with all the meshes using this morph target manager
  10407. */
  10408. synchronize(): void;
  10409. /**
  10410. * Creates a new MorphTargetManager from serialized data
  10411. * @param serializationObject defines the serialized data
  10412. * @param scene defines the hosting scene
  10413. * @returns the new MorphTargetManager
  10414. */
  10415. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10416. }
  10417. }
  10418. declare module BABYLON {
  10419. /**
  10420. * Groups all the scene component constants in one place to ease maintenance.
  10421. * @hidden
  10422. */
  10423. export class SceneComponentConstants {
  10424. static readonly NAME_EFFECTLAYER: string;
  10425. static readonly NAME_LAYER: string;
  10426. static readonly NAME_LENSFLARESYSTEM: string;
  10427. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10428. static readonly NAME_PARTICLESYSTEM: string;
  10429. static readonly NAME_GAMEPAD: string;
  10430. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10431. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10432. static readonly NAME_DEPTHRENDERER: string;
  10433. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10434. static readonly NAME_SPRITE: string;
  10435. static readonly NAME_OUTLINERENDERER: string;
  10436. static readonly NAME_PROCEDURALTEXTURE: string;
  10437. static readonly NAME_SHADOWGENERATOR: string;
  10438. static readonly NAME_OCTREE: string;
  10439. static readonly NAME_PHYSICSENGINE: string;
  10440. static readonly NAME_AUDIO: string;
  10441. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10442. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10443. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10444. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10445. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10446. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10447. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10448. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10449. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10450. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10451. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10452. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10453. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10454. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10455. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10456. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10457. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10458. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10459. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10460. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10461. static readonly STEP_AFTERRENDER_AUDIO: number;
  10462. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10463. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10464. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10465. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10466. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10467. static readonly STEP_POINTERMOVE_SPRITE: number;
  10468. static readonly STEP_POINTERDOWN_SPRITE: number;
  10469. static readonly STEP_POINTERUP_SPRITE: number;
  10470. }
  10471. /**
  10472. * This represents a scene component.
  10473. *
  10474. * This is used to decouple the dependency the scene is having on the different workloads like
  10475. * layers, post processes...
  10476. */
  10477. export interface ISceneComponent {
  10478. /**
  10479. * The name of the component. Each component must have a unique name.
  10480. */
  10481. name: string;
  10482. /**
  10483. * The scene the component belongs to.
  10484. */
  10485. scene: Scene;
  10486. /**
  10487. * Register the component to one instance of a scene.
  10488. */
  10489. register(): void;
  10490. /**
  10491. * Rebuilds the elements related to this component in case of
  10492. * context lost for instance.
  10493. */
  10494. rebuild(): void;
  10495. /**
  10496. * Disposes the component and the associated ressources.
  10497. */
  10498. dispose(): void;
  10499. }
  10500. /**
  10501. * This represents a SERIALIZABLE scene component.
  10502. *
  10503. * This extends Scene Component to add Serialization methods on top.
  10504. */
  10505. export interface ISceneSerializableComponent extends ISceneComponent {
  10506. /**
  10507. * Adds all the elements from the container to the scene
  10508. * @param container the container holding the elements
  10509. */
  10510. addFromContainer(container: AbstractScene): void;
  10511. /**
  10512. * Removes all the elements in the container from the scene
  10513. * @param container contains the elements to remove
  10514. * @param dispose if the removed element should be disposed (default: false)
  10515. */
  10516. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10517. /**
  10518. * Serializes the component data to the specified json object
  10519. * @param serializationObject The object to serialize to
  10520. */
  10521. serialize(serializationObject: any): void;
  10522. }
  10523. /**
  10524. * Strong typing of a Mesh related stage step action
  10525. */
  10526. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10527. /**
  10528. * Strong typing of a Evaluate Sub Mesh related stage step action
  10529. */
  10530. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10531. /**
  10532. * Strong typing of a Active Mesh related stage step action
  10533. */
  10534. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10535. /**
  10536. * Strong typing of a Camera related stage step action
  10537. */
  10538. export type CameraStageAction = (camera: Camera) => void;
  10539. /**
  10540. * Strong typing of a Camera Frame buffer related stage step action
  10541. */
  10542. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10543. /**
  10544. * Strong typing of a Render Target related stage step action
  10545. */
  10546. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10547. /**
  10548. * Strong typing of a RenderingGroup related stage step action
  10549. */
  10550. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10551. /**
  10552. * Strong typing of a Mesh Render related stage step action
  10553. */
  10554. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10555. /**
  10556. * Strong typing of a simple stage step action
  10557. */
  10558. export type SimpleStageAction = () => void;
  10559. /**
  10560. * Strong typing of a render target action.
  10561. */
  10562. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10563. /**
  10564. * Strong typing of a pointer move action.
  10565. */
  10566. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10567. /**
  10568. * Strong typing of a pointer up/down action.
  10569. */
  10570. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10571. /**
  10572. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10573. * @hidden
  10574. */
  10575. export class Stage<T extends Function> extends Array<{
  10576. index: number;
  10577. component: ISceneComponent;
  10578. action: T;
  10579. }> {
  10580. /**
  10581. * Hide ctor from the rest of the world.
  10582. * @param items The items to add.
  10583. */
  10584. private constructor();
  10585. /**
  10586. * Creates a new Stage.
  10587. * @returns A new instance of a Stage
  10588. */
  10589. static Create<T extends Function>(): Stage<T>;
  10590. /**
  10591. * Registers a step in an ordered way in the targeted stage.
  10592. * @param index Defines the position to register the step in
  10593. * @param component Defines the component attached to the step
  10594. * @param action Defines the action to launch during the step
  10595. */
  10596. registerStep(index: number, component: ISceneComponent, action: T): void;
  10597. /**
  10598. * Clears all the steps from the stage.
  10599. */
  10600. clear(): void;
  10601. }
  10602. }
  10603. declare module BABYLON {
  10604. /**
  10605. * Class used to represent a specific level of detail of a mesh
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10607. */
  10608. export class MeshLODLevel {
  10609. /** Defines the distance where this level should star being displayed */
  10610. distance: number;
  10611. /** Defines the mesh to use to render this level */
  10612. mesh: Nullable<Mesh>;
  10613. /**
  10614. * Creates a new LOD level
  10615. * @param distance defines the distance where this level should star being displayed
  10616. * @param mesh defines the mesh to use to render this level
  10617. */
  10618. constructor(
  10619. /** Defines the distance where this level should star being displayed */
  10620. distance: number,
  10621. /** Defines the mesh to use to render this level */
  10622. mesh: Nullable<Mesh>);
  10623. }
  10624. }
  10625. declare module BABYLON {
  10626. /**
  10627. * Interface describing all the common properties and methods a shadow light needs to implement.
  10628. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10629. * as well as binding the different shadow properties to the effects.
  10630. */
  10631. export interface IShadowLight extends Light {
  10632. /**
  10633. * The light id in the scene (used in scene.findLighById for instance)
  10634. */
  10635. id: string;
  10636. /**
  10637. * The position the shdow will be casted from.
  10638. */
  10639. position: Vector3;
  10640. /**
  10641. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10642. */
  10643. direction: Vector3;
  10644. /**
  10645. * The transformed position. Position of the light in world space taking parenting in account.
  10646. */
  10647. transformedPosition: Vector3;
  10648. /**
  10649. * The transformed direction. Direction of the light in world space taking parenting in account.
  10650. */
  10651. transformedDirection: Vector3;
  10652. /**
  10653. * The friendly name of the light in the scene.
  10654. */
  10655. name: string;
  10656. /**
  10657. * Defines the shadow projection clipping minimum z value.
  10658. */
  10659. shadowMinZ: number;
  10660. /**
  10661. * Defines the shadow projection clipping maximum z value.
  10662. */
  10663. shadowMaxZ: number;
  10664. /**
  10665. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10666. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10667. */
  10668. computeTransformedInformation(): boolean;
  10669. /**
  10670. * Gets the scene the light belongs to.
  10671. * @returns The scene
  10672. */
  10673. getScene(): Scene;
  10674. /**
  10675. * Callback defining a custom Projection Matrix Builder.
  10676. * This can be used to override the default projection matrix computation.
  10677. */
  10678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10679. /**
  10680. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10681. * @param matrix The materix to updated with the projection information
  10682. * @param viewMatrix The transform matrix of the light
  10683. * @param renderList The list of mesh to render in the map
  10684. * @returns The current light
  10685. */
  10686. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10687. /**
  10688. * Gets the current depth scale used in ESM.
  10689. * @returns The scale
  10690. */
  10691. getDepthScale(): number;
  10692. /**
  10693. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10694. * @returns true if a cube texture needs to be use
  10695. */
  10696. needCube(): boolean;
  10697. /**
  10698. * Detects if the projection matrix requires to be recomputed this frame.
  10699. * @returns true if it requires to be recomputed otherwise, false.
  10700. */
  10701. needProjectionMatrixCompute(): boolean;
  10702. /**
  10703. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10704. */
  10705. forceProjectionMatrixCompute(): void;
  10706. /**
  10707. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10708. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10709. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10710. */
  10711. getShadowDirection(faceIndex?: number): Vector3;
  10712. /**
  10713. * Gets the minZ used for shadow according to both the scene and the light.
  10714. * @param activeCamera The camera we are returning the min for
  10715. * @returns the depth min z
  10716. */
  10717. getDepthMinZ(activeCamera: Camera): number;
  10718. /**
  10719. * Gets the maxZ used for shadow according to both the scene and the light.
  10720. * @param activeCamera The camera we are returning the max for
  10721. * @returns the depth max z
  10722. */
  10723. getDepthMaxZ(activeCamera: Camera): number;
  10724. }
  10725. /**
  10726. * Base implementation IShadowLight
  10727. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10728. */
  10729. export abstract class ShadowLight extends Light implements IShadowLight {
  10730. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10731. protected _position: Vector3;
  10732. protected _setPosition(value: Vector3): void;
  10733. /**
  10734. * Sets the position the shadow will be casted from. Also use as the light position for both
  10735. * point and spot lights.
  10736. */
  10737. /**
  10738. * Sets the position the shadow will be casted from. Also use as the light position for both
  10739. * point and spot lights.
  10740. */
  10741. position: Vector3;
  10742. protected _direction: Vector3;
  10743. protected _setDirection(value: Vector3): void;
  10744. /**
  10745. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10746. * Also use as the light direction on spot and directional lights.
  10747. */
  10748. /**
  10749. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10750. * Also use as the light direction on spot and directional lights.
  10751. */
  10752. direction: Vector3;
  10753. private _shadowMinZ;
  10754. /**
  10755. * Gets the shadow projection clipping minimum z value.
  10756. */
  10757. /**
  10758. * Sets the shadow projection clipping minimum z value.
  10759. */
  10760. shadowMinZ: number;
  10761. private _shadowMaxZ;
  10762. /**
  10763. * Sets the shadow projection clipping maximum z value.
  10764. */
  10765. /**
  10766. * Gets the shadow projection clipping maximum z value.
  10767. */
  10768. shadowMaxZ: number;
  10769. /**
  10770. * Callback defining a custom Projection Matrix Builder.
  10771. * This can be used to override the default projection matrix computation.
  10772. */
  10773. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10774. /**
  10775. * The transformed position. Position of the light in world space taking parenting in account.
  10776. */
  10777. transformedPosition: Vector3;
  10778. /**
  10779. * The transformed direction. Direction of the light in world space taking parenting in account.
  10780. */
  10781. transformedDirection: Vector3;
  10782. private _needProjectionMatrixCompute;
  10783. /**
  10784. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10785. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10786. */
  10787. computeTransformedInformation(): boolean;
  10788. /**
  10789. * Return the depth scale used for the shadow map.
  10790. * @returns the depth scale.
  10791. */
  10792. getDepthScale(): number;
  10793. /**
  10794. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10795. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10796. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10797. */
  10798. getShadowDirection(faceIndex?: number): Vector3;
  10799. /**
  10800. * Returns the ShadowLight absolute position in the World.
  10801. * @returns the position vector in world space
  10802. */
  10803. getAbsolutePosition(): Vector3;
  10804. /**
  10805. * Sets the ShadowLight direction toward the passed target.
  10806. * @param target The point to target in local space
  10807. * @returns the updated ShadowLight direction
  10808. */
  10809. setDirectionToTarget(target: Vector3): Vector3;
  10810. /**
  10811. * Returns the light rotation in euler definition.
  10812. * @returns the x y z rotation in local space.
  10813. */
  10814. getRotation(): Vector3;
  10815. /**
  10816. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10817. * @returns true if a cube texture needs to be use
  10818. */
  10819. needCube(): boolean;
  10820. /**
  10821. * Detects if the projection matrix requires to be recomputed this frame.
  10822. * @returns true if it requires to be recomputed otherwise, false.
  10823. */
  10824. needProjectionMatrixCompute(): boolean;
  10825. /**
  10826. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10827. */
  10828. forceProjectionMatrixCompute(): void;
  10829. /** @hidden */
  10830. _initCache(): void;
  10831. /** @hidden */
  10832. _isSynchronized(): boolean;
  10833. /**
  10834. * Computes the world matrix of the node
  10835. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10836. * @returns the world matrix
  10837. */
  10838. computeWorldMatrix(force?: boolean): Matrix;
  10839. /**
  10840. * Gets the minZ used for shadow according to both the scene and the light.
  10841. * @param activeCamera The camera we are returning the min for
  10842. * @returns the depth min z
  10843. */
  10844. getDepthMinZ(activeCamera: Camera): number;
  10845. /**
  10846. * Gets the maxZ used for shadow according to both the scene and the light.
  10847. * @param activeCamera The camera we are returning the max for
  10848. * @returns the depth max z
  10849. */
  10850. getDepthMaxZ(activeCamera: Camera): number;
  10851. /**
  10852. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10853. * @param matrix The materix to updated with the projection information
  10854. * @param viewMatrix The transform matrix of the light
  10855. * @param renderList The list of mesh to render in the map
  10856. * @returns The current light
  10857. */
  10858. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10859. }
  10860. }
  10861. declare module BABYLON {
  10862. /**
  10863. * "Static Class" containing the most commonly used helper while dealing with material for
  10864. * rendering purpose.
  10865. *
  10866. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10867. *
  10868. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10869. */
  10870. export class MaterialHelper {
  10871. /**
  10872. * Bind the current view position to an effect.
  10873. * @param effect The effect to be bound
  10874. * @param scene The scene the eyes position is used from
  10875. */
  10876. static BindEyePosition(effect: Effect, scene: Scene): void;
  10877. /**
  10878. * Helps preparing the defines values about the UVs in used in the effect.
  10879. * UVs are shared as much as we can accross channels in the shaders.
  10880. * @param texture The texture we are preparing the UVs for
  10881. * @param defines The defines to update
  10882. * @param key The channel key "diffuse", "specular"... used in the shader
  10883. */
  10884. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10885. /**
  10886. * Binds a texture matrix value to its corrsponding uniform
  10887. * @param texture The texture to bind the matrix for
  10888. * @param uniformBuffer The uniform buffer receivin the data
  10889. * @param key The channel key "diffuse", "specular"... used in the shader
  10890. */
  10891. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10892. /**
  10893. * Gets the current status of the fog (should it be enabled?)
  10894. * @param mesh defines the mesh to evaluate for fog support
  10895. * @param scene defines the hosting scene
  10896. * @returns true if fog must be enabled
  10897. */
  10898. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10899. /**
  10900. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10901. * @param mesh defines the current mesh
  10902. * @param scene defines the current scene
  10903. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10904. * @param pointsCloud defines if point cloud rendering has to be turned on
  10905. * @param fogEnabled defines if fog has to be turned on
  10906. * @param alphaTest defines if alpha testing has to be turned on
  10907. * @param defines defines the current list of defines
  10908. */
  10909. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10910. /**
  10911. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10912. * @param scene defines the current scene
  10913. * @param engine defines the current engine
  10914. * @param defines specifies the list of active defines
  10915. * @param useInstances defines if instances have to be turned on
  10916. * @param useClipPlane defines if clip plane have to be turned on
  10917. */
  10918. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10919. /**
  10920. * Prepares the defines for bones
  10921. * @param mesh The mesh containing the geometry data we will draw
  10922. * @param defines The defines to update
  10923. */
  10924. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10925. /**
  10926. * Prepares the defines for morph targets
  10927. * @param mesh The mesh containing the geometry data we will draw
  10928. * @param defines The defines to update
  10929. */
  10930. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10931. /**
  10932. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10933. * @param mesh The mesh containing the geometry data we will draw
  10934. * @param defines The defines to update
  10935. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10936. * @param useBones Precise whether bones should be used or not (override mesh info)
  10937. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10938. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10939. * @returns false if defines are considered not dirty and have not been checked
  10940. */
  10941. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10942. /**
  10943. * Prepares the defines related to multiview
  10944. * @param scene The scene we are intending to draw
  10945. * @param defines The defines to update
  10946. */
  10947. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10948. /**
  10949. * Prepares the defines related to the light information passed in parameter
  10950. * @param scene The scene we are intending to draw
  10951. * @param mesh The mesh the effect is compiling for
  10952. * @param light The light the effect is compiling for
  10953. * @param lightIndex The index of the light
  10954. * @param defines The defines to update
  10955. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10956. * @param state Defines the current state regarding what is needed (normals, etc...)
  10957. */
  10958. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10959. needNormals: boolean;
  10960. needRebuild: boolean;
  10961. shadowEnabled: boolean;
  10962. specularEnabled: boolean;
  10963. lightmapMode: boolean;
  10964. }): void;
  10965. /**
  10966. * Prepares the defines related to the light information passed in parameter
  10967. * @param scene The scene we are intending to draw
  10968. * @param mesh The mesh the effect is compiling for
  10969. * @param defines The defines to update
  10970. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10971. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10972. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10973. * @returns true if normals will be required for the rest of the effect
  10974. */
  10975. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10976. /**
  10977. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10978. * @param lightIndex defines the light index
  10979. * @param uniformsList The uniform list
  10980. * @param samplersList The sampler list
  10981. * @param projectedLightTexture defines if projected texture must be used
  10982. * @param uniformBuffersList defines an optional list of uniform buffers
  10983. */
  10984. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  10985. /**
  10986. * Prepares the uniforms and samplers list to be used in the effect
  10987. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10988. * @param samplersList The sampler list
  10989. * @param defines The defines helping in the list generation
  10990. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10991. */
  10992. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10993. /**
  10994. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10995. * @param defines The defines to update while falling back
  10996. * @param fallbacks The authorized effect fallbacks
  10997. * @param maxSimultaneousLights The maximum number of lights allowed
  10998. * @param rank the current rank of the Effect
  10999. * @returns The newly affected rank
  11000. */
  11001. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11002. private static _TmpMorphInfluencers;
  11003. /**
  11004. * Prepares the list of attributes required for morph targets according to the effect defines.
  11005. * @param attribs The current list of supported attribs
  11006. * @param mesh The mesh to prepare the morph targets attributes for
  11007. * @param influencers The number of influencers
  11008. */
  11009. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11010. /**
  11011. * Prepares the list of attributes required for morph targets according to the effect defines.
  11012. * @param attribs The current list of supported attribs
  11013. * @param mesh The mesh to prepare the morph targets attributes for
  11014. * @param defines The current Defines of the effect
  11015. */
  11016. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11017. /**
  11018. * Prepares the list of attributes required for bones according to the effect defines.
  11019. * @param attribs The current list of supported attribs
  11020. * @param mesh The mesh to prepare the bones attributes for
  11021. * @param defines The current Defines of the effect
  11022. * @param fallbacks The current efffect fallback strategy
  11023. */
  11024. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11025. /**
  11026. * Check and prepare the list of attributes required for instances according to the effect defines.
  11027. * @param attribs The current list of supported attribs
  11028. * @param defines The current MaterialDefines of the effect
  11029. */
  11030. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11031. /**
  11032. * Add the list of attributes required for instances to the attribs array.
  11033. * @param attribs The current list of supported attribs
  11034. */
  11035. static PushAttributesForInstances(attribs: string[]): void;
  11036. /**
  11037. * Binds the light shadow information to the effect for the given mesh.
  11038. * @param light The light containing the generator
  11039. * @param scene The scene the lights belongs to
  11040. * @param mesh The mesh we are binding the information to render
  11041. * @param lightIndex The light index in the effect used to render the mesh
  11042. * @param effect The effect we are binding the data to
  11043. */
  11044. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11045. /**
  11046. * Binds the light information to the effect.
  11047. * @param light The light containing the generator
  11048. * @param effect The effect we are binding the data to
  11049. * @param lightIndex The light index in the effect used to render
  11050. */
  11051. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11052. /**
  11053. * Binds the lights information from the scene to the effect for the given mesh.
  11054. * @param light Light to bind
  11055. * @param lightIndex Light index
  11056. * @param scene The scene where the light belongs to
  11057. * @param mesh The mesh we are binding the information to render
  11058. * @param effect The effect we are binding the data to
  11059. * @param useSpecular Defines if specular is supported
  11060. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11061. */
  11062. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11063. /**
  11064. * Binds the lights information from the scene to the effect for the given mesh.
  11065. * @param scene The scene the lights belongs to
  11066. * @param mesh The mesh we are binding the information to render
  11067. * @param effect The effect we are binding the data to
  11068. * @param defines The generated defines for the effect
  11069. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11070. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11071. */
  11072. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11073. private static _tempFogColor;
  11074. /**
  11075. * Binds the fog information from the scene to the effect for the given mesh.
  11076. * @param scene The scene the lights belongs to
  11077. * @param mesh The mesh we are binding the information to render
  11078. * @param effect The effect we are binding the data to
  11079. * @param linearSpace Defines if the fog effect is applied in linear space
  11080. */
  11081. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11082. /**
  11083. * Binds the bones information from the mesh to the effect.
  11084. * @param mesh The mesh we are binding the information to render
  11085. * @param effect The effect we are binding the data to
  11086. */
  11087. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11088. /**
  11089. * Binds the morph targets information from the mesh to the effect.
  11090. * @param abstractMesh The mesh we are binding the information to render
  11091. * @param effect The effect we are binding the data to
  11092. */
  11093. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11094. /**
  11095. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11096. * @param defines The generated defines used in the effect
  11097. * @param effect The effect we are binding the data to
  11098. * @param scene The scene we are willing to render with logarithmic scale for
  11099. */
  11100. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11101. /**
  11102. * Binds the clip plane information from the scene to the effect.
  11103. * @param scene The scene the clip plane information are extracted from
  11104. * @param effect The effect we are binding the data to
  11105. */
  11106. static BindClipPlane(effect: Effect, scene: Scene): void;
  11107. }
  11108. }
  11109. declare module BABYLON {
  11110. /** @hidden */
  11111. export var shadowMapPixelShader: {
  11112. name: string;
  11113. shader: string;
  11114. };
  11115. }
  11116. declare module BABYLON {
  11117. /** @hidden */
  11118. export var bonesDeclaration: {
  11119. name: string;
  11120. shader: string;
  11121. };
  11122. }
  11123. declare module BABYLON {
  11124. /** @hidden */
  11125. export var morphTargetsVertexGlobalDeclaration: {
  11126. name: string;
  11127. shader: string;
  11128. };
  11129. }
  11130. declare module BABYLON {
  11131. /** @hidden */
  11132. export var morphTargetsVertexDeclaration: {
  11133. name: string;
  11134. shader: string;
  11135. };
  11136. }
  11137. declare module BABYLON {
  11138. /** @hidden */
  11139. export var instancesDeclaration: {
  11140. name: string;
  11141. shader: string;
  11142. };
  11143. }
  11144. declare module BABYLON {
  11145. /** @hidden */
  11146. export var helperFunctions: {
  11147. name: string;
  11148. shader: string;
  11149. };
  11150. }
  11151. declare module BABYLON {
  11152. /** @hidden */
  11153. export var morphTargetsVertex: {
  11154. name: string;
  11155. shader: string;
  11156. };
  11157. }
  11158. declare module BABYLON {
  11159. /** @hidden */
  11160. export var instancesVertex: {
  11161. name: string;
  11162. shader: string;
  11163. };
  11164. }
  11165. declare module BABYLON {
  11166. /** @hidden */
  11167. export var bonesVertex: {
  11168. name: string;
  11169. shader: string;
  11170. };
  11171. }
  11172. declare module BABYLON {
  11173. /** @hidden */
  11174. export var shadowMapVertexShader: {
  11175. name: string;
  11176. shader: string;
  11177. };
  11178. }
  11179. declare module BABYLON {
  11180. /** @hidden */
  11181. export var depthBoxBlurPixelShader: {
  11182. name: string;
  11183. shader: string;
  11184. };
  11185. }
  11186. declare module BABYLON {
  11187. /**
  11188. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11189. */
  11190. export interface ICustomShaderOptions {
  11191. /**
  11192. * Gets or sets the custom shader name to use
  11193. */
  11194. shaderName: string;
  11195. /**
  11196. * The list of attribute names used in the shader
  11197. */
  11198. attributes?: string[];
  11199. /**
  11200. * The list of unifrom names used in the shader
  11201. */
  11202. uniforms?: string[];
  11203. /**
  11204. * The list of sampler names used in the shader
  11205. */
  11206. samplers?: string[];
  11207. /**
  11208. * The list of defines used in the shader
  11209. */
  11210. defines?: string[];
  11211. }
  11212. /**
  11213. * Interface to implement to create a shadow generator compatible with BJS.
  11214. */
  11215. export interface IShadowGenerator {
  11216. /**
  11217. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11218. * @returns The render target texture if present otherwise, null
  11219. */
  11220. getShadowMap(): Nullable<RenderTargetTexture>;
  11221. /**
  11222. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11223. * @returns The render target texture if the shadow map is present otherwise, null
  11224. */
  11225. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11226. /**
  11227. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11228. * @param subMesh The submesh we want to render in the shadow map
  11229. * @param useInstances Defines wether will draw in the map using instances
  11230. * @returns true if ready otherwise, false
  11231. */
  11232. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11233. /**
  11234. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11235. * @param defines Defines of the material we want to update
  11236. * @param lightIndex Index of the light in the enabled light list of the material
  11237. */
  11238. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11239. /**
  11240. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11241. * defined in the generator but impacting the effect).
  11242. * It implies the unifroms available on the materials are the standard BJS ones.
  11243. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11244. * @param effect The effect we are binfing the information for
  11245. */
  11246. bindShadowLight(lightIndex: string, effect: Effect): void;
  11247. /**
  11248. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11249. * (eq to shadow prjection matrix * light transform matrix)
  11250. * @returns The transform matrix used to create the shadow map
  11251. */
  11252. getTransformMatrix(): Matrix;
  11253. /**
  11254. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11255. * Cube and 2D textures for instance.
  11256. */
  11257. recreateShadowMap(): void;
  11258. /**
  11259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11260. * @param onCompiled Callback triggered at the and of the effects compilation
  11261. * @param options Sets of optional options forcing the compilation with different modes
  11262. */
  11263. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11264. useInstances: boolean;
  11265. }>): void;
  11266. /**
  11267. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11268. * @param options Sets of optional options forcing the compilation with different modes
  11269. * @returns A promise that resolves when the compilation completes
  11270. */
  11271. forceCompilationAsync(options?: Partial<{
  11272. useInstances: boolean;
  11273. }>): Promise<void>;
  11274. /**
  11275. * Serializes the shadow generator setup to a json object.
  11276. * @returns The serialized JSON object
  11277. */
  11278. serialize(): any;
  11279. /**
  11280. * Disposes the Shadow map and related Textures and effects.
  11281. */
  11282. dispose(): void;
  11283. }
  11284. /**
  11285. * Default implementation IShadowGenerator.
  11286. * This is the main object responsible of generating shadows in the framework.
  11287. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11288. */
  11289. export class ShadowGenerator implements IShadowGenerator {
  11290. /**
  11291. * Shadow generator mode None: no filtering applied.
  11292. */
  11293. static readonly FILTER_NONE: number;
  11294. /**
  11295. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11296. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11297. */
  11298. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11299. /**
  11300. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11301. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11302. */
  11303. static readonly FILTER_POISSONSAMPLING: number;
  11304. /**
  11305. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11306. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11307. */
  11308. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11309. /**
  11310. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11311. * edge artifacts on steep falloff.
  11312. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11313. */
  11314. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11315. /**
  11316. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11317. * edge artifacts on steep falloff.
  11318. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11319. */
  11320. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11321. /**
  11322. * Shadow generator mode PCF: Percentage Closer Filtering
  11323. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11324. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11325. */
  11326. static readonly FILTER_PCF: number;
  11327. /**
  11328. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11329. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11330. * Contact Hardening
  11331. */
  11332. static readonly FILTER_PCSS: number;
  11333. /**
  11334. * Reserved for PCF and PCSS
  11335. * Highest Quality.
  11336. *
  11337. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11338. *
  11339. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11340. */
  11341. static readonly QUALITY_HIGH: number;
  11342. /**
  11343. * Reserved for PCF and PCSS
  11344. * Good tradeoff for quality/perf cross devices
  11345. *
  11346. * Execute PCF on a 3*3 kernel.
  11347. *
  11348. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11349. */
  11350. static readonly QUALITY_MEDIUM: number;
  11351. /**
  11352. * Reserved for PCF and PCSS
  11353. * The lowest quality but the fastest.
  11354. *
  11355. * Execute PCF on a 1*1 kernel.
  11356. *
  11357. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11358. */
  11359. static readonly QUALITY_LOW: number;
  11360. /** Gets or sets the custom shader name to use */
  11361. customShaderOptions: ICustomShaderOptions;
  11362. /**
  11363. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11364. */
  11365. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11366. /**
  11367. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11368. */
  11369. onAfterShadowMapRenderObservable: Observable<Effect>;
  11370. /**
  11371. * Observable triggered before a mesh is rendered in the shadow map.
  11372. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11373. */
  11374. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11375. /**
  11376. * Observable triggered after a mesh is rendered in the shadow map.
  11377. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11378. */
  11379. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11380. private _bias;
  11381. /**
  11382. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11383. */
  11384. /**
  11385. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11386. */
  11387. bias: number;
  11388. private _normalBias;
  11389. /**
  11390. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11391. */
  11392. /**
  11393. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11394. */
  11395. normalBias: number;
  11396. private _blurBoxOffset;
  11397. /**
  11398. * Gets the blur box offset: offset applied during the blur pass.
  11399. * Only useful if useKernelBlur = false
  11400. */
  11401. /**
  11402. * Sets the blur box offset: offset applied during the blur pass.
  11403. * Only useful if useKernelBlur = false
  11404. */
  11405. blurBoxOffset: number;
  11406. private _blurScale;
  11407. /**
  11408. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11409. * 2 means half of the size.
  11410. */
  11411. /**
  11412. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11413. * 2 means half of the size.
  11414. */
  11415. blurScale: number;
  11416. private _blurKernel;
  11417. /**
  11418. * Gets the blur kernel: kernel size of the blur pass.
  11419. * Only useful if useKernelBlur = true
  11420. */
  11421. /**
  11422. * Sets the blur kernel: kernel size of the blur pass.
  11423. * Only useful if useKernelBlur = true
  11424. */
  11425. blurKernel: number;
  11426. private _useKernelBlur;
  11427. /**
  11428. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11429. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11430. */
  11431. /**
  11432. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11433. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11434. */
  11435. useKernelBlur: boolean;
  11436. private _depthScale;
  11437. /**
  11438. * Gets the depth scale used in ESM mode.
  11439. */
  11440. /**
  11441. * Sets the depth scale used in ESM mode.
  11442. * This can override the scale stored on the light.
  11443. */
  11444. depthScale: number;
  11445. private _filter;
  11446. /**
  11447. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11448. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11449. */
  11450. /**
  11451. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11452. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11453. */
  11454. filter: number;
  11455. /**
  11456. * Gets if the current filter is set to Poisson Sampling.
  11457. */
  11458. /**
  11459. * Sets the current filter to Poisson Sampling.
  11460. */
  11461. usePoissonSampling: boolean;
  11462. /**
  11463. * Gets if the current filter is set to ESM.
  11464. */
  11465. /**
  11466. * Sets the current filter is to ESM.
  11467. */
  11468. useExponentialShadowMap: boolean;
  11469. /**
  11470. * Gets if the current filter is set to filtered ESM.
  11471. */
  11472. /**
  11473. * Gets if the current filter is set to filtered ESM.
  11474. */
  11475. useBlurExponentialShadowMap: boolean;
  11476. /**
  11477. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11478. * exponential to prevent steep falloff artifacts).
  11479. */
  11480. /**
  11481. * Sets the current filter to "close ESM" (using the inverse of the
  11482. * exponential to prevent steep falloff artifacts).
  11483. */
  11484. useCloseExponentialShadowMap: boolean;
  11485. /**
  11486. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11487. * exponential to prevent steep falloff artifacts).
  11488. */
  11489. /**
  11490. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11491. * exponential to prevent steep falloff artifacts).
  11492. */
  11493. useBlurCloseExponentialShadowMap: boolean;
  11494. /**
  11495. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11496. */
  11497. /**
  11498. * Sets the current filter to "PCF" (percentage closer filtering).
  11499. */
  11500. usePercentageCloserFiltering: boolean;
  11501. private _filteringQuality;
  11502. /**
  11503. * Gets the PCF or PCSS Quality.
  11504. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11505. */
  11506. /**
  11507. * Sets the PCF or PCSS Quality.
  11508. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11509. */
  11510. filteringQuality: number;
  11511. /**
  11512. * Gets if the current filter is set to "PCSS" (contact hardening).
  11513. */
  11514. /**
  11515. * Sets the current filter to "PCSS" (contact hardening).
  11516. */
  11517. useContactHardeningShadow: boolean;
  11518. private _contactHardeningLightSizeUVRatio;
  11519. /**
  11520. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11521. * Using a ratio helps keeping shape stability independently of the map size.
  11522. *
  11523. * It does not account for the light projection as it was having too much
  11524. * instability during the light setup or during light position changes.
  11525. *
  11526. * Only valid if useContactHardeningShadow is true.
  11527. */
  11528. /**
  11529. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11530. * Using a ratio helps keeping shape stability independently of the map size.
  11531. *
  11532. * It does not account for the light projection as it was having too much
  11533. * instability during the light setup or during light position changes.
  11534. *
  11535. * Only valid if useContactHardeningShadow is true.
  11536. */
  11537. contactHardeningLightSizeUVRatio: number;
  11538. private _darkness;
  11539. /** Gets or sets the actual darkness of a shadow */
  11540. darkness: number;
  11541. /**
  11542. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11543. * 0 means strongest and 1 would means no shadow.
  11544. * @returns the darkness.
  11545. */
  11546. getDarkness(): number;
  11547. /**
  11548. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11549. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11550. * @returns the shadow generator allowing fluent coding.
  11551. */
  11552. setDarkness(darkness: number): ShadowGenerator;
  11553. private _transparencyShadow;
  11554. /** Gets or sets the ability to have transparent shadow */
  11555. transparencyShadow: boolean;
  11556. /**
  11557. * Sets the ability to have transparent shadow (boolean).
  11558. * @param transparent True if transparent else False
  11559. * @returns the shadow generator allowing fluent coding
  11560. */
  11561. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11562. private _shadowMap;
  11563. private _shadowMap2;
  11564. /**
  11565. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11566. * @returns The render target texture if present otherwise, null
  11567. */
  11568. getShadowMap(): Nullable<RenderTargetTexture>;
  11569. /**
  11570. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11571. * @returns The render target texture if the shadow map is present otherwise, null
  11572. */
  11573. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11574. /**
  11575. * Gets the class name of that object
  11576. * @returns "ShadowGenerator"
  11577. */
  11578. getClassName(): string;
  11579. /**
  11580. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11581. * @param mesh Mesh to add
  11582. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11583. * @returns the Shadow Generator itself
  11584. */
  11585. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11586. /**
  11587. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11588. * @param mesh Mesh to remove
  11589. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11590. * @returns the Shadow Generator itself
  11591. */
  11592. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11593. /**
  11594. * Controls the extent to which the shadows fade out at the edge of the frustum
  11595. * Used only by directionals and spots
  11596. */
  11597. frustumEdgeFalloff: number;
  11598. private _light;
  11599. /**
  11600. * Returns the associated light object.
  11601. * @returns the light generating the shadow
  11602. */
  11603. getLight(): IShadowLight;
  11604. /**
  11605. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11606. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11607. * It might on the other hand introduce peter panning.
  11608. */
  11609. forceBackFacesOnly: boolean;
  11610. private _scene;
  11611. private _lightDirection;
  11612. private _effect;
  11613. private _viewMatrix;
  11614. private _projectionMatrix;
  11615. private _transformMatrix;
  11616. private _cachedPosition;
  11617. private _cachedDirection;
  11618. private _cachedDefines;
  11619. private _currentRenderID;
  11620. private _boxBlurPostprocess;
  11621. private _kernelBlurXPostprocess;
  11622. private _kernelBlurYPostprocess;
  11623. private _blurPostProcesses;
  11624. private _mapSize;
  11625. private _currentFaceIndex;
  11626. private _currentFaceIndexCache;
  11627. private _textureType;
  11628. private _defaultTextureMatrix;
  11629. /** @hidden */
  11630. static _SceneComponentInitialization: (scene: Scene) => void;
  11631. /**
  11632. * Creates a ShadowGenerator object.
  11633. * A ShadowGenerator is the required tool to use the shadows.
  11634. * Each light casting shadows needs to use its own ShadowGenerator.
  11635. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11636. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11637. * @param light The light object generating the shadows.
  11638. * @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.
  11639. */
  11640. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11641. private _initializeGenerator;
  11642. private _initializeShadowMap;
  11643. private _initializeBlurRTTAndPostProcesses;
  11644. private _renderForShadowMap;
  11645. private _renderSubMeshForShadowMap;
  11646. private _applyFilterValues;
  11647. /**
  11648. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11649. * @param onCompiled Callback triggered at the and of the effects compilation
  11650. * @param options Sets of optional options forcing the compilation with different modes
  11651. */
  11652. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11653. useInstances: boolean;
  11654. }>): void;
  11655. /**
  11656. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11657. * @param options Sets of optional options forcing the compilation with different modes
  11658. * @returns A promise that resolves when the compilation completes
  11659. */
  11660. forceCompilationAsync(options?: Partial<{
  11661. useInstances: boolean;
  11662. }>): Promise<void>;
  11663. /**
  11664. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11665. * @param subMesh The submesh we want to render in the shadow map
  11666. * @param useInstances Defines wether will draw in the map using instances
  11667. * @returns true if ready otherwise, false
  11668. */
  11669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11670. /**
  11671. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11672. * @param defines Defines of the material we want to update
  11673. * @param lightIndex Index of the light in the enabled light list of the material
  11674. */
  11675. prepareDefines(defines: any, lightIndex: number): void;
  11676. /**
  11677. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11678. * defined in the generator but impacting the effect).
  11679. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11680. * @param effect The effect we are binfing the information for
  11681. */
  11682. bindShadowLight(lightIndex: string, effect: Effect): void;
  11683. /**
  11684. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11685. * (eq to shadow prjection matrix * light transform matrix)
  11686. * @returns The transform matrix used to create the shadow map
  11687. */
  11688. getTransformMatrix(): Matrix;
  11689. /**
  11690. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11691. * Cube and 2D textures for instance.
  11692. */
  11693. recreateShadowMap(): void;
  11694. private _disposeBlurPostProcesses;
  11695. private _disposeRTTandPostProcesses;
  11696. /**
  11697. * Disposes the ShadowGenerator.
  11698. * Returns nothing.
  11699. */
  11700. dispose(): void;
  11701. /**
  11702. * Serializes the shadow generator setup to a json object.
  11703. * @returns The serialized JSON object
  11704. */
  11705. serialize(): any;
  11706. /**
  11707. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11708. * @param parsedShadowGenerator The JSON object to parse
  11709. * @param scene The scene to create the shadow map for
  11710. * @returns The parsed shadow generator
  11711. */
  11712. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11713. }
  11714. }
  11715. declare module BABYLON {
  11716. /**
  11717. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11718. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11719. * 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.
  11720. */
  11721. export abstract class Light extends Node {
  11722. /**
  11723. * Falloff Default: light is falling off following the material specification:
  11724. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11725. */
  11726. static readonly FALLOFF_DEFAULT: number;
  11727. /**
  11728. * Falloff Physical: light is falling off following the inverse squared distance law.
  11729. */
  11730. static readonly FALLOFF_PHYSICAL: number;
  11731. /**
  11732. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11733. * to enhance interoperability with other engines.
  11734. */
  11735. static readonly FALLOFF_GLTF: number;
  11736. /**
  11737. * Falloff Standard: light is falling off like in the standard material
  11738. * to enhance interoperability with other materials.
  11739. */
  11740. static readonly FALLOFF_STANDARD: number;
  11741. /**
  11742. * If every light affecting the material is in this lightmapMode,
  11743. * material.lightmapTexture adds or multiplies
  11744. * (depends on material.useLightmapAsShadowmap)
  11745. * after every other light calculations.
  11746. */
  11747. static readonly LIGHTMAP_DEFAULT: number;
  11748. /**
  11749. * material.lightmapTexture as only diffuse lighting from this light
  11750. * adds only specular lighting from this light
  11751. * adds dynamic shadows
  11752. */
  11753. static readonly LIGHTMAP_SPECULAR: number;
  11754. /**
  11755. * material.lightmapTexture as only lighting
  11756. * no light calculation from this light
  11757. * only adds dynamic shadows from this light
  11758. */
  11759. static readonly LIGHTMAP_SHADOWSONLY: number;
  11760. /**
  11761. * Each light type uses the default quantity according to its type:
  11762. * point/spot lights use luminous intensity
  11763. * directional lights use illuminance
  11764. */
  11765. static readonly INTENSITYMODE_AUTOMATIC: number;
  11766. /**
  11767. * lumen (lm)
  11768. */
  11769. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11770. /**
  11771. * candela (lm/sr)
  11772. */
  11773. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11774. /**
  11775. * lux (lm/m^2)
  11776. */
  11777. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11778. /**
  11779. * nit (cd/m^2)
  11780. */
  11781. static readonly INTENSITYMODE_LUMINANCE: number;
  11782. /**
  11783. * Light type const id of the point light.
  11784. */
  11785. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11786. /**
  11787. * Light type const id of the directional light.
  11788. */
  11789. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11790. /**
  11791. * Light type const id of the spot light.
  11792. */
  11793. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11794. /**
  11795. * Light type const id of the hemispheric light.
  11796. */
  11797. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11798. /**
  11799. * Diffuse gives the basic color to an object.
  11800. */
  11801. diffuse: Color3;
  11802. /**
  11803. * Specular produces a highlight color on an object.
  11804. * Note: This is note affecting PBR materials.
  11805. */
  11806. specular: Color3;
  11807. /**
  11808. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11809. * falling off base on range or angle.
  11810. * This can be set to any values in Light.FALLOFF_x.
  11811. *
  11812. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11813. * other types of materials.
  11814. */
  11815. falloffType: number;
  11816. /**
  11817. * Strength of the light.
  11818. * Note: By default it is define in the framework own unit.
  11819. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11820. */
  11821. intensity: number;
  11822. private _range;
  11823. protected _inverseSquaredRange: number;
  11824. /**
  11825. * Defines how far from the source the light is impacting in scene units.
  11826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11827. */
  11828. /**
  11829. * Defines how far from the source the light is impacting in scene units.
  11830. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11831. */
  11832. range: number;
  11833. /**
  11834. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11835. * of light.
  11836. */
  11837. private _photometricScale;
  11838. private _intensityMode;
  11839. /**
  11840. * Gets the photometric scale used to interpret the intensity.
  11841. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11842. */
  11843. /**
  11844. * Sets the photometric scale used to interpret the intensity.
  11845. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11846. */
  11847. intensityMode: number;
  11848. private _radius;
  11849. /**
  11850. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11851. */
  11852. /**
  11853. * sets the light radius used by PBR Materials to simulate soft area lights.
  11854. */
  11855. radius: number;
  11856. private _renderPriority;
  11857. /**
  11858. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11859. * exceeding the number allowed of the materials.
  11860. */
  11861. renderPriority: number;
  11862. private _shadowEnabled;
  11863. /**
  11864. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11865. * the current shadow generator.
  11866. */
  11867. /**
  11868. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11869. * the current shadow generator.
  11870. */
  11871. shadowEnabled: boolean;
  11872. private _includedOnlyMeshes;
  11873. /**
  11874. * Gets the only meshes impacted by this light.
  11875. */
  11876. /**
  11877. * Sets the only meshes impacted by this light.
  11878. */
  11879. includedOnlyMeshes: AbstractMesh[];
  11880. private _excludedMeshes;
  11881. /**
  11882. * Gets the meshes not impacted by this light.
  11883. */
  11884. /**
  11885. * Sets the meshes not impacted by this light.
  11886. */
  11887. excludedMeshes: AbstractMesh[];
  11888. private _excludeWithLayerMask;
  11889. /**
  11890. * Gets the layer id use to find what meshes are not impacted by the light.
  11891. * Inactive if 0
  11892. */
  11893. /**
  11894. * Sets the layer id use to find what meshes are not impacted by the light.
  11895. * Inactive if 0
  11896. */
  11897. excludeWithLayerMask: number;
  11898. private _includeOnlyWithLayerMask;
  11899. /**
  11900. * Gets the layer id use to find what meshes are impacted by the light.
  11901. * Inactive if 0
  11902. */
  11903. /**
  11904. * Sets the layer id use to find what meshes are impacted by the light.
  11905. * Inactive if 0
  11906. */
  11907. includeOnlyWithLayerMask: number;
  11908. private _lightmapMode;
  11909. /**
  11910. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11911. */
  11912. /**
  11913. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11914. */
  11915. lightmapMode: number;
  11916. /**
  11917. * Shadow generator associted to the light.
  11918. * @hidden Internal use only.
  11919. */
  11920. _shadowGenerator: Nullable<IShadowGenerator>;
  11921. /**
  11922. * @hidden Internal use only.
  11923. */
  11924. _excludedMeshesIds: string[];
  11925. /**
  11926. * @hidden Internal use only.
  11927. */
  11928. _includedOnlyMeshesIds: string[];
  11929. /**
  11930. * The current light unifom buffer.
  11931. * @hidden Internal use only.
  11932. */
  11933. _uniformBuffer: UniformBuffer;
  11934. /**
  11935. * Creates a Light object in the scene.
  11936. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11937. * @param name The firendly name of the light
  11938. * @param scene The scene the light belongs too
  11939. */
  11940. constructor(name: string, scene: Scene);
  11941. protected abstract _buildUniformLayout(): void;
  11942. /**
  11943. * Sets the passed Effect "effect" with the Light information.
  11944. * @param effect The effect to update
  11945. * @param lightIndex The index of the light in the effect to update
  11946. * @returns The light
  11947. */
  11948. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11949. /**
  11950. * Returns the string "Light".
  11951. * @returns the class name
  11952. */
  11953. getClassName(): string;
  11954. /** @hidden */
  11955. readonly _isLight: boolean;
  11956. /**
  11957. * Converts the light information to a readable string for debug purpose.
  11958. * @param fullDetails Supports for multiple levels of logging within scene loading
  11959. * @returns the human readable light info
  11960. */
  11961. toString(fullDetails?: boolean): string;
  11962. /** @hidden */
  11963. protected _syncParentEnabledState(): void;
  11964. /**
  11965. * Set the enabled state of this node.
  11966. * @param value - the new enabled state
  11967. */
  11968. setEnabled(value: boolean): void;
  11969. /**
  11970. * Returns the Light associated shadow generator if any.
  11971. * @return the associated shadow generator.
  11972. */
  11973. getShadowGenerator(): Nullable<IShadowGenerator>;
  11974. /**
  11975. * Returns a Vector3, the absolute light position in the World.
  11976. * @returns the world space position of the light
  11977. */
  11978. getAbsolutePosition(): Vector3;
  11979. /**
  11980. * Specifies if the light will affect the passed mesh.
  11981. * @param mesh The mesh to test against the light
  11982. * @return true the mesh is affected otherwise, false.
  11983. */
  11984. canAffectMesh(mesh: AbstractMesh): boolean;
  11985. /**
  11986. * Sort function to order lights for rendering.
  11987. * @param a First Light object to compare to second.
  11988. * @param b Second Light object to compare first.
  11989. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11990. */
  11991. static CompareLightsPriority(a: Light, b: Light): number;
  11992. /**
  11993. * Releases resources associated with this node.
  11994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11996. */
  11997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11998. /**
  11999. * Returns the light type ID (integer).
  12000. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12001. */
  12002. getTypeID(): number;
  12003. /**
  12004. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12005. * @returns the scaled intensity in intensity mode unit
  12006. */
  12007. getScaledIntensity(): number;
  12008. /**
  12009. * Returns a new Light object, named "name", from the current one.
  12010. * @param name The name of the cloned light
  12011. * @returns the new created light
  12012. */
  12013. clone(name: string): Nullable<Light>;
  12014. /**
  12015. * Serializes the current light into a Serialization object.
  12016. * @returns the serialized object.
  12017. */
  12018. serialize(): any;
  12019. /**
  12020. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12021. * This new light is named "name" and added to the passed scene.
  12022. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12023. * @param name The friendly name of the light
  12024. * @param scene The scene the new light will belong to
  12025. * @returns the constructor function
  12026. */
  12027. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12028. /**
  12029. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12030. * @param parsedLight The JSON representation of the light
  12031. * @param scene The scene to create the parsed light in
  12032. * @returns the created light after parsing
  12033. */
  12034. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12035. private _hookArrayForExcluded;
  12036. private _hookArrayForIncludedOnly;
  12037. private _resyncMeshes;
  12038. /**
  12039. * Forces the meshes to update their light related information in their rendering used effects
  12040. * @hidden Internal Use Only
  12041. */
  12042. _markMeshesAsLightDirty(): void;
  12043. /**
  12044. * Recomputes the cached photometric scale if needed.
  12045. */
  12046. private _computePhotometricScale;
  12047. /**
  12048. * Returns the Photometric Scale according to the light type and intensity mode.
  12049. */
  12050. private _getPhotometricScale;
  12051. /**
  12052. * Reorder the light in the scene according to their defined priority.
  12053. * @hidden Internal Use Only
  12054. */
  12055. _reorderLightsInScene(): void;
  12056. /**
  12057. * Prepares the list of defines specific to the light type.
  12058. * @param defines the list of defines
  12059. * @param lightIndex defines the index of the light for the effect
  12060. */
  12061. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12062. }
  12063. }
  12064. declare module BABYLON {
  12065. /**
  12066. * Creates an instance based on a source mesh.
  12067. */
  12068. export class InstancedMesh extends AbstractMesh {
  12069. private _sourceMesh;
  12070. private _currentLOD;
  12071. /** @hidden */
  12072. _indexInSourceMeshInstanceArray: number;
  12073. constructor(name: string, source: Mesh);
  12074. /**
  12075. * Returns the string "InstancedMesh".
  12076. */
  12077. getClassName(): string;
  12078. /** Gets the list of lights affecting that mesh */
  12079. readonly lightSources: Light[];
  12080. _resyncLightSources(): void;
  12081. _resyncLighSource(light: Light): void;
  12082. _removeLightSource(light: Light): void;
  12083. /**
  12084. * If the source mesh receives shadows
  12085. */
  12086. readonly receiveShadows: boolean;
  12087. /**
  12088. * The material of the source mesh
  12089. */
  12090. readonly material: Nullable<Material>;
  12091. /**
  12092. * Visibility of the source mesh
  12093. */
  12094. readonly visibility: number;
  12095. /**
  12096. * Skeleton of the source mesh
  12097. */
  12098. readonly skeleton: Nullable<Skeleton>;
  12099. /**
  12100. * Rendering ground id of the source mesh
  12101. */
  12102. renderingGroupId: number;
  12103. /**
  12104. * Returns the total number of vertices (integer).
  12105. */
  12106. getTotalVertices(): number;
  12107. /**
  12108. * Returns a positive integer : the total number of indices in this mesh geometry.
  12109. * @returns the numner of indices or zero if the mesh has no geometry.
  12110. */
  12111. getTotalIndices(): number;
  12112. /**
  12113. * The source mesh of the instance
  12114. */
  12115. readonly sourceMesh: Mesh;
  12116. /**
  12117. * Is this node ready to be used/rendered
  12118. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12119. * @return {boolean} is it ready
  12120. */
  12121. isReady(completeCheck?: boolean): boolean;
  12122. /**
  12123. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12124. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12125. * @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.
  12126. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12127. */
  12128. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12129. /**
  12130. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12131. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12132. * The `data` are either a numeric array either a Float32Array.
  12133. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12134. * 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).
  12135. * Note that a new underlying VertexBuffer object is created each call.
  12136. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12137. *
  12138. * Possible `kind` values :
  12139. * - VertexBuffer.PositionKind
  12140. * - VertexBuffer.UVKind
  12141. * - VertexBuffer.UV2Kind
  12142. * - VertexBuffer.UV3Kind
  12143. * - VertexBuffer.UV4Kind
  12144. * - VertexBuffer.UV5Kind
  12145. * - VertexBuffer.UV6Kind
  12146. * - VertexBuffer.ColorKind
  12147. * - VertexBuffer.MatricesIndicesKind
  12148. * - VertexBuffer.MatricesIndicesExtraKind
  12149. * - VertexBuffer.MatricesWeightsKind
  12150. * - VertexBuffer.MatricesWeightsExtraKind
  12151. *
  12152. * Returns the Mesh.
  12153. */
  12154. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12155. /**
  12156. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12157. * If the mesh has no geometry, it is simply returned as it is.
  12158. * The `data` are either a numeric array either a Float32Array.
  12159. * No new underlying VertexBuffer object is created.
  12160. * 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.
  12161. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12162. *
  12163. * Possible `kind` values :
  12164. * - VertexBuffer.PositionKind
  12165. * - VertexBuffer.UVKind
  12166. * - VertexBuffer.UV2Kind
  12167. * - VertexBuffer.UV3Kind
  12168. * - VertexBuffer.UV4Kind
  12169. * - VertexBuffer.UV5Kind
  12170. * - VertexBuffer.UV6Kind
  12171. * - VertexBuffer.ColorKind
  12172. * - VertexBuffer.MatricesIndicesKind
  12173. * - VertexBuffer.MatricesIndicesExtraKind
  12174. * - VertexBuffer.MatricesWeightsKind
  12175. * - VertexBuffer.MatricesWeightsExtraKind
  12176. *
  12177. * Returns the Mesh.
  12178. */
  12179. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12180. /**
  12181. * Sets the mesh indices.
  12182. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12183. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12184. * This method creates a new index buffer each call.
  12185. * Returns the Mesh.
  12186. */
  12187. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12188. /**
  12189. * Boolean : True if the mesh owns the requested kind of data.
  12190. */
  12191. isVerticesDataPresent(kind: string): boolean;
  12192. /**
  12193. * Returns an array of indices (IndicesArray).
  12194. */
  12195. getIndices(): Nullable<IndicesArray>;
  12196. readonly _positions: Nullable<Vector3[]>;
  12197. /**
  12198. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12199. * This means the mesh underlying bounding box and sphere are recomputed.
  12200. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12201. * @returns the current mesh
  12202. */
  12203. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12204. /** @hidden */
  12205. _preActivate(): InstancedMesh;
  12206. /** @hidden */
  12207. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12208. /** @hidden */
  12209. _postActivate(): void;
  12210. getWorldMatrix(): Matrix;
  12211. readonly isAnInstance: boolean;
  12212. /**
  12213. * Returns the current associated LOD AbstractMesh.
  12214. */
  12215. getLOD(camera: Camera): AbstractMesh;
  12216. /** @hidden */
  12217. _syncSubMeshes(): InstancedMesh;
  12218. /** @hidden */
  12219. _generatePointsArray(): boolean;
  12220. /**
  12221. * Creates a new InstancedMesh from the current mesh.
  12222. * - name (string) : the cloned mesh name
  12223. * - newParent (optional Node) : the optional Node to parent the clone to.
  12224. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12225. *
  12226. * Returns the clone.
  12227. */
  12228. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12229. /**
  12230. * Disposes the InstancedMesh.
  12231. * Returns nothing.
  12232. */
  12233. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12234. }
  12235. }
  12236. declare module BABYLON {
  12237. /**
  12238. * Defines the options associated with the creation of a shader material.
  12239. */
  12240. export interface IShaderMaterialOptions {
  12241. /**
  12242. * Does the material work in alpha blend mode
  12243. */
  12244. needAlphaBlending: boolean;
  12245. /**
  12246. * Does the material work in alpha test mode
  12247. */
  12248. needAlphaTesting: boolean;
  12249. /**
  12250. * The list of attribute names used in the shader
  12251. */
  12252. attributes: string[];
  12253. /**
  12254. * The list of unifrom names used in the shader
  12255. */
  12256. uniforms: string[];
  12257. /**
  12258. * The list of UBO names used in the shader
  12259. */
  12260. uniformBuffers: string[];
  12261. /**
  12262. * The list of sampler names used in the shader
  12263. */
  12264. samplers: string[];
  12265. /**
  12266. * The list of defines used in the shader
  12267. */
  12268. defines: string[];
  12269. }
  12270. /**
  12271. * 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.
  12272. *
  12273. * This returned material effects how the mesh will look based on the code in the shaders.
  12274. *
  12275. * @see http://doc.babylonjs.com/how_to/shader_material
  12276. */
  12277. export class ShaderMaterial extends Material {
  12278. private _shaderPath;
  12279. private _options;
  12280. private _textures;
  12281. private _textureArrays;
  12282. private _floats;
  12283. private _ints;
  12284. private _floatsArrays;
  12285. private _colors3;
  12286. private _colors3Arrays;
  12287. private _colors4;
  12288. private _colors4Arrays;
  12289. private _vectors2;
  12290. private _vectors3;
  12291. private _vectors4;
  12292. private _matrices;
  12293. private _matrices3x3;
  12294. private _matrices2x2;
  12295. private _vectors2Arrays;
  12296. private _vectors3Arrays;
  12297. private _vectors4Arrays;
  12298. private _cachedWorldViewMatrix;
  12299. private _cachedWorldViewProjectionMatrix;
  12300. private _renderId;
  12301. /**
  12302. * Instantiate a new shader material.
  12303. * 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.
  12304. * This returned material effects how the mesh will look based on the code in the shaders.
  12305. * @see http://doc.babylonjs.com/how_to/shader_material
  12306. * @param name Define the name of the material in the scene
  12307. * @param scene Define the scene the material belongs to
  12308. * @param shaderPath Defines the route to the shader code in one of three ways:
  12309. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12310. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12311. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12312. * @param options Define the options used to create the shader
  12313. */
  12314. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12315. /**
  12316. * Gets the options used to compile the shader.
  12317. * They can be modified to trigger a new compilation
  12318. */
  12319. readonly options: IShaderMaterialOptions;
  12320. /**
  12321. * Gets the current class name of the material e.g. "ShaderMaterial"
  12322. * Mainly use in serialization.
  12323. * @returns the class name
  12324. */
  12325. getClassName(): string;
  12326. /**
  12327. * Specifies if the material will require alpha blending
  12328. * @returns a boolean specifying if alpha blending is needed
  12329. */
  12330. needAlphaBlending(): boolean;
  12331. /**
  12332. * Specifies if this material should be rendered in alpha test mode
  12333. * @returns a boolean specifying if an alpha test is needed.
  12334. */
  12335. needAlphaTesting(): boolean;
  12336. private _checkUniform;
  12337. /**
  12338. * Set a texture in the shader.
  12339. * @param name Define the name of the uniform samplers as defined in the shader
  12340. * @param texture Define the texture to bind to this sampler
  12341. * @return the material itself allowing "fluent" like uniform updates
  12342. */
  12343. setTexture(name: string, texture: Texture): ShaderMaterial;
  12344. /**
  12345. * Set a texture array in the shader.
  12346. * @param name Define the name of the uniform sampler array as defined in the shader
  12347. * @param textures Define the list of textures to bind to this sampler
  12348. * @return the material itself allowing "fluent" like uniform updates
  12349. */
  12350. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12351. /**
  12352. * Set a float in the shader.
  12353. * @param name Define the name of the uniform as defined in the shader
  12354. * @param value Define the value to give to the uniform
  12355. * @return the material itself allowing "fluent" like uniform updates
  12356. */
  12357. setFloat(name: string, value: number): ShaderMaterial;
  12358. /**
  12359. * Set a int in the shader.
  12360. * @param name Define the name of the uniform as defined in the shader
  12361. * @param value Define the value to give to the uniform
  12362. * @return the material itself allowing "fluent" like uniform updates
  12363. */
  12364. setInt(name: string, value: number): ShaderMaterial;
  12365. /**
  12366. * Set an array of floats in the shader.
  12367. * @param name Define the name of the uniform as defined in the shader
  12368. * @param value Define the value to give to the uniform
  12369. * @return the material itself allowing "fluent" like uniform updates
  12370. */
  12371. setFloats(name: string, value: number[]): ShaderMaterial;
  12372. /**
  12373. * Set a vec3 in the shader from a Color3.
  12374. * @param name Define the name of the uniform as defined in the shader
  12375. * @param value Define the value to give to the uniform
  12376. * @return the material itself allowing "fluent" like uniform updates
  12377. */
  12378. setColor3(name: string, value: Color3): ShaderMaterial;
  12379. /**
  12380. * Set a vec3 array in the shader from a Color3 array.
  12381. * @param name Define the name of the uniform as defined in the shader
  12382. * @param value Define the value to give to the uniform
  12383. * @return the material itself allowing "fluent" like uniform updates
  12384. */
  12385. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12386. /**
  12387. * Set a vec4 in the shader from a Color4.
  12388. * @param name Define the name of the uniform as defined in the shader
  12389. * @param value Define the value to give to the uniform
  12390. * @return the material itself allowing "fluent" like uniform updates
  12391. */
  12392. setColor4(name: string, value: Color4): ShaderMaterial;
  12393. /**
  12394. * Set a vec4 array in the shader from a Color4 array.
  12395. * @param name Define the name of the uniform as defined in the shader
  12396. * @param value Define the value to give to the uniform
  12397. * @return the material itself allowing "fluent" like uniform updates
  12398. */
  12399. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12400. /**
  12401. * Set a vec2 in the shader from a Vector2.
  12402. * @param name Define the name of the uniform as defined in the shader
  12403. * @param value Define the value to give to the uniform
  12404. * @return the material itself allowing "fluent" like uniform updates
  12405. */
  12406. setVector2(name: string, value: Vector2): ShaderMaterial;
  12407. /**
  12408. * Set a vec3 in the shader from a Vector3.
  12409. * @param name Define the name of the uniform as defined in the shader
  12410. * @param value Define the value to give to the uniform
  12411. * @return the material itself allowing "fluent" like uniform updates
  12412. */
  12413. setVector3(name: string, value: Vector3): ShaderMaterial;
  12414. /**
  12415. * Set a vec4 in the shader from a Vector4.
  12416. * @param name Define the name of the uniform as defined in the shader
  12417. * @param value Define the value to give to the uniform
  12418. * @return the material itself allowing "fluent" like uniform updates
  12419. */
  12420. setVector4(name: string, value: Vector4): ShaderMaterial;
  12421. /**
  12422. * Set a mat4 in the shader from a Matrix.
  12423. * @param name Define the name of the uniform as defined in the shader
  12424. * @param value Define the value to give to the uniform
  12425. * @return the material itself allowing "fluent" like uniform updates
  12426. */
  12427. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12428. /**
  12429. * Set a mat3 in the shader from a Float32Array.
  12430. * @param name Define the name of the uniform as defined in the shader
  12431. * @param value Define the value to give to the uniform
  12432. * @return the material itself allowing "fluent" like uniform updates
  12433. */
  12434. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12435. /**
  12436. * Set a mat2 in the shader from a Float32Array.
  12437. * @param name Define the name of the uniform as defined in the shader
  12438. * @param value Define the value to give to the uniform
  12439. * @return the material itself allowing "fluent" like uniform updates
  12440. */
  12441. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12442. /**
  12443. * Set a vec2 array in the shader from a number array.
  12444. * @param name Define the name of the uniform as defined in the shader
  12445. * @param value Define the value to give to the uniform
  12446. * @return the material itself allowing "fluent" like uniform updates
  12447. */
  12448. setArray2(name: string, value: number[]): ShaderMaterial;
  12449. /**
  12450. * Set a vec3 array in the shader from a number array.
  12451. * @param name Define the name of the uniform as defined in the shader
  12452. * @param value Define the value to give to the uniform
  12453. * @return the material itself allowing "fluent" like uniform updates
  12454. */
  12455. setArray3(name: string, value: number[]): ShaderMaterial;
  12456. /**
  12457. * Set a vec4 array in the shader from a number array.
  12458. * @param name Define the name of the uniform as defined in the shader
  12459. * @param value Define the value to give to the uniform
  12460. * @return the material itself allowing "fluent" like uniform updates
  12461. */
  12462. setArray4(name: string, value: number[]): ShaderMaterial;
  12463. private _checkCache;
  12464. /**
  12465. * Specifies that the submesh is ready to be used
  12466. * @param mesh defines the mesh to check
  12467. * @param subMesh defines which submesh to check
  12468. * @param useInstances specifies that instances should be used
  12469. * @returns a boolean indicating that the submesh is ready or not
  12470. */
  12471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12472. /**
  12473. * Checks if the material is ready to render the requested mesh
  12474. * @param mesh Define the mesh to render
  12475. * @param useInstances Define whether or not the material is used with instances
  12476. * @returns true if ready, otherwise false
  12477. */
  12478. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12479. /**
  12480. * Binds the world matrix to the material
  12481. * @param world defines the world transformation matrix
  12482. */
  12483. bindOnlyWorldMatrix(world: Matrix): void;
  12484. /**
  12485. * Binds the material to the mesh
  12486. * @param world defines the world transformation matrix
  12487. * @param mesh defines the mesh to bind the material to
  12488. */
  12489. bind(world: Matrix, mesh?: Mesh): void;
  12490. /**
  12491. * Gets the active textures from the material
  12492. * @returns an array of textures
  12493. */
  12494. getActiveTextures(): BaseTexture[];
  12495. /**
  12496. * Specifies if the material uses a texture
  12497. * @param texture defines the texture to check against the material
  12498. * @returns a boolean specifying if the material uses the texture
  12499. */
  12500. hasTexture(texture: BaseTexture): boolean;
  12501. /**
  12502. * Makes a duplicate of the material, and gives it a new name
  12503. * @param name defines the new name for the duplicated material
  12504. * @returns the cloned material
  12505. */
  12506. clone(name: string): ShaderMaterial;
  12507. /**
  12508. * Disposes the material
  12509. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12510. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12511. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12512. */
  12513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12514. /**
  12515. * Serializes this material in a JSON representation
  12516. * @returns the serialized material object
  12517. */
  12518. serialize(): any;
  12519. /**
  12520. * Creates a shader material from parsed shader material data
  12521. * @param source defines the JSON represnetation of the material
  12522. * @param scene defines the hosting scene
  12523. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12524. * @returns a new material
  12525. */
  12526. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /** @hidden */
  12531. export var clipPlaneFragmentDeclaration: {
  12532. name: string;
  12533. shader: string;
  12534. };
  12535. }
  12536. declare module BABYLON {
  12537. /** @hidden */
  12538. export var clipPlaneFragment: {
  12539. name: string;
  12540. shader: string;
  12541. };
  12542. }
  12543. declare module BABYLON {
  12544. /** @hidden */
  12545. export var colorPixelShader: {
  12546. name: string;
  12547. shader: string;
  12548. };
  12549. }
  12550. declare module BABYLON {
  12551. /** @hidden */
  12552. export var clipPlaneVertexDeclaration: {
  12553. name: string;
  12554. shader: string;
  12555. };
  12556. }
  12557. declare module BABYLON {
  12558. /** @hidden */
  12559. export var clipPlaneVertex: {
  12560. name: string;
  12561. shader: string;
  12562. };
  12563. }
  12564. declare module BABYLON {
  12565. /** @hidden */
  12566. export var colorVertexShader: {
  12567. name: string;
  12568. shader: string;
  12569. };
  12570. }
  12571. declare module BABYLON {
  12572. /**
  12573. * Line mesh
  12574. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12575. */
  12576. export class LinesMesh extends Mesh {
  12577. /**
  12578. * If vertex color should be applied to the mesh
  12579. */
  12580. readonly useVertexColor?: boolean | undefined;
  12581. /**
  12582. * If vertex alpha should be applied to the mesh
  12583. */
  12584. readonly useVertexAlpha?: boolean | undefined;
  12585. /**
  12586. * Color of the line (Default: White)
  12587. */
  12588. color: Color3;
  12589. /**
  12590. * Alpha of the line (Default: 1)
  12591. */
  12592. alpha: number;
  12593. /**
  12594. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12595. * This margin is expressed in world space coordinates, so its value may vary.
  12596. * Default value is 0.1
  12597. */
  12598. intersectionThreshold: number;
  12599. private _colorShader;
  12600. private color4;
  12601. /**
  12602. * Creates a new LinesMesh
  12603. * @param name defines the name
  12604. * @param scene defines the hosting scene
  12605. * @param parent defines the parent mesh if any
  12606. * @param source defines the optional source LinesMesh used to clone data from
  12607. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12608. * When false, achieved by calling a clone(), also passing False.
  12609. * This will make creation of children, recursive.
  12610. * @param useVertexColor defines if this LinesMesh supports vertex color
  12611. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12612. */
  12613. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12614. /**
  12615. * If vertex color should be applied to the mesh
  12616. */
  12617. useVertexColor?: boolean | undefined,
  12618. /**
  12619. * If vertex alpha should be applied to the mesh
  12620. */
  12621. useVertexAlpha?: boolean | undefined);
  12622. private _addClipPlaneDefine;
  12623. private _removeClipPlaneDefine;
  12624. isReady(): boolean;
  12625. /**
  12626. * Returns the string "LineMesh"
  12627. */
  12628. getClassName(): string;
  12629. /**
  12630. * @hidden
  12631. */
  12632. /**
  12633. * @hidden
  12634. */
  12635. material: Material;
  12636. /**
  12637. * @hidden
  12638. */
  12639. readonly checkCollisions: boolean;
  12640. /** @hidden */
  12641. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12642. /** @hidden */
  12643. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12644. /**
  12645. * Disposes of the line mesh
  12646. * @param doNotRecurse If children should be disposed
  12647. */
  12648. dispose(doNotRecurse?: boolean): void;
  12649. /**
  12650. * Returns a new LineMesh object cloned from the current one.
  12651. */
  12652. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12653. /**
  12654. * Creates a new InstancedLinesMesh object from the mesh model.
  12655. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12656. * @param name defines the name of the new instance
  12657. * @returns a new InstancedLinesMesh
  12658. */
  12659. createInstance(name: string): InstancedLinesMesh;
  12660. }
  12661. /**
  12662. * Creates an instance based on a source LinesMesh
  12663. */
  12664. export class InstancedLinesMesh extends InstancedMesh {
  12665. /**
  12666. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12667. * This margin is expressed in world space coordinates, so its value may vary.
  12668. * Initilized with the intersectionThreshold value of the source LinesMesh
  12669. */
  12670. intersectionThreshold: number;
  12671. constructor(name: string, source: LinesMesh);
  12672. /**
  12673. * Returns the string "InstancedLinesMesh".
  12674. */
  12675. getClassName(): string;
  12676. }
  12677. }
  12678. declare module BABYLON {
  12679. /**
  12680. * Mesh representing the gorund
  12681. */
  12682. export class GroundMesh extends Mesh {
  12683. /** If octree should be generated */
  12684. generateOctree: boolean;
  12685. private _heightQuads;
  12686. /** @hidden */
  12687. _subdivisionsX: number;
  12688. /** @hidden */
  12689. _subdivisionsY: number;
  12690. /** @hidden */
  12691. _width: number;
  12692. /** @hidden */
  12693. _height: number;
  12694. /** @hidden */
  12695. _minX: number;
  12696. /** @hidden */
  12697. _maxX: number;
  12698. /** @hidden */
  12699. _minZ: number;
  12700. /** @hidden */
  12701. _maxZ: number;
  12702. constructor(name: string, scene: Scene);
  12703. /**
  12704. * "GroundMesh"
  12705. * @returns "GroundMesh"
  12706. */
  12707. getClassName(): string;
  12708. /**
  12709. * The minimum of x and y subdivisions
  12710. */
  12711. readonly subdivisions: number;
  12712. /**
  12713. * X subdivisions
  12714. */
  12715. readonly subdivisionsX: number;
  12716. /**
  12717. * Y subdivisions
  12718. */
  12719. readonly subdivisionsY: number;
  12720. /**
  12721. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12722. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12723. * @param chunksCount the number of subdivisions for x and y
  12724. * @param octreeBlocksSize (Default: 32)
  12725. */
  12726. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12727. /**
  12728. * Returns a height (y) value in the Worl system :
  12729. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12730. * @param x x coordinate
  12731. * @param z z coordinate
  12732. * @returns the ground y position if (x, z) are outside the ground surface.
  12733. */
  12734. getHeightAtCoordinates(x: number, z: number): number;
  12735. /**
  12736. * Returns a normalized vector (Vector3) orthogonal to the ground
  12737. * at the ground coordinates (x, z) expressed in the World system.
  12738. * @param x x coordinate
  12739. * @param z z coordinate
  12740. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12741. */
  12742. getNormalAtCoordinates(x: number, z: number): Vector3;
  12743. /**
  12744. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12745. * at the ground coordinates (x, z) expressed in the World system.
  12746. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12747. * @param x x coordinate
  12748. * @param z z coordinate
  12749. * @param ref vector to store the result
  12750. * @returns the GroundMesh.
  12751. */
  12752. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12753. /**
  12754. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12755. * if the ground has been updated.
  12756. * This can be used in the render loop.
  12757. * @returns the GroundMesh.
  12758. */
  12759. updateCoordinateHeights(): GroundMesh;
  12760. private _getFacetAt;
  12761. private _initHeightQuads;
  12762. private _computeHeightQuads;
  12763. /**
  12764. * Serializes this ground mesh
  12765. * @param serializationObject object to write serialization to
  12766. */
  12767. serialize(serializationObject: any): void;
  12768. /**
  12769. * Parses a serialized ground mesh
  12770. * @param parsedMesh the serialized mesh
  12771. * @param scene the scene to create the ground mesh in
  12772. * @returns the created ground mesh
  12773. */
  12774. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12775. }
  12776. }
  12777. declare module BABYLON {
  12778. /**
  12779. * Interface for Physics-Joint data
  12780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12781. */
  12782. export interface PhysicsJointData {
  12783. /**
  12784. * The main pivot of the joint
  12785. */
  12786. mainPivot?: Vector3;
  12787. /**
  12788. * The connected pivot of the joint
  12789. */
  12790. connectedPivot?: Vector3;
  12791. /**
  12792. * The main axis of the joint
  12793. */
  12794. mainAxis?: Vector3;
  12795. /**
  12796. * The connected axis of the joint
  12797. */
  12798. connectedAxis?: Vector3;
  12799. /**
  12800. * The collision of the joint
  12801. */
  12802. collision?: boolean;
  12803. /**
  12804. * Native Oimo/Cannon/Energy data
  12805. */
  12806. nativeParams?: any;
  12807. }
  12808. /**
  12809. * This is a holder class for the physics joint created by the physics plugin
  12810. * It holds a set of functions to control the underlying joint
  12811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12812. */
  12813. export class PhysicsJoint {
  12814. /**
  12815. * The type of the physics joint
  12816. */
  12817. type: number;
  12818. /**
  12819. * The data for the physics joint
  12820. */
  12821. jointData: PhysicsJointData;
  12822. private _physicsJoint;
  12823. protected _physicsPlugin: IPhysicsEnginePlugin;
  12824. /**
  12825. * Initializes the physics joint
  12826. * @param type The type of the physics joint
  12827. * @param jointData The data for the physics joint
  12828. */
  12829. constructor(
  12830. /**
  12831. * The type of the physics joint
  12832. */
  12833. type: number,
  12834. /**
  12835. * The data for the physics joint
  12836. */
  12837. jointData: PhysicsJointData);
  12838. /**
  12839. * Gets the physics joint
  12840. */
  12841. /**
  12842. * Sets the physics joint
  12843. */
  12844. physicsJoint: any;
  12845. /**
  12846. * Sets the physics plugin
  12847. */
  12848. physicsPlugin: IPhysicsEnginePlugin;
  12849. /**
  12850. * Execute a function that is physics-plugin specific.
  12851. * @param {Function} func the function that will be executed.
  12852. * It accepts two parameters: the physics world and the physics joint
  12853. */
  12854. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12855. /**
  12856. * Distance-Joint type
  12857. */
  12858. static DistanceJoint: number;
  12859. /**
  12860. * Hinge-Joint type
  12861. */
  12862. static HingeJoint: number;
  12863. /**
  12864. * Ball-and-Socket joint type
  12865. */
  12866. static BallAndSocketJoint: number;
  12867. /**
  12868. * Wheel-Joint type
  12869. */
  12870. static WheelJoint: number;
  12871. /**
  12872. * Slider-Joint type
  12873. */
  12874. static SliderJoint: number;
  12875. /**
  12876. * Prismatic-Joint type
  12877. */
  12878. static PrismaticJoint: number;
  12879. /**
  12880. * Universal-Joint type
  12881. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12882. */
  12883. static UniversalJoint: number;
  12884. /**
  12885. * Hinge-Joint 2 type
  12886. */
  12887. static Hinge2Joint: number;
  12888. /**
  12889. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12890. */
  12891. static PointToPointJoint: number;
  12892. /**
  12893. * Spring-Joint type
  12894. */
  12895. static SpringJoint: number;
  12896. /**
  12897. * Lock-Joint type
  12898. */
  12899. static LockJoint: number;
  12900. }
  12901. /**
  12902. * A class representing a physics distance joint
  12903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12904. */
  12905. export class DistanceJoint extends PhysicsJoint {
  12906. /**
  12907. *
  12908. * @param jointData The data for the Distance-Joint
  12909. */
  12910. constructor(jointData: DistanceJointData);
  12911. /**
  12912. * Update the predefined distance.
  12913. * @param maxDistance The maximum preferred distance
  12914. * @param minDistance The minimum preferred distance
  12915. */
  12916. updateDistance(maxDistance: number, minDistance?: number): void;
  12917. }
  12918. /**
  12919. * Represents a Motor-Enabled Joint
  12920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12921. */
  12922. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12923. /**
  12924. * Initializes the Motor-Enabled Joint
  12925. * @param type The type of the joint
  12926. * @param jointData The physica joint data for the joint
  12927. */
  12928. constructor(type: number, jointData: PhysicsJointData);
  12929. /**
  12930. * Set the motor values.
  12931. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12932. * @param force the force to apply
  12933. * @param maxForce max force for this motor.
  12934. */
  12935. setMotor(force?: number, maxForce?: number): void;
  12936. /**
  12937. * Set the motor's limits.
  12938. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12939. * @param upperLimit The upper limit of the motor
  12940. * @param lowerLimit The lower limit of the motor
  12941. */
  12942. setLimit(upperLimit: number, lowerLimit?: number): void;
  12943. }
  12944. /**
  12945. * This class represents a single physics Hinge-Joint
  12946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12947. */
  12948. export class HingeJoint extends MotorEnabledJoint {
  12949. /**
  12950. * Initializes the Hinge-Joint
  12951. * @param jointData The joint data for the Hinge-Joint
  12952. */
  12953. constructor(jointData: PhysicsJointData);
  12954. /**
  12955. * Set the motor values.
  12956. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12957. * @param {number} force the force to apply
  12958. * @param {number} maxForce max force for this motor.
  12959. */
  12960. setMotor(force?: number, maxForce?: number): void;
  12961. /**
  12962. * Set the motor's limits.
  12963. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12964. * @param upperLimit The upper limit of the motor
  12965. * @param lowerLimit The lower limit of the motor
  12966. */
  12967. setLimit(upperLimit: number, lowerLimit?: number): void;
  12968. }
  12969. /**
  12970. * This class represents a dual hinge physics joint (same as wheel joint)
  12971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12972. */
  12973. export class Hinge2Joint extends MotorEnabledJoint {
  12974. /**
  12975. * Initializes the Hinge2-Joint
  12976. * @param jointData The joint data for the Hinge2-Joint
  12977. */
  12978. constructor(jointData: PhysicsJointData);
  12979. /**
  12980. * Set the motor values.
  12981. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12982. * @param {number} targetSpeed the speed the motor is to reach
  12983. * @param {number} maxForce max force for this motor.
  12984. * @param {motorIndex} the motor's index, 0 or 1.
  12985. */
  12986. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12987. /**
  12988. * Set the motor limits.
  12989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12990. * @param {number} upperLimit the upper limit
  12991. * @param {number} lowerLimit lower limit
  12992. * @param {motorIndex} the motor's index, 0 or 1.
  12993. */
  12994. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12995. }
  12996. /**
  12997. * Interface for a motor enabled joint
  12998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12999. */
  13000. export interface IMotorEnabledJoint {
  13001. /**
  13002. * Physics joint
  13003. */
  13004. physicsJoint: any;
  13005. /**
  13006. * Sets the motor of the motor-enabled joint
  13007. * @param force The force of the motor
  13008. * @param maxForce The maximum force of the motor
  13009. * @param motorIndex The index of the motor
  13010. */
  13011. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13012. /**
  13013. * Sets the limit of the motor
  13014. * @param upperLimit The upper limit of the motor
  13015. * @param lowerLimit The lower limit of the motor
  13016. * @param motorIndex The index of the motor
  13017. */
  13018. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13019. }
  13020. /**
  13021. * Joint data for a Distance-Joint
  13022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13023. */
  13024. export interface DistanceJointData extends PhysicsJointData {
  13025. /**
  13026. * Max distance the 2 joint objects can be apart
  13027. */
  13028. maxDistance: number;
  13029. }
  13030. /**
  13031. * Joint data from a spring joint
  13032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13033. */
  13034. export interface SpringJointData extends PhysicsJointData {
  13035. /**
  13036. * Length of the spring
  13037. */
  13038. length: number;
  13039. /**
  13040. * Stiffness of the spring
  13041. */
  13042. stiffness: number;
  13043. /**
  13044. * Damping of the spring
  13045. */
  13046. damping: number;
  13047. /** this callback will be called when applying the force to the impostors. */
  13048. forceApplicationCallback: () => void;
  13049. }
  13050. }
  13051. declare module BABYLON {
  13052. /**
  13053. * Holds the data for the raycast result
  13054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13055. */
  13056. export class PhysicsRaycastResult {
  13057. private _hasHit;
  13058. private _hitDistance;
  13059. private _hitNormalWorld;
  13060. private _hitPointWorld;
  13061. private _rayFromWorld;
  13062. private _rayToWorld;
  13063. /**
  13064. * Gets if there was a hit
  13065. */
  13066. readonly hasHit: boolean;
  13067. /**
  13068. * Gets the distance from the hit
  13069. */
  13070. readonly hitDistance: number;
  13071. /**
  13072. * Gets the hit normal/direction in the world
  13073. */
  13074. readonly hitNormalWorld: Vector3;
  13075. /**
  13076. * Gets the hit point in the world
  13077. */
  13078. readonly hitPointWorld: Vector3;
  13079. /**
  13080. * Gets the ray "start point" of the ray in the world
  13081. */
  13082. readonly rayFromWorld: Vector3;
  13083. /**
  13084. * Gets the ray "end point" of the ray in the world
  13085. */
  13086. readonly rayToWorld: Vector3;
  13087. /**
  13088. * Sets the hit data (normal & point in world space)
  13089. * @param hitNormalWorld defines the normal in world space
  13090. * @param hitPointWorld defines the point in world space
  13091. */
  13092. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13093. /**
  13094. * Sets the distance from the start point to the hit point
  13095. * @param distance
  13096. */
  13097. setHitDistance(distance: number): void;
  13098. /**
  13099. * Calculates the distance manually
  13100. */
  13101. calculateHitDistance(): void;
  13102. /**
  13103. * Resets all the values to default
  13104. * @param from The from point on world space
  13105. * @param to The to point on world space
  13106. */
  13107. reset(from?: Vector3, to?: Vector3): void;
  13108. }
  13109. /**
  13110. * Interface for the size containing width and height
  13111. */
  13112. interface IXYZ {
  13113. /**
  13114. * X
  13115. */
  13116. x: number;
  13117. /**
  13118. * Y
  13119. */
  13120. y: number;
  13121. /**
  13122. * Z
  13123. */
  13124. z: number;
  13125. }
  13126. }
  13127. declare module BABYLON {
  13128. /**
  13129. * Interface used to describe a physics joint
  13130. */
  13131. export interface PhysicsImpostorJoint {
  13132. /** Defines the main impostor to which the joint is linked */
  13133. mainImpostor: PhysicsImpostor;
  13134. /** Defines the impostor that is connected to the main impostor using this joint */
  13135. connectedImpostor: PhysicsImpostor;
  13136. /** Defines the joint itself */
  13137. joint: PhysicsJoint;
  13138. }
  13139. /** @hidden */
  13140. export interface IPhysicsEnginePlugin {
  13141. world: any;
  13142. name: string;
  13143. setGravity(gravity: Vector3): void;
  13144. setTimeStep(timeStep: number): void;
  13145. getTimeStep(): number;
  13146. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13147. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13148. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13149. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13150. removePhysicsBody(impostor: PhysicsImpostor): void;
  13151. generateJoint(joint: PhysicsImpostorJoint): void;
  13152. removeJoint(joint: PhysicsImpostorJoint): void;
  13153. isSupported(): boolean;
  13154. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13155. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13156. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13157. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13158. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13159. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13160. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13161. getBodyMass(impostor: PhysicsImpostor): number;
  13162. getBodyFriction(impostor: PhysicsImpostor): number;
  13163. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13164. getBodyRestitution(impostor: PhysicsImpostor): number;
  13165. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13166. getBodyPressure?(impostor: PhysicsImpostor): number;
  13167. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13168. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13169. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13170. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13171. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13172. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13173. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13174. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13175. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13176. sleepBody(impostor: PhysicsImpostor): void;
  13177. wakeUpBody(impostor: PhysicsImpostor): void;
  13178. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13179. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13180. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13181. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13182. getRadius(impostor: PhysicsImpostor): number;
  13183. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13184. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13185. dispose(): void;
  13186. }
  13187. /**
  13188. * Interface used to define a physics engine
  13189. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13190. */
  13191. export interface IPhysicsEngine {
  13192. /**
  13193. * Gets the gravity vector used by the simulation
  13194. */
  13195. gravity: Vector3;
  13196. /**
  13197. * Sets the gravity vector used by the simulation
  13198. * @param gravity defines the gravity vector to use
  13199. */
  13200. setGravity(gravity: Vector3): void;
  13201. /**
  13202. * Set the time step of the physics engine.
  13203. * Default is 1/60.
  13204. * To slow it down, enter 1/600 for example.
  13205. * To speed it up, 1/30
  13206. * @param newTimeStep the new timestep to apply to this world.
  13207. */
  13208. setTimeStep(newTimeStep: number): void;
  13209. /**
  13210. * Get the time step of the physics engine.
  13211. * @returns the current time step
  13212. */
  13213. getTimeStep(): number;
  13214. /**
  13215. * Release all resources
  13216. */
  13217. dispose(): void;
  13218. /**
  13219. * Gets the name of the current physics plugin
  13220. * @returns the name of the plugin
  13221. */
  13222. getPhysicsPluginName(): string;
  13223. /**
  13224. * Adding a new impostor for the impostor tracking.
  13225. * This will be done by the impostor itself.
  13226. * @param impostor the impostor to add
  13227. */
  13228. addImpostor(impostor: PhysicsImpostor): void;
  13229. /**
  13230. * Remove an impostor from the engine.
  13231. * This impostor and its mesh will not longer be updated by the physics engine.
  13232. * @param impostor the impostor to remove
  13233. */
  13234. removeImpostor(impostor: PhysicsImpostor): void;
  13235. /**
  13236. * Add a joint to the physics engine
  13237. * @param mainImpostor defines the main impostor to which the joint is added.
  13238. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13239. * @param joint defines the joint that will connect both impostors.
  13240. */
  13241. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13242. /**
  13243. * Removes a joint from the simulation
  13244. * @param mainImpostor defines the impostor used with the joint
  13245. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13246. * @param joint defines the joint to remove
  13247. */
  13248. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13249. /**
  13250. * Gets the current plugin used to run the simulation
  13251. * @returns current plugin
  13252. */
  13253. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13254. /**
  13255. * Gets the list of physic impostors
  13256. * @returns an array of PhysicsImpostor
  13257. */
  13258. getImpostors(): Array<PhysicsImpostor>;
  13259. /**
  13260. * Gets the impostor for a physics enabled object
  13261. * @param object defines the object impersonated by the impostor
  13262. * @returns the PhysicsImpostor or null if not found
  13263. */
  13264. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13265. /**
  13266. * Gets the impostor for a physics body object
  13267. * @param body defines physics body used by the impostor
  13268. * @returns the PhysicsImpostor or null if not found
  13269. */
  13270. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13271. /**
  13272. * Does a raycast in the physics world
  13273. * @param from when should the ray start?
  13274. * @param to when should the ray end?
  13275. * @returns PhysicsRaycastResult
  13276. */
  13277. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13278. /**
  13279. * Called by the scene. No need to call it.
  13280. * @param delta defines the timespam between frames
  13281. */
  13282. _step(delta: number): void;
  13283. }
  13284. }
  13285. declare module BABYLON {
  13286. /**
  13287. * The interface for the physics imposter parameters
  13288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13289. */
  13290. export interface PhysicsImpostorParameters {
  13291. /**
  13292. * The mass of the physics imposter
  13293. */
  13294. mass: number;
  13295. /**
  13296. * The friction of the physics imposter
  13297. */
  13298. friction?: number;
  13299. /**
  13300. * The coefficient of restitution of the physics imposter
  13301. */
  13302. restitution?: number;
  13303. /**
  13304. * The native options of the physics imposter
  13305. */
  13306. nativeOptions?: any;
  13307. /**
  13308. * Specifies if the parent should be ignored
  13309. */
  13310. ignoreParent?: boolean;
  13311. /**
  13312. * Specifies if bi-directional transformations should be disabled
  13313. */
  13314. disableBidirectionalTransformation?: boolean;
  13315. /**
  13316. * The pressure inside the physics imposter, soft object only
  13317. */
  13318. pressure?: number;
  13319. /**
  13320. * The stiffness the physics imposter, soft object only
  13321. */
  13322. stiffness?: number;
  13323. /**
  13324. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13325. */
  13326. velocityIterations?: number;
  13327. /**
  13328. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13329. */
  13330. positionIterations?: number;
  13331. /**
  13332. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13333. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13334. * Add to fix multiple points
  13335. */
  13336. fixedPoints?: number;
  13337. /**
  13338. * The collision margin around a soft object
  13339. */
  13340. margin?: number;
  13341. /**
  13342. * The collision margin around a soft object
  13343. */
  13344. damping?: number;
  13345. /**
  13346. * The path for a rope based on an extrusion
  13347. */
  13348. path?: any;
  13349. /**
  13350. * The shape of an extrusion used for a rope based on an extrusion
  13351. */
  13352. shape?: any;
  13353. }
  13354. /**
  13355. * Interface for a physics-enabled object
  13356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13357. */
  13358. export interface IPhysicsEnabledObject {
  13359. /**
  13360. * The position of the physics-enabled object
  13361. */
  13362. position: Vector3;
  13363. /**
  13364. * The rotation of the physics-enabled object
  13365. */
  13366. rotationQuaternion: Nullable<Quaternion>;
  13367. /**
  13368. * The scale of the physics-enabled object
  13369. */
  13370. scaling: Vector3;
  13371. /**
  13372. * The rotation of the physics-enabled object
  13373. */
  13374. rotation?: Vector3;
  13375. /**
  13376. * The parent of the physics-enabled object
  13377. */
  13378. parent?: any;
  13379. /**
  13380. * The bounding info of the physics-enabled object
  13381. * @returns The bounding info of the physics-enabled object
  13382. */
  13383. getBoundingInfo(): BoundingInfo;
  13384. /**
  13385. * Computes the world matrix
  13386. * @param force Specifies if the world matrix should be computed by force
  13387. * @returns A world matrix
  13388. */
  13389. computeWorldMatrix(force: boolean): Matrix;
  13390. /**
  13391. * Gets the world matrix
  13392. * @returns A world matrix
  13393. */
  13394. getWorldMatrix?(): Matrix;
  13395. /**
  13396. * Gets the child meshes
  13397. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13398. * @returns An array of abstract meshes
  13399. */
  13400. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13401. /**
  13402. * Gets the vertex data
  13403. * @param kind The type of vertex data
  13404. * @returns A nullable array of numbers, or a float32 array
  13405. */
  13406. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13407. /**
  13408. * Gets the indices from the mesh
  13409. * @returns A nullable array of index arrays
  13410. */
  13411. getIndices?(): Nullable<IndicesArray>;
  13412. /**
  13413. * Gets the scene from the mesh
  13414. * @returns the indices array or null
  13415. */
  13416. getScene?(): Scene;
  13417. /**
  13418. * Gets the absolute position from the mesh
  13419. * @returns the absolute position
  13420. */
  13421. getAbsolutePosition(): Vector3;
  13422. /**
  13423. * Gets the absolute pivot point from the mesh
  13424. * @returns the absolute pivot point
  13425. */
  13426. getAbsolutePivotPoint(): Vector3;
  13427. /**
  13428. * Rotates the mesh
  13429. * @param axis The axis of rotation
  13430. * @param amount The amount of rotation
  13431. * @param space The space of the rotation
  13432. * @returns The rotation transform node
  13433. */
  13434. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13435. /**
  13436. * Translates the mesh
  13437. * @param axis The axis of translation
  13438. * @param distance The distance of translation
  13439. * @param space The space of the translation
  13440. * @returns The transform node
  13441. */
  13442. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13443. /**
  13444. * Sets the absolute position of the mesh
  13445. * @param absolutePosition The absolute position of the mesh
  13446. * @returns The transform node
  13447. */
  13448. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13449. /**
  13450. * Gets the class name of the mesh
  13451. * @returns The class name
  13452. */
  13453. getClassName(): string;
  13454. }
  13455. /**
  13456. * Represents a physics imposter
  13457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13458. */
  13459. export class PhysicsImpostor {
  13460. /**
  13461. * The physics-enabled object used as the physics imposter
  13462. */
  13463. object: IPhysicsEnabledObject;
  13464. /**
  13465. * The type of the physics imposter
  13466. */
  13467. type: number;
  13468. private _options;
  13469. private _scene?;
  13470. /**
  13471. * The default object size of the imposter
  13472. */
  13473. static DEFAULT_OBJECT_SIZE: Vector3;
  13474. /**
  13475. * The identity quaternion of the imposter
  13476. */
  13477. static IDENTITY_QUATERNION: Quaternion;
  13478. /** @hidden */
  13479. _pluginData: any;
  13480. private _physicsEngine;
  13481. private _physicsBody;
  13482. private _bodyUpdateRequired;
  13483. private _onBeforePhysicsStepCallbacks;
  13484. private _onAfterPhysicsStepCallbacks;
  13485. /** @hidden */
  13486. _onPhysicsCollideCallbacks: Array<{
  13487. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13488. otherImpostors: Array<PhysicsImpostor>;
  13489. }>;
  13490. private _deltaPosition;
  13491. private _deltaRotation;
  13492. private _deltaRotationConjugated;
  13493. /** @hidden */
  13494. _isFromLine: boolean;
  13495. private _parent;
  13496. private _isDisposed;
  13497. private static _tmpVecs;
  13498. private static _tmpQuat;
  13499. /**
  13500. * Specifies if the physics imposter is disposed
  13501. */
  13502. readonly isDisposed: boolean;
  13503. /**
  13504. * Gets the mass of the physics imposter
  13505. */
  13506. mass: number;
  13507. /**
  13508. * Gets the coefficient of friction
  13509. */
  13510. /**
  13511. * Sets the coefficient of friction
  13512. */
  13513. friction: number;
  13514. /**
  13515. * Gets the coefficient of restitution
  13516. */
  13517. /**
  13518. * Sets the coefficient of restitution
  13519. */
  13520. restitution: number;
  13521. /**
  13522. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13523. */
  13524. /**
  13525. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13526. */
  13527. pressure: number;
  13528. /**
  13529. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13530. */
  13531. /**
  13532. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13533. */
  13534. stiffness: number;
  13535. /**
  13536. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13537. */
  13538. /**
  13539. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13540. */
  13541. velocityIterations: number;
  13542. /**
  13543. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13544. */
  13545. /**
  13546. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13547. */
  13548. positionIterations: number;
  13549. /**
  13550. * The unique id of the physics imposter
  13551. * set by the physics engine when adding this impostor to the array
  13552. */
  13553. uniqueId: number;
  13554. /**
  13555. * @hidden
  13556. */
  13557. soft: boolean;
  13558. /**
  13559. * @hidden
  13560. */
  13561. segments: number;
  13562. private _joints;
  13563. /**
  13564. * Initializes the physics imposter
  13565. * @param object The physics-enabled object used as the physics imposter
  13566. * @param type The type of the physics imposter
  13567. * @param _options The options for the physics imposter
  13568. * @param _scene The Babylon scene
  13569. */
  13570. constructor(
  13571. /**
  13572. * The physics-enabled object used as the physics imposter
  13573. */
  13574. object: IPhysicsEnabledObject,
  13575. /**
  13576. * The type of the physics imposter
  13577. */
  13578. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13579. /**
  13580. * This function will completly initialize this impostor.
  13581. * It will create a new body - but only if this mesh has no parent.
  13582. * If it has, this impostor will not be used other than to define the impostor
  13583. * of the child mesh.
  13584. * @hidden
  13585. */
  13586. _init(): void;
  13587. private _getPhysicsParent;
  13588. /**
  13589. * Should a new body be generated.
  13590. * @returns boolean specifying if body initialization is required
  13591. */
  13592. isBodyInitRequired(): boolean;
  13593. /**
  13594. * Sets the updated scaling
  13595. * @param updated Specifies if the scaling is updated
  13596. */
  13597. setScalingUpdated(): void;
  13598. /**
  13599. * Force a regeneration of this or the parent's impostor's body.
  13600. * Use under cautious - This will remove all joints already implemented.
  13601. */
  13602. forceUpdate(): void;
  13603. /**
  13604. * Gets the body that holds this impostor. Either its own, or its parent.
  13605. */
  13606. /**
  13607. * Set the physics body. Used mainly by the physics engine/plugin
  13608. */
  13609. physicsBody: any;
  13610. /**
  13611. * Get the parent of the physics imposter
  13612. * @returns Physics imposter or null
  13613. */
  13614. /**
  13615. * Sets the parent of the physics imposter
  13616. */
  13617. parent: Nullable<PhysicsImpostor>;
  13618. /**
  13619. * Resets the update flags
  13620. */
  13621. resetUpdateFlags(): void;
  13622. /**
  13623. * Gets the object extend size
  13624. * @returns the object extend size
  13625. */
  13626. getObjectExtendSize(): Vector3;
  13627. /**
  13628. * Gets the object center
  13629. * @returns The object center
  13630. */
  13631. getObjectCenter(): Vector3;
  13632. /**
  13633. * Get a specific parametes from the options parameter
  13634. * @param paramName The object parameter name
  13635. * @returns The object parameter
  13636. */
  13637. getParam(paramName: string): any;
  13638. /**
  13639. * Sets a specific parameter in the options given to the physics plugin
  13640. * @param paramName The parameter name
  13641. * @param value The value of the parameter
  13642. */
  13643. setParam(paramName: string, value: number): void;
  13644. /**
  13645. * Specifically change the body's mass option. Won't recreate the physics body object
  13646. * @param mass The mass of the physics imposter
  13647. */
  13648. setMass(mass: number): void;
  13649. /**
  13650. * Gets the linear velocity
  13651. * @returns linear velocity or null
  13652. */
  13653. getLinearVelocity(): Nullable<Vector3>;
  13654. /**
  13655. * Sets the linear velocity
  13656. * @param velocity linear velocity or null
  13657. */
  13658. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13659. /**
  13660. * Gets the angular velocity
  13661. * @returns angular velocity or null
  13662. */
  13663. getAngularVelocity(): Nullable<Vector3>;
  13664. /**
  13665. * Sets the angular velocity
  13666. * @param velocity The velocity or null
  13667. */
  13668. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13669. /**
  13670. * Execute a function with the physics plugin native code
  13671. * Provide a function the will have two variables - the world object and the physics body object
  13672. * @param func The function to execute with the physics plugin native code
  13673. */
  13674. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13675. /**
  13676. * Register a function that will be executed before the physics world is stepping forward
  13677. * @param func The function to execute before the physics world is stepped forward
  13678. */
  13679. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13680. /**
  13681. * Unregister a function that will be executed before the physics world is stepping forward
  13682. * @param func The function to execute before the physics world is stepped forward
  13683. */
  13684. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13685. /**
  13686. * Register a function that will be executed after the physics step
  13687. * @param func The function to execute after physics step
  13688. */
  13689. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13690. /**
  13691. * Unregisters a function that will be executed after the physics step
  13692. * @param func The function to execute after physics step
  13693. */
  13694. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13695. /**
  13696. * register a function that will be executed when this impostor collides against a different body
  13697. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13698. * @param func Callback that is executed on collision
  13699. */
  13700. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13701. /**
  13702. * Unregisters the physics imposter on contact
  13703. * @param collideAgainst The physics object to collide against
  13704. * @param func Callback to execute on collision
  13705. */
  13706. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13707. private _tmpQuat;
  13708. private _tmpQuat2;
  13709. /**
  13710. * Get the parent rotation
  13711. * @returns The parent rotation
  13712. */
  13713. getParentsRotation(): Quaternion;
  13714. /**
  13715. * this function is executed by the physics engine.
  13716. */
  13717. beforeStep: () => void;
  13718. /**
  13719. * this function is executed by the physics engine
  13720. */
  13721. afterStep: () => void;
  13722. /**
  13723. * Legacy collision detection event support
  13724. */
  13725. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13726. /**
  13727. * event and body object due to cannon's event-based architecture.
  13728. */
  13729. onCollide: (e: {
  13730. body: any;
  13731. }) => void;
  13732. /**
  13733. * Apply a force
  13734. * @param force The force to apply
  13735. * @param contactPoint The contact point for the force
  13736. * @returns The physics imposter
  13737. */
  13738. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13739. /**
  13740. * Apply an impulse
  13741. * @param force The impulse force
  13742. * @param contactPoint The contact point for the impulse force
  13743. * @returns The physics imposter
  13744. */
  13745. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13746. /**
  13747. * A help function to create a joint
  13748. * @param otherImpostor A physics imposter used to create a joint
  13749. * @param jointType The type of joint
  13750. * @param jointData The data for the joint
  13751. * @returns The physics imposter
  13752. */
  13753. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13754. /**
  13755. * Add a joint to this impostor with a different impostor
  13756. * @param otherImpostor A physics imposter used to add a joint
  13757. * @param joint The joint to add
  13758. * @returns The physics imposter
  13759. */
  13760. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13761. /**
  13762. * Add an anchor to a cloth impostor
  13763. * @param otherImpostor rigid impostor to anchor to
  13764. * @param width ratio across width from 0 to 1
  13765. * @param height ratio up height from 0 to 1
  13766. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13767. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13768. * @returns impostor the soft imposter
  13769. */
  13770. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13771. /**
  13772. * Add a hook to a rope impostor
  13773. * @param otherImpostor rigid impostor to anchor to
  13774. * @param length ratio across rope from 0 to 1
  13775. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13776. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13777. * @returns impostor the rope imposter
  13778. */
  13779. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13780. /**
  13781. * Will keep this body still, in a sleep mode.
  13782. * @returns the physics imposter
  13783. */
  13784. sleep(): PhysicsImpostor;
  13785. /**
  13786. * Wake the body up.
  13787. * @returns The physics imposter
  13788. */
  13789. wakeUp(): PhysicsImpostor;
  13790. /**
  13791. * Clones the physics imposter
  13792. * @param newObject The physics imposter clones to this physics-enabled object
  13793. * @returns A nullable physics imposter
  13794. */
  13795. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13796. /**
  13797. * Disposes the physics imposter
  13798. */
  13799. dispose(): void;
  13800. /**
  13801. * Sets the delta position
  13802. * @param position The delta position amount
  13803. */
  13804. setDeltaPosition(position: Vector3): void;
  13805. /**
  13806. * Sets the delta rotation
  13807. * @param rotation The delta rotation amount
  13808. */
  13809. setDeltaRotation(rotation: Quaternion): void;
  13810. /**
  13811. * Gets the box size of the physics imposter and stores the result in the input parameter
  13812. * @param result Stores the box size
  13813. * @returns The physics imposter
  13814. */
  13815. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13816. /**
  13817. * Gets the radius of the physics imposter
  13818. * @returns Radius of the physics imposter
  13819. */
  13820. getRadius(): number;
  13821. /**
  13822. * Sync a bone with this impostor
  13823. * @param bone The bone to sync to the impostor.
  13824. * @param boneMesh The mesh that the bone is influencing.
  13825. * @param jointPivot The pivot of the joint / bone in local space.
  13826. * @param distToJoint Optional distance from the impostor to the joint.
  13827. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13828. */
  13829. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13830. /**
  13831. * Sync impostor to a bone
  13832. * @param bone The bone that the impostor will be synced to.
  13833. * @param boneMesh The mesh that the bone is influencing.
  13834. * @param jointPivot The pivot of the joint / bone in local space.
  13835. * @param distToJoint Optional distance from the impostor to the joint.
  13836. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13837. * @param boneAxis Optional vector3 axis the bone is aligned with
  13838. */
  13839. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13840. /**
  13841. * No-Imposter type
  13842. */
  13843. static NoImpostor: number;
  13844. /**
  13845. * Sphere-Imposter type
  13846. */
  13847. static SphereImpostor: number;
  13848. /**
  13849. * Box-Imposter type
  13850. */
  13851. static BoxImpostor: number;
  13852. /**
  13853. * Plane-Imposter type
  13854. */
  13855. static PlaneImpostor: number;
  13856. /**
  13857. * Mesh-imposter type
  13858. */
  13859. static MeshImpostor: number;
  13860. /**
  13861. * Capsule-Impostor type (Ammo.js plugin only)
  13862. */
  13863. static CapsuleImpostor: number;
  13864. /**
  13865. * Cylinder-Imposter type
  13866. */
  13867. static CylinderImpostor: number;
  13868. /**
  13869. * Particle-Imposter type
  13870. */
  13871. static ParticleImpostor: number;
  13872. /**
  13873. * Heightmap-Imposter type
  13874. */
  13875. static HeightmapImpostor: number;
  13876. /**
  13877. * ConvexHull-Impostor type (Ammo.js plugin only)
  13878. */
  13879. static ConvexHullImpostor: number;
  13880. /**
  13881. * Rope-Imposter type
  13882. */
  13883. static RopeImpostor: number;
  13884. /**
  13885. * Cloth-Imposter type
  13886. */
  13887. static ClothImpostor: number;
  13888. /**
  13889. * Softbody-Imposter type
  13890. */
  13891. static SoftbodyImpostor: number;
  13892. }
  13893. }
  13894. declare module BABYLON {
  13895. /**
  13896. * @hidden
  13897. **/
  13898. export class _CreationDataStorage {
  13899. closePath?: boolean;
  13900. closeArray?: boolean;
  13901. idx: number[];
  13902. dashSize: number;
  13903. gapSize: number;
  13904. path3D: Path3D;
  13905. pathArray: Vector3[][];
  13906. arc: number;
  13907. radius: number;
  13908. cap: number;
  13909. tessellation: number;
  13910. }
  13911. /**
  13912. * @hidden
  13913. **/
  13914. class _InstanceDataStorage {
  13915. visibleInstances: any;
  13916. batchCache: _InstancesBatch;
  13917. instancesBufferSize: number;
  13918. instancesBuffer: Nullable<Buffer>;
  13919. instancesData: Float32Array;
  13920. overridenInstanceCount: number;
  13921. isFrozen: boolean;
  13922. previousBatch: Nullable<_InstancesBatch>;
  13923. hardwareInstancedRendering: boolean;
  13924. sideOrientation: number;
  13925. }
  13926. /**
  13927. * @hidden
  13928. **/
  13929. export class _InstancesBatch {
  13930. mustReturn: boolean;
  13931. visibleInstances: Nullable<InstancedMesh[]>[];
  13932. renderSelf: boolean[];
  13933. hardwareInstancedRendering: boolean[];
  13934. }
  13935. /**
  13936. * Class used to represent renderable models
  13937. */
  13938. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13939. /**
  13940. * Mesh side orientation : usually the external or front surface
  13941. */
  13942. static readonly FRONTSIDE: number;
  13943. /**
  13944. * Mesh side orientation : usually the internal or back surface
  13945. */
  13946. static readonly BACKSIDE: number;
  13947. /**
  13948. * Mesh side orientation : both internal and external or front and back surfaces
  13949. */
  13950. static readonly DOUBLESIDE: number;
  13951. /**
  13952. * Mesh side orientation : by default, `FRONTSIDE`
  13953. */
  13954. static readonly DEFAULTSIDE: number;
  13955. /**
  13956. * Mesh cap setting : no cap
  13957. */
  13958. static readonly NO_CAP: number;
  13959. /**
  13960. * Mesh cap setting : one cap at the beginning of the mesh
  13961. */
  13962. static readonly CAP_START: number;
  13963. /**
  13964. * Mesh cap setting : one cap at the end of the mesh
  13965. */
  13966. static readonly CAP_END: number;
  13967. /**
  13968. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13969. */
  13970. static readonly CAP_ALL: number;
  13971. /**
  13972. * Mesh pattern setting : no flip or rotate
  13973. */
  13974. static readonly NO_FLIP: number;
  13975. /**
  13976. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13977. */
  13978. static readonly FLIP_TILE: number;
  13979. /**
  13980. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13981. */
  13982. static readonly ROTATE_TILE: number;
  13983. /**
  13984. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13985. */
  13986. static readonly FLIP_ROW: number;
  13987. /**
  13988. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13989. */
  13990. static readonly ROTATE_ROW: number;
  13991. /**
  13992. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13993. */
  13994. static readonly FLIP_N_ROTATE_TILE: number;
  13995. /**
  13996. * Mesh pattern setting : rotate pattern and rotate
  13997. */
  13998. static readonly FLIP_N_ROTATE_ROW: number;
  13999. /**
  14000. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14001. */
  14002. static readonly CENTER: number;
  14003. /**
  14004. * Mesh tile positioning : part tiles on left
  14005. */
  14006. static readonly LEFT: number;
  14007. /**
  14008. * Mesh tile positioning : part tiles on right
  14009. */
  14010. static readonly RIGHT: number;
  14011. /**
  14012. * Mesh tile positioning : part tiles on top
  14013. */
  14014. static readonly TOP: number;
  14015. /**
  14016. * Mesh tile positioning : part tiles on bottom
  14017. */
  14018. static readonly BOTTOM: number;
  14019. /**
  14020. * Gets the default side orientation.
  14021. * @param orientation the orientation to value to attempt to get
  14022. * @returns the default orientation
  14023. * @hidden
  14024. */
  14025. static _GetDefaultSideOrientation(orientation?: number): number;
  14026. private _internalMeshDataInfo;
  14027. /**
  14028. * An event triggered before rendering the mesh
  14029. */
  14030. readonly onBeforeRenderObservable: Observable<Mesh>;
  14031. /**
  14032. * An event triggered before binding the mesh
  14033. */
  14034. readonly onBeforeBindObservable: Observable<Mesh>;
  14035. /**
  14036. * An event triggered after rendering the mesh
  14037. */
  14038. readonly onAfterRenderObservable: Observable<Mesh>;
  14039. /**
  14040. * An event triggered before drawing the mesh
  14041. */
  14042. readonly onBeforeDrawObservable: Observable<Mesh>;
  14043. private _onBeforeDrawObserver;
  14044. /**
  14045. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14046. */
  14047. onBeforeDraw: () => void;
  14048. /**
  14049. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14050. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14051. */
  14052. delayLoadState: number;
  14053. /**
  14054. * Gets the list of instances created from this mesh
  14055. * it is not supposed to be modified manually.
  14056. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14057. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14058. */
  14059. instances: InstancedMesh[];
  14060. /**
  14061. * Gets the file containing delay loading data for this mesh
  14062. */
  14063. delayLoadingFile: string;
  14064. /** @hidden */
  14065. _binaryInfo: any;
  14066. /**
  14067. * User defined function used to change how LOD level selection is done
  14068. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14069. */
  14070. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14071. /**
  14072. * Gets or sets the morph target manager
  14073. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14074. */
  14075. morphTargetManager: Nullable<MorphTargetManager>;
  14076. /** @hidden */
  14077. _creationDataStorage: Nullable<_CreationDataStorage>;
  14078. /** @hidden */
  14079. _geometry: Nullable<Geometry>;
  14080. /** @hidden */
  14081. _delayInfo: Array<string>;
  14082. /** @hidden */
  14083. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14084. /** @hidden */
  14085. _instanceDataStorage: _InstanceDataStorage;
  14086. private _effectiveMaterial;
  14087. /** @hidden */
  14088. _shouldGenerateFlatShading: boolean;
  14089. /** @hidden */
  14090. _originalBuilderSideOrientation: number;
  14091. /**
  14092. * Use this property to change the original side orientation defined at construction time
  14093. */
  14094. overrideMaterialSideOrientation: Nullable<number>;
  14095. /**
  14096. * Gets the source mesh (the one used to clone this one from)
  14097. */
  14098. readonly source: Nullable<Mesh>;
  14099. /**
  14100. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14101. */
  14102. isUnIndexed: boolean;
  14103. /**
  14104. * @constructor
  14105. * @param name The value used by scene.getMeshByName() to do a lookup.
  14106. * @param scene The scene to add this mesh to.
  14107. * @param parent The parent of this mesh, if it has one
  14108. * @param source An optional Mesh from which geometry is shared, cloned.
  14109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14110. * When false, achieved by calling a clone(), also passing False.
  14111. * This will make creation of children, recursive.
  14112. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14113. */
  14114. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14115. /**
  14116. * Gets the class name
  14117. * @returns the string "Mesh".
  14118. */
  14119. getClassName(): string;
  14120. /** @hidden */
  14121. readonly _isMesh: boolean;
  14122. /**
  14123. * Returns a description of this mesh
  14124. * @param fullDetails define if full details about this mesh must be used
  14125. * @returns a descriptive string representing this mesh
  14126. */
  14127. toString(fullDetails?: boolean): string;
  14128. /** @hidden */
  14129. _unBindEffect(): void;
  14130. /**
  14131. * Gets a boolean indicating if this mesh has LOD
  14132. */
  14133. readonly hasLODLevels: boolean;
  14134. /**
  14135. * Gets the list of MeshLODLevel associated with the current mesh
  14136. * @returns an array of MeshLODLevel
  14137. */
  14138. getLODLevels(): MeshLODLevel[];
  14139. private _sortLODLevels;
  14140. /**
  14141. * Add a mesh as LOD level triggered at the given distance.
  14142. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14143. * @param distance The distance from the center of the object to show this level
  14144. * @param mesh The mesh to be added as LOD level (can be null)
  14145. * @return This mesh (for chaining)
  14146. */
  14147. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14148. /**
  14149. * Returns the LOD level mesh at the passed distance or null if not found.
  14150. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14151. * @param distance The distance from the center of the object to show this level
  14152. * @returns a Mesh or `null`
  14153. */
  14154. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14155. /**
  14156. * Remove a mesh from the LOD array
  14157. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14158. * @param mesh defines the mesh to be removed
  14159. * @return This mesh (for chaining)
  14160. */
  14161. removeLODLevel(mesh: Mesh): Mesh;
  14162. /**
  14163. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14165. * @param camera defines the camera to use to compute distance
  14166. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14167. * @return This mesh (for chaining)
  14168. */
  14169. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14170. /**
  14171. * Gets the mesh internal Geometry object
  14172. */
  14173. readonly geometry: Nullable<Geometry>;
  14174. /**
  14175. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14176. * @returns the total number of vertices
  14177. */
  14178. getTotalVertices(): number;
  14179. /**
  14180. * Returns the content of an associated vertex buffer
  14181. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14182. * - VertexBuffer.PositionKind
  14183. * - VertexBuffer.UVKind
  14184. * - VertexBuffer.UV2Kind
  14185. * - VertexBuffer.UV3Kind
  14186. * - VertexBuffer.UV4Kind
  14187. * - VertexBuffer.UV5Kind
  14188. * - VertexBuffer.UV6Kind
  14189. * - VertexBuffer.ColorKind
  14190. * - VertexBuffer.MatricesIndicesKind
  14191. * - VertexBuffer.MatricesIndicesExtraKind
  14192. * - VertexBuffer.MatricesWeightsKind
  14193. * - VertexBuffer.MatricesWeightsExtraKind
  14194. * @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
  14195. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14196. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14197. */
  14198. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14199. /**
  14200. * Returns the mesh VertexBuffer object from the requested `kind`
  14201. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14202. * - VertexBuffer.PositionKind
  14203. * - VertexBuffer.NormalKind
  14204. * - VertexBuffer.UVKind
  14205. * - VertexBuffer.UV2Kind
  14206. * - VertexBuffer.UV3Kind
  14207. * - VertexBuffer.UV4Kind
  14208. * - VertexBuffer.UV5Kind
  14209. * - VertexBuffer.UV6Kind
  14210. * - VertexBuffer.ColorKind
  14211. * - VertexBuffer.MatricesIndicesKind
  14212. * - VertexBuffer.MatricesIndicesExtraKind
  14213. * - VertexBuffer.MatricesWeightsKind
  14214. * - VertexBuffer.MatricesWeightsExtraKind
  14215. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14216. */
  14217. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14218. /**
  14219. * Tests if a specific vertex buffer is associated with this mesh
  14220. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14221. * - VertexBuffer.PositionKind
  14222. * - VertexBuffer.NormalKind
  14223. * - VertexBuffer.UVKind
  14224. * - VertexBuffer.UV2Kind
  14225. * - VertexBuffer.UV3Kind
  14226. * - VertexBuffer.UV4Kind
  14227. * - VertexBuffer.UV5Kind
  14228. * - VertexBuffer.UV6Kind
  14229. * - VertexBuffer.ColorKind
  14230. * - VertexBuffer.MatricesIndicesKind
  14231. * - VertexBuffer.MatricesIndicesExtraKind
  14232. * - VertexBuffer.MatricesWeightsKind
  14233. * - VertexBuffer.MatricesWeightsExtraKind
  14234. * @returns a boolean
  14235. */
  14236. isVerticesDataPresent(kind: string): boolean;
  14237. /**
  14238. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14240. * - VertexBuffer.PositionKind
  14241. * - VertexBuffer.UVKind
  14242. * - VertexBuffer.UV2Kind
  14243. * - VertexBuffer.UV3Kind
  14244. * - VertexBuffer.UV4Kind
  14245. * - VertexBuffer.UV5Kind
  14246. * - VertexBuffer.UV6Kind
  14247. * - VertexBuffer.ColorKind
  14248. * - VertexBuffer.MatricesIndicesKind
  14249. * - VertexBuffer.MatricesIndicesExtraKind
  14250. * - VertexBuffer.MatricesWeightsKind
  14251. * - VertexBuffer.MatricesWeightsExtraKind
  14252. * @returns a boolean
  14253. */
  14254. isVertexBufferUpdatable(kind: string): boolean;
  14255. /**
  14256. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14257. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14258. * - VertexBuffer.PositionKind
  14259. * - VertexBuffer.NormalKind
  14260. * - VertexBuffer.UVKind
  14261. * - VertexBuffer.UV2Kind
  14262. * - VertexBuffer.UV3Kind
  14263. * - VertexBuffer.UV4Kind
  14264. * - VertexBuffer.UV5Kind
  14265. * - VertexBuffer.UV6Kind
  14266. * - VertexBuffer.ColorKind
  14267. * - VertexBuffer.MatricesIndicesKind
  14268. * - VertexBuffer.MatricesIndicesExtraKind
  14269. * - VertexBuffer.MatricesWeightsKind
  14270. * - VertexBuffer.MatricesWeightsExtraKind
  14271. * @returns an array of strings
  14272. */
  14273. getVerticesDataKinds(): string[];
  14274. /**
  14275. * Returns a positive integer : the total number of indices in this mesh geometry.
  14276. * @returns the numner of indices or zero if the mesh has no geometry.
  14277. */
  14278. getTotalIndices(): number;
  14279. /**
  14280. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14281. * @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.
  14282. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14283. * @returns the indices array or an empty array if the mesh has no geometry
  14284. */
  14285. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14286. readonly isBlocked: boolean;
  14287. /**
  14288. * Determine if the current mesh is ready to be rendered
  14289. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14290. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14291. * @returns true if all associated assets are ready (material, textures, shaders)
  14292. */
  14293. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14294. /**
  14295. * 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.
  14296. */
  14297. readonly areNormalsFrozen: boolean;
  14298. /**
  14299. * 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.
  14300. * @returns the current mesh
  14301. */
  14302. freezeNormals(): Mesh;
  14303. /**
  14304. * 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
  14305. * @returns the current mesh
  14306. */
  14307. unfreezeNormals(): Mesh;
  14308. /**
  14309. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14310. */
  14311. overridenInstanceCount: number;
  14312. /** @hidden */
  14313. _preActivate(): Mesh;
  14314. /** @hidden */
  14315. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14316. /** @hidden */
  14317. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14318. /**
  14319. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14320. * This means the mesh underlying bounding box and sphere are recomputed.
  14321. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14322. * @returns the current mesh
  14323. */
  14324. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14325. /** @hidden */
  14326. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14327. /**
  14328. * This function will subdivide the mesh into multiple submeshes
  14329. * @param count defines the expected number of submeshes
  14330. */
  14331. subdivide(count: number): void;
  14332. /**
  14333. * Copy a FloatArray into a specific associated vertex buffer
  14334. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14335. * - VertexBuffer.PositionKind
  14336. * - VertexBuffer.UVKind
  14337. * - VertexBuffer.UV2Kind
  14338. * - VertexBuffer.UV3Kind
  14339. * - VertexBuffer.UV4Kind
  14340. * - VertexBuffer.UV5Kind
  14341. * - VertexBuffer.UV6Kind
  14342. * - VertexBuffer.ColorKind
  14343. * - VertexBuffer.MatricesIndicesKind
  14344. * - VertexBuffer.MatricesIndicesExtraKind
  14345. * - VertexBuffer.MatricesWeightsKind
  14346. * - VertexBuffer.MatricesWeightsExtraKind
  14347. * @param data defines the data source
  14348. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14349. * @param stride defines the data stride size (can be null)
  14350. * @returns the current mesh
  14351. */
  14352. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14353. /**
  14354. * Flags an associated vertex buffer as updatable
  14355. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14356. * - VertexBuffer.PositionKind
  14357. * - VertexBuffer.UVKind
  14358. * - VertexBuffer.UV2Kind
  14359. * - VertexBuffer.UV3Kind
  14360. * - VertexBuffer.UV4Kind
  14361. * - VertexBuffer.UV5Kind
  14362. * - VertexBuffer.UV6Kind
  14363. * - VertexBuffer.ColorKind
  14364. * - VertexBuffer.MatricesIndicesKind
  14365. * - VertexBuffer.MatricesIndicesExtraKind
  14366. * - VertexBuffer.MatricesWeightsKind
  14367. * - VertexBuffer.MatricesWeightsExtraKind
  14368. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14369. */
  14370. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14371. /**
  14372. * Sets the mesh global Vertex Buffer
  14373. * @param buffer defines the buffer to use
  14374. * @returns the current mesh
  14375. */
  14376. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14377. /**
  14378. * Update a specific associated vertex buffer
  14379. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14380. * - VertexBuffer.PositionKind
  14381. * - VertexBuffer.UVKind
  14382. * - VertexBuffer.UV2Kind
  14383. * - VertexBuffer.UV3Kind
  14384. * - VertexBuffer.UV4Kind
  14385. * - VertexBuffer.UV5Kind
  14386. * - VertexBuffer.UV6Kind
  14387. * - VertexBuffer.ColorKind
  14388. * - VertexBuffer.MatricesIndicesKind
  14389. * - VertexBuffer.MatricesIndicesExtraKind
  14390. * - VertexBuffer.MatricesWeightsKind
  14391. * - VertexBuffer.MatricesWeightsExtraKind
  14392. * @param data defines the data source
  14393. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14394. * @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)
  14395. * @returns the current mesh
  14396. */
  14397. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14398. /**
  14399. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14400. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14401. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14402. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14403. * @returns the current mesh
  14404. */
  14405. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14406. /**
  14407. * Creates a un-shared specific occurence of the geometry for the mesh.
  14408. * @returns the current mesh
  14409. */
  14410. makeGeometryUnique(): Mesh;
  14411. /**
  14412. * Set the index buffer of this mesh
  14413. * @param indices defines the source data
  14414. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14415. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14416. * @returns the current mesh
  14417. */
  14418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14419. /**
  14420. * Update the current index buffer
  14421. * @param indices defines the source data
  14422. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14423. * @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)
  14424. * @returns the current mesh
  14425. */
  14426. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14427. /**
  14428. * Invert the geometry to move from a right handed system to a left handed one.
  14429. * @returns the current mesh
  14430. */
  14431. toLeftHanded(): Mesh;
  14432. /** @hidden */
  14433. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14434. /** @hidden */
  14435. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14436. /**
  14437. * Registers for this mesh a javascript function called just before the rendering process
  14438. * @param func defines the function to call before rendering this mesh
  14439. * @returns the current mesh
  14440. */
  14441. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14442. /**
  14443. * Disposes a previously registered javascript function called before the rendering
  14444. * @param func defines the function to remove
  14445. * @returns the current mesh
  14446. */
  14447. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14448. /**
  14449. * Registers for this mesh a javascript function called just after the rendering is complete
  14450. * @param func defines the function to call after rendering this mesh
  14451. * @returns the current mesh
  14452. */
  14453. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14454. /**
  14455. * Disposes a previously registered javascript function called after the rendering.
  14456. * @param func defines the function to remove
  14457. * @returns the current mesh
  14458. */
  14459. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14460. /** @hidden */
  14461. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14462. /** @hidden */
  14463. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14464. /** @hidden */
  14465. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14466. /** @hidden */
  14467. _rebuild(): void;
  14468. /** @hidden */
  14469. _freeze(): void;
  14470. /** @hidden */
  14471. _unFreeze(): void;
  14472. /**
  14473. * 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
  14474. * @param subMesh defines the subMesh to render
  14475. * @param enableAlphaMode defines if alpha mode can be changed
  14476. * @returns the current mesh
  14477. */
  14478. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14479. private _onBeforeDraw;
  14480. /**
  14481. * Renormalize the mesh and patch it up if there are no weights
  14482. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14483. * However in the case of zero weights then we set just a single influence to 1.
  14484. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14485. */
  14486. cleanMatrixWeights(): void;
  14487. private normalizeSkinFourWeights;
  14488. private normalizeSkinWeightsAndExtra;
  14489. /**
  14490. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14491. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14492. * the user know there was an issue with importing the mesh
  14493. * @returns a validation object with skinned, valid and report string
  14494. */
  14495. validateSkinning(): {
  14496. skinned: boolean;
  14497. valid: boolean;
  14498. report: string;
  14499. };
  14500. /** @hidden */
  14501. _checkDelayState(): Mesh;
  14502. private _queueLoad;
  14503. /**
  14504. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14505. * A mesh is in the frustum if its bounding box intersects the frustum
  14506. * @param frustumPlanes defines the frustum to test
  14507. * @returns true if the mesh is in the frustum planes
  14508. */
  14509. isInFrustum(frustumPlanes: Plane[]): boolean;
  14510. /**
  14511. * Sets the mesh material by the material or multiMaterial `id` property
  14512. * @param id is a string identifying the material or the multiMaterial
  14513. * @returns the current mesh
  14514. */
  14515. setMaterialByID(id: string): Mesh;
  14516. /**
  14517. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14518. * @returns an array of IAnimatable
  14519. */
  14520. getAnimatables(): IAnimatable[];
  14521. /**
  14522. * Modifies the mesh geometry according to the passed transformation matrix.
  14523. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14524. * The mesh normals are modified using the same transformation.
  14525. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14526. * @param transform defines the transform matrix to use
  14527. * @see http://doc.babylonjs.com/resources/baking_transformations
  14528. * @returns the current mesh
  14529. */
  14530. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14531. /**
  14532. * Modifies the mesh geometry according to its own current World Matrix.
  14533. * The mesh World Matrix is then reset.
  14534. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14535. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14536. * @see http://doc.babylonjs.com/resources/baking_transformations
  14537. * @returns the current mesh
  14538. */
  14539. bakeCurrentTransformIntoVertices(): Mesh;
  14540. /** @hidden */
  14541. readonly _positions: Nullable<Vector3[]>;
  14542. /** @hidden */
  14543. _resetPointsArrayCache(): Mesh;
  14544. /** @hidden */
  14545. _generatePointsArray(): boolean;
  14546. /**
  14547. * Returns a new Mesh object generated from the current mesh properties.
  14548. * This method must not get confused with createInstance()
  14549. * @param name is a string, the name given to the new mesh
  14550. * @param newParent can be any Node object (default `null`)
  14551. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14552. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14553. * @returns a new mesh
  14554. */
  14555. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14556. /**
  14557. * Releases resources associated with this mesh.
  14558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14560. */
  14561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14562. /**
  14563. * Modifies the mesh geometry according to a displacement map.
  14564. * 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.
  14565. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14566. * @param url is a string, the URL from the image file is to be downloaded.
  14567. * @param minHeight is the lower limit of the displacement.
  14568. * @param maxHeight is the upper limit of the displacement.
  14569. * @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.
  14570. * @param uvOffset is an optional vector2 used to offset UV.
  14571. * @param uvScale is an optional vector2 used to scale UV.
  14572. * @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.
  14573. * @returns the Mesh.
  14574. */
  14575. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14576. /**
  14577. * Modifies the mesh geometry according to a displacementMap buffer.
  14578. * 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.
  14579. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14580. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14581. * @param heightMapWidth is the width of the buffer image.
  14582. * @param heightMapHeight is the height of the buffer image.
  14583. * @param minHeight is the lower limit of the displacement.
  14584. * @param maxHeight is the upper limit of the displacement.
  14585. * @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.
  14586. * @param uvOffset is an optional vector2 used to offset UV.
  14587. * @param uvScale is an optional vector2 used to scale UV.
  14588. * @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.
  14589. * @returns the Mesh.
  14590. */
  14591. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14592. /**
  14593. * Modify the mesh to get a flat shading rendering.
  14594. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14595. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14596. * @returns current mesh
  14597. */
  14598. convertToFlatShadedMesh(): Mesh;
  14599. /**
  14600. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14601. * In other words, more vertices, no more indices and a single bigger VBO.
  14602. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14603. * @returns current mesh
  14604. */
  14605. convertToUnIndexedMesh(): Mesh;
  14606. /**
  14607. * Inverses facet orientations.
  14608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14609. * @param flipNormals will also inverts the normals
  14610. * @returns current mesh
  14611. */
  14612. flipFaces(flipNormals?: boolean): Mesh;
  14613. /**
  14614. * Increase the number of facets and hence vertices in a mesh
  14615. * Vertex normals are interpolated from existing vertex normals
  14616. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14617. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14618. */
  14619. increaseVertices(numberPerEdge: number): void;
  14620. /**
  14621. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14622. * This will undo any application of covertToFlatShadedMesh
  14623. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14624. */
  14625. forceSharedVertices(): void;
  14626. /** @hidden */
  14627. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14628. /** @hidden */
  14629. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14630. /**
  14631. * Creates a new InstancedMesh object from the mesh model.
  14632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14633. * @param name defines the name of the new instance
  14634. * @returns a new InstancedMesh
  14635. */
  14636. createInstance(name: string): InstancedMesh;
  14637. /**
  14638. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14639. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14640. * @returns the current mesh
  14641. */
  14642. synchronizeInstances(): Mesh;
  14643. /**
  14644. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14645. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14646. * This should be used together with the simplification to avoid disappearing triangles.
  14647. * @param successCallback an optional success callback to be called after the optimization finished.
  14648. * @returns the current mesh
  14649. */
  14650. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14651. /**
  14652. * Serialize current mesh
  14653. * @param serializationObject defines the object which will receive the serialization data
  14654. */
  14655. serialize(serializationObject: any): void;
  14656. /** @hidden */
  14657. _syncGeometryWithMorphTargetManager(): void;
  14658. /** @hidden */
  14659. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14660. /**
  14661. * Returns a new Mesh object parsed from the source provided.
  14662. * @param parsedMesh is the source
  14663. * @param scene defines the hosting scene
  14664. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14665. * @returns a new Mesh
  14666. */
  14667. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14668. /**
  14669. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14670. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14671. * @param name defines the name of the mesh to create
  14672. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14673. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14674. * @param closePath creates a seam between the first and the last points of each path of the path array
  14675. * @param offset is taken in account only if the `pathArray` is containing a single path
  14676. * @param scene defines the hosting scene
  14677. * @param updatable defines if the mesh must be flagged as updatable
  14678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14679. * @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)
  14680. * @returns a new Mesh
  14681. */
  14682. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14683. /**
  14684. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14685. * @param name defines the name of the mesh to create
  14686. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14687. * @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
  14688. * @param scene defines the hosting scene
  14689. * @param updatable defines if the mesh must be flagged as updatable
  14690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14691. * @returns a new Mesh
  14692. */
  14693. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14694. /**
  14695. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14696. * @param name defines the name of the mesh to create
  14697. * @param size sets the size (float) of each box side (default 1)
  14698. * @param scene defines the hosting scene
  14699. * @param updatable defines if the mesh must be flagged as updatable
  14700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14701. * @returns a new Mesh
  14702. */
  14703. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14704. /**
  14705. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14706. * @param name defines the name of the mesh to create
  14707. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14708. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14709. * @param scene defines the hosting scene
  14710. * @param updatable defines if the mesh must be flagged as updatable
  14711. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14712. * @returns a new Mesh
  14713. */
  14714. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14715. /**
  14716. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14717. * @param name defines the name of the mesh to create
  14718. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14719. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14720. * @param scene defines the hosting scene
  14721. * @returns a new Mesh
  14722. */
  14723. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14724. /**
  14725. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14726. * @param name defines the name of the mesh to create
  14727. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14728. * @param diameterTop set the top cap diameter (floats, default 1)
  14729. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14730. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14731. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14732. * @param scene defines the hosting scene
  14733. * @param updatable defines if the mesh must be flagged as updatable
  14734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14735. * @returns a new Mesh
  14736. */
  14737. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14738. /**
  14739. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14740. * @param name defines the name of the mesh to create
  14741. * @param diameter sets the diameter size (float) of the torus (default 1)
  14742. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14743. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14744. * @param scene defines the hosting scene
  14745. * @param updatable defines if the mesh must be flagged as updatable
  14746. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14747. * @returns a new Mesh
  14748. */
  14749. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14750. /**
  14751. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14752. * @param name defines the name of the mesh to create
  14753. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14754. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14755. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14756. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14757. * @param p the number of windings on X axis (positive integers, default 2)
  14758. * @param q the number of windings on Y axis (positive integers, default 3)
  14759. * @param scene defines the hosting scene
  14760. * @param updatable defines if the mesh must be flagged as updatable
  14761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14762. * @returns a new Mesh
  14763. */
  14764. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14765. /**
  14766. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14767. * @param name defines the name of the mesh to create
  14768. * @param points is an array successive Vector3
  14769. * @param scene defines the hosting scene
  14770. * @param updatable defines if the mesh must be flagged as updatable
  14771. * @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).
  14772. * @returns a new Mesh
  14773. */
  14774. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14775. /**
  14776. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14777. * @param name defines the name of the mesh to create
  14778. * @param points is an array successive Vector3
  14779. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14780. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14781. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14782. * @param scene defines the hosting scene
  14783. * @param updatable defines if the mesh must be flagged as updatable
  14784. * @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)
  14785. * @returns a new Mesh
  14786. */
  14787. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14788. /**
  14789. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14790. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14791. * 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.
  14792. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14793. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14794. * Remember you can only change the shape positions, not their number when updating a polygon.
  14795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14796. * @param name defines the name of the mesh to create
  14797. * @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
  14798. * @param scene defines the hosting scene
  14799. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14800. * @param updatable defines if the mesh must be flagged as updatable
  14801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14802. * @param earcutInjection can be used to inject your own earcut reference
  14803. * @returns a new Mesh
  14804. */
  14805. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14806. /**
  14807. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14808. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14809. * @param name defines the name of the mesh to create
  14810. * @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
  14811. * @param depth defines the height of extrusion
  14812. * @param scene defines the hosting scene
  14813. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14814. * @param updatable defines if the mesh must be flagged as updatable
  14815. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14816. * @param earcutInjection can be used to inject your own earcut reference
  14817. * @returns a new Mesh
  14818. */
  14819. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14820. /**
  14821. * Creates an extruded shape mesh.
  14822. * 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
  14823. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14824. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14825. * @param name defines the name of the mesh to create
  14826. * @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
  14827. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14828. * @param scale is the value to scale the shape
  14829. * @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
  14830. * @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
  14831. * @param scene defines the hosting scene
  14832. * @param updatable defines if the mesh must be flagged as updatable
  14833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14834. * @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)
  14835. * @returns a new Mesh
  14836. */
  14837. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14838. /**
  14839. * Creates an custom extruded shape mesh.
  14840. * The custom extrusion is a parametric shape.
  14841. * It has no predefined shape. Its final shape will depend on the input parameters.
  14842. * Please consider using the same method from the MeshBuilder class instead
  14843. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14844. * @param name defines the name of the mesh to create
  14845. * @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
  14846. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14847. * @param scaleFunction is a custom Javascript function called on each path point
  14848. * @param rotationFunction is a custom Javascript function called on each path point
  14849. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14850. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14851. * @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
  14852. * @param scene defines the hosting scene
  14853. * @param updatable defines if the mesh must be flagged as updatable
  14854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14855. * @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)
  14856. * @returns a new Mesh
  14857. */
  14858. 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;
  14859. /**
  14860. * Creates lathe mesh.
  14861. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14862. * Please consider using the same method from the MeshBuilder class instead
  14863. * @param name defines the name of the mesh to create
  14864. * @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
  14865. * @param radius is the radius value of the lathe
  14866. * @param tessellation is the side number of the lathe.
  14867. * @param scene defines the hosting scene
  14868. * @param updatable defines if the mesh must be flagged as updatable
  14869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14870. * @returns a new Mesh
  14871. */
  14872. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14873. /**
  14874. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14875. * @param name defines the name of the mesh to create
  14876. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14877. * @param scene defines the hosting scene
  14878. * @param updatable defines if the mesh must be flagged as updatable
  14879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14880. * @returns a new Mesh
  14881. */
  14882. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14883. /**
  14884. * Creates a ground mesh.
  14885. * Please consider using the same method from the MeshBuilder class instead
  14886. * @param name defines the name of the mesh to create
  14887. * @param width set the width of the ground
  14888. * @param height set the height of the ground
  14889. * @param subdivisions sets the number of subdivisions per side
  14890. * @param scene defines the hosting scene
  14891. * @param updatable defines if the mesh must be flagged as updatable
  14892. * @returns a new Mesh
  14893. */
  14894. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14895. /**
  14896. * Creates a tiled ground mesh.
  14897. * Please consider using the same method from the MeshBuilder class instead
  14898. * @param name defines the name of the mesh to create
  14899. * @param xmin set the ground minimum X coordinate
  14900. * @param zmin set the ground minimum Y coordinate
  14901. * @param xmax set the ground maximum X coordinate
  14902. * @param zmax set the ground maximum Z coordinate
  14903. * @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
  14904. * @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
  14905. * @param scene defines the hosting scene
  14906. * @param updatable defines if the mesh must be flagged as updatable
  14907. * @returns a new Mesh
  14908. */
  14909. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14910. w: number;
  14911. h: number;
  14912. }, precision: {
  14913. w: number;
  14914. h: number;
  14915. }, scene: Scene, updatable?: boolean): Mesh;
  14916. /**
  14917. * Creates a ground mesh from a height map.
  14918. * Please consider using the same method from the MeshBuilder class instead
  14919. * @see http://doc.babylonjs.com/babylon101/height_map
  14920. * @param name defines the name of the mesh to create
  14921. * @param url sets the URL of the height map image resource
  14922. * @param width set the ground width size
  14923. * @param height set the ground height size
  14924. * @param subdivisions sets the number of subdivision per side
  14925. * @param minHeight is the minimum altitude on the ground
  14926. * @param maxHeight is the maximum altitude on the ground
  14927. * @param scene defines the hosting scene
  14928. * @param updatable defines if the mesh must be flagged as updatable
  14929. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14930. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14931. * @returns a new Mesh
  14932. */
  14933. 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;
  14934. /**
  14935. * Creates a tube mesh.
  14936. * The tube is a parametric shape.
  14937. * It has no predefined shape. Its final shape will depend on the input parameters.
  14938. * Please consider using the same method from the MeshBuilder class instead
  14939. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14940. * @param name defines the name of the mesh to create
  14941. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14942. * @param radius sets the tube radius size
  14943. * @param tessellation is the number of sides on the tubular surface
  14944. * @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
  14945. * @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
  14946. * @param scene defines the hosting scene
  14947. * @param updatable defines if the mesh must be flagged as updatable
  14948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14949. * @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)
  14950. * @returns a new Mesh
  14951. */
  14952. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14953. (i: number, distance: number): number;
  14954. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14955. /**
  14956. * Creates a polyhedron mesh.
  14957. * Please consider using the same method from the MeshBuilder class instead.
  14958. * * 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
  14959. * * The parameter `size` (positive float, default 1) sets the polygon size
  14960. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14961. * * 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`
  14962. * * 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
  14963. * * 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)`)
  14964. * * 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
  14965. * * 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
  14966. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14967. * * 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
  14968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14969. * @param name defines the name of the mesh to create
  14970. * @param options defines the options used to create the mesh
  14971. * @param scene defines the hosting scene
  14972. * @returns a new Mesh
  14973. */
  14974. static CreatePolyhedron(name: string, options: {
  14975. type?: number;
  14976. size?: number;
  14977. sizeX?: number;
  14978. sizeY?: number;
  14979. sizeZ?: number;
  14980. custom?: any;
  14981. faceUV?: Vector4[];
  14982. faceColors?: Color4[];
  14983. updatable?: boolean;
  14984. sideOrientation?: number;
  14985. }, scene: Scene): Mesh;
  14986. /**
  14987. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14988. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14989. * * 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`)
  14990. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14991. * * 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
  14992. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14993. * * 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
  14994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14995. * @param name defines the name of the mesh
  14996. * @param options defines the options used to create the mesh
  14997. * @param scene defines the hosting scene
  14998. * @returns a new Mesh
  14999. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15000. */
  15001. static CreateIcoSphere(name: string, options: {
  15002. radius?: number;
  15003. flat?: boolean;
  15004. subdivisions?: number;
  15005. sideOrientation?: number;
  15006. updatable?: boolean;
  15007. }, scene: Scene): Mesh;
  15008. /**
  15009. * Creates a decal mesh.
  15010. * Please consider using the same method from the MeshBuilder class instead.
  15011. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15012. * @param name defines the name of the mesh
  15013. * @param sourceMesh defines the mesh receiving the decal
  15014. * @param position sets the position of the decal in world coordinates
  15015. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15016. * @param size sets the decal scaling
  15017. * @param angle sets the angle to rotate the decal
  15018. * @returns a new Mesh
  15019. */
  15020. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15021. /**
  15022. * Prepare internal position array for software CPU skinning
  15023. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15024. */
  15025. setPositionsForCPUSkinning(): Float32Array;
  15026. /**
  15027. * Prepare internal normal array for software CPU skinning
  15028. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15029. */
  15030. setNormalsForCPUSkinning(): Float32Array;
  15031. /**
  15032. * Updates the vertex buffer by applying transformation from the bones
  15033. * @param skeleton defines the skeleton to apply to current mesh
  15034. * @returns the current mesh
  15035. */
  15036. applySkeleton(skeleton: Skeleton): Mesh;
  15037. /**
  15038. * 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
  15039. * @param meshes defines the list of meshes to scan
  15040. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15041. */
  15042. static MinMax(meshes: AbstractMesh[]): {
  15043. min: Vector3;
  15044. max: Vector3;
  15045. };
  15046. /**
  15047. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15048. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15049. * @returns a vector3
  15050. */
  15051. static Center(meshesOrMinMaxVector: {
  15052. min: Vector3;
  15053. max: Vector3;
  15054. } | AbstractMesh[]): Vector3;
  15055. /**
  15056. * Merge the array of meshes into a single mesh for performance reasons.
  15057. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15058. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15059. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15060. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15061. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15062. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15063. * @returns a new mesh
  15064. */
  15065. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15066. /** @hidden */
  15067. addInstance(instance: InstancedMesh): void;
  15068. /** @hidden */
  15069. removeInstance(instance: InstancedMesh): void;
  15070. }
  15071. }
  15072. declare module BABYLON {
  15073. /**
  15074. * Interface used to define Action
  15075. */
  15076. export interface IAction {
  15077. /**
  15078. * Trigger for the action
  15079. */
  15080. trigger: number;
  15081. /** Options of the trigger */
  15082. triggerOptions: any;
  15083. /**
  15084. * Gets the trigger parameters
  15085. * @returns the trigger parameters
  15086. */
  15087. getTriggerParameter(): any;
  15088. /**
  15089. * Internal only - executes current action event
  15090. * @hidden
  15091. */
  15092. _executeCurrent(evt?: ActionEvent): void;
  15093. /**
  15094. * Serialize placeholder for child classes
  15095. * @param parent of child
  15096. * @returns the serialized object
  15097. */
  15098. serialize(parent: any): any;
  15099. /**
  15100. * Internal only
  15101. * @hidden
  15102. */
  15103. _prepare(): void;
  15104. /**
  15105. * Internal only - manager for action
  15106. * @hidden
  15107. */
  15108. _actionManager: AbstractActionManager;
  15109. /**
  15110. * Adds action to chain of actions, may be a DoNothingAction
  15111. * @param action defines the next action to execute
  15112. * @returns The action passed in
  15113. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15114. */
  15115. then(action: IAction): IAction;
  15116. }
  15117. /**
  15118. * The action to be carried out following a trigger
  15119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15120. */
  15121. export class Action implements IAction {
  15122. /** the trigger, with or without parameters, for the action */
  15123. triggerOptions: any;
  15124. /**
  15125. * Trigger for the action
  15126. */
  15127. trigger: number;
  15128. /**
  15129. * Internal only - manager for action
  15130. * @hidden
  15131. */
  15132. _actionManager: ActionManager;
  15133. private _nextActiveAction;
  15134. private _child;
  15135. private _condition?;
  15136. private _triggerParameter;
  15137. /**
  15138. * An event triggered prior to action being executed.
  15139. */
  15140. onBeforeExecuteObservable: Observable<Action>;
  15141. /**
  15142. * Creates a new Action
  15143. * @param triggerOptions the trigger, with or without parameters, for the action
  15144. * @param condition an optional determinant of action
  15145. */
  15146. constructor(
  15147. /** the trigger, with or without parameters, for the action */
  15148. triggerOptions: any, condition?: Condition);
  15149. /**
  15150. * Internal only
  15151. * @hidden
  15152. */
  15153. _prepare(): void;
  15154. /**
  15155. * Gets the trigger parameters
  15156. * @returns the trigger parameters
  15157. */
  15158. getTriggerParameter(): any;
  15159. /**
  15160. * Internal only - executes current action event
  15161. * @hidden
  15162. */
  15163. _executeCurrent(evt?: ActionEvent): void;
  15164. /**
  15165. * Execute placeholder for child classes
  15166. * @param evt optional action event
  15167. */
  15168. execute(evt?: ActionEvent): void;
  15169. /**
  15170. * Skips to next active action
  15171. */
  15172. skipToNextActiveAction(): void;
  15173. /**
  15174. * Adds action to chain of actions, may be a DoNothingAction
  15175. * @param action defines the next action to execute
  15176. * @returns The action passed in
  15177. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15178. */
  15179. then(action: Action): Action;
  15180. /**
  15181. * Internal only
  15182. * @hidden
  15183. */
  15184. _getProperty(propertyPath: string): string;
  15185. /**
  15186. * Internal only
  15187. * @hidden
  15188. */
  15189. _getEffectiveTarget(target: any, propertyPath: string): any;
  15190. /**
  15191. * Serialize placeholder for child classes
  15192. * @param parent of child
  15193. * @returns the serialized object
  15194. */
  15195. serialize(parent: any): any;
  15196. /**
  15197. * Internal only called by serialize
  15198. * @hidden
  15199. */
  15200. protected _serialize(serializedAction: any, parent?: any): any;
  15201. /**
  15202. * Internal only
  15203. * @hidden
  15204. */
  15205. static _SerializeValueAsString: (value: any) => string;
  15206. /**
  15207. * Internal only
  15208. * @hidden
  15209. */
  15210. static _GetTargetProperty: (target: Scene | Node) => {
  15211. name: string;
  15212. targetType: string;
  15213. value: string;
  15214. };
  15215. }
  15216. }
  15217. declare module BABYLON {
  15218. /**
  15219. * A Condition applied to an Action
  15220. */
  15221. export class Condition {
  15222. /**
  15223. * Internal only - manager for action
  15224. * @hidden
  15225. */
  15226. _actionManager: ActionManager;
  15227. /**
  15228. * Internal only
  15229. * @hidden
  15230. */
  15231. _evaluationId: number;
  15232. /**
  15233. * Internal only
  15234. * @hidden
  15235. */
  15236. _currentResult: boolean;
  15237. /**
  15238. * Creates a new Condition
  15239. * @param actionManager the manager of the action the condition is applied to
  15240. */
  15241. constructor(actionManager: ActionManager);
  15242. /**
  15243. * Check if the current condition is valid
  15244. * @returns a boolean
  15245. */
  15246. isValid(): boolean;
  15247. /**
  15248. * Internal only
  15249. * @hidden
  15250. */
  15251. _getProperty(propertyPath: string): string;
  15252. /**
  15253. * Internal only
  15254. * @hidden
  15255. */
  15256. _getEffectiveTarget(target: any, propertyPath: string): any;
  15257. /**
  15258. * Serialize placeholder for child classes
  15259. * @returns the serialized object
  15260. */
  15261. serialize(): any;
  15262. /**
  15263. * Internal only
  15264. * @hidden
  15265. */
  15266. protected _serialize(serializedCondition: any): any;
  15267. }
  15268. /**
  15269. * Defines specific conditional operators as extensions of Condition
  15270. */
  15271. export class ValueCondition extends Condition {
  15272. /** path to specify the property of the target the conditional operator uses */
  15273. propertyPath: string;
  15274. /** the value compared by the conditional operator against the current value of the property */
  15275. value: any;
  15276. /** the conditional operator, default ValueCondition.IsEqual */
  15277. operator: number;
  15278. /**
  15279. * Internal only
  15280. * @hidden
  15281. */
  15282. private static _IsEqual;
  15283. /**
  15284. * Internal only
  15285. * @hidden
  15286. */
  15287. private static _IsDifferent;
  15288. /**
  15289. * Internal only
  15290. * @hidden
  15291. */
  15292. private static _IsGreater;
  15293. /**
  15294. * Internal only
  15295. * @hidden
  15296. */
  15297. private static _IsLesser;
  15298. /**
  15299. * returns the number for IsEqual
  15300. */
  15301. static readonly IsEqual: number;
  15302. /**
  15303. * Returns the number for IsDifferent
  15304. */
  15305. static readonly IsDifferent: number;
  15306. /**
  15307. * Returns the number for IsGreater
  15308. */
  15309. static readonly IsGreater: number;
  15310. /**
  15311. * Returns the number for IsLesser
  15312. */
  15313. static readonly IsLesser: number;
  15314. /**
  15315. * Internal only The action manager for the condition
  15316. * @hidden
  15317. */
  15318. _actionManager: ActionManager;
  15319. /**
  15320. * Internal only
  15321. * @hidden
  15322. */
  15323. private _target;
  15324. /**
  15325. * Internal only
  15326. * @hidden
  15327. */
  15328. private _effectiveTarget;
  15329. /**
  15330. * Internal only
  15331. * @hidden
  15332. */
  15333. private _property;
  15334. /**
  15335. * Creates a new ValueCondition
  15336. * @param actionManager manager for the action the condition applies to
  15337. * @param target for the action
  15338. * @param propertyPath path to specify the property of the target the conditional operator uses
  15339. * @param value the value compared by the conditional operator against the current value of the property
  15340. * @param operator the conditional operator, default ValueCondition.IsEqual
  15341. */
  15342. constructor(actionManager: ActionManager, target: any,
  15343. /** path to specify the property of the target the conditional operator uses */
  15344. propertyPath: string,
  15345. /** the value compared by the conditional operator against the current value of the property */
  15346. value: any,
  15347. /** the conditional operator, default ValueCondition.IsEqual */
  15348. operator?: number);
  15349. /**
  15350. * Compares the given value with the property value for the specified conditional operator
  15351. * @returns the result of the comparison
  15352. */
  15353. isValid(): boolean;
  15354. /**
  15355. * Serialize the ValueCondition into a JSON compatible object
  15356. * @returns serialization object
  15357. */
  15358. serialize(): any;
  15359. /**
  15360. * Gets the name of the conditional operator for the ValueCondition
  15361. * @param operator the conditional operator
  15362. * @returns the name
  15363. */
  15364. static GetOperatorName(operator: number): string;
  15365. }
  15366. /**
  15367. * Defines a predicate condition as an extension of Condition
  15368. */
  15369. export class PredicateCondition extends Condition {
  15370. /** defines the predicate function used to validate the condition */
  15371. predicate: () => boolean;
  15372. /**
  15373. * Internal only - manager for action
  15374. * @hidden
  15375. */
  15376. _actionManager: ActionManager;
  15377. /**
  15378. * Creates a new PredicateCondition
  15379. * @param actionManager manager for the action the condition applies to
  15380. * @param predicate defines the predicate function used to validate the condition
  15381. */
  15382. constructor(actionManager: ActionManager,
  15383. /** defines the predicate function used to validate the condition */
  15384. predicate: () => boolean);
  15385. /**
  15386. * @returns the validity of the predicate condition
  15387. */
  15388. isValid(): boolean;
  15389. }
  15390. /**
  15391. * Defines a state condition as an extension of Condition
  15392. */
  15393. export class StateCondition extends Condition {
  15394. /** Value to compare with target state */
  15395. value: string;
  15396. /**
  15397. * Internal only - manager for action
  15398. * @hidden
  15399. */
  15400. _actionManager: ActionManager;
  15401. /**
  15402. * Internal only
  15403. * @hidden
  15404. */
  15405. private _target;
  15406. /**
  15407. * Creates a new StateCondition
  15408. * @param actionManager manager for the action the condition applies to
  15409. * @param target of the condition
  15410. * @param value to compare with target state
  15411. */
  15412. constructor(actionManager: ActionManager, target: any,
  15413. /** Value to compare with target state */
  15414. value: string);
  15415. /**
  15416. * Gets a boolean indicating if the current condition is met
  15417. * @returns the validity of the state
  15418. */
  15419. isValid(): boolean;
  15420. /**
  15421. * Serialize the StateCondition into a JSON compatible object
  15422. * @returns serialization object
  15423. */
  15424. serialize(): any;
  15425. }
  15426. }
  15427. declare module BABYLON {
  15428. /**
  15429. * This defines an action responsible to toggle a boolean once triggered.
  15430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15431. */
  15432. export class SwitchBooleanAction extends Action {
  15433. /**
  15434. * The path to the boolean property in the target object
  15435. */
  15436. propertyPath: string;
  15437. private _target;
  15438. private _effectiveTarget;
  15439. private _property;
  15440. /**
  15441. * Instantiate the action
  15442. * @param triggerOptions defines the trigger options
  15443. * @param target defines the object containing the boolean
  15444. * @param propertyPath defines the path to the boolean property in the target object
  15445. * @param condition defines the trigger related conditions
  15446. */
  15447. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15448. /** @hidden */
  15449. _prepare(): void;
  15450. /**
  15451. * Execute the action toggle the boolean value.
  15452. */
  15453. execute(): void;
  15454. /**
  15455. * Serializes the actions and its related information.
  15456. * @param parent defines the object to serialize in
  15457. * @returns the serialized object
  15458. */
  15459. serialize(parent: any): any;
  15460. }
  15461. /**
  15462. * This defines an action responsible to set a the state field of the target
  15463. * to a desired value once triggered.
  15464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15465. */
  15466. export class SetStateAction extends Action {
  15467. /**
  15468. * The value to store in the state field.
  15469. */
  15470. value: string;
  15471. private _target;
  15472. /**
  15473. * Instantiate the action
  15474. * @param triggerOptions defines the trigger options
  15475. * @param target defines the object containing the state property
  15476. * @param value defines the value to store in the state field
  15477. * @param condition defines the trigger related conditions
  15478. */
  15479. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15480. /**
  15481. * Execute the action and store the value on the target state property.
  15482. */
  15483. execute(): void;
  15484. /**
  15485. * Serializes the actions and its related information.
  15486. * @param parent defines the object to serialize in
  15487. * @returns the serialized object
  15488. */
  15489. serialize(parent: any): any;
  15490. }
  15491. /**
  15492. * This defines an action responsible to set a property of the target
  15493. * to a desired value once triggered.
  15494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15495. */
  15496. export class SetValueAction extends Action {
  15497. /**
  15498. * The path of the property to set in the target.
  15499. */
  15500. propertyPath: string;
  15501. /**
  15502. * The value to set in the property
  15503. */
  15504. value: any;
  15505. private _target;
  15506. private _effectiveTarget;
  15507. private _property;
  15508. /**
  15509. * Instantiate the action
  15510. * @param triggerOptions defines the trigger options
  15511. * @param target defines the object containing the property
  15512. * @param propertyPath defines the path of the property to set in the target
  15513. * @param value defines the value to set in the property
  15514. * @param condition defines the trigger related conditions
  15515. */
  15516. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15517. /** @hidden */
  15518. _prepare(): void;
  15519. /**
  15520. * Execute the action and set the targetted property to the desired value.
  15521. */
  15522. execute(): void;
  15523. /**
  15524. * Serializes the actions and its related information.
  15525. * @param parent defines the object to serialize in
  15526. * @returns the serialized object
  15527. */
  15528. serialize(parent: any): any;
  15529. }
  15530. /**
  15531. * This defines an action responsible to increment the target value
  15532. * to a desired value once triggered.
  15533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15534. */
  15535. export class IncrementValueAction extends Action {
  15536. /**
  15537. * The path of the property to increment in the target.
  15538. */
  15539. propertyPath: string;
  15540. /**
  15541. * The value we should increment the property by.
  15542. */
  15543. value: any;
  15544. private _target;
  15545. private _effectiveTarget;
  15546. private _property;
  15547. /**
  15548. * Instantiate the action
  15549. * @param triggerOptions defines the trigger options
  15550. * @param target defines the object containing the property
  15551. * @param propertyPath defines the path of the property to increment in the target
  15552. * @param value defines the value value we should increment the property by
  15553. * @param condition defines the trigger related conditions
  15554. */
  15555. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15556. /** @hidden */
  15557. _prepare(): void;
  15558. /**
  15559. * Execute the action and increment the target of the value amount.
  15560. */
  15561. execute(): void;
  15562. /**
  15563. * Serializes the actions and its related information.
  15564. * @param parent defines the object to serialize in
  15565. * @returns the serialized object
  15566. */
  15567. serialize(parent: any): any;
  15568. }
  15569. /**
  15570. * This defines an action responsible to start an animation once triggered.
  15571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15572. */
  15573. export class PlayAnimationAction extends Action {
  15574. /**
  15575. * Where the animation should start (animation frame)
  15576. */
  15577. from: number;
  15578. /**
  15579. * Where the animation should stop (animation frame)
  15580. */
  15581. to: number;
  15582. /**
  15583. * Define if the animation should loop or stop after the first play.
  15584. */
  15585. loop?: boolean;
  15586. private _target;
  15587. /**
  15588. * Instantiate the action
  15589. * @param triggerOptions defines the trigger options
  15590. * @param target defines the target animation or animation name
  15591. * @param from defines from where the animation should start (animation frame)
  15592. * @param end defines where the animation should stop (animation frame)
  15593. * @param loop defines if the animation should loop or stop after the first play
  15594. * @param condition defines the trigger related conditions
  15595. */
  15596. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15597. /** @hidden */
  15598. _prepare(): void;
  15599. /**
  15600. * Execute the action and play the animation.
  15601. */
  15602. execute(): void;
  15603. /**
  15604. * Serializes the actions and its related information.
  15605. * @param parent defines the object to serialize in
  15606. * @returns the serialized object
  15607. */
  15608. serialize(parent: any): any;
  15609. }
  15610. /**
  15611. * This defines an action responsible to stop an animation once triggered.
  15612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15613. */
  15614. export class StopAnimationAction extends Action {
  15615. private _target;
  15616. /**
  15617. * Instantiate the action
  15618. * @param triggerOptions defines the trigger options
  15619. * @param target defines the target animation or animation name
  15620. * @param condition defines the trigger related conditions
  15621. */
  15622. constructor(triggerOptions: any, target: any, condition?: Condition);
  15623. /** @hidden */
  15624. _prepare(): void;
  15625. /**
  15626. * Execute the action and stop the animation.
  15627. */
  15628. execute(): void;
  15629. /**
  15630. * Serializes the actions and its related information.
  15631. * @param parent defines the object to serialize in
  15632. * @returns the serialized object
  15633. */
  15634. serialize(parent: any): any;
  15635. }
  15636. /**
  15637. * This defines an action responsible that does nothing once triggered.
  15638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15639. */
  15640. export class DoNothingAction extends Action {
  15641. /**
  15642. * Instantiate the action
  15643. * @param triggerOptions defines the trigger options
  15644. * @param condition defines the trigger related conditions
  15645. */
  15646. constructor(triggerOptions?: any, condition?: Condition);
  15647. /**
  15648. * Execute the action and do nothing.
  15649. */
  15650. execute(): void;
  15651. /**
  15652. * Serializes the actions and its related information.
  15653. * @param parent defines the object to serialize in
  15654. * @returns the serialized object
  15655. */
  15656. serialize(parent: any): any;
  15657. }
  15658. /**
  15659. * This defines an action responsible to trigger several actions once triggered.
  15660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15661. */
  15662. export class CombineAction extends Action {
  15663. /**
  15664. * The list of aggregated animations to run.
  15665. */
  15666. children: Action[];
  15667. /**
  15668. * Instantiate the action
  15669. * @param triggerOptions defines the trigger options
  15670. * @param children defines the list of aggregated animations to run
  15671. * @param condition defines the trigger related conditions
  15672. */
  15673. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15674. /** @hidden */
  15675. _prepare(): void;
  15676. /**
  15677. * Execute the action and executes all the aggregated actions.
  15678. */
  15679. execute(evt: ActionEvent): void;
  15680. /**
  15681. * Serializes the actions and its related information.
  15682. * @param parent defines the object to serialize in
  15683. * @returns the serialized object
  15684. */
  15685. serialize(parent: any): any;
  15686. }
  15687. /**
  15688. * This defines an action responsible to run code (external event) once triggered.
  15689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15690. */
  15691. export class ExecuteCodeAction extends Action {
  15692. /**
  15693. * The callback function to run.
  15694. */
  15695. func: (evt: ActionEvent) => void;
  15696. /**
  15697. * Instantiate the action
  15698. * @param triggerOptions defines the trigger options
  15699. * @param func defines the callback function to run
  15700. * @param condition defines the trigger related conditions
  15701. */
  15702. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15703. /**
  15704. * Execute the action and run the attached code.
  15705. */
  15706. execute(evt: ActionEvent): void;
  15707. }
  15708. /**
  15709. * This defines an action responsible to set the parent property of the target once triggered.
  15710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15711. */
  15712. export class SetParentAction extends Action {
  15713. private _parent;
  15714. private _target;
  15715. /**
  15716. * Instantiate the action
  15717. * @param triggerOptions defines the trigger options
  15718. * @param target defines the target containing the parent property
  15719. * @param parent defines from where the animation should start (animation frame)
  15720. * @param condition defines the trigger related conditions
  15721. */
  15722. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15723. /** @hidden */
  15724. _prepare(): void;
  15725. /**
  15726. * Execute the action and set the parent property.
  15727. */
  15728. execute(): void;
  15729. /**
  15730. * Serializes the actions and its related information.
  15731. * @param parent defines the object to serialize in
  15732. * @returns the serialized object
  15733. */
  15734. serialize(parent: any): any;
  15735. }
  15736. }
  15737. declare module BABYLON {
  15738. /**
  15739. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15740. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15742. */
  15743. export class ActionManager extends AbstractActionManager {
  15744. /**
  15745. * Nothing
  15746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15747. */
  15748. static readonly NothingTrigger: number;
  15749. /**
  15750. * On pick
  15751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15752. */
  15753. static readonly OnPickTrigger: number;
  15754. /**
  15755. * On left pick
  15756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15757. */
  15758. static readonly OnLeftPickTrigger: number;
  15759. /**
  15760. * On right pick
  15761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15762. */
  15763. static readonly OnRightPickTrigger: number;
  15764. /**
  15765. * On center pick
  15766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15767. */
  15768. static readonly OnCenterPickTrigger: number;
  15769. /**
  15770. * On pick down
  15771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15772. */
  15773. static readonly OnPickDownTrigger: number;
  15774. /**
  15775. * On double pick
  15776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15777. */
  15778. static readonly OnDoublePickTrigger: number;
  15779. /**
  15780. * On pick up
  15781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15782. */
  15783. static readonly OnPickUpTrigger: number;
  15784. /**
  15785. * On pick out.
  15786. * This trigger will only be raised if you also declared a OnPickDown
  15787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15788. */
  15789. static readonly OnPickOutTrigger: number;
  15790. /**
  15791. * On long press
  15792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15793. */
  15794. static readonly OnLongPressTrigger: number;
  15795. /**
  15796. * On pointer over
  15797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15798. */
  15799. static readonly OnPointerOverTrigger: number;
  15800. /**
  15801. * On pointer out
  15802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15803. */
  15804. static readonly OnPointerOutTrigger: number;
  15805. /**
  15806. * On every frame
  15807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15808. */
  15809. static readonly OnEveryFrameTrigger: number;
  15810. /**
  15811. * On intersection enter
  15812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15813. */
  15814. static readonly OnIntersectionEnterTrigger: number;
  15815. /**
  15816. * On intersection exit
  15817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15818. */
  15819. static readonly OnIntersectionExitTrigger: number;
  15820. /**
  15821. * On key down
  15822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15823. */
  15824. static readonly OnKeyDownTrigger: number;
  15825. /**
  15826. * On key up
  15827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15828. */
  15829. static readonly OnKeyUpTrigger: number;
  15830. private _scene;
  15831. /**
  15832. * Creates a new action manager
  15833. * @param scene defines the hosting scene
  15834. */
  15835. constructor(scene: Scene);
  15836. /**
  15837. * Releases all associated resources
  15838. */
  15839. dispose(): void;
  15840. /**
  15841. * Gets hosting scene
  15842. * @returns the hosting scene
  15843. */
  15844. getScene(): Scene;
  15845. /**
  15846. * Does this action manager handles actions of any of the given triggers
  15847. * @param triggers defines the triggers to be tested
  15848. * @return a boolean indicating whether one (or more) of the triggers is handled
  15849. */
  15850. hasSpecificTriggers(triggers: number[]): boolean;
  15851. /**
  15852. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15853. * speed.
  15854. * @param triggerA defines the trigger to be tested
  15855. * @param triggerB defines the trigger to be tested
  15856. * @return a boolean indicating whether one (or more) of the triggers is handled
  15857. */
  15858. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15859. /**
  15860. * Does this action manager handles actions of a given trigger
  15861. * @param trigger defines the trigger to be tested
  15862. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15863. * @return whether the trigger is handled
  15864. */
  15865. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15866. /**
  15867. * Does this action manager has pointer triggers
  15868. */
  15869. readonly hasPointerTriggers: boolean;
  15870. /**
  15871. * Does this action manager has pick triggers
  15872. */
  15873. readonly hasPickTriggers: boolean;
  15874. /**
  15875. * Registers an action to this action manager
  15876. * @param action defines the action to be registered
  15877. * @return the action amended (prepared) after registration
  15878. */
  15879. registerAction(action: IAction): Nullable<IAction>;
  15880. /**
  15881. * Unregisters an action to this action manager
  15882. * @param action defines the action to be unregistered
  15883. * @return a boolean indicating whether the action has been unregistered
  15884. */
  15885. unregisterAction(action: IAction): Boolean;
  15886. /**
  15887. * Process a specific trigger
  15888. * @param trigger defines the trigger to process
  15889. * @param evt defines the event details to be processed
  15890. */
  15891. processTrigger(trigger: number, evt?: IActionEvent): void;
  15892. /** @hidden */
  15893. _getEffectiveTarget(target: any, propertyPath: string): any;
  15894. /** @hidden */
  15895. _getProperty(propertyPath: string): string;
  15896. /**
  15897. * Serialize this manager to a JSON object
  15898. * @param name defines the property name to store this manager
  15899. * @returns a JSON representation of this manager
  15900. */
  15901. serialize(name: string): any;
  15902. /**
  15903. * Creates a new ActionManager from a JSON data
  15904. * @param parsedActions defines the JSON data to read from
  15905. * @param object defines the hosting mesh
  15906. * @param scene defines the hosting scene
  15907. */
  15908. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15909. /**
  15910. * Get a trigger name by index
  15911. * @param trigger defines the trigger index
  15912. * @returns a trigger name
  15913. */
  15914. static GetTriggerName(trigger: number): string;
  15915. }
  15916. }
  15917. declare module BABYLON {
  15918. /**
  15919. * Class representing a ray with position and direction
  15920. */
  15921. export class Ray {
  15922. /** origin point */
  15923. origin: Vector3;
  15924. /** direction */
  15925. direction: Vector3;
  15926. /** length of the ray */
  15927. length: number;
  15928. private static readonly TmpVector3;
  15929. private _tmpRay;
  15930. /**
  15931. * Creates a new ray
  15932. * @param origin origin point
  15933. * @param direction direction
  15934. * @param length length of the ray
  15935. */
  15936. constructor(
  15937. /** origin point */
  15938. origin: Vector3,
  15939. /** direction */
  15940. direction: Vector3,
  15941. /** length of the ray */
  15942. length?: number);
  15943. /**
  15944. * Checks if the ray intersects a box
  15945. * @param minimum bound of the box
  15946. * @param maximum bound of the box
  15947. * @param intersectionTreshold extra extend to be added to the box in all direction
  15948. * @returns if the box was hit
  15949. */
  15950. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15951. /**
  15952. * Checks if the ray intersects a box
  15953. * @param box the bounding box to check
  15954. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15955. * @returns if the box was hit
  15956. */
  15957. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15958. /**
  15959. * If the ray hits a sphere
  15960. * @param sphere the bounding sphere to check
  15961. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15962. * @returns true if it hits the sphere
  15963. */
  15964. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15965. /**
  15966. * If the ray hits a triange
  15967. * @param vertex0 triangle vertex
  15968. * @param vertex1 triangle vertex
  15969. * @param vertex2 triangle vertex
  15970. * @returns intersection information if hit
  15971. */
  15972. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15973. /**
  15974. * Checks if ray intersects a plane
  15975. * @param plane the plane to check
  15976. * @returns the distance away it was hit
  15977. */
  15978. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15979. /**
  15980. * Checks if ray intersects a mesh
  15981. * @param mesh the mesh to check
  15982. * @param fastCheck if only the bounding box should checked
  15983. * @returns picking info of the intersecton
  15984. */
  15985. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15986. /**
  15987. * Checks if ray intersects a mesh
  15988. * @param meshes the meshes to check
  15989. * @param fastCheck if only the bounding box should checked
  15990. * @param results array to store result in
  15991. * @returns Array of picking infos
  15992. */
  15993. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15994. private _comparePickingInfo;
  15995. private static smallnum;
  15996. private static rayl;
  15997. /**
  15998. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  15999. * @param sega the first point of the segment to test the intersection against
  16000. * @param segb the second point of the segment to test the intersection against
  16001. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16002. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16003. */
  16004. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16005. /**
  16006. * Update the ray from viewport position
  16007. * @param x position
  16008. * @param y y position
  16009. * @param viewportWidth viewport width
  16010. * @param viewportHeight viewport height
  16011. * @param world world matrix
  16012. * @param view view matrix
  16013. * @param projection projection matrix
  16014. * @returns this ray updated
  16015. */
  16016. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16017. /**
  16018. * Creates a ray with origin and direction of 0,0,0
  16019. * @returns the new ray
  16020. */
  16021. static Zero(): Ray;
  16022. /**
  16023. * Creates a new ray from screen space and viewport
  16024. * @param x position
  16025. * @param y y position
  16026. * @param viewportWidth viewport width
  16027. * @param viewportHeight viewport height
  16028. * @param world world matrix
  16029. * @param view view matrix
  16030. * @param projection projection matrix
  16031. * @returns new ray
  16032. */
  16033. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16034. /**
  16035. * 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
  16036. * transformed to the given world matrix.
  16037. * @param origin The origin point
  16038. * @param end The end point
  16039. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16040. * @returns the new ray
  16041. */
  16042. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16043. /**
  16044. * Transforms a ray by a matrix
  16045. * @param ray ray to transform
  16046. * @param matrix matrix to apply
  16047. * @returns the resulting new ray
  16048. */
  16049. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16050. /**
  16051. * Transforms a ray by a matrix
  16052. * @param ray ray to transform
  16053. * @param matrix matrix to apply
  16054. * @param result ray to store result in
  16055. */
  16056. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16057. /**
  16058. * Unproject a ray from screen space to object space
  16059. * @param sourceX defines the screen space x coordinate to use
  16060. * @param sourceY defines the screen space y coordinate to use
  16061. * @param viewportWidth defines the current width of the viewport
  16062. * @param viewportHeight defines the current height of the viewport
  16063. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16064. * @param view defines the view matrix to use
  16065. * @param projection defines the projection matrix to use
  16066. */
  16067. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16068. }
  16069. /**
  16070. * Type used to define predicate used to select faces when a mesh intersection is detected
  16071. */
  16072. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16073. interface Scene {
  16074. /** @hidden */
  16075. _tempPickingRay: Nullable<Ray>;
  16076. /** @hidden */
  16077. _cachedRayForTransform: Ray;
  16078. /** @hidden */
  16079. _pickWithRayInverseMatrix: Matrix;
  16080. /** @hidden */
  16081. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16082. /** @hidden */
  16083. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16084. }
  16085. }
  16086. declare module BABYLON {
  16087. interface Scene {
  16088. /** @hidden */
  16089. _pointerOverSprite: Nullable<Sprite>;
  16090. /** @hidden */
  16091. _pickedDownSprite: Nullable<Sprite>;
  16092. /** @hidden */
  16093. _tempSpritePickingRay: Nullable<Ray>;
  16094. /**
  16095. * All of the sprite managers added to this scene
  16096. * @see http://doc.babylonjs.com/babylon101/sprites
  16097. */
  16098. spriteManagers: Array<ISpriteManager>;
  16099. /**
  16100. * An event triggered when sprites rendering is about to start
  16101. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16102. */
  16103. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16104. /**
  16105. * An event triggered when sprites rendering is done
  16106. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16107. */
  16108. onAfterSpritesRenderingObservable: Observable<Scene>;
  16109. /** @hidden */
  16110. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16111. /** Launch a ray to try to pick a sprite in the scene
  16112. * @param x position on screen
  16113. * @param y position on screen
  16114. * @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
  16115. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16116. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16117. * @returns a PickingInfo
  16118. */
  16119. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16120. /** Use the given ray to pick a sprite in the scene
  16121. * @param ray The ray (in world space) to use to pick meshes
  16122. * @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
  16123. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16124. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16125. * @returns a PickingInfo
  16126. */
  16127. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16128. /**
  16129. * Force the sprite under the pointer
  16130. * @param sprite defines the sprite to use
  16131. */
  16132. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16133. /**
  16134. * Gets the sprite under the pointer
  16135. * @returns a Sprite or null if no sprite is under the pointer
  16136. */
  16137. getPointerOverSprite(): Nullable<Sprite>;
  16138. }
  16139. /**
  16140. * Defines the sprite scene component responsible to manage sprites
  16141. * in a given scene.
  16142. */
  16143. export class SpriteSceneComponent implements ISceneComponent {
  16144. /**
  16145. * The component name helpfull to identify the component in the list of scene components.
  16146. */
  16147. readonly name: string;
  16148. /**
  16149. * The scene the component belongs to.
  16150. */
  16151. scene: Scene;
  16152. /** @hidden */
  16153. private _spritePredicate;
  16154. /**
  16155. * Creates a new instance of the component for the given scene
  16156. * @param scene Defines the scene to register the component in
  16157. */
  16158. constructor(scene: Scene);
  16159. /**
  16160. * Registers the component in a given scene
  16161. */
  16162. register(): void;
  16163. /**
  16164. * Rebuilds the elements related to this component in case of
  16165. * context lost for instance.
  16166. */
  16167. rebuild(): void;
  16168. /**
  16169. * Disposes the component and the associated ressources.
  16170. */
  16171. dispose(): void;
  16172. private _pickSpriteButKeepRay;
  16173. private _pointerMove;
  16174. private _pointerDown;
  16175. private _pointerUp;
  16176. }
  16177. }
  16178. declare module BABYLON {
  16179. /** @hidden */
  16180. export var fogFragmentDeclaration: {
  16181. name: string;
  16182. shader: string;
  16183. };
  16184. }
  16185. declare module BABYLON {
  16186. /** @hidden */
  16187. export var fogFragment: {
  16188. name: string;
  16189. shader: string;
  16190. };
  16191. }
  16192. declare module BABYLON {
  16193. /** @hidden */
  16194. export var spritesPixelShader: {
  16195. name: string;
  16196. shader: string;
  16197. };
  16198. }
  16199. declare module BABYLON {
  16200. /** @hidden */
  16201. export var fogVertexDeclaration: {
  16202. name: string;
  16203. shader: string;
  16204. };
  16205. }
  16206. declare module BABYLON {
  16207. /** @hidden */
  16208. export var spritesVertexShader: {
  16209. name: string;
  16210. shader: string;
  16211. };
  16212. }
  16213. declare module BABYLON {
  16214. /**
  16215. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16216. */
  16217. export interface ISpriteManager extends IDisposable {
  16218. /**
  16219. * Restricts the camera to viewing objects with the same layerMask.
  16220. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16221. */
  16222. layerMask: number;
  16223. /**
  16224. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16225. */
  16226. isPickable: boolean;
  16227. /**
  16228. * Specifies the rendering group id for this mesh (0 by default)
  16229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16230. */
  16231. renderingGroupId: number;
  16232. /**
  16233. * Defines the list of sprites managed by the manager.
  16234. */
  16235. sprites: Array<Sprite>;
  16236. /**
  16237. * Tests the intersection of a sprite with a specific ray.
  16238. * @param ray The ray we are sending to test the collision
  16239. * @param camera The camera space we are sending rays in
  16240. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16241. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16242. * @returns picking info or null.
  16243. */
  16244. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16245. /**
  16246. * Renders the list of sprites on screen.
  16247. */
  16248. render(): void;
  16249. }
  16250. /**
  16251. * Class used to manage multiple sprites on the same spritesheet
  16252. * @see http://doc.babylonjs.com/babylon101/sprites
  16253. */
  16254. export class SpriteManager implements ISpriteManager {
  16255. /** defines the manager's name */
  16256. name: string;
  16257. /** Gets the list of sprites */
  16258. sprites: Sprite[];
  16259. /** Gets or sets the rendering group id (0 by default) */
  16260. renderingGroupId: number;
  16261. /** Gets or sets camera layer mask */
  16262. layerMask: number;
  16263. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16264. fogEnabled: boolean;
  16265. /** Gets or sets a boolean indicating if the sprites are pickable */
  16266. isPickable: boolean;
  16267. /** Defines the default width of a cell in the spritesheet */
  16268. cellWidth: number;
  16269. /** Defines the default height of a cell in the spritesheet */
  16270. cellHeight: number;
  16271. /**
  16272. * An event triggered when the manager is disposed.
  16273. */
  16274. onDisposeObservable: Observable<SpriteManager>;
  16275. private _onDisposeObserver;
  16276. /**
  16277. * Callback called when the manager is disposed
  16278. */
  16279. onDispose: () => void;
  16280. private _capacity;
  16281. private _spriteTexture;
  16282. private _epsilon;
  16283. private _scene;
  16284. private _vertexData;
  16285. private _buffer;
  16286. private _vertexBuffers;
  16287. private _indexBuffer;
  16288. private _effectBase;
  16289. private _effectFog;
  16290. /**
  16291. * Gets or sets the spritesheet texture
  16292. */
  16293. texture: Texture;
  16294. /**
  16295. * Creates a new sprite manager
  16296. * @param name defines the manager's name
  16297. * @param imgUrl defines the sprite sheet url
  16298. * @param capacity defines the maximum allowed number of sprites
  16299. * @param cellSize defines the size of a sprite cell
  16300. * @param scene defines the hosting scene
  16301. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16302. * @param samplingMode defines the smapling mode to use with spritesheet
  16303. */
  16304. constructor(
  16305. /** defines the manager's name */
  16306. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16307. private _appendSpriteVertex;
  16308. /**
  16309. * Intersects the sprites with a ray
  16310. * @param ray defines the ray to intersect with
  16311. * @param camera defines the current active camera
  16312. * @param predicate defines a predicate used to select candidate sprites
  16313. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16314. * @returns null if no hit or a PickingInfo
  16315. */
  16316. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16317. /**
  16318. * Render all child sprites
  16319. */
  16320. render(): void;
  16321. /**
  16322. * Release associated resources
  16323. */
  16324. dispose(): void;
  16325. }
  16326. }
  16327. declare module BABYLON {
  16328. /**
  16329. * Class used to represent a sprite
  16330. * @see http://doc.babylonjs.com/babylon101/sprites
  16331. */
  16332. export class Sprite {
  16333. /** defines the name */
  16334. name: string;
  16335. /** Gets or sets the current world position */
  16336. position: Vector3;
  16337. /** Gets or sets the main color */
  16338. color: Color4;
  16339. /** Gets or sets the width */
  16340. width: number;
  16341. /** Gets or sets the height */
  16342. height: number;
  16343. /** Gets or sets rotation angle */
  16344. angle: number;
  16345. /** Gets or sets the cell index in the sprite sheet */
  16346. cellIndex: number;
  16347. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16348. invertU: number;
  16349. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16350. invertV: number;
  16351. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16352. disposeWhenFinishedAnimating: boolean;
  16353. /** Gets the list of attached animations */
  16354. animations: Animation[];
  16355. /** Gets or sets a boolean indicating if the sprite can be picked */
  16356. isPickable: boolean;
  16357. /**
  16358. * Gets or sets the associated action manager
  16359. */
  16360. actionManager: Nullable<ActionManager>;
  16361. private _animationStarted;
  16362. private _loopAnimation;
  16363. private _fromIndex;
  16364. private _toIndex;
  16365. private _delay;
  16366. private _direction;
  16367. private _manager;
  16368. private _time;
  16369. private _onAnimationEnd;
  16370. /**
  16371. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16372. */
  16373. isVisible: boolean;
  16374. /**
  16375. * Gets or sets the sprite size
  16376. */
  16377. size: number;
  16378. /**
  16379. * Creates a new Sprite
  16380. * @param name defines the name
  16381. * @param manager defines the manager
  16382. */
  16383. constructor(
  16384. /** defines the name */
  16385. name: string, manager: ISpriteManager);
  16386. /**
  16387. * Starts an animation
  16388. * @param from defines the initial key
  16389. * @param to defines the end key
  16390. * @param loop defines if the animation must loop
  16391. * @param delay defines the start delay (in ms)
  16392. * @param onAnimationEnd defines a callback to call when animation ends
  16393. */
  16394. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16395. /** Stops current animation (if any) */
  16396. stopAnimation(): void;
  16397. /** @hidden */
  16398. _animate(deltaTime: number): void;
  16399. /** Release associated resources */
  16400. dispose(): void;
  16401. }
  16402. }
  16403. declare module BABYLON {
  16404. /**
  16405. * Information about the result of picking within a scene
  16406. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16407. */
  16408. export class PickingInfo {
  16409. /** @hidden */
  16410. _pickingUnavailable: boolean;
  16411. /**
  16412. * If the pick collided with an object
  16413. */
  16414. hit: boolean;
  16415. /**
  16416. * Distance away where the pick collided
  16417. */
  16418. distance: number;
  16419. /**
  16420. * The location of pick collision
  16421. */
  16422. pickedPoint: Nullable<Vector3>;
  16423. /**
  16424. * The mesh corresponding the the pick collision
  16425. */
  16426. pickedMesh: Nullable<AbstractMesh>;
  16427. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16428. bu: number;
  16429. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16430. bv: number;
  16431. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16432. faceId: number;
  16433. /** Id of the the submesh that was picked */
  16434. subMeshId: number;
  16435. /** If a sprite was picked, this will be the sprite the pick collided with */
  16436. pickedSprite: Nullable<Sprite>;
  16437. /**
  16438. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16439. */
  16440. originMesh: Nullable<AbstractMesh>;
  16441. /**
  16442. * The ray that was used to perform the picking.
  16443. */
  16444. ray: Nullable<Ray>;
  16445. /**
  16446. * Gets the normal correspodning to the face the pick collided with
  16447. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16448. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16449. * @returns The normal correspodning to the face the pick collided with
  16450. */
  16451. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16452. /**
  16453. * Gets the texture coordinates of where the pick occured
  16454. * @returns the vector containing the coordnates of the texture
  16455. */
  16456. getTextureCoordinates(): Nullable<Vector2>;
  16457. }
  16458. }
  16459. declare module BABYLON {
  16460. /**
  16461. * Gather the list of pointer event types as constants.
  16462. */
  16463. export class PointerEventTypes {
  16464. /**
  16465. * 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.
  16466. */
  16467. static readonly POINTERDOWN: number;
  16468. /**
  16469. * The pointerup event is fired when a pointer is no longer active.
  16470. */
  16471. static readonly POINTERUP: number;
  16472. /**
  16473. * The pointermove event is fired when a pointer changes coordinates.
  16474. */
  16475. static readonly POINTERMOVE: number;
  16476. /**
  16477. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16478. */
  16479. static readonly POINTERWHEEL: number;
  16480. /**
  16481. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16482. */
  16483. static readonly POINTERPICK: number;
  16484. /**
  16485. * The pointertap event is fired when a the object has been touched and released without drag.
  16486. */
  16487. static readonly POINTERTAP: number;
  16488. /**
  16489. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16490. */
  16491. static readonly POINTERDOUBLETAP: number;
  16492. }
  16493. /**
  16494. * Base class of pointer info types.
  16495. */
  16496. export class PointerInfoBase {
  16497. /**
  16498. * Defines the type of event (PointerEventTypes)
  16499. */
  16500. type: number;
  16501. /**
  16502. * Defines the related dom event
  16503. */
  16504. event: PointerEvent | MouseWheelEvent;
  16505. /**
  16506. * Instantiates the base class of pointers info.
  16507. * @param type Defines the type of event (PointerEventTypes)
  16508. * @param event Defines the related dom event
  16509. */
  16510. constructor(
  16511. /**
  16512. * Defines the type of event (PointerEventTypes)
  16513. */
  16514. type: number,
  16515. /**
  16516. * Defines the related dom event
  16517. */
  16518. event: PointerEvent | MouseWheelEvent);
  16519. }
  16520. /**
  16521. * This class is used to store pointer related info for the onPrePointerObservable event.
  16522. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16523. */
  16524. export class PointerInfoPre extends PointerInfoBase {
  16525. /**
  16526. * Ray from a pointer if availible (eg. 6dof controller)
  16527. */
  16528. ray: Nullable<Ray>;
  16529. /**
  16530. * Defines the local position of the pointer on the canvas.
  16531. */
  16532. localPosition: Vector2;
  16533. /**
  16534. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16535. */
  16536. skipOnPointerObservable: boolean;
  16537. /**
  16538. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16539. * @param type Defines the type of event (PointerEventTypes)
  16540. * @param event Defines the related dom event
  16541. * @param localX Defines the local x coordinates of the pointer when the event occured
  16542. * @param localY Defines the local y coordinates of the pointer when the event occured
  16543. */
  16544. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16545. }
  16546. /**
  16547. * This type contains all the data related to a pointer event in Babylon.js.
  16548. * 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.
  16549. */
  16550. export class PointerInfo extends PointerInfoBase {
  16551. /**
  16552. * Defines the picking info associated to the info (if any)\
  16553. */
  16554. pickInfo: Nullable<PickingInfo>;
  16555. /**
  16556. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16557. * @param type Defines the type of event (PointerEventTypes)
  16558. * @param event Defines the related dom event
  16559. * @param pickInfo Defines the picking info associated to the info (if any)\
  16560. */
  16561. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16562. /**
  16563. * Defines the picking info associated to the info (if any)\
  16564. */
  16565. pickInfo: Nullable<PickingInfo>);
  16566. }
  16567. /**
  16568. * Data relating to a touch event on the screen.
  16569. */
  16570. export interface PointerTouch {
  16571. /**
  16572. * X coordinate of touch.
  16573. */
  16574. x: number;
  16575. /**
  16576. * Y coordinate of touch.
  16577. */
  16578. y: number;
  16579. /**
  16580. * Id of touch. Unique for each finger.
  16581. */
  16582. pointerId: number;
  16583. /**
  16584. * Event type passed from DOM.
  16585. */
  16586. type: any;
  16587. }
  16588. }
  16589. declare module BABYLON {
  16590. /**
  16591. * Manage the mouse inputs to control the movement of a free camera.
  16592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16593. */
  16594. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16595. /**
  16596. * Define if touch is enabled in the mouse input
  16597. */
  16598. touchEnabled: boolean;
  16599. /**
  16600. * Defines the camera the input is attached to.
  16601. */
  16602. camera: FreeCamera;
  16603. /**
  16604. * Defines the buttons associated with the input to handle camera move.
  16605. */
  16606. buttons: number[];
  16607. /**
  16608. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16609. */
  16610. angularSensibility: number;
  16611. private _pointerInput;
  16612. private _onMouseMove;
  16613. private _observer;
  16614. private previousPosition;
  16615. /**
  16616. * Observable for when a pointer move event occurs containing the move offset
  16617. */
  16618. onPointerMovedObservable: Observable<{
  16619. offsetX: number;
  16620. offsetY: number;
  16621. }>;
  16622. /**
  16623. * @hidden
  16624. * If the camera should be rotated automatically based on pointer movement
  16625. */
  16626. _allowCameraRotation: boolean;
  16627. /**
  16628. * Manage the mouse inputs to control the movement of a free camera.
  16629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16630. * @param touchEnabled Defines if touch is enabled or not
  16631. */
  16632. constructor(
  16633. /**
  16634. * Define if touch is enabled in the mouse input
  16635. */
  16636. touchEnabled?: boolean);
  16637. /**
  16638. * Attach the input controls to a specific dom element to get the input from.
  16639. * @param element Defines the element the controls should be listened from
  16640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16641. */
  16642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16643. /**
  16644. * Called on JS contextmenu event.
  16645. * Override this method to provide functionality.
  16646. */
  16647. protected onContextMenu(evt: PointerEvent): void;
  16648. /**
  16649. * Detach the current controls from the specified dom element.
  16650. * @param element Defines the element to stop listening the inputs from
  16651. */
  16652. detachControl(element: Nullable<HTMLElement>): void;
  16653. /**
  16654. * Gets the class name of the current intput.
  16655. * @returns the class name
  16656. */
  16657. getClassName(): string;
  16658. /**
  16659. * Get the friendly name associated with the input class.
  16660. * @returns the input friendly name
  16661. */
  16662. getSimpleName(): string;
  16663. }
  16664. }
  16665. declare module BABYLON {
  16666. /**
  16667. * Manage the touch inputs to control the movement of a free camera.
  16668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16669. */
  16670. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16671. /**
  16672. * Defines the camera the input is attached to.
  16673. */
  16674. camera: FreeCamera;
  16675. /**
  16676. * Defines the touch sensibility for rotation.
  16677. * The higher the faster.
  16678. */
  16679. touchAngularSensibility: number;
  16680. /**
  16681. * Defines the touch sensibility for move.
  16682. * The higher the faster.
  16683. */
  16684. touchMoveSensibility: number;
  16685. private _offsetX;
  16686. private _offsetY;
  16687. private _pointerPressed;
  16688. private _pointerInput;
  16689. private _observer;
  16690. private _onLostFocus;
  16691. /**
  16692. * Attach the input controls to a specific dom element to get the input from.
  16693. * @param element Defines the element the controls should be listened from
  16694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16695. */
  16696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16697. /**
  16698. * Detach the current controls from the specified dom element.
  16699. * @param element Defines the element to stop listening the inputs from
  16700. */
  16701. detachControl(element: Nullable<HTMLElement>): void;
  16702. /**
  16703. * Update the current camera state depending on the inputs that have been used this frame.
  16704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16705. */
  16706. checkInputs(): void;
  16707. /**
  16708. * Gets the class name of the current intput.
  16709. * @returns the class name
  16710. */
  16711. getClassName(): string;
  16712. /**
  16713. * Get the friendly name associated with the input class.
  16714. * @returns the input friendly name
  16715. */
  16716. getSimpleName(): string;
  16717. }
  16718. }
  16719. declare module BABYLON {
  16720. /**
  16721. * Default Inputs manager for the FreeCamera.
  16722. * It groups all the default supported inputs for ease of use.
  16723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16724. */
  16725. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16726. /**
  16727. * @hidden
  16728. */
  16729. _mouseInput: Nullable<FreeCameraMouseInput>;
  16730. /**
  16731. * Instantiates a new FreeCameraInputsManager.
  16732. * @param camera Defines the camera the inputs belong to
  16733. */
  16734. constructor(camera: FreeCamera);
  16735. /**
  16736. * Add keyboard input support to the input manager.
  16737. * @returns the current input manager
  16738. */
  16739. addKeyboard(): FreeCameraInputsManager;
  16740. /**
  16741. * Add mouse input support to the input manager.
  16742. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16743. * @returns the current input manager
  16744. */
  16745. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16746. /**
  16747. * Removes the mouse input support from the manager
  16748. * @returns the current input manager
  16749. */
  16750. removeMouse(): FreeCameraInputsManager;
  16751. /**
  16752. * Add touch input support to the input manager.
  16753. * @returns the current input manager
  16754. */
  16755. addTouch(): FreeCameraInputsManager;
  16756. /**
  16757. * Remove all attached input methods from a camera
  16758. */
  16759. clear(): void;
  16760. }
  16761. }
  16762. declare module BABYLON {
  16763. /**
  16764. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16765. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16766. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16767. */
  16768. export class FreeCamera extends TargetCamera {
  16769. /**
  16770. * Define the collision ellipsoid of the camera.
  16771. * This is helpful to simulate a camera body like the player body around the camera
  16772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16773. */
  16774. ellipsoid: Vector3;
  16775. /**
  16776. * Define an offset for the position of the ellipsoid around the camera.
  16777. * This can be helpful to determine the center of the body near the gravity center of the body
  16778. * instead of its head.
  16779. */
  16780. ellipsoidOffset: Vector3;
  16781. /**
  16782. * Enable or disable collisions of the camera with the rest of the scene objects.
  16783. */
  16784. checkCollisions: boolean;
  16785. /**
  16786. * Enable or disable gravity on the camera.
  16787. */
  16788. applyGravity: boolean;
  16789. /**
  16790. * Define the input manager associated to the camera.
  16791. */
  16792. inputs: FreeCameraInputsManager;
  16793. /**
  16794. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16795. * Higher values reduce sensitivity.
  16796. */
  16797. /**
  16798. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16799. * Higher values reduce sensitivity.
  16800. */
  16801. angularSensibility: number;
  16802. /**
  16803. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16804. */
  16805. keysUp: number[];
  16806. /**
  16807. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16808. */
  16809. keysDown: number[];
  16810. /**
  16811. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16812. */
  16813. keysLeft: number[];
  16814. /**
  16815. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16816. */
  16817. keysRight: number[];
  16818. /**
  16819. * Event raised when the camera collide with a mesh in the scene.
  16820. */
  16821. onCollide: (collidedMesh: AbstractMesh) => void;
  16822. private _collider;
  16823. private _needMoveForGravity;
  16824. private _oldPosition;
  16825. private _diffPosition;
  16826. private _newPosition;
  16827. /** @hidden */
  16828. _localDirection: Vector3;
  16829. /** @hidden */
  16830. _transformedDirection: Vector3;
  16831. /**
  16832. * Instantiates a Free Camera.
  16833. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16834. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16835. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16836. * @param name Define the name of the camera in the scene
  16837. * @param position Define the start position of the camera in the scene
  16838. * @param scene Define the scene the camera belongs to
  16839. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16840. */
  16841. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16842. /**
  16843. * Attached controls to the current camera.
  16844. * @param element Defines the element the controls should be listened from
  16845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16846. */
  16847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16848. /**
  16849. * Detach the current controls from the camera.
  16850. * The camera will stop reacting to inputs.
  16851. * @param element Defines the element to stop listening the inputs from
  16852. */
  16853. detachControl(element: HTMLElement): void;
  16854. private _collisionMask;
  16855. /**
  16856. * Define a collision mask to limit the list of object the camera can collide with
  16857. */
  16858. collisionMask: number;
  16859. /** @hidden */
  16860. _collideWithWorld(displacement: Vector3): void;
  16861. private _onCollisionPositionChange;
  16862. /** @hidden */
  16863. _checkInputs(): void;
  16864. /** @hidden */
  16865. _decideIfNeedsToMove(): boolean;
  16866. /** @hidden */
  16867. _updatePosition(): void;
  16868. /**
  16869. * Destroy the camera and release the current resources hold by it.
  16870. */
  16871. dispose(): void;
  16872. /**
  16873. * Gets the current object class name.
  16874. * @return the class name
  16875. */
  16876. getClassName(): string;
  16877. }
  16878. }
  16879. declare module BABYLON {
  16880. /**
  16881. * Represents a gamepad control stick position
  16882. */
  16883. export class StickValues {
  16884. /**
  16885. * The x component of the control stick
  16886. */
  16887. x: number;
  16888. /**
  16889. * The y component of the control stick
  16890. */
  16891. y: number;
  16892. /**
  16893. * Initializes the gamepad x and y control stick values
  16894. * @param x The x component of the gamepad control stick value
  16895. * @param y The y component of the gamepad control stick value
  16896. */
  16897. constructor(
  16898. /**
  16899. * The x component of the control stick
  16900. */
  16901. x: number,
  16902. /**
  16903. * The y component of the control stick
  16904. */
  16905. y: number);
  16906. }
  16907. /**
  16908. * An interface which manages callbacks for gamepad button changes
  16909. */
  16910. export interface GamepadButtonChanges {
  16911. /**
  16912. * Called when a gamepad has been changed
  16913. */
  16914. changed: boolean;
  16915. /**
  16916. * Called when a gamepad press event has been triggered
  16917. */
  16918. pressChanged: boolean;
  16919. /**
  16920. * Called when a touch event has been triggered
  16921. */
  16922. touchChanged: boolean;
  16923. /**
  16924. * Called when a value has changed
  16925. */
  16926. valueChanged: boolean;
  16927. }
  16928. /**
  16929. * Represents a gamepad
  16930. */
  16931. export class Gamepad {
  16932. /**
  16933. * The id of the gamepad
  16934. */
  16935. id: string;
  16936. /**
  16937. * The index of the gamepad
  16938. */
  16939. index: number;
  16940. /**
  16941. * The browser gamepad
  16942. */
  16943. browserGamepad: any;
  16944. /**
  16945. * Specifies what type of gamepad this represents
  16946. */
  16947. type: number;
  16948. private _leftStick;
  16949. private _rightStick;
  16950. /** @hidden */
  16951. _isConnected: boolean;
  16952. private _leftStickAxisX;
  16953. private _leftStickAxisY;
  16954. private _rightStickAxisX;
  16955. private _rightStickAxisY;
  16956. /**
  16957. * Triggered when the left control stick has been changed
  16958. */
  16959. private _onleftstickchanged;
  16960. /**
  16961. * Triggered when the right control stick has been changed
  16962. */
  16963. private _onrightstickchanged;
  16964. /**
  16965. * Represents a gamepad controller
  16966. */
  16967. static GAMEPAD: number;
  16968. /**
  16969. * Represents a generic controller
  16970. */
  16971. static GENERIC: number;
  16972. /**
  16973. * Represents an XBox controller
  16974. */
  16975. static XBOX: number;
  16976. /**
  16977. * Represents a pose-enabled controller
  16978. */
  16979. static POSE_ENABLED: number;
  16980. /**
  16981. * Specifies whether the left control stick should be Y-inverted
  16982. */
  16983. protected _invertLeftStickY: boolean;
  16984. /**
  16985. * Specifies if the gamepad has been connected
  16986. */
  16987. readonly isConnected: boolean;
  16988. /**
  16989. * Initializes the gamepad
  16990. * @param id The id of the gamepad
  16991. * @param index The index of the gamepad
  16992. * @param browserGamepad The browser gamepad
  16993. * @param leftStickX The x component of the left joystick
  16994. * @param leftStickY The y component of the left joystick
  16995. * @param rightStickX The x component of the right joystick
  16996. * @param rightStickY The y component of the right joystick
  16997. */
  16998. constructor(
  16999. /**
  17000. * The id of the gamepad
  17001. */
  17002. id: string,
  17003. /**
  17004. * The index of the gamepad
  17005. */
  17006. index: number,
  17007. /**
  17008. * The browser gamepad
  17009. */
  17010. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17011. /**
  17012. * Callback triggered when the left joystick has changed
  17013. * @param callback
  17014. */
  17015. onleftstickchanged(callback: (values: StickValues) => void): void;
  17016. /**
  17017. * Callback triggered when the right joystick has changed
  17018. * @param callback
  17019. */
  17020. onrightstickchanged(callback: (values: StickValues) => void): void;
  17021. /**
  17022. * Gets the left joystick
  17023. */
  17024. /**
  17025. * Sets the left joystick values
  17026. */
  17027. leftStick: StickValues;
  17028. /**
  17029. * Gets the right joystick
  17030. */
  17031. /**
  17032. * Sets the right joystick value
  17033. */
  17034. rightStick: StickValues;
  17035. /**
  17036. * Updates the gamepad joystick positions
  17037. */
  17038. update(): void;
  17039. /**
  17040. * Disposes the gamepad
  17041. */
  17042. dispose(): void;
  17043. }
  17044. /**
  17045. * Represents a generic gamepad
  17046. */
  17047. export class GenericPad extends Gamepad {
  17048. private _buttons;
  17049. private _onbuttondown;
  17050. private _onbuttonup;
  17051. /**
  17052. * Observable triggered when a button has been pressed
  17053. */
  17054. onButtonDownObservable: Observable<number>;
  17055. /**
  17056. * Observable triggered when a button has been released
  17057. */
  17058. onButtonUpObservable: Observable<number>;
  17059. /**
  17060. * Callback triggered when a button has been pressed
  17061. * @param callback Called when a button has been pressed
  17062. */
  17063. onbuttondown(callback: (buttonPressed: number) => void): void;
  17064. /**
  17065. * Callback triggered when a button has been released
  17066. * @param callback Called when a button has been released
  17067. */
  17068. onbuttonup(callback: (buttonReleased: number) => void): void;
  17069. /**
  17070. * Initializes the generic gamepad
  17071. * @param id The id of the generic gamepad
  17072. * @param index The index of the generic gamepad
  17073. * @param browserGamepad The browser gamepad
  17074. */
  17075. constructor(id: string, index: number, browserGamepad: any);
  17076. private _setButtonValue;
  17077. /**
  17078. * Updates the generic gamepad
  17079. */
  17080. update(): void;
  17081. /**
  17082. * Disposes the generic gamepad
  17083. */
  17084. dispose(): void;
  17085. }
  17086. }
  17087. declare module BABYLON {
  17088. /**
  17089. * Defines the types of pose enabled controllers that are supported
  17090. */
  17091. export enum PoseEnabledControllerType {
  17092. /**
  17093. * HTC Vive
  17094. */
  17095. VIVE = 0,
  17096. /**
  17097. * Oculus Rift
  17098. */
  17099. OCULUS = 1,
  17100. /**
  17101. * Windows mixed reality
  17102. */
  17103. WINDOWS = 2,
  17104. /**
  17105. * Samsung gear VR
  17106. */
  17107. GEAR_VR = 3,
  17108. /**
  17109. * Google Daydream
  17110. */
  17111. DAYDREAM = 4,
  17112. /**
  17113. * Generic
  17114. */
  17115. GENERIC = 5
  17116. }
  17117. /**
  17118. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17119. */
  17120. export interface MutableGamepadButton {
  17121. /**
  17122. * Value of the button/trigger
  17123. */
  17124. value: number;
  17125. /**
  17126. * If the button/trigger is currently touched
  17127. */
  17128. touched: boolean;
  17129. /**
  17130. * If the button/trigger is currently pressed
  17131. */
  17132. pressed: boolean;
  17133. }
  17134. /**
  17135. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17136. * @hidden
  17137. */
  17138. export interface ExtendedGamepadButton extends GamepadButton {
  17139. /**
  17140. * If the button/trigger is currently pressed
  17141. */
  17142. readonly pressed: boolean;
  17143. /**
  17144. * If the button/trigger is currently touched
  17145. */
  17146. readonly touched: boolean;
  17147. /**
  17148. * Value of the button/trigger
  17149. */
  17150. readonly value: number;
  17151. }
  17152. /** @hidden */
  17153. export interface _GamePadFactory {
  17154. /**
  17155. * Returns wether or not the current gamepad can be created for this type of controller.
  17156. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17157. * @returns true if it can be created, otherwise false
  17158. */
  17159. canCreate(gamepadInfo: any): boolean;
  17160. /**
  17161. * Creates a new instance of the Gamepad.
  17162. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17163. * @returns the new gamepad instance
  17164. */
  17165. create(gamepadInfo: any): Gamepad;
  17166. }
  17167. /**
  17168. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17169. */
  17170. export class PoseEnabledControllerHelper {
  17171. /** @hidden */
  17172. static _ControllerFactories: _GamePadFactory[];
  17173. /** @hidden */
  17174. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17175. /**
  17176. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17177. * @param vrGamepad the gamepad to initialized
  17178. * @returns a vr controller of the type the gamepad identified as
  17179. */
  17180. static InitiateController(vrGamepad: any): Gamepad;
  17181. }
  17182. /**
  17183. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17184. */
  17185. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17186. private _deviceRoomPosition;
  17187. private _deviceRoomRotationQuaternion;
  17188. /**
  17189. * The device position in babylon space
  17190. */
  17191. devicePosition: Vector3;
  17192. /**
  17193. * The device rotation in babylon space
  17194. */
  17195. deviceRotationQuaternion: Quaternion;
  17196. /**
  17197. * The scale factor of the device in babylon space
  17198. */
  17199. deviceScaleFactor: number;
  17200. /**
  17201. * (Likely devicePosition should be used instead) The device position in its room space
  17202. */
  17203. position: Vector3;
  17204. /**
  17205. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17206. */
  17207. rotationQuaternion: Quaternion;
  17208. /**
  17209. * The type of controller (Eg. Windows mixed reality)
  17210. */
  17211. controllerType: PoseEnabledControllerType;
  17212. protected _calculatedPosition: Vector3;
  17213. private _calculatedRotation;
  17214. /**
  17215. * The raw pose from the device
  17216. */
  17217. rawPose: DevicePose;
  17218. private _trackPosition;
  17219. private _maxRotationDistFromHeadset;
  17220. private _draggedRoomRotation;
  17221. /**
  17222. * @hidden
  17223. */
  17224. _disableTrackPosition(fixedPosition: Vector3): void;
  17225. /**
  17226. * Internal, the mesh attached to the controller
  17227. * @hidden
  17228. */
  17229. _mesh: Nullable<AbstractMesh>;
  17230. private _poseControlledCamera;
  17231. private _leftHandSystemQuaternion;
  17232. /**
  17233. * Internal, matrix used to convert room space to babylon space
  17234. * @hidden
  17235. */
  17236. _deviceToWorld: Matrix;
  17237. /**
  17238. * Node to be used when casting a ray from the controller
  17239. * @hidden
  17240. */
  17241. _pointingPoseNode: Nullable<TransformNode>;
  17242. /**
  17243. * Name of the child mesh that can be used to cast a ray from the controller
  17244. */
  17245. static readonly POINTING_POSE: string;
  17246. /**
  17247. * Creates a new PoseEnabledController from a gamepad
  17248. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17249. */
  17250. constructor(browserGamepad: any);
  17251. private _workingMatrix;
  17252. /**
  17253. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17254. */
  17255. update(): void;
  17256. /**
  17257. * Updates only the pose device and mesh without doing any button event checking
  17258. */
  17259. protected _updatePoseAndMesh(): void;
  17260. /**
  17261. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17262. * @param poseData raw pose fromthe device
  17263. */
  17264. updateFromDevice(poseData: DevicePose): void;
  17265. /**
  17266. * @hidden
  17267. */
  17268. _meshAttachedObservable: Observable<AbstractMesh>;
  17269. /**
  17270. * Attaches a mesh to the controller
  17271. * @param mesh the mesh to be attached
  17272. */
  17273. attachToMesh(mesh: AbstractMesh): void;
  17274. /**
  17275. * Attaches the controllers mesh to a camera
  17276. * @param camera the camera the mesh should be attached to
  17277. */
  17278. attachToPoseControlledCamera(camera: TargetCamera): void;
  17279. /**
  17280. * Disposes of the controller
  17281. */
  17282. dispose(): void;
  17283. /**
  17284. * The mesh that is attached to the controller
  17285. */
  17286. readonly mesh: Nullable<AbstractMesh>;
  17287. /**
  17288. * Gets the ray of the controller in the direction the controller is pointing
  17289. * @param length the length the resulting ray should be
  17290. * @returns a ray in the direction the controller is pointing
  17291. */
  17292. getForwardRay(length?: number): Ray;
  17293. }
  17294. }
  17295. declare module BABYLON {
  17296. /**
  17297. * Defines the WebVRController object that represents controllers tracked in 3D space
  17298. */
  17299. export abstract class WebVRController extends PoseEnabledController {
  17300. /**
  17301. * Internal, the default controller model for the controller
  17302. */
  17303. protected _defaultModel: AbstractMesh;
  17304. /**
  17305. * Fired when the trigger state has changed
  17306. */
  17307. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17308. /**
  17309. * Fired when the main button state has changed
  17310. */
  17311. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17312. /**
  17313. * Fired when the secondary button state has changed
  17314. */
  17315. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17316. /**
  17317. * Fired when the pad state has changed
  17318. */
  17319. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17320. /**
  17321. * Fired when controllers stick values have changed
  17322. */
  17323. onPadValuesChangedObservable: Observable<StickValues>;
  17324. /**
  17325. * Array of button availible on the controller
  17326. */
  17327. protected _buttons: Array<MutableGamepadButton>;
  17328. private _onButtonStateChange;
  17329. /**
  17330. * Fired when a controller button's state has changed
  17331. * @param callback the callback containing the button that was modified
  17332. */
  17333. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17334. /**
  17335. * X and Y axis corresponding to the controllers joystick
  17336. */
  17337. pad: StickValues;
  17338. /**
  17339. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17340. */
  17341. hand: string;
  17342. /**
  17343. * The default controller model for the controller
  17344. */
  17345. readonly defaultModel: AbstractMesh;
  17346. /**
  17347. * Creates a new WebVRController from a gamepad
  17348. * @param vrGamepad the gamepad that the WebVRController should be created from
  17349. */
  17350. constructor(vrGamepad: any);
  17351. /**
  17352. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17353. */
  17354. update(): void;
  17355. /**
  17356. * Function to be called when a button is modified
  17357. */
  17358. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17359. /**
  17360. * Loads a mesh and attaches it to the controller
  17361. * @param scene the scene the mesh should be added to
  17362. * @param meshLoaded callback for when the mesh has been loaded
  17363. */
  17364. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17365. private _setButtonValue;
  17366. private _changes;
  17367. private _checkChanges;
  17368. /**
  17369. * Disposes of th webVRCOntroller
  17370. */
  17371. dispose(): void;
  17372. }
  17373. }
  17374. declare module BABYLON {
  17375. /**
  17376. * The HemisphericLight simulates the ambient environment light,
  17377. * so the passed direction is the light reflection direction, not the incoming direction.
  17378. */
  17379. export class HemisphericLight extends Light {
  17380. /**
  17381. * The groundColor is the light in the opposite direction to the one specified during creation.
  17382. * 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.
  17383. */
  17384. groundColor: Color3;
  17385. /**
  17386. * The light reflection direction, not the incoming direction.
  17387. */
  17388. direction: Vector3;
  17389. /**
  17390. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17391. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17392. * The HemisphericLight can't cast shadows.
  17393. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17394. * @param name The friendly name of the light
  17395. * @param direction The direction of the light reflection
  17396. * @param scene The scene the light belongs to
  17397. */
  17398. constructor(name: string, direction: Vector3, scene: Scene);
  17399. protected _buildUniformLayout(): void;
  17400. /**
  17401. * Returns the string "HemisphericLight".
  17402. * @return The class name
  17403. */
  17404. getClassName(): string;
  17405. /**
  17406. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17407. * Returns the updated direction.
  17408. * @param target The target the direction should point to
  17409. * @return The computed direction
  17410. */
  17411. setDirectionToTarget(target: Vector3): Vector3;
  17412. /**
  17413. * Returns the shadow generator associated to the light.
  17414. * @returns Always null for hemispheric lights because it does not support shadows.
  17415. */
  17416. getShadowGenerator(): Nullable<IShadowGenerator>;
  17417. /**
  17418. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17419. * @param effect The effect to update
  17420. * @param lightIndex The index of the light in the effect to update
  17421. * @returns The hemispheric light
  17422. */
  17423. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17424. /**
  17425. * Computes the world matrix of the node
  17426. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17427. * @param useWasUpdatedFlag defines a reserved property
  17428. * @returns the world matrix
  17429. */
  17430. computeWorldMatrix(): Matrix;
  17431. /**
  17432. * Returns the integer 3.
  17433. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17434. */
  17435. getTypeID(): number;
  17436. /**
  17437. * Prepares the list of defines specific to the light type.
  17438. * @param defines the list of defines
  17439. * @param lightIndex defines the index of the light for the effect
  17440. */
  17441. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17442. }
  17443. }
  17444. declare module BABYLON {
  17445. /** @hidden */
  17446. export var vrMultiviewToSingleviewPixelShader: {
  17447. name: string;
  17448. shader: string;
  17449. };
  17450. }
  17451. declare module BABYLON {
  17452. /**
  17453. * Renders to multiple views with a single draw call
  17454. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17455. */
  17456. export class MultiviewRenderTarget extends RenderTargetTexture {
  17457. /**
  17458. * Creates a multiview render target
  17459. * @param scene scene used with the render target
  17460. * @param size the size of the render target (used for each view)
  17461. */
  17462. constructor(scene: Scene, size?: number | {
  17463. width: number;
  17464. height: number;
  17465. } | {
  17466. ratio: number;
  17467. });
  17468. /**
  17469. * @hidden
  17470. * @param faceIndex the face index, if its a cube texture
  17471. */
  17472. _bindFrameBuffer(faceIndex?: number): void;
  17473. /**
  17474. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17475. * @returns the view count
  17476. */
  17477. getViewCount(): number;
  17478. }
  17479. }
  17480. declare module BABYLON {
  17481. interface Engine {
  17482. /**
  17483. * Creates a new multiview render target
  17484. * @param width defines the width of the texture
  17485. * @param height defines the height of the texture
  17486. * @returns the created multiview texture
  17487. */
  17488. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17489. /**
  17490. * Binds a multiview framebuffer to be drawn to
  17491. * @param multiviewTexture texture to bind
  17492. */
  17493. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17494. }
  17495. interface Camera {
  17496. /**
  17497. * @hidden
  17498. * 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)
  17499. */
  17500. _useMultiviewToSingleView: boolean;
  17501. /**
  17502. * @hidden
  17503. * 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)
  17504. */
  17505. _multiviewTexture: Nullable<RenderTargetTexture>;
  17506. /**
  17507. * @hidden
  17508. * ensures the multiview texture of the camera exists and has the specified width/height
  17509. * @param width height to set on the multiview texture
  17510. * @param height width to set on the multiview texture
  17511. */
  17512. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17513. }
  17514. interface Scene {
  17515. /** @hidden */
  17516. _transformMatrixR: Matrix;
  17517. /** @hidden */
  17518. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17519. /** @hidden */
  17520. _createMultiviewUbo(): void;
  17521. /** @hidden */
  17522. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17523. /** @hidden */
  17524. _renderMultiviewToSingleView(camera: Camera): void;
  17525. }
  17526. }
  17527. declare module BABYLON {
  17528. /**
  17529. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17530. * This will not be used for webXR as it supports displaying texture arrays directly
  17531. */
  17532. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17533. /**
  17534. * Initializes a VRMultiviewToSingleview
  17535. * @param name name of the post process
  17536. * @param camera camera to be applied to
  17537. * @param scaleFactor scaling factor to the size of the output texture
  17538. */
  17539. constructor(name: string, camera: Camera, scaleFactor: number);
  17540. }
  17541. }
  17542. declare module BABYLON {
  17543. interface Engine {
  17544. /** @hidden */
  17545. _vrDisplay: any;
  17546. /** @hidden */
  17547. _vrSupported: boolean;
  17548. /** @hidden */
  17549. _oldSize: Size;
  17550. /** @hidden */
  17551. _oldHardwareScaleFactor: number;
  17552. /** @hidden */
  17553. _vrExclusivePointerMode: boolean;
  17554. /** @hidden */
  17555. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17556. /** @hidden */
  17557. _onVRDisplayPointerRestricted: () => void;
  17558. /** @hidden */
  17559. _onVRDisplayPointerUnrestricted: () => void;
  17560. /** @hidden */
  17561. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17562. /** @hidden */
  17563. _onVrDisplayDisconnect: Nullable<() => void>;
  17564. /** @hidden */
  17565. _onVrDisplayPresentChange: Nullable<() => void>;
  17566. /**
  17567. * Observable signaled when VR display mode changes
  17568. */
  17569. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17570. /**
  17571. * Observable signaled when VR request present is complete
  17572. */
  17573. onVRRequestPresentComplete: Observable<boolean>;
  17574. /**
  17575. * Observable signaled when VR request present starts
  17576. */
  17577. onVRRequestPresentStart: Observable<Engine>;
  17578. /**
  17579. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17580. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17581. */
  17582. isInVRExclusivePointerMode: boolean;
  17583. /**
  17584. * Gets a boolean indicating if a webVR device was detected
  17585. * @returns true if a webVR device was detected
  17586. */
  17587. isVRDevicePresent(): boolean;
  17588. /**
  17589. * Gets the current webVR device
  17590. * @returns the current webVR device (or null)
  17591. */
  17592. getVRDevice(): any;
  17593. /**
  17594. * Initializes a webVR display and starts listening to display change events
  17595. * The onVRDisplayChangedObservable will be notified upon these changes
  17596. * @returns A promise containing a VRDisplay and if vr is supported
  17597. */
  17598. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17599. /** @hidden */
  17600. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17601. /**
  17602. * Call this function to switch to webVR mode
  17603. * Will do nothing if webVR is not supported or if there is no webVR device
  17604. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17605. */
  17606. enableVR(): void;
  17607. /** @hidden */
  17608. _onVRFullScreenTriggered(): void;
  17609. }
  17610. }
  17611. declare module BABYLON {
  17612. /**
  17613. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17614. * IMPORTANT!! The data is right-hand data.
  17615. * @export
  17616. * @interface DevicePose
  17617. */
  17618. export interface DevicePose {
  17619. /**
  17620. * The position of the device, values in array are [x,y,z].
  17621. */
  17622. readonly position: Nullable<Float32Array>;
  17623. /**
  17624. * The linearVelocity of the device, values in array are [x,y,z].
  17625. */
  17626. readonly linearVelocity: Nullable<Float32Array>;
  17627. /**
  17628. * The linearAcceleration of the device, values in array are [x,y,z].
  17629. */
  17630. readonly linearAcceleration: Nullable<Float32Array>;
  17631. /**
  17632. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17633. */
  17634. readonly orientation: Nullable<Float32Array>;
  17635. /**
  17636. * The angularVelocity of the device, values in array are [x,y,z].
  17637. */
  17638. readonly angularVelocity: Nullable<Float32Array>;
  17639. /**
  17640. * The angularAcceleration of the device, values in array are [x,y,z].
  17641. */
  17642. readonly angularAcceleration: Nullable<Float32Array>;
  17643. }
  17644. /**
  17645. * Interface representing a pose controlled object in Babylon.
  17646. * A pose controlled object has both regular pose values as well as pose values
  17647. * from an external device such as a VR head mounted display
  17648. */
  17649. export interface PoseControlled {
  17650. /**
  17651. * The position of the object in babylon space.
  17652. */
  17653. position: Vector3;
  17654. /**
  17655. * The rotation quaternion of the object in babylon space.
  17656. */
  17657. rotationQuaternion: Quaternion;
  17658. /**
  17659. * The position of the device in babylon space.
  17660. */
  17661. devicePosition?: Vector3;
  17662. /**
  17663. * The rotation quaternion of the device in babylon space.
  17664. */
  17665. deviceRotationQuaternion: Quaternion;
  17666. /**
  17667. * The raw pose coming from the device.
  17668. */
  17669. rawPose: Nullable<DevicePose>;
  17670. /**
  17671. * The scale of the device to be used when translating from device space to babylon space.
  17672. */
  17673. deviceScaleFactor: number;
  17674. /**
  17675. * Updates the poseControlled values based on the input device pose.
  17676. * @param poseData the pose data to update the object with
  17677. */
  17678. updateFromDevice(poseData: DevicePose): void;
  17679. }
  17680. /**
  17681. * Set of options to customize the webVRCamera
  17682. */
  17683. export interface WebVROptions {
  17684. /**
  17685. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17686. */
  17687. trackPosition?: boolean;
  17688. /**
  17689. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17690. */
  17691. positionScale?: number;
  17692. /**
  17693. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17694. */
  17695. displayName?: string;
  17696. /**
  17697. * Should the native controller meshes be initialized. (default: true)
  17698. */
  17699. controllerMeshes?: boolean;
  17700. /**
  17701. * Creating a default HemiLight only on controllers. (default: true)
  17702. */
  17703. defaultLightingOnControllers?: boolean;
  17704. /**
  17705. * If you don't want to use the default VR button of the helper. (default: false)
  17706. */
  17707. useCustomVRButton?: boolean;
  17708. /**
  17709. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17710. */
  17711. customVRButton?: HTMLButtonElement;
  17712. /**
  17713. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17714. */
  17715. rayLength?: number;
  17716. /**
  17717. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17718. */
  17719. defaultHeight?: number;
  17720. /**
  17721. * If multiview should be used if availible (default: false)
  17722. */
  17723. useMultiview?: boolean;
  17724. }
  17725. /**
  17726. * This represents a WebVR camera.
  17727. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17728. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17729. */
  17730. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17731. private webVROptions;
  17732. /**
  17733. * @hidden
  17734. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17735. */
  17736. _vrDevice: any;
  17737. /**
  17738. * The rawPose of the vrDevice.
  17739. */
  17740. rawPose: Nullable<DevicePose>;
  17741. private _onVREnabled;
  17742. private _specsVersion;
  17743. private _attached;
  17744. private _frameData;
  17745. protected _descendants: Array<Node>;
  17746. private _deviceRoomPosition;
  17747. /** @hidden */
  17748. _deviceRoomRotationQuaternion: Quaternion;
  17749. private _standingMatrix;
  17750. /**
  17751. * Represents device position in babylon space.
  17752. */
  17753. devicePosition: Vector3;
  17754. /**
  17755. * Represents device rotation in babylon space.
  17756. */
  17757. deviceRotationQuaternion: Quaternion;
  17758. /**
  17759. * The scale of the device to be used when translating from device space to babylon space.
  17760. */
  17761. deviceScaleFactor: number;
  17762. private _deviceToWorld;
  17763. private _worldToDevice;
  17764. /**
  17765. * References to the webVR controllers for the vrDevice.
  17766. */
  17767. controllers: Array<WebVRController>;
  17768. /**
  17769. * Emits an event when a controller is attached.
  17770. */
  17771. onControllersAttachedObservable: Observable<WebVRController[]>;
  17772. /**
  17773. * Emits an event when a controller's mesh has been loaded;
  17774. */
  17775. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17776. /**
  17777. * Emits an event when the HMD's pose has been updated.
  17778. */
  17779. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17780. private _poseSet;
  17781. /**
  17782. * If the rig cameras be used as parent instead of this camera.
  17783. */
  17784. rigParenting: boolean;
  17785. private _lightOnControllers;
  17786. private _defaultHeight?;
  17787. /**
  17788. * Instantiates a WebVRFreeCamera.
  17789. * @param name The name of the WebVRFreeCamera
  17790. * @param position The starting anchor position for the camera
  17791. * @param scene The scene the camera belongs to
  17792. * @param webVROptions a set of customizable options for the webVRCamera
  17793. */
  17794. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17795. /**
  17796. * Gets the device distance from the ground in meters.
  17797. * @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.
  17798. */
  17799. deviceDistanceToRoomGround(): number;
  17800. /**
  17801. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17802. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17803. */
  17804. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17805. /**
  17806. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17807. * @returns A promise with a boolean set to if the standing matrix is supported.
  17808. */
  17809. useStandingMatrixAsync(): Promise<boolean>;
  17810. /**
  17811. * Disposes the camera
  17812. */
  17813. dispose(): void;
  17814. /**
  17815. * Gets a vrController by name.
  17816. * @param name The name of the controller to retreive
  17817. * @returns the controller matching the name specified or null if not found
  17818. */
  17819. getControllerByName(name: string): Nullable<WebVRController>;
  17820. private _leftController;
  17821. /**
  17822. * The controller corresponding to the users left hand.
  17823. */
  17824. readonly leftController: Nullable<WebVRController>;
  17825. private _rightController;
  17826. /**
  17827. * The controller corresponding to the users right hand.
  17828. */
  17829. readonly rightController: Nullable<WebVRController>;
  17830. /**
  17831. * Casts a ray forward from the vrCamera's gaze.
  17832. * @param length Length of the ray (default: 100)
  17833. * @returns the ray corresponding to the gaze
  17834. */
  17835. getForwardRay(length?: number): Ray;
  17836. /**
  17837. * @hidden
  17838. * Updates the camera based on device's frame data
  17839. */
  17840. _checkInputs(): void;
  17841. /**
  17842. * Updates the poseControlled values based on the input device pose.
  17843. * @param poseData Pose coming from the device
  17844. */
  17845. updateFromDevice(poseData: DevicePose): void;
  17846. private _htmlElementAttached;
  17847. private _detachIfAttached;
  17848. /**
  17849. * WebVR's attach control will start broadcasting frames to the device.
  17850. * Note that in certain browsers (chrome for example) this function must be called
  17851. * within a user-interaction callback. Example:
  17852. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17853. *
  17854. * @param element html element to attach the vrDevice to
  17855. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17856. */
  17857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17858. /**
  17859. * Detaches the camera from the html element and disables VR
  17860. *
  17861. * @param element html element to detach from
  17862. */
  17863. detachControl(element: HTMLElement): void;
  17864. /**
  17865. * @returns the name of this class
  17866. */
  17867. getClassName(): string;
  17868. /**
  17869. * Calls resetPose on the vrDisplay
  17870. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17871. */
  17872. resetToCurrentRotation(): void;
  17873. /**
  17874. * @hidden
  17875. * Updates the rig cameras (left and right eye)
  17876. */
  17877. _updateRigCameras(): void;
  17878. private _workingVector;
  17879. private _oneVector;
  17880. private _workingMatrix;
  17881. private updateCacheCalled;
  17882. private _correctPositionIfNotTrackPosition;
  17883. /**
  17884. * @hidden
  17885. * Updates the cached values of the camera
  17886. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17887. */
  17888. _updateCache(ignoreParentClass?: boolean): void;
  17889. /**
  17890. * @hidden
  17891. * Get current device position in babylon world
  17892. */
  17893. _computeDevicePosition(): void;
  17894. /**
  17895. * Updates the current device position and rotation in the babylon world
  17896. */
  17897. update(): void;
  17898. /**
  17899. * @hidden
  17900. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17901. * @returns an identity matrix
  17902. */
  17903. _getViewMatrix(): Matrix;
  17904. private _tmpMatrix;
  17905. /**
  17906. * This function is called by the two RIG cameras.
  17907. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17908. * @hidden
  17909. */
  17910. _getWebVRViewMatrix(): Matrix;
  17911. /** @hidden */
  17912. _getWebVRProjectionMatrix(): Matrix;
  17913. private _onGamepadConnectedObserver;
  17914. private _onGamepadDisconnectedObserver;
  17915. private _updateCacheWhenTrackingDisabledObserver;
  17916. /**
  17917. * Initializes the controllers and their meshes
  17918. */
  17919. initControllers(): void;
  17920. }
  17921. }
  17922. declare module BABYLON {
  17923. /**
  17924. * Size options for a post process
  17925. */
  17926. export type PostProcessOptions = {
  17927. width: number;
  17928. height: number;
  17929. };
  17930. /**
  17931. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17932. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17933. */
  17934. export class PostProcess {
  17935. /** Name of the PostProcess. */
  17936. name: string;
  17937. /**
  17938. * Gets or sets the unique id of the post process
  17939. */
  17940. uniqueId: number;
  17941. /**
  17942. * Width of the texture to apply the post process on
  17943. */
  17944. width: number;
  17945. /**
  17946. * Height of the texture to apply the post process on
  17947. */
  17948. height: number;
  17949. /**
  17950. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17951. * @hidden
  17952. */
  17953. _outputTexture: Nullable<InternalTexture>;
  17954. /**
  17955. * Sampling mode used by the shader
  17956. * See https://doc.babylonjs.com/classes/3.1/texture
  17957. */
  17958. renderTargetSamplingMode: number;
  17959. /**
  17960. * Clear color to use when screen clearing
  17961. */
  17962. clearColor: Color4;
  17963. /**
  17964. * If the buffer needs to be cleared before applying the post process. (default: true)
  17965. * Should be set to false if shader will overwrite all previous pixels.
  17966. */
  17967. autoClear: boolean;
  17968. /**
  17969. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17970. */
  17971. alphaMode: number;
  17972. /**
  17973. * Sets the setAlphaBlendConstants of the babylon engine
  17974. */
  17975. alphaConstants: Color4;
  17976. /**
  17977. * Animations to be used for the post processing
  17978. */
  17979. animations: Animation[];
  17980. /**
  17981. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17982. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17983. */
  17984. enablePixelPerfectMode: boolean;
  17985. /**
  17986. * Force the postprocess to be applied without taking in account viewport
  17987. */
  17988. forceFullscreenViewport: boolean;
  17989. /**
  17990. * List of inspectable custom properties (used by the Inspector)
  17991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17992. */
  17993. inspectableCustomProperties: IInspectable[];
  17994. /**
  17995. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17996. *
  17997. * | Value | Type | Description |
  17998. * | ----- | ----------------------------------- | ----------- |
  17999. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18000. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18001. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18002. *
  18003. */
  18004. scaleMode: number;
  18005. /**
  18006. * Force textures to be a power of two (default: false)
  18007. */
  18008. alwaysForcePOT: boolean;
  18009. private _samples;
  18010. /**
  18011. * Number of sample textures (default: 1)
  18012. */
  18013. samples: number;
  18014. /**
  18015. * Modify the scale of the post process to be the same as the viewport (default: false)
  18016. */
  18017. adaptScaleToCurrentViewport: boolean;
  18018. private _camera;
  18019. private _scene;
  18020. private _engine;
  18021. private _options;
  18022. private _reusable;
  18023. private _textureType;
  18024. /**
  18025. * Smart array of input and output textures for the post process.
  18026. * @hidden
  18027. */
  18028. _textures: SmartArray<InternalTexture>;
  18029. /**
  18030. * The index in _textures that corresponds to the output texture.
  18031. * @hidden
  18032. */
  18033. _currentRenderTextureInd: number;
  18034. private _effect;
  18035. private _samplers;
  18036. private _fragmentUrl;
  18037. private _vertexUrl;
  18038. private _parameters;
  18039. private _scaleRatio;
  18040. protected _indexParameters: any;
  18041. private _shareOutputWithPostProcess;
  18042. private _texelSize;
  18043. private _forcedOutputTexture;
  18044. /**
  18045. * Returns the fragment url or shader name used in the post process.
  18046. * @returns the fragment url or name in the shader store.
  18047. */
  18048. getEffectName(): string;
  18049. /**
  18050. * An event triggered when the postprocess is activated.
  18051. */
  18052. onActivateObservable: Observable<Camera>;
  18053. private _onActivateObserver;
  18054. /**
  18055. * A function that is added to the onActivateObservable
  18056. */
  18057. onActivate: Nullable<(camera: Camera) => void>;
  18058. /**
  18059. * An event triggered when the postprocess changes its size.
  18060. */
  18061. onSizeChangedObservable: Observable<PostProcess>;
  18062. private _onSizeChangedObserver;
  18063. /**
  18064. * A function that is added to the onSizeChangedObservable
  18065. */
  18066. onSizeChanged: (postProcess: PostProcess) => void;
  18067. /**
  18068. * An event triggered when the postprocess applies its effect.
  18069. */
  18070. onApplyObservable: Observable<Effect>;
  18071. private _onApplyObserver;
  18072. /**
  18073. * A function that is added to the onApplyObservable
  18074. */
  18075. onApply: (effect: Effect) => void;
  18076. /**
  18077. * An event triggered before rendering the postprocess
  18078. */
  18079. onBeforeRenderObservable: Observable<Effect>;
  18080. private _onBeforeRenderObserver;
  18081. /**
  18082. * A function that is added to the onBeforeRenderObservable
  18083. */
  18084. onBeforeRender: (effect: Effect) => void;
  18085. /**
  18086. * An event triggered after rendering the postprocess
  18087. */
  18088. onAfterRenderObservable: Observable<Effect>;
  18089. private _onAfterRenderObserver;
  18090. /**
  18091. * A function that is added to the onAfterRenderObservable
  18092. */
  18093. onAfterRender: (efect: Effect) => void;
  18094. /**
  18095. * 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
  18096. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18097. */
  18098. inputTexture: InternalTexture;
  18099. /**
  18100. * Gets the camera which post process is applied to.
  18101. * @returns The camera the post process is applied to.
  18102. */
  18103. getCamera(): Camera;
  18104. /**
  18105. * Gets the texel size of the postprocess.
  18106. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18107. */
  18108. readonly texelSize: Vector2;
  18109. /**
  18110. * Creates a new instance PostProcess
  18111. * @param name The name of the PostProcess.
  18112. * @param fragmentUrl The url of the fragment shader to be used.
  18113. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18114. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18115. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18116. * @param camera The camera to apply the render pass to.
  18117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18118. * @param engine The engine which the post process will be applied. (default: current engine)
  18119. * @param reusable If the post process can be reused on the same frame. (default: false)
  18120. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18121. * @param textureType Type of textures used when performing the post process. (default: 0)
  18122. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18123. * @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
  18124. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18125. */
  18126. constructor(
  18127. /** Name of the PostProcess. */
  18128. 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);
  18129. /**
  18130. * Gets a string idenfifying the name of the class
  18131. * @returns "PostProcess" string
  18132. */
  18133. getClassName(): string;
  18134. /**
  18135. * Gets the engine which this post process belongs to.
  18136. * @returns The engine the post process was enabled with.
  18137. */
  18138. getEngine(): Engine;
  18139. /**
  18140. * The effect that is created when initializing the post process.
  18141. * @returns The created effect corresponding the the postprocess.
  18142. */
  18143. getEffect(): Effect;
  18144. /**
  18145. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18146. * @param postProcess The post process to share the output with.
  18147. * @returns This post process.
  18148. */
  18149. shareOutputWith(postProcess: PostProcess): PostProcess;
  18150. /**
  18151. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18152. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18153. */
  18154. useOwnOutput(): void;
  18155. /**
  18156. * Updates the effect with the current post process compile time values and recompiles the shader.
  18157. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18158. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18159. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18160. * @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
  18161. * @param onCompiled Called when the shader has been compiled.
  18162. * @param onError Called if there is an error when compiling a shader.
  18163. */
  18164. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18165. /**
  18166. * The post process is reusable if it can be used multiple times within one frame.
  18167. * @returns If the post process is reusable
  18168. */
  18169. isReusable(): boolean;
  18170. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18171. markTextureDirty(): void;
  18172. /**
  18173. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18174. * 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.
  18175. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18176. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18177. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18178. * @returns The target texture that was bound to be written to.
  18179. */
  18180. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18181. /**
  18182. * If the post process is supported.
  18183. */
  18184. readonly isSupported: boolean;
  18185. /**
  18186. * The aspect ratio of the output texture.
  18187. */
  18188. readonly aspectRatio: number;
  18189. /**
  18190. * Get a value indicating if the post-process is ready to be used
  18191. * @returns true if the post-process is ready (shader is compiled)
  18192. */
  18193. isReady(): boolean;
  18194. /**
  18195. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18196. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18197. */
  18198. apply(): Nullable<Effect>;
  18199. private _disposeTextures;
  18200. /**
  18201. * Disposes the post process.
  18202. * @param camera The camera to dispose the post process on.
  18203. */
  18204. dispose(camera?: Camera): void;
  18205. }
  18206. }
  18207. declare module BABYLON {
  18208. /** @hidden */
  18209. export var kernelBlurVaryingDeclaration: {
  18210. name: string;
  18211. shader: string;
  18212. };
  18213. }
  18214. declare module BABYLON {
  18215. /** @hidden */
  18216. export var kernelBlurFragment: {
  18217. name: string;
  18218. shader: string;
  18219. };
  18220. }
  18221. declare module BABYLON {
  18222. /** @hidden */
  18223. export var kernelBlurFragment2: {
  18224. name: string;
  18225. shader: string;
  18226. };
  18227. }
  18228. declare module BABYLON {
  18229. /** @hidden */
  18230. export var kernelBlurPixelShader: {
  18231. name: string;
  18232. shader: string;
  18233. };
  18234. }
  18235. declare module BABYLON {
  18236. /** @hidden */
  18237. export var kernelBlurVertex: {
  18238. name: string;
  18239. shader: string;
  18240. };
  18241. }
  18242. declare module BABYLON {
  18243. /** @hidden */
  18244. export var kernelBlurVertexShader: {
  18245. name: string;
  18246. shader: string;
  18247. };
  18248. }
  18249. declare module BABYLON {
  18250. /**
  18251. * The Blur Post Process which blurs an image based on a kernel and direction.
  18252. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18253. */
  18254. export class BlurPostProcess extends PostProcess {
  18255. /** The direction in which to blur the image. */
  18256. direction: Vector2;
  18257. private blockCompilation;
  18258. protected _kernel: number;
  18259. protected _idealKernel: number;
  18260. protected _packedFloat: boolean;
  18261. private _staticDefines;
  18262. /**
  18263. * Sets the length in pixels of the blur sample region
  18264. */
  18265. /**
  18266. * Gets the length in pixels of the blur sample region
  18267. */
  18268. kernel: number;
  18269. /**
  18270. * Sets wether or not the blur needs to unpack/repack floats
  18271. */
  18272. /**
  18273. * Gets wether or not the blur is unpacking/repacking floats
  18274. */
  18275. packedFloat: boolean;
  18276. /**
  18277. * Creates a new instance BlurPostProcess
  18278. * @param name The name of the effect.
  18279. * @param direction The direction in which to blur the image.
  18280. * @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.
  18281. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18282. * @param camera The camera to apply the render pass to.
  18283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18284. * @param engine The engine which the post process will be applied. (default: current engine)
  18285. * @param reusable If the post process can be reused on the same frame. (default: false)
  18286. * @param textureType Type of textures used when performing the post process. (default: 0)
  18287. * @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)
  18288. */
  18289. constructor(name: string,
  18290. /** The direction in which to blur the image. */
  18291. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18292. /**
  18293. * Updates the effect with the current post process compile time values and recompiles the shader.
  18294. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18295. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18296. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18297. * @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
  18298. * @param onCompiled Called when the shader has been compiled.
  18299. * @param onError Called if there is an error when compiling a shader.
  18300. */
  18301. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18302. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18303. /**
  18304. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18305. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18306. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18307. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18308. * The gaps between physical kernels are compensated for in the weighting of the samples
  18309. * @param idealKernel Ideal blur kernel.
  18310. * @return Nearest best kernel.
  18311. */
  18312. protected _nearestBestKernel(idealKernel: number): number;
  18313. /**
  18314. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18315. * @param x The point on the Gaussian distribution to sample.
  18316. * @return the value of the Gaussian function at x.
  18317. */
  18318. protected _gaussianWeight(x: number): number;
  18319. /**
  18320. * Generates a string that can be used as a floating point number in GLSL.
  18321. * @param x Value to print.
  18322. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18323. * @return GLSL float string.
  18324. */
  18325. protected _glslFloat(x: number, decimalFigures?: number): string;
  18326. }
  18327. }
  18328. declare module BABYLON {
  18329. /**
  18330. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18331. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18332. * You can then easily use it as a reflectionTexture on a flat surface.
  18333. * In case the surface is not a plane, please consider relying on reflection probes.
  18334. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18335. */
  18336. export class MirrorTexture extends RenderTargetTexture {
  18337. private scene;
  18338. /**
  18339. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18340. * 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.
  18341. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18342. */
  18343. mirrorPlane: Plane;
  18344. /**
  18345. * Define the blur ratio used to blur the reflection if needed.
  18346. */
  18347. blurRatio: number;
  18348. /**
  18349. * Define the adaptive blur kernel used to blur the reflection if needed.
  18350. * This will autocompute the closest best match for the `blurKernel`
  18351. */
  18352. adaptiveBlurKernel: number;
  18353. /**
  18354. * Define the blur kernel used to blur the reflection if needed.
  18355. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18356. */
  18357. blurKernel: number;
  18358. /**
  18359. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18360. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18361. */
  18362. blurKernelX: number;
  18363. /**
  18364. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18365. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18366. */
  18367. blurKernelY: number;
  18368. private _autoComputeBlurKernel;
  18369. protected _onRatioRescale(): void;
  18370. private _updateGammaSpace;
  18371. private _imageProcessingConfigChangeObserver;
  18372. private _transformMatrix;
  18373. private _mirrorMatrix;
  18374. private _savedViewMatrix;
  18375. private _blurX;
  18376. private _blurY;
  18377. private _adaptiveBlurKernel;
  18378. private _blurKernelX;
  18379. private _blurKernelY;
  18380. private _blurRatio;
  18381. /**
  18382. * Instantiates a Mirror Texture.
  18383. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18384. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18385. * You can then easily use it as a reflectionTexture on a flat surface.
  18386. * In case the surface is not a plane, please consider relying on reflection probes.
  18387. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18388. * @param name
  18389. * @param size
  18390. * @param scene
  18391. * @param generateMipMaps
  18392. * @param type
  18393. * @param samplingMode
  18394. * @param generateDepthBuffer
  18395. */
  18396. constructor(name: string, size: number | {
  18397. width: number;
  18398. height: number;
  18399. } | {
  18400. ratio: number;
  18401. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18402. private _preparePostProcesses;
  18403. /**
  18404. * Clone the mirror texture.
  18405. * @returns the cloned texture
  18406. */
  18407. clone(): MirrorTexture;
  18408. /**
  18409. * Serialize the texture to a JSON representation you could use in Parse later on
  18410. * @returns the serialized JSON representation
  18411. */
  18412. serialize(): any;
  18413. /**
  18414. * Dispose the texture and release its associated resources.
  18415. */
  18416. dispose(): void;
  18417. }
  18418. }
  18419. declare module BABYLON {
  18420. /**
  18421. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18422. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18423. */
  18424. export class Texture extends BaseTexture {
  18425. /** @hidden */
  18426. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18427. /** @hidden */
  18428. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18429. /** @hidden */
  18430. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18431. /** nearest is mag = nearest and min = nearest and mip = linear */
  18432. static readonly NEAREST_SAMPLINGMODE: number;
  18433. /** nearest is mag = nearest and min = nearest and mip = linear */
  18434. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18435. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18436. static readonly BILINEAR_SAMPLINGMODE: number;
  18437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18438. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18439. /** Trilinear is mag = linear and min = linear and mip = linear */
  18440. static readonly TRILINEAR_SAMPLINGMODE: number;
  18441. /** Trilinear is mag = linear and min = linear and mip = linear */
  18442. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18443. /** mag = nearest and min = nearest and mip = nearest */
  18444. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18445. /** mag = nearest and min = linear and mip = nearest */
  18446. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18447. /** mag = nearest and min = linear and mip = linear */
  18448. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18449. /** mag = nearest and min = linear and mip = none */
  18450. static readonly NEAREST_LINEAR: number;
  18451. /** mag = nearest and min = nearest and mip = none */
  18452. static readonly NEAREST_NEAREST: number;
  18453. /** mag = linear and min = nearest and mip = nearest */
  18454. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18455. /** mag = linear and min = nearest and mip = linear */
  18456. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18457. /** mag = linear and min = linear and mip = none */
  18458. static readonly LINEAR_LINEAR: number;
  18459. /** mag = linear and min = nearest and mip = none */
  18460. static readonly LINEAR_NEAREST: number;
  18461. /** Explicit coordinates mode */
  18462. static readonly EXPLICIT_MODE: number;
  18463. /** Spherical coordinates mode */
  18464. static readonly SPHERICAL_MODE: number;
  18465. /** Planar coordinates mode */
  18466. static readonly PLANAR_MODE: number;
  18467. /** Cubic coordinates mode */
  18468. static readonly CUBIC_MODE: number;
  18469. /** Projection coordinates mode */
  18470. static readonly PROJECTION_MODE: number;
  18471. /** Inverse Cubic coordinates mode */
  18472. static readonly SKYBOX_MODE: number;
  18473. /** Inverse Cubic coordinates mode */
  18474. static readonly INVCUBIC_MODE: number;
  18475. /** Equirectangular coordinates mode */
  18476. static readonly EQUIRECTANGULAR_MODE: number;
  18477. /** Equirectangular Fixed coordinates mode */
  18478. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18479. /** Equirectangular Fixed Mirrored coordinates mode */
  18480. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18481. /** Texture is not repeating outside of 0..1 UVs */
  18482. static readonly CLAMP_ADDRESSMODE: number;
  18483. /** Texture is repeating outside of 0..1 UVs */
  18484. static readonly WRAP_ADDRESSMODE: number;
  18485. /** Texture is repeating and mirrored */
  18486. static readonly MIRROR_ADDRESSMODE: number;
  18487. /**
  18488. * 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
  18489. */
  18490. static UseSerializedUrlIfAny: boolean;
  18491. /**
  18492. * Define the url of the texture.
  18493. */
  18494. url: Nullable<string>;
  18495. /**
  18496. * Define an offset on the texture to offset the u coordinates of the UVs
  18497. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18498. */
  18499. uOffset: number;
  18500. /**
  18501. * Define an offset on the texture to offset the v coordinates of the UVs
  18502. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18503. */
  18504. vOffset: number;
  18505. /**
  18506. * Define an offset on the texture to scale the u coordinates of the UVs
  18507. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18508. */
  18509. uScale: number;
  18510. /**
  18511. * Define an offset on the texture to scale the v coordinates of the UVs
  18512. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18513. */
  18514. vScale: number;
  18515. /**
  18516. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18517. * @see http://doc.babylonjs.com/how_to/more_materials
  18518. */
  18519. uAng: number;
  18520. /**
  18521. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18522. * @see http://doc.babylonjs.com/how_to/more_materials
  18523. */
  18524. vAng: number;
  18525. /**
  18526. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18527. * @see http://doc.babylonjs.com/how_to/more_materials
  18528. */
  18529. wAng: number;
  18530. /**
  18531. * Defines the center of rotation (U)
  18532. */
  18533. uRotationCenter: number;
  18534. /**
  18535. * Defines the center of rotation (V)
  18536. */
  18537. vRotationCenter: number;
  18538. /**
  18539. * Defines the center of rotation (W)
  18540. */
  18541. wRotationCenter: number;
  18542. /**
  18543. * Are mip maps generated for this texture or not.
  18544. */
  18545. readonly noMipmap: boolean;
  18546. /**
  18547. * List of inspectable custom properties (used by the Inspector)
  18548. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18549. */
  18550. inspectableCustomProperties: Nullable<IInspectable[]>;
  18551. private _noMipmap;
  18552. /** @hidden */
  18553. _invertY: boolean;
  18554. private _rowGenerationMatrix;
  18555. private _cachedTextureMatrix;
  18556. private _projectionModeMatrix;
  18557. private _t0;
  18558. private _t1;
  18559. private _t2;
  18560. private _cachedUOffset;
  18561. private _cachedVOffset;
  18562. private _cachedUScale;
  18563. private _cachedVScale;
  18564. private _cachedUAng;
  18565. private _cachedVAng;
  18566. private _cachedWAng;
  18567. private _cachedProjectionMatrixId;
  18568. private _cachedCoordinatesMode;
  18569. /** @hidden */
  18570. protected _initialSamplingMode: number;
  18571. /** @hidden */
  18572. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18573. private _deleteBuffer;
  18574. protected _format: Nullable<number>;
  18575. private _delayedOnLoad;
  18576. private _delayedOnError;
  18577. /**
  18578. * Observable triggered once the texture has been loaded.
  18579. */
  18580. onLoadObservable: Observable<Texture>;
  18581. protected _isBlocking: boolean;
  18582. /**
  18583. * Is the texture preventing material to render while loading.
  18584. * If false, a default texture will be used instead of the loading one during the preparation step.
  18585. */
  18586. isBlocking: boolean;
  18587. /**
  18588. * Get the current sampling mode associated with the texture.
  18589. */
  18590. readonly samplingMode: number;
  18591. /**
  18592. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18593. */
  18594. readonly invertY: boolean;
  18595. /**
  18596. * Instantiates a new texture.
  18597. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18598. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18599. * @param url define the url of the picture to load as a texture
  18600. * @param scene define the scene the texture will belong to
  18601. * @param noMipmap define if the texture will require mip maps or not
  18602. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18603. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18604. * @param onLoad define a callback triggered when the texture has been loaded
  18605. * @param onError define a callback triggered when an error occurred during the loading session
  18606. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18607. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18608. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18609. */
  18610. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18611. /**
  18612. * Update the url (and optional buffer) of this texture if url was null during construction.
  18613. * @param url the url of the texture
  18614. * @param buffer the buffer of the texture (defaults to null)
  18615. * @param onLoad callback called when the texture is loaded (defaults to null)
  18616. */
  18617. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18618. /**
  18619. * Finish the loading sequence of a texture flagged as delayed load.
  18620. * @hidden
  18621. */
  18622. delayLoad(): void;
  18623. private _prepareRowForTextureGeneration;
  18624. /**
  18625. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18626. * @returns the transform matrix of the texture.
  18627. */
  18628. getTextureMatrix(): Matrix;
  18629. /**
  18630. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18631. * @returns The reflection texture transform
  18632. */
  18633. getReflectionTextureMatrix(): Matrix;
  18634. /**
  18635. * Clones the texture.
  18636. * @returns the cloned texture
  18637. */
  18638. clone(): Texture;
  18639. /**
  18640. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18641. * @returns The JSON representation of the texture
  18642. */
  18643. serialize(): any;
  18644. /**
  18645. * Get the current class name of the texture useful for serialization or dynamic coding.
  18646. * @returns "Texture"
  18647. */
  18648. getClassName(): string;
  18649. /**
  18650. * Dispose the texture and release its associated resources.
  18651. */
  18652. dispose(): void;
  18653. /**
  18654. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18655. * @param parsedTexture Define the JSON representation of the texture
  18656. * @param scene Define the scene the parsed texture should be instantiated in
  18657. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18658. * @returns The parsed texture if successful
  18659. */
  18660. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18661. /**
  18662. * Creates a texture from its base 64 representation.
  18663. * @param data Define the base64 payload without the data: prefix
  18664. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18665. * @param scene Define the scene the texture should belong to
  18666. * @param noMipmap Forces the texture to not create mip map information if true
  18667. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18668. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18669. * @param onLoad define a callback triggered when the texture has been loaded
  18670. * @param onError define a callback triggered when an error occurred during the loading session
  18671. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18672. * @returns the created texture
  18673. */
  18674. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18675. /**
  18676. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18677. * @param data Define the base64 payload without the data: prefix
  18678. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18679. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18680. * @param scene Define the scene the texture should belong to
  18681. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18682. * @param noMipmap Forces the texture to not create mip map information if true
  18683. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18684. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18685. * @param onLoad define a callback triggered when the texture has been loaded
  18686. * @param onError define a callback triggered when an error occurred during the loading session
  18687. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18688. * @returns the created texture
  18689. */
  18690. 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;
  18691. }
  18692. }
  18693. declare module BABYLON {
  18694. /**
  18695. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18696. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18697. */
  18698. export class PostProcessManager {
  18699. private _scene;
  18700. private _indexBuffer;
  18701. private _vertexBuffers;
  18702. /**
  18703. * Creates a new instance PostProcess
  18704. * @param scene The scene that the post process is associated with.
  18705. */
  18706. constructor(scene: Scene);
  18707. private _prepareBuffers;
  18708. private _buildIndexBuffer;
  18709. /**
  18710. * Rebuilds the vertex buffers of the manager.
  18711. * @hidden
  18712. */
  18713. _rebuild(): void;
  18714. /**
  18715. * Prepares a frame to be run through a post process.
  18716. * @param sourceTexture The input texture to the post procesess. (default: null)
  18717. * @param postProcesses An array of post processes to be run. (default: null)
  18718. * @returns True if the post processes were able to be run.
  18719. * @hidden
  18720. */
  18721. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18722. /**
  18723. * Manually render a set of post processes to a texture.
  18724. * @param postProcesses An array of post processes to be run.
  18725. * @param targetTexture The target texture to render to.
  18726. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18727. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18728. * @param lodLevel defines which lod of the texture to render to
  18729. */
  18730. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18731. /**
  18732. * Finalize the result of the output of the postprocesses.
  18733. * @param doNotPresent If true the result will not be displayed to the screen.
  18734. * @param targetTexture The target texture to render to.
  18735. * @param faceIndex The index of the face to bind the target texture to.
  18736. * @param postProcesses The array of post processes to render.
  18737. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18738. * @hidden
  18739. */
  18740. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18741. /**
  18742. * Disposes of the post process manager.
  18743. */
  18744. dispose(): void;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. interface AbstractScene {
  18749. /**
  18750. * The list of procedural textures added to the scene
  18751. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18752. */
  18753. proceduralTextures: Array<ProceduralTexture>;
  18754. }
  18755. /**
  18756. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18757. * in a given scene.
  18758. */
  18759. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18760. /**
  18761. * The component name helpfull to identify the component in the list of scene components.
  18762. */
  18763. readonly name: string;
  18764. /**
  18765. * The scene the component belongs to.
  18766. */
  18767. scene: Scene;
  18768. /**
  18769. * Creates a new instance of the component for the given scene
  18770. * @param scene Defines the scene to register the component in
  18771. */
  18772. constructor(scene: Scene);
  18773. /**
  18774. * Registers the component in a given scene
  18775. */
  18776. register(): void;
  18777. /**
  18778. * Rebuilds the elements related to this component in case of
  18779. * context lost for instance.
  18780. */
  18781. rebuild(): void;
  18782. /**
  18783. * Disposes the component and the associated ressources.
  18784. */
  18785. dispose(): void;
  18786. private _beforeClear;
  18787. }
  18788. }
  18789. declare module BABYLON {
  18790. interface Engine {
  18791. /**
  18792. * Creates a new render target cube texture
  18793. * @param size defines the size of the texture
  18794. * @param options defines the options used to create the texture
  18795. * @returns a new render target cube texture stored in an InternalTexture
  18796. */
  18797. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18798. }
  18799. }
  18800. declare module BABYLON {
  18801. /** @hidden */
  18802. export var proceduralVertexShader: {
  18803. name: string;
  18804. shader: string;
  18805. };
  18806. }
  18807. declare module BABYLON {
  18808. /**
  18809. * 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.
  18810. * This is the base class of any Procedural texture and contains most of the shareable code.
  18811. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18812. */
  18813. export class ProceduralTexture extends Texture {
  18814. isCube: boolean;
  18815. /**
  18816. * Define if the texture is enabled or not (disabled texture will not render)
  18817. */
  18818. isEnabled: boolean;
  18819. /**
  18820. * Define if the texture must be cleared before rendering (default is true)
  18821. */
  18822. autoClear: boolean;
  18823. /**
  18824. * Callback called when the texture is generated
  18825. */
  18826. onGenerated: () => void;
  18827. /**
  18828. * Event raised when the texture is generated
  18829. */
  18830. onGeneratedObservable: Observable<ProceduralTexture>;
  18831. /** @hidden */
  18832. _generateMipMaps: boolean;
  18833. /** @hidden **/
  18834. _effect: Effect;
  18835. /** @hidden */
  18836. _textures: {
  18837. [key: string]: Texture;
  18838. };
  18839. private _size;
  18840. private _currentRefreshId;
  18841. private _refreshRate;
  18842. private _vertexBuffers;
  18843. private _indexBuffer;
  18844. private _uniforms;
  18845. private _samplers;
  18846. private _fragment;
  18847. private _floats;
  18848. private _ints;
  18849. private _floatsArrays;
  18850. private _colors3;
  18851. private _colors4;
  18852. private _vectors2;
  18853. private _vectors3;
  18854. private _matrices;
  18855. private _fallbackTexture;
  18856. private _fallbackTextureUsed;
  18857. private _engine;
  18858. private _cachedDefines;
  18859. private _contentUpdateId;
  18860. private _contentData;
  18861. /**
  18862. * Instantiates a new procedural texture.
  18863. * 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.
  18864. * This is the base class of any Procedural texture and contains most of the shareable code.
  18865. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18866. * @param name Define the name of the texture
  18867. * @param size Define the size of the texture to create
  18868. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18869. * @param scene Define the scene the texture belongs to
  18870. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18871. * @param generateMipMaps Define if the texture should creates mip maps or not
  18872. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18873. */
  18874. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18875. /**
  18876. * The effect that is created when initializing the post process.
  18877. * @returns The created effect corresponding the the postprocess.
  18878. */
  18879. getEffect(): Effect;
  18880. /**
  18881. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18882. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18883. */
  18884. getContent(): Nullable<ArrayBufferView>;
  18885. private _createIndexBuffer;
  18886. /** @hidden */
  18887. _rebuild(): void;
  18888. /**
  18889. * Resets the texture in order to recreate its associated resources.
  18890. * This can be called in case of context loss
  18891. */
  18892. reset(): void;
  18893. protected _getDefines(): string;
  18894. /**
  18895. * Is the texture ready to be used ? (rendered at least once)
  18896. * @returns true if ready, otherwise, false.
  18897. */
  18898. isReady(): boolean;
  18899. /**
  18900. * Resets the refresh counter of the texture and start bak from scratch.
  18901. * Could be useful to regenerate the texture if it is setup to render only once.
  18902. */
  18903. resetRefreshCounter(): void;
  18904. /**
  18905. * Set the fragment shader to use in order to render the texture.
  18906. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18907. */
  18908. setFragment(fragment: any): void;
  18909. /**
  18910. * Define the refresh rate of the texture or the rendering frequency.
  18911. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18912. */
  18913. refreshRate: number;
  18914. /** @hidden */
  18915. _shouldRender(): boolean;
  18916. /**
  18917. * Get the size the texture is rendering at.
  18918. * @returns the size (texture is always squared)
  18919. */
  18920. getRenderSize(): number;
  18921. /**
  18922. * Resize the texture to new value.
  18923. * @param size Define the new size the texture should have
  18924. * @param generateMipMaps Define whether the new texture should create mip maps
  18925. */
  18926. resize(size: number, generateMipMaps: boolean): void;
  18927. private _checkUniform;
  18928. /**
  18929. * Set a texture in the shader program used to render.
  18930. * @param name Define the name of the uniform samplers as defined in the shader
  18931. * @param texture Define the texture to bind to this sampler
  18932. * @return the texture itself allowing "fluent" like uniform updates
  18933. */
  18934. setTexture(name: string, texture: Texture): ProceduralTexture;
  18935. /**
  18936. * Set a float in the shader.
  18937. * @param name Define the name of the uniform as defined in the shader
  18938. * @param value Define the value to give to the uniform
  18939. * @return the texture itself allowing "fluent" like uniform updates
  18940. */
  18941. setFloat(name: string, value: number): ProceduralTexture;
  18942. /**
  18943. * Set a int in the shader.
  18944. * @param name Define the name of the uniform as defined in the shader
  18945. * @param value Define the value to give to the uniform
  18946. * @return the texture itself allowing "fluent" like uniform updates
  18947. */
  18948. setInt(name: string, value: number): ProceduralTexture;
  18949. /**
  18950. * Set an array of floats in the shader.
  18951. * @param name Define the name of the uniform as defined in the shader
  18952. * @param value Define the value to give to the uniform
  18953. * @return the texture itself allowing "fluent" like uniform updates
  18954. */
  18955. setFloats(name: string, value: number[]): ProceduralTexture;
  18956. /**
  18957. * Set a vec3 in the shader from a Color3.
  18958. * @param name Define the name of the uniform as defined in the shader
  18959. * @param value Define the value to give to the uniform
  18960. * @return the texture itself allowing "fluent" like uniform updates
  18961. */
  18962. setColor3(name: string, value: Color3): ProceduralTexture;
  18963. /**
  18964. * Set a vec4 in the shader from a Color4.
  18965. * @param name Define the name of the uniform as defined in the shader
  18966. * @param value Define the value to give to the uniform
  18967. * @return the texture itself allowing "fluent" like uniform updates
  18968. */
  18969. setColor4(name: string, value: Color4): ProceduralTexture;
  18970. /**
  18971. * Set a vec2 in the shader from a Vector2.
  18972. * @param name Define the name of the uniform as defined in the shader
  18973. * @param value Define the value to give to the uniform
  18974. * @return the texture itself allowing "fluent" like uniform updates
  18975. */
  18976. setVector2(name: string, value: Vector2): ProceduralTexture;
  18977. /**
  18978. * Set a vec3 in the shader from a Vector3.
  18979. * @param name Define the name of the uniform as defined in the shader
  18980. * @param value Define the value to give to the uniform
  18981. * @return the texture itself allowing "fluent" like uniform updates
  18982. */
  18983. setVector3(name: string, value: Vector3): ProceduralTexture;
  18984. /**
  18985. * Set a mat4 in the shader from a MAtrix.
  18986. * @param name Define the name of the uniform as defined in the shader
  18987. * @param value Define the value to give to the uniform
  18988. * @return the texture itself allowing "fluent" like uniform updates
  18989. */
  18990. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18991. /**
  18992. * Render the texture to its associated render target.
  18993. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18994. */
  18995. render(useCameraPostProcess?: boolean): void;
  18996. /**
  18997. * Clone the texture.
  18998. * @returns the cloned texture
  18999. */
  19000. clone(): ProceduralTexture;
  19001. /**
  19002. * Dispose the texture and release its asoociated resources.
  19003. */
  19004. dispose(): void;
  19005. }
  19006. }
  19007. declare module BABYLON {
  19008. /**
  19009. * This represents the base class for particle system in Babylon.
  19010. * 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.
  19011. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19012. * @example https://doc.babylonjs.com/babylon101/particles
  19013. */
  19014. export class BaseParticleSystem {
  19015. /**
  19016. * Source color is added to the destination color without alpha affecting the result
  19017. */
  19018. static BLENDMODE_ONEONE: number;
  19019. /**
  19020. * Blend current color and particle color using particle’s alpha
  19021. */
  19022. static BLENDMODE_STANDARD: number;
  19023. /**
  19024. * Add current color and particle color multiplied by particle’s alpha
  19025. */
  19026. static BLENDMODE_ADD: number;
  19027. /**
  19028. * Multiply current color with particle color
  19029. */
  19030. static BLENDMODE_MULTIPLY: number;
  19031. /**
  19032. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19033. */
  19034. static BLENDMODE_MULTIPLYADD: number;
  19035. /**
  19036. * List of animations used by the particle system.
  19037. */
  19038. animations: Animation[];
  19039. /**
  19040. * The id of the Particle system.
  19041. */
  19042. id: string;
  19043. /**
  19044. * The friendly name of the Particle system.
  19045. */
  19046. name: string;
  19047. /**
  19048. * The rendering group used by the Particle system to chose when to render.
  19049. */
  19050. renderingGroupId: number;
  19051. /**
  19052. * The emitter represents the Mesh or position we are attaching the particle system to.
  19053. */
  19054. emitter: Nullable<AbstractMesh | Vector3>;
  19055. /**
  19056. * The maximum number of particles to emit per frame
  19057. */
  19058. emitRate: number;
  19059. /**
  19060. * If you want to launch only a few particles at once, that can be done, as well.
  19061. */
  19062. manualEmitCount: number;
  19063. /**
  19064. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19065. */
  19066. updateSpeed: number;
  19067. /**
  19068. * The amount of time the particle system is running (depends of the overall update speed).
  19069. */
  19070. targetStopDuration: number;
  19071. /**
  19072. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19073. */
  19074. disposeOnStop: boolean;
  19075. /**
  19076. * Minimum power of emitting particles.
  19077. */
  19078. minEmitPower: number;
  19079. /**
  19080. * Maximum power of emitting particles.
  19081. */
  19082. maxEmitPower: number;
  19083. /**
  19084. * Minimum life time of emitting particles.
  19085. */
  19086. minLifeTime: number;
  19087. /**
  19088. * Maximum life time of emitting particles.
  19089. */
  19090. maxLifeTime: number;
  19091. /**
  19092. * Minimum Size of emitting particles.
  19093. */
  19094. minSize: number;
  19095. /**
  19096. * Maximum Size of emitting particles.
  19097. */
  19098. maxSize: number;
  19099. /**
  19100. * Minimum scale of emitting particles on X axis.
  19101. */
  19102. minScaleX: number;
  19103. /**
  19104. * Maximum scale of emitting particles on X axis.
  19105. */
  19106. maxScaleX: number;
  19107. /**
  19108. * Minimum scale of emitting particles on Y axis.
  19109. */
  19110. minScaleY: number;
  19111. /**
  19112. * Maximum scale of emitting particles on Y axis.
  19113. */
  19114. maxScaleY: number;
  19115. /**
  19116. * Gets or sets the minimal initial rotation in radians.
  19117. */
  19118. minInitialRotation: number;
  19119. /**
  19120. * Gets or sets the maximal initial rotation in radians.
  19121. */
  19122. maxInitialRotation: number;
  19123. /**
  19124. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19125. */
  19126. minAngularSpeed: number;
  19127. /**
  19128. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19129. */
  19130. maxAngularSpeed: number;
  19131. /**
  19132. * The texture used to render each particle. (this can be a spritesheet)
  19133. */
  19134. particleTexture: Nullable<Texture>;
  19135. /**
  19136. * The layer mask we are rendering the particles through.
  19137. */
  19138. layerMask: number;
  19139. /**
  19140. * This can help using your own shader to render the particle system.
  19141. * The according effect will be created
  19142. */
  19143. customShader: any;
  19144. /**
  19145. * By default particle system starts as soon as they are created. This prevents the
  19146. * automatic start to happen and let you decide when to start emitting particles.
  19147. */
  19148. preventAutoStart: boolean;
  19149. private _noiseTexture;
  19150. /**
  19151. * Gets or sets a texture used to add random noise to particle positions
  19152. */
  19153. noiseTexture: Nullable<ProceduralTexture>;
  19154. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19155. noiseStrength: Vector3;
  19156. /**
  19157. * Callback triggered when the particle animation is ending.
  19158. */
  19159. onAnimationEnd: Nullable<() => void>;
  19160. /**
  19161. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19162. */
  19163. blendMode: number;
  19164. /**
  19165. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19166. * to override the particles.
  19167. */
  19168. forceDepthWrite: boolean;
  19169. /** 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 */
  19170. preWarmCycles: number;
  19171. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19172. preWarmStepOffset: number;
  19173. /**
  19174. * 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)
  19175. */
  19176. spriteCellChangeSpeed: number;
  19177. /**
  19178. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19179. */
  19180. startSpriteCellID: number;
  19181. /**
  19182. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19183. */
  19184. endSpriteCellID: number;
  19185. /**
  19186. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19187. */
  19188. spriteCellWidth: number;
  19189. /**
  19190. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19191. */
  19192. spriteCellHeight: number;
  19193. /**
  19194. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19195. */
  19196. spriteRandomStartCell: boolean;
  19197. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19198. translationPivot: Vector2;
  19199. /** @hidden */
  19200. protected _isAnimationSheetEnabled: boolean;
  19201. /**
  19202. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19203. */
  19204. beginAnimationOnStart: boolean;
  19205. /**
  19206. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19207. */
  19208. beginAnimationFrom: number;
  19209. /**
  19210. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19211. */
  19212. beginAnimationTo: number;
  19213. /**
  19214. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19215. */
  19216. beginAnimationLoop: boolean;
  19217. /**
  19218. * Gets or sets a world offset applied to all particles
  19219. */
  19220. worldOffset: Vector3;
  19221. /**
  19222. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19223. */
  19224. isAnimationSheetEnabled: boolean;
  19225. /**
  19226. * Get hosting scene
  19227. * @returns the scene
  19228. */
  19229. getScene(): Scene;
  19230. /**
  19231. * You can use gravity if you want to give an orientation to your particles.
  19232. */
  19233. gravity: Vector3;
  19234. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19235. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19236. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19237. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19238. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19239. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19240. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19241. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19242. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19243. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19244. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19245. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19246. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19247. /**
  19248. * Defines the delay in milliseconds before starting the system (0 by default)
  19249. */
  19250. startDelay: number;
  19251. /**
  19252. * Gets the current list of drag gradients.
  19253. * You must use addDragGradient and removeDragGradient to udpate this list
  19254. * @returns the list of drag gradients
  19255. */
  19256. getDragGradients(): Nullable<Array<FactorGradient>>;
  19257. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19258. limitVelocityDamping: number;
  19259. /**
  19260. * Gets the current list of limit velocity gradients.
  19261. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19262. * @returns the list of limit velocity gradients
  19263. */
  19264. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19265. /**
  19266. * Gets the current list of color gradients.
  19267. * You must use addColorGradient and removeColorGradient to udpate this list
  19268. * @returns the list of color gradients
  19269. */
  19270. getColorGradients(): Nullable<Array<ColorGradient>>;
  19271. /**
  19272. * Gets the current list of size gradients.
  19273. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19274. * @returns the list of size gradients
  19275. */
  19276. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19277. /**
  19278. * Gets the current list of color remap gradients.
  19279. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19280. * @returns the list of color remap gradients
  19281. */
  19282. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Gets the current list of alpha remap gradients.
  19285. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19286. * @returns the list of alpha remap gradients
  19287. */
  19288. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19289. /**
  19290. * Gets the current list of life time gradients.
  19291. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19292. * @returns the list of life time gradients
  19293. */
  19294. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Gets the current list of angular speed gradients.
  19297. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19298. * @returns the list of angular speed gradients
  19299. */
  19300. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19301. /**
  19302. * Gets the current list of velocity gradients.
  19303. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19304. * @returns the list of velocity gradients
  19305. */
  19306. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19307. /**
  19308. * Gets the current list of start size gradients.
  19309. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19310. * @returns the list of start size gradients
  19311. */
  19312. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19313. /**
  19314. * Gets the current list of emit rate gradients.
  19315. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19316. * @returns the list of emit rate gradients
  19317. */
  19318. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19319. /**
  19320. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19321. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19322. */
  19323. direction1: Vector3;
  19324. /**
  19325. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19326. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19327. */
  19328. direction2: Vector3;
  19329. /**
  19330. * 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.
  19331. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19332. */
  19333. minEmitBox: Vector3;
  19334. /**
  19335. * 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.
  19336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19337. */
  19338. maxEmitBox: Vector3;
  19339. /**
  19340. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19341. */
  19342. color1: Color4;
  19343. /**
  19344. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19345. */
  19346. color2: Color4;
  19347. /**
  19348. * Color the particle will have at the end of its lifetime
  19349. */
  19350. colorDead: Color4;
  19351. /**
  19352. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19353. */
  19354. textureMask: Color4;
  19355. /**
  19356. * The particle emitter type defines the emitter used by the particle system.
  19357. * It can be for example box, sphere, or cone...
  19358. */
  19359. particleEmitterType: IParticleEmitterType;
  19360. /** @hidden */
  19361. _isSubEmitter: boolean;
  19362. /**
  19363. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19364. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19365. */
  19366. billboardMode: number;
  19367. protected _isBillboardBased: boolean;
  19368. /**
  19369. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19370. */
  19371. isBillboardBased: boolean;
  19372. /**
  19373. * The scene the particle system belongs to.
  19374. */
  19375. protected _scene: Scene;
  19376. /**
  19377. * Local cache of defines for image processing.
  19378. */
  19379. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19380. /**
  19381. * Default configuration related to image processing available in the standard Material.
  19382. */
  19383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19384. /**
  19385. * Gets the image processing configuration used either in this material.
  19386. */
  19387. /**
  19388. * Sets the Default image processing configuration used either in the this material.
  19389. *
  19390. * If sets to null, the scene one is in use.
  19391. */
  19392. imageProcessingConfiguration: ImageProcessingConfiguration;
  19393. /**
  19394. * Attaches a new image processing configuration to the Standard Material.
  19395. * @param configuration
  19396. */
  19397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19398. /** @hidden */
  19399. protected _reset(): void;
  19400. /** @hidden */
  19401. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19402. /**
  19403. * Instantiates a particle system.
  19404. * 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.
  19405. * @param name The name of the particle system
  19406. */
  19407. constructor(name: string);
  19408. /**
  19409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19412. * @returns the emitter
  19413. */
  19414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19415. /**
  19416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19417. * @param radius The radius of the hemisphere to emit from
  19418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19419. * @returns the emitter
  19420. */
  19421. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19422. /**
  19423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19424. * @param radius The radius of the sphere to emit from
  19425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19426. * @returns the emitter
  19427. */
  19428. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19429. /**
  19430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19431. * @param radius The radius of the sphere to emit from
  19432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19434. * @returns the emitter
  19435. */
  19436. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19437. /**
  19438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19439. * @param radius The radius of the emission cylinder
  19440. * @param height The height of the emission cylinder
  19441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19443. * @returns the emitter
  19444. */
  19445. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19446. /**
  19447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19448. * @param radius The radius of the cylinder to emit from
  19449. * @param height The height of the emission cylinder
  19450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19453. * @returns the emitter
  19454. */
  19455. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19456. /**
  19457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19458. * @param radius The radius of the cone to emit from
  19459. * @param angle The base angle of the cone
  19460. * @returns the emitter
  19461. */
  19462. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19463. /**
  19464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19469. * @returns the emitter
  19470. */
  19471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19472. }
  19473. }
  19474. declare module BABYLON {
  19475. /**
  19476. * Type of sub emitter
  19477. */
  19478. export enum SubEmitterType {
  19479. /**
  19480. * Attached to the particle over it's lifetime
  19481. */
  19482. ATTACHED = 0,
  19483. /**
  19484. * Created when the particle dies
  19485. */
  19486. END = 1
  19487. }
  19488. /**
  19489. * Sub emitter class used to emit particles from an existing particle
  19490. */
  19491. export class SubEmitter {
  19492. /**
  19493. * the particle system to be used by the sub emitter
  19494. */
  19495. particleSystem: ParticleSystem;
  19496. /**
  19497. * Type of the submitter (Default: END)
  19498. */
  19499. type: SubEmitterType;
  19500. /**
  19501. * 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)
  19502. * Note: This only is supported when using an emitter of type Mesh
  19503. */
  19504. inheritDirection: boolean;
  19505. /**
  19506. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19507. */
  19508. inheritedVelocityAmount: number;
  19509. /**
  19510. * Creates a sub emitter
  19511. * @param particleSystem the particle system to be used by the sub emitter
  19512. */
  19513. constructor(
  19514. /**
  19515. * the particle system to be used by the sub emitter
  19516. */
  19517. particleSystem: ParticleSystem);
  19518. /**
  19519. * Clones the sub emitter
  19520. * @returns the cloned sub emitter
  19521. */
  19522. clone(): SubEmitter;
  19523. /**
  19524. * Serialize current object to a JSON object
  19525. * @returns the serialized object
  19526. */
  19527. serialize(): any;
  19528. /** @hidden */
  19529. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19530. /**
  19531. * Creates a new SubEmitter from a serialized JSON version
  19532. * @param serializationObject defines the JSON object to read from
  19533. * @param scene defines the hosting scene
  19534. * @param rootUrl defines the rootUrl for data loading
  19535. * @returns a new SubEmitter
  19536. */
  19537. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19538. /** Release associated resources */
  19539. dispose(): void;
  19540. }
  19541. }
  19542. declare module BABYLON {
  19543. /** @hidden */
  19544. export var imageProcessingDeclaration: {
  19545. name: string;
  19546. shader: string;
  19547. };
  19548. }
  19549. declare module BABYLON {
  19550. /** @hidden */
  19551. export var imageProcessingFunctions: {
  19552. name: string;
  19553. shader: string;
  19554. };
  19555. }
  19556. declare module BABYLON {
  19557. /** @hidden */
  19558. export var particlesPixelShader: {
  19559. name: string;
  19560. shader: string;
  19561. };
  19562. }
  19563. declare module BABYLON {
  19564. /** @hidden */
  19565. export var particlesVertexShader: {
  19566. name: string;
  19567. shader: string;
  19568. };
  19569. }
  19570. declare module BABYLON {
  19571. /**
  19572. * This represents a particle system in Babylon.
  19573. * 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.
  19574. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19575. * @example https://doc.babylonjs.com/babylon101/particles
  19576. */
  19577. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19578. /**
  19579. * Billboard mode will only apply to Y axis
  19580. */
  19581. static readonly BILLBOARDMODE_Y: number;
  19582. /**
  19583. * Billboard mode will apply to all axes
  19584. */
  19585. static readonly BILLBOARDMODE_ALL: number;
  19586. /**
  19587. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19588. */
  19589. static readonly BILLBOARDMODE_STRETCHED: number;
  19590. /**
  19591. * This function can be defined to provide custom update for active particles.
  19592. * This function will be called instead of regular update (age, position, color, etc.).
  19593. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19594. */
  19595. updateFunction: (particles: Particle[]) => void;
  19596. private _emitterWorldMatrix;
  19597. /**
  19598. * This function can be defined to specify initial direction for every new particle.
  19599. * It by default use the emitterType defined function
  19600. */
  19601. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19602. /**
  19603. * This function can be defined to specify initial position for every new particle.
  19604. * It by default use the emitterType defined function
  19605. */
  19606. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19607. /**
  19608. * @hidden
  19609. */
  19610. _inheritedVelocityOffset: Vector3;
  19611. /**
  19612. * An event triggered when the system is disposed
  19613. */
  19614. onDisposeObservable: Observable<ParticleSystem>;
  19615. private _onDisposeObserver;
  19616. /**
  19617. * Sets a callback that will be triggered when the system is disposed
  19618. */
  19619. onDispose: () => void;
  19620. private _particles;
  19621. private _epsilon;
  19622. private _capacity;
  19623. private _stockParticles;
  19624. private _newPartsExcess;
  19625. private _vertexData;
  19626. private _vertexBuffer;
  19627. private _vertexBuffers;
  19628. private _spriteBuffer;
  19629. private _indexBuffer;
  19630. private _effect;
  19631. private _customEffect;
  19632. private _cachedDefines;
  19633. private _scaledColorStep;
  19634. private _colorDiff;
  19635. private _scaledDirection;
  19636. private _scaledGravity;
  19637. private _currentRenderId;
  19638. private _alive;
  19639. private _useInstancing;
  19640. private _started;
  19641. private _stopped;
  19642. private _actualFrame;
  19643. private _scaledUpdateSpeed;
  19644. private _vertexBufferSize;
  19645. /** @hidden */
  19646. _currentEmitRateGradient: Nullable<FactorGradient>;
  19647. /** @hidden */
  19648. _currentEmitRate1: number;
  19649. /** @hidden */
  19650. _currentEmitRate2: number;
  19651. /** @hidden */
  19652. _currentStartSizeGradient: Nullable<FactorGradient>;
  19653. /** @hidden */
  19654. _currentStartSize1: number;
  19655. /** @hidden */
  19656. _currentStartSize2: number;
  19657. private readonly _rawTextureWidth;
  19658. private _rampGradientsTexture;
  19659. private _useRampGradients;
  19660. /** Gets or sets a boolean indicating that ramp gradients must be used
  19661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19662. */
  19663. useRampGradients: boolean;
  19664. /**
  19665. * 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.
  19666. * 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: [])
  19667. */
  19668. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19669. private _subEmitters;
  19670. /**
  19671. * @hidden
  19672. * If the particle systems emitter should be disposed when the particle system is disposed
  19673. */
  19674. _disposeEmitterOnDispose: boolean;
  19675. /**
  19676. * The current active Sub-systems, this property is used by the root particle system only.
  19677. */
  19678. activeSubSystems: Array<ParticleSystem>;
  19679. private _rootParticleSystem;
  19680. /**
  19681. * Gets the current list of active particles
  19682. */
  19683. readonly particles: Particle[];
  19684. /**
  19685. * Returns the string "ParticleSystem"
  19686. * @returns a string containing the class name
  19687. */
  19688. getClassName(): string;
  19689. /**
  19690. * Instantiates a particle system.
  19691. * 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.
  19692. * @param name The name of the particle system
  19693. * @param capacity The max number of particles alive at the same time
  19694. * @param scene The scene the particle system belongs to
  19695. * @param customEffect a custom effect used to change the way particles are rendered by default
  19696. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19697. * @param epsilon Offset used to render the particles
  19698. */
  19699. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19700. private _addFactorGradient;
  19701. private _removeFactorGradient;
  19702. /**
  19703. * Adds a new life time gradient
  19704. * @param gradient defines the gradient to use (between 0 and 1)
  19705. * @param factor defines the life time factor to affect to the specified gradient
  19706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19707. * @returns the current particle system
  19708. */
  19709. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19710. /**
  19711. * Remove a specific life time gradient
  19712. * @param gradient defines the gradient to remove
  19713. * @returns the current particle system
  19714. */
  19715. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19716. /**
  19717. * Adds a new size gradient
  19718. * @param gradient defines the gradient to use (between 0 and 1)
  19719. * @param factor defines the size factor to affect to the specified gradient
  19720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19721. * @returns the current particle system
  19722. */
  19723. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19724. /**
  19725. * Remove a specific size gradient
  19726. * @param gradient defines the gradient to remove
  19727. * @returns the current particle system
  19728. */
  19729. removeSizeGradient(gradient: number): IParticleSystem;
  19730. /**
  19731. * Adds a new color remap gradient
  19732. * @param gradient defines the gradient to use (between 0 and 1)
  19733. * @param min defines the color remap minimal range
  19734. * @param max defines the color remap maximal range
  19735. * @returns the current particle system
  19736. */
  19737. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19738. /**
  19739. * Remove a specific color remap gradient
  19740. * @param gradient defines the gradient to remove
  19741. * @returns the current particle system
  19742. */
  19743. removeColorRemapGradient(gradient: number): IParticleSystem;
  19744. /**
  19745. * Adds a new alpha remap gradient
  19746. * @param gradient defines the gradient to use (between 0 and 1)
  19747. * @param min defines the alpha remap minimal range
  19748. * @param max defines the alpha remap maximal range
  19749. * @returns the current particle system
  19750. */
  19751. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19752. /**
  19753. * Remove a specific alpha remap gradient
  19754. * @param gradient defines the gradient to remove
  19755. * @returns the current particle system
  19756. */
  19757. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19758. /**
  19759. * Adds a new angular speed gradient
  19760. * @param gradient defines the gradient to use (between 0 and 1)
  19761. * @param factor defines the angular speed to affect to the specified gradient
  19762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19763. * @returns the current particle system
  19764. */
  19765. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19766. /**
  19767. * Remove a specific angular speed gradient
  19768. * @param gradient defines the gradient to remove
  19769. * @returns the current particle system
  19770. */
  19771. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19772. /**
  19773. * Adds a new velocity gradient
  19774. * @param gradient defines the gradient to use (between 0 and 1)
  19775. * @param factor defines the velocity to affect to the specified gradient
  19776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19777. * @returns the current particle system
  19778. */
  19779. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19780. /**
  19781. * Remove a specific velocity gradient
  19782. * @param gradient defines the gradient to remove
  19783. * @returns the current particle system
  19784. */
  19785. removeVelocityGradient(gradient: number): IParticleSystem;
  19786. /**
  19787. * Adds a new limit velocity gradient
  19788. * @param gradient defines the gradient to use (between 0 and 1)
  19789. * @param factor defines the limit velocity value to affect to the specified gradient
  19790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19791. * @returns the current particle system
  19792. */
  19793. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19794. /**
  19795. * Remove a specific limit velocity gradient
  19796. * @param gradient defines the gradient to remove
  19797. * @returns the current particle system
  19798. */
  19799. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19800. /**
  19801. * Adds a new drag gradient
  19802. * @param gradient defines the gradient to use (between 0 and 1)
  19803. * @param factor defines the drag value to affect to the specified gradient
  19804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19805. * @returns the current particle system
  19806. */
  19807. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19808. /**
  19809. * Remove a specific drag gradient
  19810. * @param gradient defines the gradient to remove
  19811. * @returns the current particle system
  19812. */
  19813. removeDragGradient(gradient: number): IParticleSystem;
  19814. /**
  19815. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19816. * @param gradient defines the gradient to use (between 0 and 1)
  19817. * @param factor defines the emit rate value to affect to the specified gradient
  19818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19819. * @returns the current particle system
  19820. */
  19821. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19822. /**
  19823. * Remove a specific emit rate gradient
  19824. * @param gradient defines the gradient to remove
  19825. * @returns the current particle system
  19826. */
  19827. removeEmitRateGradient(gradient: number): IParticleSystem;
  19828. /**
  19829. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19830. * @param gradient defines the gradient to use (between 0 and 1)
  19831. * @param factor defines the start size value to affect to the specified gradient
  19832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19833. * @returns the current particle system
  19834. */
  19835. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19836. /**
  19837. * Remove a specific start size gradient
  19838. * @param gradient defines the gradient to remove
  19839. * @returns the current particle system
  19840. */
  19841. removeStartSizeGradient(gradient: number): IParticleSystem;
  19842. private _createRampGradientTexture;
  19843. /**
  19844. * Gets the current list of ramp gradients.
  19845. * You must use addRampGradient and removeRampGradient to udpate this list
  19846. * @returns the list of ramp gradients
  19847. */
  19848. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19849. /**
  19850. * Adds a new ramp gradient used to remap particle colors
  19851. * @param gradient defines the gradient to use (between 0 and 1)
  19852. * @param color defines the color to affect to the specified gradient
  19853. * @returns the current particle system
  19854. */
  19855. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19856. /**
  19857. * Remove a specific ramp gradient
  19858. * @param gradient defines the gradient to remove
  19859. * @returns the current particle system
  19860. */
  19861. removeRampGradient(gradient: number): ParticleSystem;
  19862. /**
  19863. * Adds a new color gradient
  19864. * @param gradient defines the gradient to use (between 0 and 1)
  19865. * @param color1 defines the color to affect to the specified gradient
  19866. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19867. * @returns this particle system
  19868. */
  19869. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19870. /**
  19871. * Remove a specific color gradient
  19872. * @param gradient defines the gradient to remove
  19873. * @returns this particle system
  19874. */
  19875. removeColorGradient(gradient: number): IParticleSystem;
  19876. private _fetchR;
  19877. protected _reset(): void;
  19878. private _resetEffect;
  19879. private _createVertexBuffers;
  19880. private _createIndexBuffer;
  19881. /**
  19882. * Gets the maximum number of particles active at the same time.
  19883. * @returns The max number of active particles.
  19884. */
  19885. getCapacity(): number;
  19886. /**
  19887. * Gets whether there are still active particles in the system.
  19888. * @returns True if it is alive, otherwise false.
  19889. */
  19890. isAlive(): boolean;
  19891. /**
  19892. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19893. * @returns True if it has been started, otherwise false.
  19894. */
  19895. isStarted(): boolean;
  19896. private _prepareSubEmitterInternalArray;
  19897. /**
  19898. * Starts the particle system and begins to emit
  19899. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19900. */
  19901. start(delay?: number): void;
  19902. /**
  19903. * Stops the particle system.
  19904. * @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.
  19905. */
  19906. stop(stopSubEmitters?: boolean): void;
  19907. /**
  19908. * Remove all active particles
  19909. */
  19910. reset(): void;
  19911. /**
  19912. * @hidden (for internal use only)
  19913. */
  19914. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19915. /**
  19916. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19917. * Its lifetime will start back at 0.
  19918. */
  19919. recycleParticle: (particle: Particle) => void;
  19920. private _stopSubEmitters;
  19921. private _createParticle;
  19922. private _removeFromRoot;
  19923. private _emitFromParticle;
  19924. private _update;
  19925. /** @hidden */
  19926. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19927. /** @hidden */
  19928. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19929. /** @hidden */
  19930. private _getEffect;
  19931. /**
  19932. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19933. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19934. */
  19935. animate(preWarmOnly?: boolean): void;
  19936. private _appendParticleVertices;
  19937. /**
  19938. * Rebuilds the particle system.
  19939. */
  19940. rebuild(): void;
  19941. /**
  19942. * Is this system ready to be used/rendered
  19943. * @return true if the system is ready
  19944. */
  19945. isReady(): boolean;
  19946. private _render;
  19947. /**
  19948. * Renders the particle system in its current state.
  19949. * @returns the current number of particles
  19950. */
  19951. render(): number;
  19952. /**
  19953. * Disposes the particle system and free the associated resources
  19954. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19955. */
  19956. dispose(disposeTexture?: boolean): void;
  19957. /**
  19958. * Clones the particle system.
  19959. * @param name The name of the cloned object
  19960. * @param newEmitter The new emitter to use
  19961. * @returns the cloned particle system
  19962. */
  19963. clone(name: string, newEmitter: any): ParticleSystem;
  19964. /**
  19965. * Serializes the particle system to a JSON object.
  19966. * @returns the JSON object
  19967. */
  19968. serialize(): any;
  19969. /** @hidden */
  19970. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19971. /** @hidden */
  19972. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19973. /**
  19974. * Parses a JSON object to create a particle system.
  19975. * @param parsedParticleSystem The JSON object to parse
  19976. * @param scene The scene to create the particle system in
  19977. * @param rootUrl The root url to use to load external dependencies like texture
  19978. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19979. * @returns the Parsed particle system
  19980. */
  19981. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19982. }
  19983. }
  19984. declare module BABYLON {
  19985. /**
  19986. * A particle represents one of the element emitted by a particle system.
  19987. * This is mainly define by its coordinates, direction, velocity and age.
  19988. */
  19989. export class Particle {
  19990. /**
  19991. * The particle system the particle belongs to.
  19992. */
  19993. particleSystem: ParticleSystem;
  19994. private static _Count;
  19995. /**
  19996. * Unique ID of the particle
  19997. */
  19998. id: number;
  19999. /**
  20000. * The world position of the particle in the scene.
  20001. */
  20002. position: Vector3;
  20003. /**
  20004. * The world direction of the particle in the scene.
  20005. */
  20006. direction: Vector3;
  20007. /**
  20008. * The color of the particle.
  20009. */
  20010. color: Color4;
  20011. /**
  20012. * The color change of the particle per step.
  20013. */
  20014. colorStep: Color4;
  20015. /**
  20016. * Defines how long will the life of the particle be.
  20017. */
  20018. lifeTime: number;
  20019. /**
  20020. * The current age of the particle.
  20021. */
  20022. age: number;
  20023. /**
  20024. * The current size of the particle.
  20025. */
  20026. size: number;
  20027. /**
  20028. * The current scale of the particle.
  20029. */
  20030. scale: Vector2;
  20031. /**
  20032. * The current angle of the particle.
  20033. */
  20034. angle: number;
  20035. /**
  20036. * Defines how fast is the angle changing.
  20037. */
  20038. angularSpeed: number;
  20039. /**
  20040. * Defines the cell index used by the particle to be rendered from a sprite.
  20041. */
  20042. cellIndex: number;
  20043. /**
  20044. * The information required to support color remapping
  20045. */
  20046. remapData: Vector4;
  20047. /** @hidden */
  20048. _randomCellOffset?: number;
  20049. /** @hidden */
  20050. _initialDirection: Nullable<Vector3>;
  20051. /** @hidden */
  20052. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20053. /** @hidden */
  20054. _initialStartSpriteCellID: number;
  20055. /** @hidden */
  20056. _initialEndSpriteCellID: number;
  20057. /** @hidden */
  20058. _currentColorGradient: Nullable<ColorGradient>;
  20059. /** @hidden */
  20060. _currentColor1: Color4;
  20061. /** @hidden */
  20062. _currentColor2: Color4;
  20063. /** @hidden */
  20064. _currentSizeGradient: Nullable<FactorGradient>;
  20065. /** @hidden */
  20066. _currentSize1: number;
  20067. /** @hidden */
  20068. _currentSize2: number;
  20069. /** @hidden */
  20070. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20071. /** @hidden */
  20072. _currentAngularSpeed1: number;
  20073. /** @hidden */
  20074. _currentAngularSpeed2: number;
  20075. /** @hidden */
  20076. _currentVelocityGradient: Nullable<FactorGradient>;
  20077. /** @hidden */
  20078. _currentVelocity1: number;
  20079. /** @hidden */
  20080. _currentVelocity2: number;
  20081. /** @hidden */
  20082. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20083. /** @hidden */
  20084. _currentLimitVelocity1: number;
  20085. /** @hidden */
  20086. _currentLimitVelocity2: number;
  20087. /** @hidden */
  20088. _currentDragGradient: Nullable<FactorGradient>;
  20089. /** @hidden */
  20090. _currentDrag1: number;
  20091. /** @hidden */
  20092. _currentDrag2: number;
  20093. /** @hidden */
  20094. _randomNoiseCoordinates1: Vector3;
  20095. /** @hidden */
  20096. _randomNoiseCoordinates2: Vector3;
  20097. /**
  20098. * Creates a new instance Particle
  20099. * @param particleSystem the particle system the particle belongs to
  20100. */
  20101. constructor(
  20102. /**
  20103. * The particle system the particle belongs to.
  20104. */
  20105. particleSystem: ParticleSystem);
  20106. private updateCellInfoFromSystem;
  20107. /**
  20108. * Defines how the sprite cell index is updated for the particle
  20109. */
  20110. updateCellIndex(): void;
  20111. /** @hidden */
  20112. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20113. /** @hidden */
  20114. _inheritParticleInfoToSubEmitters(): void;
  20115. /** @hidden */
  20116. _reset(): void;
  20117. /**
  20118. * Copy the properties of particle to another one.
  20119. * @param other the particle to copy the information to.
  20120. */
  20121. copyTo(other: Particle): void;
  20122. }
  20123. }
  20124. declare module BABYLON {
  20125. /**
  20126. * Particle emitter represents a volume emitting particles.
  20127. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20128. */
  20129. export interface IParticleEmitterType {
  20130. /**
  20131. * Called by the particle System when the direction is computed for the created particle.
  20132. * @param worldMatrix is the world matrix of the particle system
  20133. * @param directionToUpdate is the direction vector to update with the result
  20134. * @param particle is the particle we are computed the direction for
  20135. */
  20136. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20137. /**
  20138. * Called by the particle System when the position is computed for the created particle.
  20139. * @param worldMatrix is the world matrix of the particle system
  20140. * @param positionToUpdate is the position vector to update with the result
  20141. * @param particle is the particle we are computed the position for
  20142. */
  20143. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20144. /**
  20145. * Clones the current emitter and returns a copy of it
  20146. * @returns the new emitter
  20147. */
  20148. clone(): IParticleEmitterType;
  20149. /**
  20150. * Called by the GPUParticleSystem to setup the update shader
  20151. * @param effect defines the update shader
  20152. */
  20153. applyToShader(effect: Effect): void;
  20154. /**
  20155. * Returns a string to use to update the GPU particles update shader
  20156. * @returns the effect defines string
  20157. */
  20158. getEffectDefines(): string;
  20159. /**
  20160. * Returns a string representing the class name
  20161. * @returns a string containing the class name
  20162. */
  20163. getClassName(): string;
  20164. /**
  20165. * Serializes the particle system to a JSON object.
  20166. * @returns the JSON object
  20167. */
  20168. serialize(): any;
  20169. /**
  20170. * Parse properties from a JSON object
  20171. * @param serializationObject defines the JSON object
  20172. */
  20173. parse(serializationObject: any): void;
  20174. }
  20175. }
  20176. declare module BABYLON {
  20177. /**
  20178. * Particle emitter emitting particles from the inside of a box.
  20179. * It emits the particles randomly between 2 given directions.
  20180. */
  20181. export class BoxParticleEmitter implements IParticleEmitterType {
  20182. /**
  20183. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20184. */
  20185. direction1: Vector3;
  20186. /**
  20187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20188. */
  20189. direction2: Vector3;
  20190. /**
  20191. * 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.
  20192. */
  20193. minEmitBox: Vector3;
  20194. /**
  20195. * 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.
  20196. */
  20197. maxEmitBox: Vector3;
  20198. /**
  20199. * Creates a new instance BoxParticleEmitter
  20200. */
  20201. constructor();
  20202. /**
  20203. * Called by the particle System when the direction is computed for the created particle.
  20204. * @param worldMatrix is the world matrix of the particle system
  20205. * @param directionToUpdate is the direction vector to update with the result
  20206. * @param particle is the particle we are computed the direction for
  20207. */
  20208. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20209. /**
  20210. * Called by the particle System when the position is computed for the created particle.
  20211. * @param worldMatrix is the world matrix of the particle system
  20212. * @param positionToUpdate is the position vector to update with the result
  20213. * @param particle is the particle we are computed the position for
  20214. */
  20215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20216. /**
  20217. * Clones the current emitter and returns a copy of it
  20218. * @returns the new emitter
  20219. */
  20220. clone(): BoxParticleEmitter;
  20221. /**
  20222. * Called by the GPUParticleSystem to setup the update shader
  20223. * @param effect defines the update shader
  20224. */
  20225. applyToShader(effect: Effect): void;
  20226. /**
  20227. * Returns a string to use to update the GPU particles update shader
  20228. * @returns a string containng the defines string
  20229. */
  20230. getEffectDefines(): string;
  20231. /**
  20232. * Returns the string "BoxParticleEmitter"
  20233. * @returns a string containing the class name
  20234. */
  20235. getClassName(): string;
  20236. /**
  20237. * Serializes the particle system to a JSON object.
  20238. * @returns the JSON object
  20239. */
  20240. serialize(): any;
  20241. /**
  20242. * Parse properties from a JSON object
  20243. * @param serializationObject defines the JSON object
  20244. */
  20245. parse(serializationObject: any): void;
  20246. }
  20247. }
  20248. declare module BABYLON {
  20249. /**
  20250. * Particle emitter emitting particles from the inside of a cone.
  20251. * It emits the particles alongside the cone volume from the base to the particle.
  20252. * The emission direction might be randomized.
  20253. */
  20254. export class ConeParticleEmitter implements IParticleEmitterType {
  20255. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20256. directionRandomizer: number;
  20257. private _radius;
  20258. private _angle;
  20259. private _height;
  20260. /**
  20261. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20262. */
  20263. radiusRange: number;
  20264. /**
  20265. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20266. */
  20267. heightRange: number;
  20268. /**
  20269. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20270. */
  20271. emitFromSpawnPointOnly: boolean;
  20272. /**
  20273. * Gets or sets the radius of the emission cone
  20274. */
  20275. radius: number;
  20276. /**
  20277. * Gets or sets the angle of the emission cone
  20278. */
  20279. angle: number;
  20280. private _buildHeight;
  20281. /**
  20282. * Creates a new instance ConeParticleEmitter
  20283. * @param radius the radius of the emission cone (1 by default)
  20284. * @param angle the cone base angle (PI by default)
  20285. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20286. */
  20287. constructor(radius?: number, angle?: number,
  20288. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20289. directionRandomizer?: number);
  20290. /**
  20291. * Called by the particle System when the direction is computed for the created particle.
  20292. * @param worldMatrix is the world matrix of the particle system
  20293. * @param directionToUpdate is the direction vector to update with the result
  20294. * @param particle is the particle we are computed the direction for
  20295. */
  20296. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20297. /**
  20298. * Called by the particle System when the position is computed for the created particle.
  20299. * @param worldMatrix is the world matrix of the particle system
  20300. * @param positionToUpdate is the position vector to update with the result
  20301. * @param particle is the particle we are computed the position for
  20302. */
  20303. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20304. /**
  20305. * Clones the current emitter and returns a copy of it
  20306. * @returns the new emitter
  20307. */
  20308. clone(): ConeParticleEmitter;
  20309. /**
  20310. * Called by the GPUParticleSystem to setup the update shader
  20311. * @param effect defines the update shader
  20312. */
  20313. applyToShader(effect: Effect): void;
  20314. /**
  20315. * Returns a string to use to update the GPU particles update shader
  20316. * @returns a string containng the defines string
  20317. */
  20318. getEffectDefines(): string;
  20319. /**
  20320. * Returns the string "ConeParticleEmitter"
  20321. * @returns a string containing the class name
  20322. */
  20323. getClassName(): string;
  20324. /**
  20325. * Serializes the particle system to a JSON object.
  20326. * @returns the JSON object
  20327. */
  20328. serialize(): any;
  20329. /**
  20330. * Parse properties from a JSON object
  20331. * @param serializationObject defines the JSON object
  20332. */
  20333. parse(serializationObject: any): void;
  20334. }
  20335. }
  20336. declare module BABYLON {
  20337. /**
  20338. * Particle emitter emitting particles from the inside of a cylinder.
  20339. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20340. */
  20341. export class CylinderParticleEmitter implements IParticleEmitterType {
  20342. /**
  20343. * The radius of the emission cylinder.
  20344. */
  20345. radius: number;
  20346. /**
  20347. * The height of the emission cylinder.
  20348. */
  20349. height: number;
  20350. /**
  20351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20352. */
  20353. radiusRange: number;
  20354. /**
  20355. * How much to randomize the particle direction [0-1].
  20356. */
  20357. directionRandomizer: number;
  20358. /**
  20359. * Creates a new instance CylinderParticleEmitter
  20360. * @param radius the radius of the emission cylinder (1 by default)
  20361. * @param height the height of the emission cylinder (1 by default)
  20362. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20363. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20364. */
  20365. constructor(
  20366. /**
  20367. * The radius of the emission cylinder.
  20368. */
  20369. radius?: number,
  20370. /**
  20371. * The height of the emission cylinder.
  20372. */
  20373. height?: number,
  20374. /**
  20375. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20376. */
  20377. radiusRange?: number,
  20378. /**
  20379. * How much to randomize the particle direction [0-1].
  20380. */
  20381. directionRandomizer?: number);
  20382. /**
  20383. * Called by the particle System when the direction is computed for the created particle.
  20384. * @param worldMatrix is the world matrix of the particle system
  20385. * @param directionToUpdate is the direction vector to update with the result
  20386. * @param particle is the particle we are computed the direction for
  20387. */
  20388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20389. /**
  20390. * Called by the particle System when the position is computed for the created particle.
  20391. * @param worldMatrix is the world matrix of the particle system
  20392. * @param positionToUpdate is the position vector to update with the result
  20393. * @param particle is the particle we are computed the position for
  20394. */
  20395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20396. /**
  20397. * Clones the current emitter and returns a copy of it
  20398. * @returns the new emitter
  20399. */
  20400. clone(): CylinderParticleEmitter;
  20401. /**
  20402. * Called by the GPUParticleSystem to setup the update shader
  20403. * @param effect defines the update shader
  20404. */
  20405. applyToShader(effect: Effect): void;
  20406. /**
  20407. * Returns a string to use to update the GPU particles update shader
  20408. * @returns a string containng the defines string
  20409. */
  20410. getEffectDefines(): string;
  20411. /**
  20412. * Returns the string "CylinderParticleEmitter"
  20413. * @returns a string containing the class name
  20414. */
  20415. getClassName(): string;
  20416. /**
  20417. * Serializes the particle system to a JSON object.
  20418. * @returns the JSON object
  20419. */
  20420. serialize(): any;
  20421. /**
  20422. * Parse properties from a JSON object
  20423. * @param serializationObject defines the JSON object
  20424. */
  20425. parse(serializationObject: any): void;
  20426. }
  20427. /**
  20428. * Particle emitter emitting particles from the inside of a cylinder.
  20429. * It emits the particles randomly between two vectors.
  20430. */
  20431. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20432. /**
  20433. * The min limit of the emission direction.
  20434. */
  20435. direction1: Vector3;
  20436. /**
  20437. * The max limit of the emission direction.
  20438. */
  20439. direction2: Vector3;
  20440. /**
  20441. * Creates a new instance CylinderDirectedParticleEmitter
  20442. * @param radius the radius of the emission cylinder (1 by default)
  20443. * @param height the height of the emission cylinder (1 by default)
  20444. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20445. * @param direction1 the min limit of the emission direction (up vector by default)
  20446. * @param direction2 the max limit of the emission direction (up vector by default)
  20447. */
  20448. constructor(radius?: number, height?: number, radiusRange?: number,
  20449. /**
  20450. * The min limit of the emission direction.
  20451. */
  20452. direction1?: Vector3,
  20453. /**
  20454. * The max limit of the emission direction.
  20455. */
  20456. direction2?: Vector3);
  20457. /**
  20458. * Called by the particle System when the direction is computed for the created particle.
  20459. * @param worldMatrix is the world matrix of the particle system
  20460. * @param directionToUpdate is the direction vector to update with the result
  20461. * @param particle is the particle we are computed the direction for
  20462. */
  20463. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20464. /**
  20465. * Clones the current emitter and returns a copy of it
  20466. * @returns the new emitter
  20467. */
  20468. clone(): CylinderDirectedParticleEmitter;
  20469. /**
  20470. * Called by the GPUParticleSystem to setup the update shader
  20471. * @param effect defines the update shader
  20472. */
  20473. applyToShader(effect: Effect): void;
  20474. /**
  20475. * Returns a string to use to update the GPU particles update shader
  20476. * @returns a string containng the defines string
  20477. */
  20478. getEffectDefines(): string;
  20479. /**
  20480. * Returns the string "CylinderDirectedParticleEmitter"
  20481. * @returns a string containing the class name
  20482. */
  20483. getClassName(): string;
  20484. /**
  20485. * Serializes the particle system to a JSON object.
  20486. * @returns the JSON object
  20487. */
  20488. serialize(): any;
  20489. /**
  20490. * Parse properties from a JSON object
  20491. * @param serializationObject defines the JSON object
  20492. */
  20493. parse(serializationObject: any): void;
  20494. }
  20495. }
  20496. declare module BABYLON {
  20497. /**
  20498. * Particle emitter emitting particles from the inside of a hemisphere.
  20499. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20500. */
  20501. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20502. /**
  20503. * The radius of the emission hemisphere.
  20504. */
  20505. radius: number;
  20506. /**
  20507. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20508. */
  20509. radiusRange: number;
  20510. /**
  20511. * How much to randomize the particle direction [0-1].
  20512. */
  20513. directionRandomizer: number;
  20514. /**
  20515. * Creates a new instance HemisphericParticleEmitter
  20516. * @param radius the radius of the emission hemisphere (1 by default)
  20517. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20518. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20519. */
  20520. constructor(
  20521. /**
  20522. * The radius of the emission hemisphere.
  20523. */
  20524. radius?: number,
  20525. /**
  20526. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20527. */
  20528. radiusRange?: number,
  20529. /**
  20530. * How much to randomize the particle direction [0-1].
  20531. */
  20532. directionRandomizer?: number);
  20533. /**
  20534. * Called by the particle System when the direction is computed for the created particle.
  20535. * @param worldMatrix is the world matrix of the particle system
  20536. * @param directionToUpdate is the direction vector to update with the result
  20537. * @param particle is the particle we are computed the direction for
  20538. */
  20539. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20540. /**
  20541. * Called by the particle System when the position is computed for the created particle.
  20542. * @param worldMatrix is the world matrix of the particle system
  20543. * @param positionToUpdate is the position vector to update with the result
  20544. * @param particle is the particle we are computed the position for
  20545. */
  20546. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20547. /**
  20548. * Clones the current emitter and returns a copy of it
  20549. * @returns the new emitter
  20550. */
  20551. clone(): HemisphericParticleEmitter;
  20552. /**
  20553. * Called by the GPUParticleSystem to setup the update shader
  20554. * @param effect defines the update shader
  20555. */
  20556. applyToShader(effect: Effect): void;
  20557. /**
  20558. * Returns a string to use to update the GPU particles update shader
  20559. * @returns a string containng the defines string
  20560. */
  20561. getEffectDefines(): string;
  20562. /**
  20563. * Returns the string "HemisphericParticleEmitter"
  20564. * @returns a string containing the class name
  20565. */
  20566. getClassName(): string;
  20567. /**
  20568. * Serializes the particle system to a JSON object.
  20569. * @returns the JSON object
  20570. */
  20571. serialize(): any;
  20572. /**
  20573. * Parse properties from a JSON object
  20574. * @param serializationObject defines the JSON object
  20575. */
  20576. parse(serializationObject: any): void;
  20577. }
  20578. }
  20579. declare module BABYLON {
  20580. /**
  20581. * Particle emitter emitting particles from a point.
  20582. * It emits the particles randomly between 2 given directions.
  20583. */
  20584. export class PointParticleEmitter implements IParticleEmitterType {
  20585. /**
  20586. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20587. */
  20588. direction1: Vector3;
  20589. /**
  20590. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20591. */
  20592. direction2: Vector3;
  20593. /**
  20594. * Creates a new instance PointParticleEmitter
  20595. */
  20596. constructor();
  20597. /**
  20598. * Called by the particle System when the direction is computed for the created particle.
  20599. * @param worldMatrix is the world matrix of the particle system
  20600. * @param directionToUpdate is the direction vector to update with the result
  20601. * @param particle is the particle we are computed the direction for
  20602. */
  20603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20604. /**
  20605. * Called by the particle System when the position is computed for the created particle.
  20606. * @param worldMatrix is the world matrix of the particle system
  20607. * @param positionToUpdate is the position vector to update with the result
  20608. * @param particle is the particle we are computed the position for
  20609. */
  20610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20611. /**
  20612. * Clones the current emitter and returns a copy of it
  20613. * @returns the new emitter
  20614. */
  20615. clone(): PointParticleEmitter;
  20616. /**
  20617. * Called by the GPUParticleSystem to setup the update shader
  20618. * @param effect defines the update shader
  20619. */
  20620. applyToShader(effect: Effect): void;
  20621. /**
  20622. * Returns a string to use to update the GPU particles update shader
  20623. * @returns a string containng the defines string
  20624. */
  20625. getEffectDefines(): string;
  20626. /**
  20627. * Returns the string "PointParticleEmitter"
  20628. * @returns a string containing the class name
  20629. */
  20630. getClassName(): string;
  20631. /**
  20632. * Serializes the particle system to a JSON object.
  20633. * @returns the JSON object
  20634. */
  20635. serialize(): any;
  20636. /**
  20637. * Parse properties from a JSON object
  20638. * @param serializationObject defines the JSON object
  20639. */
  20640. parse(serializationObject: any): void;
  20641. }
  20642. }
  20643. declare module BABYLON {
  20644. /**
  20645. * Particle emitter emitting particles from the inside of a sphere.
  20646. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20647. */
  20648. export class SphereParticleEmitter implements IParticleEmitterType {
  20649. /**
  20650. * The radius of the emission sphere.
  20651. */
  20652. radius: number;
  20653. /**
  20654. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20655. */
  20656. radiusRange: number;
  20657. /**
  20658. * How much to randomize the particle direction [0-1].
  20659. */
  20660. directionRandomizer: number;
  20661. /**
  20662. * Creates a new instance SphereParticleEmitter
  20663. * @param radius the radius of the emission sphere (1 by default)
  20664. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20665. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20666. */
  20667. constructor(
  20668. /**
  20669. * The radius of the emission sphere.
  20670. */
  20671. radius?: number,
  20672. /**
  20673. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20674. */
  20675. radiusRange?: number,
  20676. /**
  20677. * How much to randomize the particle direction [0-1].
  20678. */
  20679. directionRandomizer?: number);
  20680. /**
  20681. * Called by the particle System when the direction is computed for the created particle.
  20682. * @param worldMatrix is the world matrix of the particle system
  20683. * @param directionToUpdate is the direction vector to update with the result
  20684. * @param particle is the particle we are computed the direction for
  20685. */
  20686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20687. /**
  20688. * Called by the particle System when the position is computed for the created particle.
  20689. * @param worldMatrix is the world matrix of the particle system
  20690. * @param positionToUpdate is the position vector to update with the result
  20691. * @param particle is the particle we are computed the position for
  20692. */
  20693. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20694. /**
  20695. * Clones the current emitter and returns a copy of it
  20696. * @returns the new emitter
  20697. */
  20698. clone(): SphereParticleEmitter;
  20699. /**
  20700. * Called by the GPUParticleSystem to setup the update shader
  20701. * @param effect defines the update shader
  20702. */
  20703. applyToShader(effect: Effect): void;
  20704. /**
  20705. * Returns a string to use to update the GPU particles update shader
  20706. * @returns a string containng the defines string
  20707. */
  20708. getEffectDefines(): string;
  20709. /**
  20710. * Returns the string "SphereParticleEmitter"
  20711. * @returns a string containing the class name
  20712. */
  20713. getClassName(): string;
  20714. /**
  20715. * Serializes the particle system to a JSON object.
  20716. * @returns the JSON object
  20717. */
  20718. serialize(): any;
  20719. /**
  20720. * Parse properties from a JSON object
  20721. * @param serializationObject defines the JSON object
  20722. */
  20723. parse(serializationObject: any): void;
  20724. }
  20725. /**
  20726. * Particle emitter emitting particles from the inside of a sphere.
  20727. * It emits the particles randomly between two vectors.
  20728. */
  20729. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20730. /**
  20731. * The min limit of the emission direction.
  20732. */
  20733. direction1: Vector3;
  20734. /**
  20735. * The max limit of the emission direction.
  20736. */
  20737. direction2: Vector3;
  20738. /**
  20739. * Creates a new instance SphereDirectedParticleEmitter
  20740. * @param radius the radius of the emission sphere (1 by default)
  20741. * @param direction1 the min limit of the emission direction (up vector by default)
  20742. * @param direction2 the max limit of the emission direction (up vector by default)
  20743. */
  20744. constructor(radius?: number,
  20745. /**
  20746. * The min limit of the emission direction.
  20747. */
  20748. direction1?: Vector3,
  20749. /**
  20750. * The max limit of the emission direction.
  20751. */
  20752. direction2?: Vector3);
  20753. /**
  20754. * Called by the particle System when the direction is computed for the created particle.
  20755. * @param worldMatrix is the world matrix of the particle system
  20756. * @param directionToUpdate is the direction vector to update with the result
  20757. * @param particle is the particle we are computed the direction for
  20758. */
  20759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20760. /**
  20761. * Clones the current emitter and returns a copy of it
  20762. * @returns the new emitter
  20763. */
  20764. clone(): SphereDirectedParticleEmitter;
  20765. /**
  20766. * Called by the GPUParticleSystem to setup the update shader
  20767. * @param effect defines the update shader
  20768. */
  20769. applyToShader(effect: Effect): void;
  20770. /**
  20771. * Returns a string to use to update the GPU particles update shader
  20772. * @returns a string containng the defines string
  20773. */
  20774. getEffectDefines(): string;
  20775. /**
  20776. * Returns the string "SphereDirectedParticleEmitter"
  20777. * @returns a string containing the class name
  20778. */
  20779. getClassName(): string;
  20780. /**
  20781. * Serializes the particle system to a JSON object.
  20782. * @returns the JSON object
  20783. */
  20784. serialize(): any;
  20785. /**
  20786. * Parse properties from a JSON object
  20787. * @param serializationObject defines the JSON object
  20788. */
  20789. parse(serializationObject: any): void;
  20790. }
  20791. }
  20792. declare module BABYLON {
  20793. /**
  20794. * Interface representing a particle system in Babylon.js.
  20795. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20796. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20797. */
  20798. export interface IParticleSystem {
  20799. /**
  20800. * List of animations used by the particle system.
  20801. */
  20802. animations: Animation[];
  20803. /**
  20804. * The id of the Particle system.
  20805. */
  20806. id: string;
  20807. /**
  20808. * The name of the Particle system.
  20809. */
  20810. name: string;
  20811. /**
  20812. * The emitter represents the Mesh or position we are attaching the particle system to.
  20813. */
  20814. emitter: Nullable<AbstractMesh | Vector3>;
  20815. /**
  20816. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20817. */
  20818. isBillboardBased: boolean;
  20819. /**
  20820. * The rendering group used by the Particle system to chose when to render.
  20821. */
  20822. renderingGroupId: number;
  20823. /**
  20824. * The layer mask we are rendering the particles through.
  20825. */
  20826. layerMask: number;
  20827. /**
  20828. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20829. */
  20830. updateSpeed: number;
  20831. /**
  20832. * The amount of time the particle system is running (depends of the overall update speed).
  20833. */
  20834. targetStopDuration: number;
  20835. /**
  20836. * The texture used to render each particle. (this can be a spritesheet)
  20837. */
  20838. particleTexture: Nullable<Texture>;
  20839. /**
  20840. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20841. */
  20842. blendMode: number;
  20843. /**
  20844. * Minimum life time of emitting particles.
  20845. */
  20846. minLifeTime: number;
  20847. /**
  20848. * Maximum life time of emitting particles.
  20849. */
  20850. maxLifeTime: number;
  20851. /**
  20852. * Minimum Size of emitting particles.
  20853. */
  20854. minSize: number;
  20855. /**
  20856. * Maximum Size of emitting particles.
  20857. */
  20858. maxSize: number;
  20859. /**
  20860. * Minimum scale of emitting particles on X axis.
  20861. */
  20862. minScaleX: number;
  20863. /**
  20864. * Maximum scale of emitting particles on X axis.
  20865. */
  20866. maxScaleX: number;
  20867. /**
  20868. * Minimum scale of emitting particles on Y axis.
  20869. */
  20870. minScaleY: number;
  20871. /**
  20872. * Maximum scale of emitting particles on Y axis.
  20873. */
  20874. maxScaleY: number;
  20875. /**
  20876. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20877. */
  20878. color1: Color4;
  20879. /**
  20880. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20881. */
  20882. color2: Color4;
  20883. /**
  20884. * Color the particle will have at the end of its lifetime.
  20885. */
  20886. colorDead: Color4;
  20887. /**
  20888. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20889. */
  20890. emitRate: number;
  20891. /**
  20892. * You can use gravity if you want to give an orientation to your particles.
  20893. */
  20894. gravity: Vector3;
  20895. /**
  20896. * Minimum power of emitting particles.
  20897. */
  20898. minEmitPower: number;
  20899. /**
  20900. * Maximum power of emitting particles.
  20901. */
  20902. maxEmitPower: number;
  20903. /**
  20904. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20905. */
  20906. minAngularSpeed: number;
  20907. /**
  20908. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20909. */
  20910. maxAngularSpeed: number;
  20911. /**
  20912. * Gets or sets the minimal initial rotation in radians.
  20913. */
  20914. minInitialRotation: number;
  20915. /**
  20916. * Gets or sets the maximal initial rotation in radians.
  20917. */
  20918. maxInitialRotation: number;
  20919. /**
  20920. * The particle emitter type defines the emitter used by the particle system.
  20921. * It can be for example box, sphere, or cone...
  20922. */
  20923. particleEmitterType: Nullable<IParticleEmitterType>;
  20924. /**
  20925. * Defines the delay in milliseconds before starting the system (0 by default)
  20926. */
  20927. startDelay: number;
  20928. /**
  20929. * 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
  20930. */
  20931. preWarmCycles: number;
  20932. /**
  20933. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20934. */
  20935. preWarmStepOffset: number;
  20936. /**
  20937. * 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)
  20938. */
  20939. spriteCellChangeSpeed: number;
  20940. /**
  20941. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20942. */
  20943. startSpriteCellID: number;
  20944. /**
  20945. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20946. */
  20947. endSpriteCellID: number;
  20948. /**
  20949. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20950. */
  20951. spriteCellWidth: number;
  20952. /**
  20953. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20954. */
  20955. spriteCellHeight: number;
  20956. /**
  20957. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20958. */
  20959. spriteRandomStartCell: boolean;
  20960. /**
  20961. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20962. */
  20963. isAnimationSheetEnabled: boolean;
  20964. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20965. translationPivot: Vector2;
  20966. /**
  20967. * Gets or sets a texture used to add random noise to particle positions
  20968. */
  20969. noiseTexture: Nullable<BaseTexture>;
  20970. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20971. noiseStrength: Vector3;
  20972. /**
  20973. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20974. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20975. */
  20976. billboardMode: number;
  20977. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20978. limitVelocityDamping: number;
  20979. /**
  20980. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20981. */
  20982. beginAnimationOnStart: boolean;
  20983. /**
  20984. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20985. */
  20986. beginAnimationFrom: number;
  20987. /**
  20988. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20989. */
  20990. beginAnimationTo: number;
  20991. /**
  20992. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20993. */
  20994. beginAnimationLoop: boolean;
  20995. /**
  20996. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20997. */
  20998. disposeOnStop: boolean;
  20999. /**
  21000. * Gets the maximum number of particles active at the same time.
  21001. * @returns The max number of active particles.
  21002. */
  21003. getCapacity(): number;
  21004. /**
  21005. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21006. * @returns True if it has been started, otherwise false.
  21007. */
  21008. isStarted(): boolean;
  21009. /**
  21010. * Animates the particle system for this frame.
  21011. */
  21012. animate(): void;
  21013. /**
  21014. * Renders the particle system in its current state.
  21015. * @returns the current number of particles
  21016. */
  21017. render(): number;
  21018. /**
  21019. * Dispose the particle system and frees its associated resources.
  21020. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21021. */
  21022. dispose(disposeTexture?: boolean): void;
  21023. /**
  21024. * Clones the particle system.
  21025. * @param name The name of the cloned object
  21026. * @param newEmitter The new emitter to use
  21027. * @returns the cloned particle system
  21028. */
  21029. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21030. /**
  21031. * Serializes the particle system to a JSON object.
  21032. * @returns the JSON object
  21033. */
  21034. serialize(): any;
  21035. /**
  21036. * Rebuild the particle system
  21037. */
  21038. rebuild(): void;
  21039. /**
  21040. * Starts the particle system and begins to emit
  21041. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21042. */
  21043. start(delay?: number): void;
  21044. /**
  21045. * Stops the particle system.
  21046. */
  21047. stop(): void;
  21048. /**
  21049. * Remove all active particles
  21050. */
  21051. reset(): void;
  21052. /**
  21053. * Is this system ready to be used/rendered
  21054. * @return true if the system is ready
  21055. */
  21056. isReady(): boolean;
  21057. /**
  21058. * Adds a new color gradient
  21059. * @param gradient defines the gradient to use (between 0 and 1)
  21060. * @param color1 defines the color to affect to the specified gradient
  21061. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21062. * @returns the current particle system
  21063. */
  21064. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21065. /**
  21066. * Remove a specific color gradient
  21067. * @param gradient defines the gradient to remove
  21068. * @returns the current particle system
  21069. */
  21070. removeColorGradient(gradient: number): IParticleSystem;
  21071. /**
  21072. * Adds a new size gradient
  21073. * @param gradient defines the gradient to use (between 0 and 1)
  21074. * @param factor defines the size factor to affect to the specified gradient
  21075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21076. * @returns the current particle system
  21077. */
  21078. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21079. /**
  21080. * Remove a specific size gradient
  21081. * @param gradient defines the gradient to remove
  21082. * @returns the current particle system
  21083. */
  21084. removeSizeGradient(gradient: number): IParticleSystem;
  21085. /**
  21086. * Gets the current list of color gradients.
  21087. * You must use addColorGradient and removeColorGradient to udpate this list
  21088. * @returns the list of color gradients
  21089. */
  21090. getColorGradients(): Nullable<Array<ColorGradient>>;
  21091. /**
  21092. * Gets the current list of size gradients.
  21093. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21094. * @returns the list of size gradients
  21095. */
  21096. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21097. /**
  21098. * Gets the current list of angular speed gradients.
  21099. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21100. * @returns the list of angular speed gradients
  21101. */
  21102. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21103. /**
  21104. * Adds a new angular speed gradient
  21105. * @param gradient defines the gradient to use (between 0 and 1)
  21106. * @param factor defines the angular speed to affect to the specified gradient
  21107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21108. * @returns the current particle system
  21109. */
  21110. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21111. /**
  21112. * Remove a specific angular speed gradient
  21113. * @param gradient defines the gradient to remove
  21114. * @returns the current particle system
  21115. */
  21116. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21117. /**
  21118. * Gets the current list of velocity gradients.
  21119. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21120. * @returns the list of velocity gradients
  21121. */
  21122. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21123. /**
  21124. * Adds a new velocity gradient
  21125. * @param gradient defines the gradient to use (between 0 and 1)
  21126. * @param factor defines the velocity to affect to the specified gradient
  21127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21128. * @returns the current particle system
  21129. */
  21130. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21131. /**
  21132. * Remove a specific velocity gradient
  21133. * @param gradient defines the gradient to remove
  21134. * @returns the current particle system
  21135. */
  21136. removeVelocityGradient(gradient: number): IParticleSystem;
  21137. /**
  21138. * Gets the current list of limit velocity gradients.
  21139. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21140. * @returns the list of limit velocity gradients
  21141. */
  21142. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21143. /**
  21144. * Adds a new limit velocity gradient
  21145. * @param gradient defines the gradient to use (between 0 and 1)
  21146. * @param factor defines the limit velocity to affect to the specified gradient
  21147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21148. * @returns the current particle system
  21149. */
  21150. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21151. /**
  21152. * Remove a specific limit velocity gradient
  21153. * @param gradient defines the gradient to remove
  21154. * @returns the current particle system
  21155. */
  21156. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21157. /**
  21158. * Adds a new drag gradient
  21159. * @param gradient defines the gradient to use (between 0 and 1)
  21160. * @param factor defines the drag to affect to the specified gradient
  21161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21162. * @returns the current particle system
  21163. */
  21164. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21165. /**
  21166. * Remove a specific drag gradient
  21167. * @param gradient defines the gradient to remove
  21168. * @returns the current particle system
  21169. */
  21170. removeDragGradient(gradient: number): IParticleSystem;
  21171. /**
  21172. * Gets the current list of drag gradients.
  21173. * You must use addDragGradient and removeDragGradient to udpate this list
  21174. * @returns the list of drag gradients
  21175. */
  21176. getDragGradients(): Nullable<Array<FactorGradient>>;
  21177. /**
  21178. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21179. * @param gradient defines the gradient to use (between 0 and 1)
  21180. * @param factor defines the emit rate to affect to the specified gradient
  21181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21182. * @returns the current particle system
  21183. */
  21184. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21185. /**
  21186. * Remove a specific emit rate gradient
  21187. * @param gradient defines the gradient to remove
  21188. * @returns the current particle system
  21189. */
  21190. removeEmitRateGradient(gradient: number): IParticleSystem;
  21191. /**
  21192. * Gets the current list of emit rate gradients.
  21193. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21194. * @returns the list of emit rate gradients
  21195. */
  21196. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21197. /**
  21198. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21199. * @param gradient defines the gradient to use (between 0 and 1)
  21200. * @param factor defines the start size to affect to the specified gradient
  21201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21202. * @returns the current particle system
  21203. */
  21204. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21205. /**
  21206. * Remove a specific start size gradient
  21207. * @param gradient defines the gradient to remove
  21208. * @returns the current particle system
  21209. */
  21210. removeStartSizeGradient(gradient: number): IParticleSystem;
  21211. /**
  21212. * Gets the current list of start size gradients.
  21213. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21214. * @returns the list of start size gradients
  21215. */
  21216. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21217. /**
  21218. * Adds a new life time gradient
  21219. * @param gradient defines the gradient to use (between 0 and 1)
  21220. * @param factor defines the life time factor to affect to the specified gradient
  21221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21222. * @returns the current particle system
  21223. */
  21224. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21225. /**
  21226. * Remove a specific life time gradient
  21227. * @param gradient defines the gradient to remove
  21228. * @returns the current particle system
  21229. */
  21230. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21231. /**
  21232. * Gets the current list of life time gradients.
  21233. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21234. * @returns the list of life time gradients
  21235. */
  21236. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21237. /**
  21238. * Gets the current list of color gradients.
  21239. * You must use addColorGradient and removeColorGradient to udpate this list
  21240. * @returns the list of color gradients
  21241. */
  21242. getColorGradients(): Nullable<Array<ColorGradient>>;
  21243. /**
  21244. * Adds a new ramp gradient used to remap particle colors
  21245. * @param gradient defines the gradient to use (between 0 and 1)
  21246. * @param color defines the color to affect to the specified gradient
  21247. * @returns the current particle system
  21248. */
  21249. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21250. /**
  21251. * Gets the current list of ramp gradients.
  21252. * You must use addRampGradient and removeRampGradient to udpate this list
  21253. * @returns the list of ramp gradients
  21254. */
  21255. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21256. /** Gets or sets a boolean indicating that ramp gradients must be used
  21257. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21258. */
  21259. useRampGradients: boolean;
  21260. /**
  21261. * Adds a new color remap gradient
  21262. * @param gradient defines the gradient to use (between 0 and 1)
  21263. * @param min defines the color remap minimal range
  21264. * @param max defines the color remap maximal range
  21265. * @returns the current particle system
  21266. */
  21267. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21268. /**
  21269. * Gets the current list of color remap gradients.
  21270. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21271. * @returns the list of color remap gradients
  21272. */
  21273. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21274. /**
  21275. * Adds a new alpha remap gradient
  21276. * @param gradient defines the gradient to use (between 0 and 1)
  21277. * @param min defines the alpha remap minimal range
  21278. * @param max defines the alpha remap maximal range
  21279. * @returns the current particle system
  21280. */
  21281. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21282. /**
  21283. * Gets the current list of alpha remap gradients.
  21284. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21285. * @returns the list of alpha remap gradients
  21286. */
  21287. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21288. /**
  21289. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21290. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21291. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21292. * @returns the emitter
  21293. */
  21294. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21295. /**
  21296. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21297. * @param radius The radius of the hemisphere to emit from
  21298. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21299. * @returns the emitter
  21300. */
  21301. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21302. /**
  21303. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21304. * @param radius The radius of the sphere to emit from
  21305. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21306. * @returns the emitter
  21307. */
  21308. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21309. /**
  21310. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21311. * @param radius The radius of the sphere to emit from
  21312. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21313. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21314. * @returns the emitter
  21315. */
  21316. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21317. /**
  21318. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21319. * @param radius The radius of the emission cylinder
  21320. * @param height The height of the emission cylinder
  21321. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21322. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21323. * @returns the emitter
  21324. */
  21325. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21326. /**
  21327. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21328. * @param radius The radius of the cylinder to emit from
  21329. * @param height The height of the emission cylinder
  21330. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21331. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21332. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21333. * @returns the emitter
  21334. */
  21335. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21336. /**
  21337. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21338. * @param radius The radius of the cone to emit from
  21339. * @param angle The base angle of the cone
  21340. * @returns the emitter
  21341. */
  21342. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21343. /**
  21344. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21345. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21346. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21347. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21348. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21349. * @returns the emitter
  21350. */
  21351. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21352. /**
  21353. * Get hosting scene
  21354. * @returns the scene
  21355. */
  21356. getScene(): Scene;
  21357. }
  21358. }
  21359. declare module BABYLON {
  21360. /** @hidden */
  21361. export var linePixelShader: {
  21362. name: string;
  21363. shader: string;
  21364. };
  21365. }
  21366. declare module BABYLON {
  21367. /** @hidden */
  21368. export var lineVertexShader: {
  21369. name: string;
  21370. shader: string;
  21371. };
  21372. }
  21373. declare module BABYLON {
  21374. interface AbstractMesh {
  21375. /**
  21376. * Gets the edgesRenderer associated with the mesh
  21377. */
  21378. edgesRenderer: Nullable<EdgesRenderer>;
  21379. }
  21380. interface LinesMesh {
  21381. /**
  21382. * Enables the edge rendering mode on the mesh.
  21383. * This mode makes the mesh edges visible
  21384. * @param epsilon defines the maximal distance between two angles to detect a face
  21385. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21386. * @returns the currentAbstractMesh
  21387. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21388. */
  21389. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21390. }
  21391. interface InstancedLinesMesh {
  21392. /**
  21393. * Enables the edge rendering mode on the mesh.
  21394. * This mode makes the mesh edges visible
  21395. * @param epsilon defines the maximal distance between two angles to detect a face
  21396. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21397. * @returns the current InstancedLinesMesh
  21398. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21399. */
  21400. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21401. }
  21402. /**
  21403. * Defines the minimum contract an Edges renderer should follow.
  21404. */
  21405. export interface IEdgesRenderer extends IDisposable {
  21406. /**
  21407. * Gets or sets a boolean indicating if the edgesRenderer is active
  21408. */
  21409. isEnabled: boolean;
  21410. /**
  21411. * Renders the edges of the attached mesh,
  21412. */
  21413. render(): void;
  21414. /**
  21415. * Checks wether or not the edges renderer is ready to render.
  21416. * @return true if ready, otherwise false.
  21417. */
  21418. isReady(): boolean;
  21419. }
  21420. /**
  21421. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21422. */
  21423. export class EdgesRenderer implements IEdgesRenderer {
  21424. /**
  21425. * Define the size of the edges with an orthographic camera
  21426. */
  21427. edgesWidthScalerForOrthographic: number;
  21428. /**
  21429. * Define the size of the edges with a perspective camera
  21430. */
  21431. edgesWidthScalerForPerspective: number;
  21432. protected _source: AbstractMesh;
  21433. protected _linesPositions: number[];
  21434. protected _linesNormals: number[];
  21435. protected _linesIndices: number[];
  21436. protected _epsilon: number;
  21437. protected _indicesCount: number;
  21438. protected _lineShader: ShaderMaterial;
  21439. protected _ib: DataBuffer;
  21440. protected _buffers: {
  21441. [key: string]: Nullable<VertexBuffer>;
  21442. };
  21443. protected _checkVerticesInsteadOfIndices: boolean;
  21444. private _meshRebuildObserver;
  21445. private _meshDisposeObserver;
  21446. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21447. isEnabled: boolean;
  21448. /**
  21449. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21450. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21451. * @param source Mesh used to create edges
  21452. * @param epsilon sum of angles in adjacency to check for edge
  21453. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21454. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21455. */
  21456. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21457. protected _prepareRessources(): void;
  21458. /** @hidden */
  21459. _rebuild(): void;
  21460. /**
  21461. * Releases the required resources for the edges renderer
  21462. */
  21463. dispose(): void;
  21464. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21465. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21466. /**
  21467. * Checks if the pair of p0 and p1 is en edge
  21468. * @param faceIndex
  21469. * @param edge
  21470. * @param faceNormals
  21471. * @param p0
  21472. * @param p1
  21473. * @private
  21474. */
  21475. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21476. /**
  21477. * push line into the position, normal and index buffer
  21478. * @protected
  21479. */
  21480. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21481. /**
  21482. * Generates lines edges from adjacencjes
  21483. * @private
  21484. */
  21485. _generateEdgesLines(): void;
  21486. /**
  21487. * Checks wether or not the edges renderer is ready to render.
  21488. * @return true if ready, otherwise false.
  21489. */
  21490. isReady(): boolean;
  21491. /**
  21492. * Renders the edges of the attached mesh,
  21493. */
  21494. render(): void;
  21495. }
  21496. /**
  21497. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21498. */
  21499. export class LineEdgesRenderer extends EdgesRenderer {
  21500. /**
  21501. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21502. * @param source LineMesh used to generate edges
  21503. * @param epsilon not important (specified angle for edge detection)
  21504. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21505. */
  21506. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21507. /**
  21508. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21509. */
  21510. _generateEdgesLines(): void;
  21511. }
  21512. }
  21513. declare module BABYLON {
  21514. /**
  21515. * This represents the object necessary to create a rendering group.
  21516. * This is exclusively used and created by the rendering manager.
  21517. * To modify the behavior, you use the available helpers in your scene or meshes.
  21518. * @hidden
  21519. */
  21520. export class RenderingGroup {
  21521. index: number;
  21522. private static _zeroVector;
  21523. private _scene;
  21524. private _opaqueSubMeshes;
  21525. private _transparentSubMeshes;
  21526. private _alphaTestSubMeshes;
  21527. private _depthOnlySubMeshes;
  21528. private _particleSystems;
  21529. private _spriteManagers;
  21530. private _opaqueSortCompareFn;
  21531. private _alphaTestSortCompareFn;
  21532. private _transparentSortCompareFn;
  21533. private _renderOpaque;
  21534. private _renderAlphaTest;
  21535. private _renderTransparent;
  21536. /** @hidden */
  21537. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21538. onBeforeTransparentRendering: () => void;
  21539. /**
  21540. * Set the opaque sort comparison function.
  21541. * If null the sub meshes will be render in the order they were created
  21542. */
  21543. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21544. /**
  21545. * Set the alpha test sort comparison function.
  21546. * If null the sub meshes will be render in the order they were created
  21547. */
  21548. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21549. /**
  21550. * Set the transparent sort comparison function.
  21551. * If null the sub meshes will be render in the order they were created
  21552. */
  21553. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21554. /**
  21555. * Creates a new rendering group.
  21556. * @param index The rendering group index
  21557. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21558. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21559. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21560. */
  21561. 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>);
  21562. /**
  21563. * Render all the sub meshes contained in the group.
  21564. * @param customRenderFunction Used to override the default render behaviour of the group.
  21565. * @returns true if rendered some submeshes.
  21566. */
  21567. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21568. /**
  21569. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21570. * @param subMeshes The submeshes to render
  21571. */
  21572. private renderOpaqueSorted;
  21573. /**
  21574. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21575. * @param subMeshes The submeshes to render
  21576. */
  21577. private renderAlphaTestSorted;
  21578. /**
  21579. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21580. * @param subMeshes The submeshes to render
  21581. */
  21582. private renderTransparentSorted;
  21583. /**
  21584. * Renders the submeshes in a specified order.
  21585. * @param subMeshes The submeshes to sort before render
  21586. * @param sortCompareFn The comparison function use to sort
  21587. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21588. * @param transparent Specifies to activate blending if true
  21589. */
  21590. private static renderSorted;
  21591. /**
  21592. * Renders the submeshes in the order they were dispatched (no sort applied).
  21593. * @param subMeshes The submeshes to render
  21594. */
  21595. private static renderUnsorted;
  21596. /**
  21597. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21598. * are rendered back to front if in the same alpha index.
  21599. *
  21600. * @param a The first submesh
  21601. * @param b The second submesh
  21602. * @returns The result of the comparison
  21603. */
  21604. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21605. /**
  21606. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21607. * are rendered back to front.
  21608. *
  21609. * @param a The first submesh
  21610. * @param b The second submesh
  21611. * @returns The result of the comparison
  21612. */
  21613. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21614. /**
  21615. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21616. * are rendered front to back (prevent overdraw).
  21617. *
  21618. * @param a The first submesh
  21619. * @param b The second submesh
  21620. * @returns The result of the comparison
  21621. */
  21622. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21623. /**
  21624. * Resets the different lists of submeshes to prepare a new frame.
  21625. */
  21626. prepare(): void;
  21627. dispose(): void;
  21628. /**
  21629. * Inserts the submesh in its correct queue depending on its material.
  21630. * @param subMesh The submesh to dispatch
  21631. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21632. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21633. */
  21634. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21635. dispatchSprites(spriteManager: ISpriteManager): void;
  21636. dispatchParticles(particleSystem: IParticleSystem): void;
  21637. private _renderParticles;
  21638. private _renderSprites;
  21639. }
  21640. }
  21641. declare module BABYLON {
  21642. /**
  21643. * Interface describing the different options available in the rendering manager
  21644. * regarding Auto Clear between groups.
  21645. */
  21646. export interface IRenderingManagerAutoClearSetup {
  21647. /**
  21648. * Defines whether or not autoclear is enable.
  21649. */
  21650. autoClear: boolean;
  21651. /**
  21652. * Defines whether or not to autoclear the depth buffer.
  21653. */
  21654. depth: boolean;
  21655. /**
  21656. * Defines whether or not to autoclear the stencil buffer.
  21657. */
  21658. stencil: boolean;
  21659. }
  21660. /**
  21661. * This class is used by the onRenderingGroupObservable
  21662. */
  21663. export class RenderingGroupInfo {
  21664. /**
  21665. * The Scene that being rendered
  21666. */
  21667. scene: Scene;
  21668. /**
  21669. * The camera currently used for the rendering pass
  21670. */
  21671. camera: Nullable<Camera>;
  21672. /**
  21673. * The ID of the renderingGroup being processed
  21674. */
  21675. renderingGroupId: number;
  21676. }
  21677. /**
  21678. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21679. * It is enable to manage the different groups as well as the different necessary sort functions.
  21680. * This should not be used directly aside of the few static configurations
  21681. */
  21682. export class RenderingManager {
  21683. /**
  21684. * The max id used for rendering groups (not included)
  21685. */
  21686. static MAX_RENDERINGGROUPS: number;
  21687. /**
  21688. * The min id used for rendering groups (included)
  21689. */
  21690. static MIN_RENDERINGGROUPS: number;
  21691. /**
  21692. * Used to globally prevent autoclearing scenes.
  21693. */
  21694. static AUTOCLEAR: boolean;
  21695. /**
  21696. * @hidden
  21697. */
  21698. _useSceneAutoClearSetup: boolean;
  21699. private _scene;
  21700. private _renderingGroups;
  21701. private _depthStencilBufferAlreadyCleaned;
  21702. private _autoClearDepthStencil;
  21703. private _customOpaqueSortCompareFn;
  21704. private _customAlphaTestSortCompareFn;
  21705. private _customTransparentSortCompareFn;
  21706. private _renderingGroupInfo;
  21707. /**
  21708. * Instantiates a new rendering group for a particular scene
  21709. * @param scene Defines the scene the groups belongs to
  21710. */
  21711. constructor(scene: Scene);
  21712. private _clearDepthStencilBuffer;
  21713. /**
  21714. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21715. * @hidden
  21716. */
  21717. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21718. /**
  21719. * Resets the different information of the group to prepare a new frame
  21720. * @hidden
  21721. */
  21722. reset(): void;
  21723. /**
  21724. * Dispose and release the group and its associated resources.
  21725. * @hidden
  21726. */
  21727. dispose(): void;
  21728. /**
  21729. * Clear the info related to rendering groups preventing retention points during dispose.
  21730. */
  21731. freeRenderingGroups(): void;
  21732. private _prepareRenderingGroup;
  21733. /**
  21734. * Add a sprite manager to the rendering manager in order to render it this frame.
  21735. * @param spriteManager Define the sprite manager to render
  21736. */
  21737. dispatchSprites(spriteManager: ISpriteManager): void;
  21738. /**
  21739. * Add a particle system to the rendering manager in order to render it this frame.
  21740. * @param particleSystem Define the particle system to render
  21741. */
  21742. dispatchParticles(particleSystem: IParticleSystem): void;
  21743. /**
  21744. * Add a submesh to the manager in order to render it this frame
  21745. * @param subMesh The submesh to dispatch
  21746. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21747. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21748. */
  21749. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21750. /**
  21751. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21752. * This allowed control for front to back rendering or reversly depending of the special needs.
  21753. *
  21754. * @param renderingGroupId The rendering group id corresponding to its index
  21755. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21756. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21757. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21758. */
  21759. 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;
  21760. /**
  21761. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21762. *
  21763. * @param renderingGroupId The rendering group id corresponding to its index
  21764. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21765. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21766. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21767. */
  21768. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21769. /**
  21770. * Gets the current auto clear configuration for one rendering group of the rendering
  21771. * manager.
  21772. * @param index the rendering group index to get the information for
  21773. * @returns The auto clear setup for the requested rendering group
  21774. */
  21775. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21776. }
  21777. }
  21778. declare module BABYLON {
  21779. /**
  21780. * This Helps creating a texture that will be created from a camera in your scene.
  21781. * It is basically a dynamic texture that could be used to create special effects for instance.
  21782. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21783. */
  21784. export class RenderTargetTexture extends Texture {
  21785. isCube: boolean;
  21786. /**
  21787. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21788. */
  21789. static readonly REFRESHRATE_RENDER_ONCE: number;
  21790. /**
  21791. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21792. */
  21793. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21794. /**
  21795. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21796. * the central point of your effect and can save a lot of performances.
  21797. */
  21798. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21799. /**
  21800. * Use this predicate to dynamically define the list of mesh you want to render.
  21801. * If set, the renderList property will be overwritten.
  21802. */
  21803. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21804. private _renderList;
  21805. /**
  21806. * Use this list to define the list of mesh you want to render.
  21807. */
  21808. renderList: Nullable<Array<AbstractMesh>>;
  21809. private _hookArray;
  21810. /**
  21811. * Define if particles should be rendered in your texture.
  21812. */
  21813. renderParticles: boolean;
  21814. /**
  21815. * Define if sprites should be rendered in your texture.
  21816. */
  21817. renderSprites: boolean;
  21818. /**
  21819. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21820. */
  21821. coordinatesMode: number;
  21822. /**
  21823. * Define the camera used to render the texture.
  21824. */
  21825. activeCamera: Nullable<Camera>;
  21826. /**
  21827. * Override the render function of the texture with your own one.
  21828. */
  21829. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21830. /**
  21831. * Define if camera post processes should be use while rendering the texture.
  21832. */
  21833. useCameraPostProcesses: boolean;
  21834. /**
  21835. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21836. */
  21837. ignoreCameraViewport: boolean;
  21838. private _postProcessManager;
  21839. private _postProcesses;
  21840. private _resizeObserver;
  21841. /**
  21842. * An event triggered when the texture is unbind.
  21843. */
  21844. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21845. /**
  21846. * An event triggered when the texture is unbind.
  21847. */
  21848. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21849. private _onAfterUnbindObserver;
  21850. /**
  21851. * Set a after unbind callback in the texture.
  21852. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21853. */
  21854. onAfterUnbind: () => void;
  21855. /**
  21856. * An event triggered before rendering the texture
  21857. */
  21858. onBeforeRenderObservable: Observable<number>;
  21859. private _onBeforeRenderObserver;
  21860. /**
  21861. * Set a before render callback in the texture.
  21862. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21863. */
  21864. onBeforeRender: (faceIndex: number) => void;
  21865. /**
  21866. * An event triggered after rendering the texture
  21867. */
  21868. onAfterRenderObservable: Observable<number>;
  21869. private _onAfterRenderObserver;
  21870. /**
  21871. * Set a after render callback in the texture.
  21872. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21873. */
  21874. onAfterRender: (faceIndex: number) => void;
  21875. /**
  21876. * An event triggered after the texture clear
  21877. */
  21878. onClearObservable: Observable<Engine>;
  21879. private _onClearObserver;
  21880. /**
  21881. * Set a clear callback in the texture.
  21882. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21883. */
  21884. onClear: (Engine: Engine) => void;
  21885. /**
  21886. * Define the clear color of the Render Target if it should be different from the scene.
  21887. */
  21888. clearColor: Color4;
  21889. protected _size: number | {
  21890. width: number;
  21891. height: number;
  21892. };
  21893. protected _initialSizeParameter: number | {
  21894. width: number;
  21895. height: number;
  21896. } | {
  21897. ratio: number;
  21898. };
  21899. protected _sizeRatio: Nullable<number>;
  21900. /** @hidden */
  21901. _generateMipMaps: boolean;
  21902. protected _renderingManager: RenderingManager;
  21903. /** @hidden */
  21904. _waitingRenderList: string[];
  21905. protected _doNotChangeAspectRatio: boolean;
  21906. protected _currentRefreshId: number;
  21907. protected _refreshRate: number;
  21908. protected _textureMatrix: Matrix;
  21909. protected _samples: number;
  21910. protected _renderTargetOptions: RenderTargetCreationOptions;
  21911. /**
  21912. * Gets render target creation options that were used.
  21913. */
  21914. readonly renderTargetOptions: RenderTargetCreationOptions;
  21915. protected _engine: Engine;
  21916. protected _onRatioRescale(): void;
  21917. /**
  21918. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21919. * It must define where the camera used to render the texture is set
  21920. */
  21921. boundingBoxPosition: Vector3;
  21922. private _boundingBoxSize;
  21923. /**
  21924. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21925. * When defined, the cubemap will switch to local mode
  21926. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21927. * @example https://www.babylonjs-playground.com/#RNASML
  21928. */
  21929. boundingBoxSize: Vector3;
  21930. /**
  21931. * In case the RTT has been created with a depth texture, get the associated
  21932. * depth texture.
  21933. * Otherwise, return null.
  21934. */
  21935. depthStencilTexture: Nullable<InternalTexture>;
  21936. /**
  21937. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21938. * or used a shadow, depth texture...
  21939. * @param name The friendly name of the texture
  21940. * @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)
  21941. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21942. * @param generateMipMaps True if mip maps need to be generated after render.
  21943. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21944. * @param type The type of the buffer in the RTT (int, half float, float...)
  21945. * @param isCube True if a cube texture needs to be created
  21946. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21947. * @param generateDepthBuffer True to generate a depth buffer
  21948. * @param generateStencilBuffer True to generate a stencil buffer
  21949. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21950. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21951. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21952. */
  21953. constructor(name: string, size: number | {
  21954. width: number;
  21955. height: number;
  21956. } | {
  21957. ratio: number;
  21958. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21959. /**
  21960. * Creates a depth stencil texture.
  21961. * This is only available in WebGL 2 or with the depth texture extension available.
  21962. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21963. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21964. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21965. */
  21966. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21967. private _processSizeParameter;
  21968. /**
  21969. * Define the number of samples to use in case of MSAA.
  21970. * It defaults to one meaning no MSAA has been enabled.
  21971. */
  21972. samples: number;
  21973. /**
  21974. * Resets the refresh counter of the texture and start bak from scratch.
  21975. * Could be useful to regenerate the texture if it is setup to render only once.
  21976. */
  21977. resetRefreshCounter(): void;
  21978. /**
  21979. * Define the refresh rate of the texture or the rendering frequency.
  21980. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21981. */
  21982. refreshRate: number;
  21983. /**
  21984. * Adds a post process to the render target rendering passes.
  21985. * @param postProcess define the post process to add
  21986. */
  21987. addPostProcess(postProcess: PostProcess): void;
  21988. /**
  21989. * Clear all the post processes attached to the render target
  21990. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21991. */
  21992. clearPostProcesses(dispose?: boolean): void;
  21993. /**
  21994. * Remove one of the post process from the list of attached post processes to the texture
  21995. * @param postProcess define the post process to remove from the list
  21996. */
  21997. removePostProcess(postProcess: PostProcess): void;
  21998. /** @hidden */
  21999. _shouldRender(): boolean;
  22000. /**
  22001. * Gets the actual render size of the texture.
  22002. * @returns the width of the render size
  22003. */
  22004. getRenderSize(): number;
  22005. /**
  22006. * Gets the actual render width of the texture.
  22007. * @returns the width of the render size
  22008. */
  22009. getRenderWidth(): number;
  22010. /**
  22011. * Gets the actual render height of the texture.
  22012. * @returns the height of the render size
  22013. */
  22014. getRenderHeight(): number;
  22015. /**
  22016. * Get if the texture can be rescaled or not.
  22017. */
  22018. readonly canRescale: boolean;
  22019. /**
  22020. * Resize the texture using a ratio.
  22021. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22022. */
  22023. scale(ratio: number): void;
  22024. /**
  22025. * Get the texture reflection matrix used to rotate/transform the reflection.
  22026. * @returns the reflection matrix
  22027. */
  22028. getReflectionTextureMatrix(): Matrix;
  22029. /**
  22030. * Resize the texture to a new desired size.
  22031. * Be carrefull as it will recreate all the data in the new texture.
  22032. * @param size Define the new size. It can be:
  22033. * - a number for squared texture,
  22034. * - an object containing { width: number, height: number }
  22035. * - or an object containing a ratio { ratio: number }
  22036. */
  22037. resize(size: number | {
  22038. width: number;
  22039. height: number;
  22040. } | {
  22041. ratio: number;
  22042. }): void;
  22043. /**
  22044. * Renders all the objects from the render list into the texture.
  22045. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22046. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22047. */
  22048. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22049. private _bestReflectionRenderTargetDimension;
  22050. /**
  22051. * @hidden
  22052. * @param faceIndex face index to bind to if this is a cubetexture
  22053. */
  22054. _bindFrameBuffer(faceIndex?: number): void;
  22055. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22056. private renderToTarget;
  22057. /**
  22058. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22059. * This allowed control for front to back rendering or reversly depending of the special needs.
  22060. *
  22061. * @param renderingGroupId The rendering group id corresponding to its index
  22062. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22063. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22064. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22065. */
  22066. 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;
  22067. /**
  22068. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22069. *
  22070. * @param renderingGroupId The rendering group id corresponding to its index
  22071. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22072. */
  22073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22074. /**
  22075. * Clones the texture.
  22076. * @returns the cloned texture
  22077. */
  22078. clone(): RenderTargetTexture;
  22079. /**
  22080. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22081. * @returns The JSON representation of the texture
  22082. */
  22083. serialize(): any;
  22084. /**
  22085. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22086. */
  22087. disposeFramebufferObjects(): void;
  22088. /**
  22089. * Dispose the texture and release its associated resources.
  22090. */
  22091. dispose(): void;
  22092. /** @hidden */
  22093. _rebuild(): void;
  22094. /**
  22095. * Clear the info related to rendering groups preventing retention point in material dispose.
  22096. */
  22097. freeRenderingGroups(): void;
  22098. /**
  22099. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22100. * @returns the view count
  22101. */
  22102. getViewCount(): number;
  22103. }
  22104. }
  22105. declare module BABYLON {
  22106. /**
  22107. * Base class for the main features of a material in Babylon.js
  22108. */
  22109. export class Material implements IAnimatable {
  22110. /**
  22111. * Returns the triangle fill mode
  22112. */
  22113. static readonly TriangleFillMode: number;
  22114. /**
  22115. * Returns the wireframe mode
  22116. */
  22117. static readonly WireFrameFillMode: number;
  22118. /**
  22119. * Returns the point fill mode
  22120. */
  22121. static readonly PointFillMode: number;
  22122. /**
  22123. * Returns the point list draw mode
  22124. */
  22125. static readonly PointListDrawMode: number;
  22126. /**
  22127. * Returns the line list draw mode
  22128. */
  22129. static readonly LineListDrawMode: number;
  22130. /**
  22131. * Returns the line loop draw mode
  22132. */
  22133. static readonly LineLoopDrawMode: number;
  22134. /**
  22135. * Returns the line strip draw mode
  22136. */
  22137. static readonly LineStripDrawMode: number;
  22138. /**
  22139. * Returns the triangle strip draw mode
  22140. */
  22141. static readonly TriangleStripDrawMode: number;
  22142. /**
  22143. * Returns the triangle fan draw mode
  22144. */
  22145. static readonly TriangleFanDrawMode: number;
  22146. /**
  22147. * Stores the clock-wise side orientation
  22148. */
  22149. static readonly ClockWiseSideOrientation: number;
  22150. /**
  22151. * Stores the counter clock-wise side orientation
  22152. */
  22153. static readonly CounterClockWiseSideOrientation: number;
  22154. /**
  22155. * The dirty texture flag value
  22156. */
  22157. static readonly TextureDirtyFlag: number;
  22158. /**
  22159. * The dirty light flag value
  22160. */
  22161. static readonly LightDirtyFlag: number;
  22162. /**
  22163. * The dirty fresnel flag value
  22164. */
  22165. static readonly FresnelDirtyFlag: number;
  22166. /**
  22167. * The dirty attribute flag value
  22168. */
  22169. static readonly AttributesDirtyFlag: number;
  22170. /**
  22171. * The dirty misc flag value
  22172. */
  22173. static readonly MiscDirtyFlag: number;
  22174. /**
  22175. * The all dirty flag value
  22176. */
  22177. static readonly AllDirtyFlag: number;
  22178. /**
  22179. * The ID of the material
  22180. */
  22181. id: string;
  22182. /**
  22183. * Gets or sets the unique id of the material
  22184. */
  22185. uniqueId: number;
  22186. /**
  22187. * The name of the material
  22188. */
  22189. name: string;
  22190. /**
  22191. * Gets or sets user defined metadata
  22192. */
  22193. metadata: any;
  22194. /**
  22195. * For internal use only. Please do not use.
  22196. */
  22197. reservedDataStore: any;
  22198. /**
  22199. * Specifies if the ready state should be checked on each call
  22200. */
  22201. checkReadyOnEveryCall: boolean;
  22202. /**
  22203. * Specifies if the ready state should be checked once
  22204. */
  22205. checkReadyOnlyOnce: boolean;
  22206. /**
  22207. * The state of the material
  22208. */
  22209. state: string;
  22210. /**
  22211. * The alpha value of the material
  22212. */
  22213. protected _alpha: number;
  22214. /**
  22215. * List of inspectable custom properties (used by the Inspector)
  22216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22217. */
  22218. inspectableCustomProperties: IInspectable[];
  22219. /**
  22220. * Sets the alpha value of the material
  22221. */
  22222. /**
  22223. * Gets the alpha value of the material
  22224. */
  22225. alpha: number;
  22226. /**
  22227. * Specifies if back face culling is enabled
  22228. */
  22229. protected _backFaceCulling: boolean;
  22230. /**
  22231. * Sets the back-face culling state
  22232. */
  22233. /**
  22234. * Gets the back-face culling state
  22235. */
  22236. backFaceCulling: boolean;
  22237. /**
  22238. * Stores the value for side orientation
  22239. */
  22240. sideOrientation: number;
  22241. /**
  22242. * Callback triggered when the material is compiled
  22243. */
  22244. onCompiled: Nullable<(effect: Effect) => void>;
  22245. /**
  22246. * Callback triggered when an error occurs
  22247. */
  22248. onError: Nullable<(effect: Effect, errors: string) => void>;
  22249. /**
  22250. * Callback triggered to get the render target textures
  22251. */
  22252. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22253. /**
  22254. * Gets a boolean indicating that current material needs to register RTT
  22255. */
  22256. readonly hasRenderTargetTextures: boolean;
  22257. /**
  22258. * Specifies if the material should be serialized
  22259. */
  22260. doNotSerialize: boolean;
  22261. /**
  22262. * @hidden
  22263. */
  22264. _storeEffectOnSubMeshes: boolean;
  22265. /**
  22266. * Stores the animations for the material
  22267. */
  22268. animations: Nullable<Array<Animation>>;
  22269. /**
  22270. * An event triggered when the material is disposed
  22271. */
  22272. onDisposeObservable: Observable<Material>;
  22273. /**
  22274. * An observer which watches for dispose events
  22275. */
  22276. private _onDisposeObserver;
  22277. private _onUnBindObservable;
  22278. /**
  22279. * Called during a dispose event
  22280. */
  22281. onDispose: () => void;
  22282. private _onBindObservable;
  22283. /**
  22284. * An event triggered when the material is bound
  22285. */
  22286. readonly onBindObservable: Observable<AbstractMesh>;
  22287. /**
  22288. * An observer which watches for bind events
  22289. */
  22290. private _onBindObserver;
  22291. /**
  22292. * Called during a bind event
  22293. */
  22294. onBind: (Mesh: AbstractMesh) => void;
  22295. /**
  22296. * An event triggered when the material is unbound
  22297. */
  22298. readonly onUnBindObservable: Observable<Material>;
  22299. /**
  22300. * Stores the value of the alpha mode
  22301. */
  22302. private _alphaMode;
  22303. /**
  22304. * Sets the value of the alpha mode.
  22305. *
  22306. * | Value | Type | Description |
  22307. * | --- | --- | --- |
  22308. * | 0 | ALPHA_DISABLE | |
  22309. * | 1 | ALPHA_ADD | |
  22310. * | 2 | ALPHA_COMBINE | |
  22311. * | 3 | ALPHA_SUBTRACT | |
  22312. * | 4 | ALPHA_MULTIPLY | |
  22313. * | 5 | ALPHA_MAXIMIZED | |
  22314. * | 6 | ALPHA_ONEONE | |
  22315. * | 7 | ALPHA_PREMULTIPLIED | |
  22316. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22317. * | 9 | ALPHA_INTERPOLATE | |
  22318. * | 10 | ALPHA_SCREENMODE | |
  22319. *
  22320. */
  22321. /**
  22322. * Gets the value of the alpha mode
  22323. */
  22324. alphaMode: number;
  22325. /**
  22326. * Stores the state of the need depth pre-pass value
  22327. */
  22328. private _needDepthPrePass;
  22329. /**
  22330. * Sets the need depth pre-pass value
  22331. */
  22332. /**
  22333. * Gets the depth pre-pass value
  22334. */
  22335. needDepthPrePass: boolean;
  22336. /**
  22337. * Specifies if depth writing should be disabled
  22338. */
  22339. disableDepthWrite: boolean;
  22340. /**
  22341. * Specifies if depth writing should be forced
  22342. */
  22343. forceDepthWrite: boolean;
  22344. /**
  22345. * Specifies if there should be a separate pass for culling
  22346. */
  22347. separateCullingPass: boolean;
  22348. /**
  22349. * Stores the state specifing if fog should be enabled
  22350. */
  22351. private _fogEnabled;
  22352. /**
  22353. * Sets the state for enabling fog
  22354. */
  22355. /**
  22356. * Gets the value of the fog enabled state
  22357. */
  22358. fogEnabled: boolean;
  22359. /**
  22360. * Stores the size of points
  22361. */
  22362. pointSize: number;
  22363. /**
  22364. * Stores the z offset value
  22365. */
  22366. zOffset: number;
  22367. /**
  22368. * Gets a value specifying if wireframe mode is enabled
  22369. */
  22370. /**
  22371. * Sets the state of wireframe mode
  22372. */
  22373. wireframe: boolean;
  22374. /**
  22375. * Gets the value specifying if point clouds are enabled
  22376. */
  22377. /**
  22378. * Sets the state of point cloud mode
  22379. */
  22380. pointsCloud: boolean;
  22381. /**
  22382. * Gets the material fill mode
  22383. */
  22384. /**
  22385. * Sets the material fill mode
  22386. */
  22387. fillMode: number;
  22388. /**
  22389. * @hidden
  22390. * Stores the effects for the material
  22391. */
  22392. _effect: Nullable<Effect>;
  22393. /**
  22394. * @hidden
  22395. * Specifies if the material was previously ready
  22396. */
  22397. _wasPreviouslyReady: boolean;
  22398. /**
  22399. * Specifies if uniform buffers should be used
  22400. */
  22401. private _useUBO;
  22402. /**
  22403. * Stores a reference to the scene
  22404. */
  22405. private _scene;
  22406. /**
  22407. * Stores the fill mode state
  22408. */
  22409. private _fillMode;
  22410. /**
  22411. * Specifies if the depth write state should be cached
  22412. */
  22413. private _cachedDepthWriteState;
  22414. /**
  22415. * Stores the uniform buffer
  22416. */
  22417. protected _uniformBuffer: UniformBuffer;
  22418. /** @hidden */
  22419. _indexInSceneMaterialArray: number;
  22420. /** @hidden */
  22421. meshMap: Nullable<{
  22422. [id: string]: AbstractMesh | undefined;
  22423. }>;
  22424. /**
  22425. * Creates a material instance
  22426. * @param name defines the name of the material
  22427. * @param scene defines the scene to reference
  22428. * @param doNotAdd specifies if the material should be added to the scene
  22429. */
  22430. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22431. /**
  22432. * Returns a string representation of the current material
  22433. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22434. * @returns a string with material information
  22435. */
  22436. toString(fullDetails?: boolean): string;
  22437. /**
  22438. * Gets the class name of the material
  22439. * @returns a string with the class name of the material
  22440. */
  22441. getClassName(): string;
  22442. /**
  22443. * Specifies if updates for the material been locked
  22444. */
  22445. readonly isFrozen: boolean;
  22446. /**
  22447. * Locks updates for the material
  22448. */
  22449. freeze(): void;
  22450. /**
  22451. * Unlocks updates for the material
  22452. */
  22453. unfreeze(): void;
  22454. /**
  22455. * Specifies if the material is ready to be used
  22456. * @param mesh defines the mesh to check
  22457. * @param useInstances specifies if instances should be used
  22458. * @returns a boolean indicating if the material is ready to be used
  22459. */
  22460. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22461. /**
  22462. * Specifies that the submesh is ready to be used
  22463. * @param mesh defines the mesh to check
  22464. * @param subMesh defines which submesh to check
  22465. * @param useInstances specifies that instances should be used
  22466. * @returns a boolean indicating that the submesh is ready or not
  22467. */
  22468. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22469. /**
  22470. * Returns the material effect
  22471. * @returns the effect associated with the material
  22472. */
  22473. getEffect(): Nullable<Effect>;
  22474. /**
  22475. * Returns the current scene
  22476. * @returns a Scene
  22477. */
  22478. getScene(): Scene;
  22479. /**
  22480. * Specifies if the material will require alpha blending
  22481. * @returns a boolean specifying if alpha blending is needed
  22482. */
  22483. needAlphaBlending(): boolean;
  22484. /**
  22485. * Specifies if the mesh will require alpha blending
  22486. * @param mesh defines the mesh to check
  22487. * @returns a boolean specifying if alpha blending is needed for the mesh
  22488. */
  22489. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22490. /**
  22491. * Specifies if this material should be rendered in alpha test mode
  22492. * @returns a boolean specifying if an alpha test is needed.
  22493. */
  22494. needAlphaTesting(): boolean;
  22495. /**
  22496. * Gets the texture used for the alpha test
  22497. * @returns the texture to use for alpha testing
  22498. */
  22499. getAlphaTestTexture(): Nullable<BaseTexture>;
  22500. /**
  22501. * Marks the material to indicate that it needs to be re-calculated
  22502. */
  22503. markDirty(): void;
  22504. /** @hidden */
  22505. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22506. /**
  22507. * Binds the material to the mesh
  22508. * @param world defines the world transformation matrix
  22509. * @param mesh defines the mesh to bind the material to
  22510. */
  22511. bind(world: Matrix, mesh?: Mesh): void;
  22512. /**
  22513. * Binds the submesh to the material
  22514. * @param world defines the world transformation matrix
  22515. * @param mesh defines the mesh containing the submesh
  22516. * @param subMesh defines the submesh to bind the material to
  22517. */
  22518. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22519. /**
  22520. * Binds the world matrix to the material
  22521. * @param world defines the world transformation matrix
  22522. */
  22523. bindOnlyWorldMatrix(world: Matrix): void;
  22524. /**
  22525. * Binds the scene's uniform buffer to the effect.
  22526. * @param effect defines the effect to bind to the scene uniform buffer
  22527. * @param sceneUbo defines the uniform buffer storing scene data
  22528. */
  22529. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22530. /**
  22531. * Binds the view matrix to the effect
  22532. * @param effect defines the effect to bind the view matrix to
  22533. */
  22534. bindView(effect: Effect): void;
  22535. /**
  22536. * Binds the view projection matrix to the effect
  22537. * @param effect defines the effect to bind the view projection matrix to
  22538. */
  22539. bindViewProjection(effect: Effect): void;
  22540. /**
  22541. * Specifies if material alpha testing should be turned on for the mesh
  22542. * @param mesh defines the mesh to check
  22543. */
  22544. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22545. /**
  22546. * Processes to execute after binding the material to a mesh
  22547. * @param mesh defines the rendered mesh
  22548. */
  22549. protected _afterBind(mesh?: Mesh): void;
  22550. /**
  22551. * Unbinds the material from the mesh
  22552. */
  22553. unbind(): void;
  22554. /**
  22555. * Gets the active textures from the material
  22556. * @returns an array of textures
  22557. */
  22558. getActiveTextures(): BaseTexture[];
  22559. /**
  22560. * Specifies if the material uses a texture
  22561. * @param texture defines the texture to check against the material
  22562. * @returns a boolean specifying if the material uses the texture
  22563. */
  22564. hasTexture(texture: BaseTexture): boolean;
  22565. /**
  22566. * Makes a duplicate of the material, and gives it a new name
  22567. * @param name defines the new name for the duplicated material
  22568. * @returns the cloned material
  22569. */
  22570. clone(name: string): Nullable<Material>;
  22571. /**
  22572. * Gets the meshes bound to the material
  22573. * @returns an array of meshes bound to the material
  22574. */
  22575. getBindedMeshes(): AbstractMesh[];
  22576. /**
  22577. * Force shader compilation
  22578. * @param mesh defines the mesh associated with this material
  22579. * @param onCompiled defines a function to execute once the material is compiled
  22580. * @param options defines the options to configure the compilation
  22581. */
  22582. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22583. clipPlane: boolean;
  22584. }>): void;
  22585. /**
  22586. * Force shader compilation
  22587. * @param mesh defines the mesh that will use this material
  22588. * @param options defines additional options for compiling the shaders
  22589. * @returns a promise that resolves when the compilation completes
  22590. */
  22591. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22592. clipPlane: boolean;
  22593. }>): Promise<void>;
  22594. private static readonly _AllDirtyCallBack;
  22595. private static readonly _ImageProcessingDirtyCallBack;
  22596. private static readonly _TextureDirtyCallBack;
  22597. private static readonly _FresnelDirtyCallBack;
  22598. private static readonly _MiscDirtyCallBack;
  22599. private static readonly _LightsDirtyCallBack;
  22600. private static readonly _AttributeDirtyCallBack;
  22601. private static _FresnelAndMiscDirtyCallBack;
  22602. private static _TextureAndMiscDirtyCallBack;
  22603. private static readonly _DirtyCallbackArray;
  22604. private static readonly _RunDirtyCallBacks;
  22605. /**
  22606. * Marks a define in the material to indicate that it needs to be re-computed
  22607. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22608. */
  22609. markAsDirty(flag: number): void;
  22610. /**
  22611. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22612. * @param func defines a function which checks material defines against the submeshes
  22613. */
  22614. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22615. /**
  22616. * Indicates that we need to re-calculated for all submeshes
  22617. */
  22618. protected _markAllSubMeshesAsAllDirty(): void;
  22619. /**
  22620. * Indicates that image processing needs to be re-calculated for all submeshes
  22621. */
  22622. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22623. /**
  22624. * Indicates that textures need to be re-calculated for all submeshes
  22625. */
  22626. protected _markAllSubMeshesAsTexturesDirty(): void;
  22627. /**
  22628. * Indicates that fresnel needs to be re-calculated for all submeshes
  22629. */
  22630. protected _markAllSubMeshesAsFresnelDirty(): void;
  22631. /**
  22632. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22633. */
  22634. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22635. /**
  22636. * Indicates that lights need to be re-calculated for all submeshes
  22637. */
  22638. protected _markAllSubMeshesAsLightsDirty(): void;
  22639. /**
  22640. * Indicates that attributes need to be re-calculated for all submeshes
  22641. */
  22642. protected _markAllSubMeshesAsAttributesDirty(): void;
  22643. /**
  22644. * Indicates that misc needs to be re-calculated for all submeshes
  22645. */
  22646. protected _markAllSubMeshesAsMiscDirty(): void;
  22647. /**
  22648. * Indicates that textures and misc need to be re-calculated for all submeshes
  22649. */
  22650. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22651. /**
  22652. * Disposes the material
  22653. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22654. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22655. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22656. */
  22657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22658. /** @hidden */
  22659. private releaseVertexArrayObject;
  22660. /**
  22661. * Serializes this material
  22662. * @returns the serialized material object
  22663. */
  22664. serialize(): any;
  22665. /**
  22666. * Creates a material from parsed material data
  22667. * @param parsedMaterial defines parsed material data
  22668. * @param scene defines the hosting scene
  22669. * @param rootUrl defines the root URL to use to load textures
  22670. * @returns a new material
  22671. */
  22672. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22673. }
  22674. }
  22675. declare module BABYLON {
  22676. /**
  22677. * Base class for submeshes
  22678. */
  22679. export class BaseSubMesh {
  22680. /** @hidden */
  22681. _materialDefines: Nullable<MaterialDefines>;
  22682. /** @hidden */
  22683. _materialEffect: Nullable<Effect>;
  22684. /**
  22685. * Gets associated effect
  22686. */
  22687. readonly effect: Nullable<Effect>;
  22688. /**
  22689. * Sets associated effect (effect used to render this submesh)
  22690. * @param effect defines the effect to associate with
  22691. * @param defines defines the set of defines used to compile this effect
  22692. */
  22693. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22694. }
  22695. /**
  22696. * Defines a subdivision inside a mesh
  22697. */
  22698. export class SubMesh extends BaseSubMesh implements ICullable {
  22699. /** the material index to use */
  22700. materialIndex: number;
  22701. /** vertex index start */
  22702. verticesStart: number;
  22703. /** vertices count */
  22704. verticesCount: number;
  22705. /** index start */
  22706. indexStart: number;
  22707. /** indices count */
  22708. indexCount: number;
  22709. /** @hidden */
  22710. _linesIndexCount: number;
  22711. private _mesh;
  22712. private _renderingMesh;
  22713. private _boundingInfo;
  22714. private _linesIndexBuffer;
  22715. /** @hidden */
  22716. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22717. /** @hidden */
  22718. _trianglePlanes: Plane[];
  22719. /** @hidden */
  22720. _lastColliderTransformMatrix: Nullable<Matrix>;
  22721. /** @hidden */
  22722. _renderId: number;
  22723. /** @hidden */
  22724. _alphaIndex: number;
  22725. /** @hidden */
  22726. _distanceToCamera: number;
  22727. /** @hidden */
  22728. _id: number;
  22729. private _currentMaterial;
  22730. /**
  22731. * Add a new submesh to a mesh
  22732. * @param materialIndex defines the material index to use
  22733. * @param verticesStart defines vertex index start
  22734. * @param verticesCount defines vertices count
  22735. * @param indexStart defines index start
  22736. * @param indexCount defines indices count
  22737. * @param mesh defines the parent mesh
  22738. * @param renderingMesh defines an optional rendering mesh
  22739. * @param createBoundingBox defines if bounding box should be created for this submesh
  22740. * @returns the new submesh
  22741. */
  22742. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22743. /**
  22744. * Creates a new submesh
  22745. * @param materialIndex defines the material index to use
  22746. * @param verticesStart defines vertex index start
  22747. * @param verticesCount defines vertices count
  22748. * @param indexStart defines index start
  22749. * @param indexCount defines indices count
  22750. * @param mesh defines the parent mesh
  22751. * @param renderingMesh defines an optional rendering mesh
  22752. * @param createBoundingBox defines if bounding box should be created for this submesh
  22753. */
  22754. constructor(
  22755. /** the material index to use */
  22756. materialIndex: number,
  22757. /** vertex index start */
  22758. verticesStart: number,
  22759. /** vertices count */
  22760. verticesCount: number,
  22761. /** index start */
  22762. indexStart: number,
  22763. /** indices count */
  22764. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22765. /**
  22766. * Returns true if this submesh covers the entire parent mesh
  22767. * @ignorenaming
  22768. */
  22769. readonly IsGlobal: boolean;
  22770. /**
  22771. * Returns the submesh BoudingInfo object
  22772. * @returns current bounding info (or mesh's one if the submesh is global)
  22773. */
  22774. getBoundingInfo(): BoundingInfo;
  22775. /**
  22776. * Sets the submesh BoundingInfo
  22777. * @param boundingInfo defines the new bounding info to use
  22778. * @returns the SubMesh
  22779. */
  22780. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22781. /**
  22782. * Returns the mesh of the current submesh
  22783. * @return the parent mesh
  22784. */
  22785. getMesh(): AbstractMesh;
  22786. /**
  22787. * Returns the rendering mesh of the submesh
  22788. * @returns the rendering mesh (could be different from parent mesh)
  22789. */
  22790. getRenderingMesh(): Mesh;
  22791. /**
  22792. * Returns the submesh material
  22793. * @returns null or the current material
  22794. */
  22795. getMaterial(): Nullable<Material>;
  22796. /**
  22797. * Sets a new updated BoundingInfo object to the submesh
  22798. * @param data defines an optional position array to use to determine the bounding info
  22799. * @returns the SubMesh
  22800. */
  22801. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22802. /** @hidden */
  22803. _checkCollision(collider: Collider): boolean;
  22804. /**
  22805. * Updates the submesh BoundingInfo
  22806. * @param world defines the world matrix to use to update the bounding info
  22807. * @returns the submesh
  22808. */
  22809. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22810. /**
  22811. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22812. * @param frustumPlanes defines the frustum planes
  22813. * @returns true if the submesh is intersecting with the frustum
  22814. */
  22815. isInFrustum(frustumPlanes: Plane[]): boolean;
  22816. /**
  22817. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22818. * @param frustumPlanes defines the frustum planes
  22819. * @returns true if the submesh is inside the frustum
  22820. */
  22821. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22822. /**
  22823. * Renders the submesh
  22824. * @param enableAlphaMode defines if alpha needs to be used
  22825. * @returns the submesh
  22826. */
  22827. render(enableAlphaMode: boolean): SubMesh;
  22828. /**
  22829. * @hidden
  22830. */
  22831. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22832. /**
  22833. * Checks if the submesh intersects with a ray
  22834. * @param ray defines the ray to test
  22835. * @returns true is the passed ray intersects the submesh bounding box
  22836. */
  22837. canIntersects(ray: Ray): boolean;
  22838. /**
  22839. * Intersects current submesh with a ray
  22840. * @param ray defines the ray to test
  22841. * @param positions defines mesh's positions array
  22842. * @param indices defines mesh's indices array
  22843. * @param fastCheck defines if only bounding info should be used
  22844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22845. * @returns intersection info or null if no intersection
  22846. */
  22847. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22848. /** @hidden */
  22849. private _intersectLines;
  22850. /** @hidden */
  22851. private _intersectUnIndexedLines;
  22852. /** @hidden */
  22853. private _intersectTriangles;
  22854. /** @hidden */
  22855. private _intersectUnIndexedTriangles;
  22856. /** @hidden */
  22857. _rebuild(): void;
  22858. /**
  22859. * Creates a new submesh from the passed mesh
  22860. * @param newMesh defines the new hosting mesh
  22861. * @param newRenderingMesh defines an optional rendering mesh
  22862. * @returns the new submesh
  22863. */
  22864. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22865. /**
  22866. * Release associated resources
  22867. */
  22868. dispose(): void;
  22869. /**
  22870. * Gets the class name
  22871. * @returns the string "SubMesh".
  22872. */
  22873. getClassName(): string;
  22874. /**
  22875. * Creates a new submesh from indices data
  22876. * @param materialIndex the index of the main mesh material
  22877. * @param startIndex the index where to start the copy in the mesh indices array
  22878. * @param indexCount the number of indices to copy then from the startIndex
  22879. * @param mesh the main mesh to create the submesh from
  22880. * @param renderingMesh the optional rendering mesh
  22881. * @returns a new submesh
  22882. */
  22883. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22884. }
  22885. }
  22886. declare module BABYLON {
  22887. /**
  22888. * Class used to store geometry data (vertex buffers + index buffer)
  22889. */
  22890. export class Geometry implements IGetSetVerticesData {
  22891. /**
  22892. * Gets or sets the ID of the geometry
  22893. */
  22894. id: string;
  22895. /**
  22896. * Gets or sets the unique ID of the geometry
  22897. */
  22898. uniqueId: number;
  22899. /**
  22900. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22901. */
  22902. delayLoadState: number;
  22903. /**
  22904. * Gets the file containing the data to load when running in delay load state
  22905. */
  22906. delayLoadingFile: Nullable<string>;
  22907. /**
  22908. * Callback called when the geometry is updated
  22909. */
  22910. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22911. private _scene;
  22912. private _engine;
  22913. private _meshes;
  22914. private _totalVertices;
  22915. /** @hidden */
  22916. _indices: IndicesArray;
  22917. /** @hidden */
  22918. _vertexBuffers: {
  22919. [key: string]: VertexBuffer;
  22920. };
  22921. private _isDisposed;
  22922. private _extend;
  22923. private _boundingBias;
  22924. /** @hidden */
  22925. _delayInfo: Array<string>;
  22926. private _indexBuffer;
  22927. private _indexBufferIsUpdatable;
  22928. /** @hidden */
  22929. _boundingInfo: Nullable<BoundingInfo>;
  22930. /** @hidden */
  22931. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22932. /** @hidden */
  22933. _softwareSkinningFrameId: number;
  22934. private _vertexArrayObjects;
  22935. private _updatable;
  22936. /** @hidden */
  22937. _positions: Nullable<Vector3[]>;
  22938. /**
  22939. * 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
  22940. */
  22941. /**
  22942. * 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
  22943. */
  22944. boundingBias: Vector2;
  22945. /**
  22946. * Static function used to attach a new empty geometry to a mesh
  22947. * @param mesh defines the mesh to attach the geometry to
  22948. * @returns the new Geometry
  22949. */
  22950. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22951. /**
  22952. * Creates a new geometry
  22953. * @param id defines the unique ID
  22954. * @param scene defines the hosting scene
  22955. * @param vertexData defines the VertexData used to get geometry data
  22956. * @param updatable defines if geometry must be updatable (false by default)
  22957. * @param mesh defines the mesh that will be associated with the geometry
  22958. */
  22959. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22960. /**
  22961. * Gets the current extend of the geometry
  22962. */
  22963. readonly extend: {
  22964. minimum: Vector3;
  22965. maximum: Vector3;
  22966. };
  22967. /**
  22968. * Gets the hosting scene
  22969. * @returns the hosting Scene
  22970. */
  22971. getScene(): Scene;
  22972. /**
  22973. * Gets the hosting engine
  22974. * @returns the hosting Engine
  22975. */
  22976. getEngine(): Engine;
  22977. /**
  22978. * Defines if the geometry is ready to use
  22979. * @returns true if the geometry is ready to be used
  22980. */
  22981. isReady(): boolean;
  22982. /**
  22983. * Gets a value indicating that the geometry should not be serialized
  22984. */
  22985. readonly doNotSerialize: boolean;
  22986. /** @hidden */
  22987. _rebuild(): void;
  22988. /**
  22989. * Affects all geometry data in one call
  22990. * @param vertexData defines the geometry data
  22991. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22992. */
  22993. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22994. /**
  22995. * Set specific vertex data
  22996. * @param kind defines the data kind (Position, normal, etc...)
  22997. * @param data defines the vertex data to use
  22998. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22999. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23000. */
  23001. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23002. /**
  23003. * Removes a specific vertex data
  23004. * @param kind defines the data kind (Position, normal, etc...)
  23005. */
  23006. removeVerticesData(kind: string): void;
  23007. /**
  23008. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23009. * @param buffer defines the vertex buffer to use
  23010. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23011. */
  23012. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23013. /**
  23014. * Update a specific vertex buffer
  23015. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23016. * It will do nothing if the buffer is not updatable
  23017. * @param kind defines the data kind (Position, normal, etc...)
  23018. * @param data defines the data to use
  23019. * @param offset defines the offset in the target buffer where to store the data
  23020. * @param useBytes set to true if the offset is in bytes
  23021. */
  23022. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23023. /**
  23024. * Update a specific vertex buffer
  23025. * This function will create a new buffer if the current one is not updatable
  23026. * @param kind defines the data kind (Position, normal, etc...)
  23027. * @param data defines the data to use
  23028. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23029. */
  23030. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23031. private _updateBoundingInfo;
  23032. /** @hidden */
  23033. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23034. /**
  23035. * Gets total number of vertices
  23036. * @returns the total number of vertices
  23037. */
  23038. getTotalVertices(): number;
  23039. /**
  23040. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23041. * @param kind defines the data kind (Position, normal, etc...)
  23042. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23043. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23044. * @returns a float array containing vertex data
  23045. */
  23046. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23047. /**
  23048. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23049. * @param kind defines the data kind (Position, normal, etc...)
  23050. * @returns true if the vertex buffer with the specified kind is updatable
  23051. */
  23052. isVertexBufferUpdatable(kind: string): boolean;
  23053. /**
  23054. * Gets a specific vertex buffer
  23055. * @param kind defines the data kind (Position, normal, etc...)
  23056. * @returns a VertexBuffer
  23057. */
  23058. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23059. /**
  23060. * Returns all vertex buffers
  23061. * @return an object holding all vertex buffers indexed by kind
  23062. */
  23063. getVertexBuffers(): Nullable<{
  23064. [key: string]: VertexBuffer;
  23065. }>;
  23066. /**
  23067. * Gets a boolean indicating if specific vertex buffer is present
  23068. * @param kind defines the data kind (Position, normal, etc...)
  23069. * @returns true if data is present
  23070. */
  23071. isVerticesDataPresent(kind: string): boolean;
  23072. /**
  23073. * Gets a list of all attached data kinds (Position, normal, etc...)
  23074. * @returns a list of string containing all kinds
  23075. */
  23076. getVerticesDataKinds(): string[];
  23077. /**
  23078. * Update index buffer
  23079. * @param indices defines the indices to store in the index buffer
  23080. * @param offset defines the offset in the target buffer where to store the data
  23081. * @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)
  23082. */
  23083. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23084. /**
  23085. * Creates a new index buffer
  23086. * @param indices defines the indices to store in the index buffer
  23087. * @param totalVertices defines the total number of vertices (could be null)
  23088. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23089. */
  23090. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23091. /**
  23092. * Return the total number of indices
  23093. * @returns the total number of indices
  23094. */
  23095. getTotalIndices(): number;
  23096. /**
  23097. * Gets the index buffer array
  23098. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23099. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23100. * @returns the index buffer array
  23101. */
  23102. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23103. /**
  23104. * Gets the index buffer
  23105. * @return the index buffer
  23106. */
  23107. getIndexBuffer(): Nullable<DataBuffer>;
  23108. /** @hidden */
  23109. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23110. /**
  23111. * Release the associated resources for a specific mesh
  23112. * @param mesh defines the source mesh
  23113. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23114. */
  23115. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23116. /**
  23117. * Apply current geometry to a given mesh
  23118. * @param mesh defines the mesh to apply geometry to
  23119. */
  23120. applyToMesh(mesh: Mesh): void;
  23121. private _updateExtend;
  23122. private _applyToMesh;
  23123. private notifyUpdate;
  23124. /**
  23125. * Load the geometry if it was flagged as delay loaded
  23126. * @param scene defines the hosting scene
  23127. * @param onLoaded defines a callback called when the geometry is loaded
  23128. */
  23129. load(scene: Scene, onLoaded?: () => void): void;
  23130. private _queueLoad;
  23131. /**
  23132. * Invert the geometry to move from a right handed system to a left handed one.
  23133. */
  23134. toLeftHanded(): void;
  23135. /** @hidden */
  23136. _resetPointsArrayCache(): void;
  23137. /** @hidden */
  23138. _generatePointsArray(): boolean;
  23139. /**
  23140. * Gets a value indicating if the geometry is disposed
  23141. * @returns true if the geometry was disposed
  23142. */
  23143. isDisposed(): boolean;
  23144. private _disposeVertexArrayObjects;
  23145. /**
  23146. * Free all associated resources
  23147. */
  23148. dispose(): void;
  23149. /**
  23150. * Clone the current geometry into a new geometry
  23151. * @param id defines the unique ID of the new geometry
  23152. * @returns a new geometry object
  23153. */
  23154. copy(id: string): Geometry;
  23155. /**
  23156. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23157. * @return a JSON representation of the current geometry data (without the vertices data)
  23158. */
  23159. serialize(): any;
  23160. private toNumberArray;
  23161. /**
  23162. * Serialize all vertices data into a JSON oject
  23163. * @returns a JSON representation of the current geometry data
  23164. */
  23165. serializeVerticeData(): any;
  23166. /**
  23167. * Extracts a clone of a mesh geometry
  23168. * @param mesh defines the source mesh
  23169. * @param id defines the unique ID of the new geometry object
  23170. * @returns the new geometry object
  23171. */
  23172. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23173. /**
  23174. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23175. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23176. * Be aware Math.random() could cause collisions, but:
  23177. * "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"
  23178. * @returns a string containing a new GUID
  23179. */
  23180. static RandomId(): string;
  23181. /** @hidden */
  23182. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23183. private static _CleanMatricesWeights;
  23184. /**
  23185. * Create a new geometry from persisted data (Using .babylon file format)
  23186. * @param parsedVertexData defines the persisted data
  23187. * @param scene defines the hosting scene
  23188. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23189. * @returns the new geometry object
  23190. */
  23191. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23192. }
  23193. }
  23194. declare module BABYLON {
  23195. /**
  23196. * Define an interface for all classes that will get and set the data on vertices
  23197. */
  23198. export interface IGetSetVerticesData {
  23199. /**
  23200. * Gets a boolean indicating if specific vertex data is present
  23201. * @param kind defines the vertex data kind to use
  23202. * @returns true is data kind is present
  23203. */
  23204. isVerticesDataPresent(kind: string): boolean;
  23205. /**
  23206. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23207. * @param kind defines the data kind (Position, normal, etc...)
  23208. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23209. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23210. * @returns a float array containing vertex data
  23211. */
  23212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23213. /**
  23214. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23215. * @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.
  23216. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23217. * @returns the indices array or an empty array if the mesh has no geometry
  23218. */
  23219. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23220. /**
  23221. * Set specific vertex data
  23222. * @param kind defines the data kind (Position, normal, etc...)
  23223. * @param data defines the vertex data to use
  23224. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23225. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23226. */
  23227. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23228. /**
  23229. * Update a specific associated vertex buffer
  23230. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23231. * - VertexBuffer.PositionKind
  23232. * - VertexBuffer.UVKind
  23233. * - VertexBuffer.UV2Kind
  23234. * - VertexBuffer.UV3Kind
  23235. * - VertexBuffer.UV4Kind
  23236. * - VertexBuffer.UV5Kind
  23237. * - VertexBuffer.UV6Kind
  23238. * - VertexBuffer.ColorKind
  23239. * - VertexBuffer.MatricesIndicesKind
  23240. * - VertexBuffer.MatricesIndicesExtraKind
  23241. * - VertexBuffer.MatricesWeightsKind
  23242. * - VertexBuffer.MatricesWeightsExtraKind
  23243. * @param data defines the data source
  23244. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23245. * @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)
  23246. */
  23247. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23248. /**
  23249. * Creates a new index buffer
  23250. * @param indices defines the indices to store in the index buffer
  23251. * @param totalVertices defines the total number of vertices (could be null)
  23252. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23253. */
  23254. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23255. }
  23256. /**
  23257. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23258. */
  23259. export class VertexData {
  23260. /**
  23261. * Mesh side orientation : usually the external or front surface
  23262. */
  23263. static readonly FRONTSIDE: number;
  23264. /**
  23265. * Mesh side orientation : usually the internal or back surface
  23266. */
  23267. static readonly BACKSIDE: number;
  23268. /**
  23269. * Mesh side orientation : both internal and external or front and back surfaces
  23270. */
  23271. static readonly DOUBLESIDE: number;
  23272. /**
  23273. * Mesh side orientation : by default, `FRONTSIDE`
  23274. */
  23275. static readonly DEFAULTSIDE: number;
  23276. /**
  23277. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23278. */
  23279. positions: Nullable<FloatArray>;
  23280. /**
  23281. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23282. */
  23283. normals: Nullable<FloatArray>;
  23284. /**
  23285. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23286. */
  23287. tangents: Nullable<FloatArray>;
  23288. /**
  23289. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23290. */
  23291. uvs: Nullable<FloatArray>;
  23292. /**
  23293. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23294. */
  23295. uvs2: Nullable<FloatArray>;
  23296. /**
  23297. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23298. */
  23299. uvs3: Nullable<FloatArray>;
  23300. /**
  23301. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23302. */
  23303. uvs4: Nullable<FloatArray>;
  23304. /**
  23305. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23306. */
  23307. uvs5: Nullable<FloatArray>;
  23308. /**
  23309. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23310. */
  23311. uvs6: Nullable<FloatArray>;
  23312. /**
  23313. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23314. */
  23315. colors: Nullable<FloatArray>;
  23316. /**
  23317. * 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).
  23318. */
  23319. matricesIndices: Nullable<FloatArray>;
  23320. /**
  23321. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23322. */
  23323. matricesWeights: Nullable<FloatArray>;
  23324. /**
  23325. * An array extending the number of possible indices
  23326. */
  23327. matricesIndicesExtra: Nullable<FloatArray>;
  23328. /**
  23329. * An array extending the number of possible weights when the number of indices is extended
  23330. */
  23331. matricesWeightsExtra: Nullable<FloatArray>;
  23332. /**
  23333. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23334. */
  23335. indices: Nullable<IndicesArray>;
  23336. /**
  23337. * Uses the passed data array to set the set the values for the specified kind of data
  23338. * @param data a linear array of floating numbers
  23339. * @param kind the type of data that is being set, eg positions, colors etc
  23340. */
  23341. set(data: FloatArray, kind: string): void;
  23342. /**
  23343. * Associates the vertexData to the passed Mesh.
  23344. * Sets it as updatable or not (default `false`)
  23345. * @param mesh the mesh the vertexData is applied to
  23346. * @param updatable when used and having the value true allows new data to update the vertexData
  23347. * @returns the VertexData
  23348. */
  23349. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23350. /**
  23351. * Associates the vertexData to the passed Geometry.
  23352. * Sets it as updatable or not (default `false`)
  23353. * @param geometry the geometry the vertexData is applied to
  23354. * @param updatable when used and having the value true allows new data to update the vertexData
  23355. * @returns VertexData
  23356. */
  23357. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23358. /**
  23359. * Updates the associated mesh
  23360. * @param mesh the mesh to be updated
  23361. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23362. * @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
  23363. * @returns VertexData
  23364. */
  23365. updateMesh(mesh: Mesh): VertexData;
  23366. /**
  23367. * Updates the associated geometry
  23368. * @param geometry the geometry to be updated
  23369. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23370. * @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
  23371. * @returns VertexData.
  23372. */
  23373. updateGeometry(geometry: Geometry): VertexData;
  23374. private _applyTo;
  23375. private _update;
  23376. /**
  23377. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23378. * @param matrix the transforming matrix
  23379. * @returns the VertexData
  23380. */
  23381. transform(matrix: Matrix): VertexData;
  23382. /**
  23383. * Merges the passed VertexData into the current one
  23384. * @param other the VertexData to be merged into the current one
  23385. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23386. * @returns the modified VertexData
  23387. */
  23388. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23389. private _mergeElement;
  23390. private _validate;
  23391. /**
  23392. * Serializes the VertexData
  23393. * @returns a serialized object
  23394. */
  23395. serialize(): any;
  23396. /**
  23397. * Extracts the vertexData from a mesh
  23398. * @param mesh the mesh from which to extract the VertexData
  23399. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23400. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23401. * @returns the object VertexData associated to the passed mesh
  23402. */
  23403. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23404. /**
  23405. * Extracts the vertexData from the geometry
  23406. * @param geometry the geometry from which to extract the VertexData
  23407. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23408. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23409. * @returns the object VertexData associated to the passed mesh
  23410. */
  23411. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23412. private static _ExtractFrom;
  23413. /**
  23414. * Creates the VertexData for a Ribbon
  23415. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23416. * * pathArray array of paths, each of which an array of successive Vector3
  23417. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23418. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23419. * * 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
  23420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23421. * * 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)
  23422. * * 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)
  23423. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23424. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23425. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23426. * @returns the VertexData of the ribbon
  23427. */
  23428. static CreateRibbon(options: {
  23429. pathArray: Vector3[][];
  23430. closeArray?: boolean;
  23431. closePath?: boolean;
  23432. offset?: number;
  23433. sideOrientation?: number;
  23434. frontUVs?: Vector4;
  23435. backUVs?: Vector4;
  23436. invertUV?: boolean;
  23437. uvs?: Vector2[];
  23438. colors?: Color4[];
  23439. }): VertexData;
  23440. /**
  23441. * Creates the VertexData for a box
  23442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23443. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23444. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23445. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23446. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23447. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23448. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23450. * * 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)
  23451. * * 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)
  23452. * @returns the VertexData of the box
  23453. */
  23454. static CreateBox(options: {
  23455. size?: number;
  23456. width?: number;
  23457. height?: number;
  23458. depth?: number;
  23459. faceUV?: Vector4[];
  23460. faceColors?: Color4[];
  23461. sideOrientation?: number;
  23462. frontUVs?: Vector4;
  23463. backUVs?: Vector4;
  23464. }): VertexData;
  23465. /**
  23466. * Creates the VertexData for a tiled box
  23467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23468. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23469. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23470. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23472. * @returns the VertexData of the box
  23473. */
  23474. static CreateTiledBox(options: {
  23475. pattern?: number;
  23476. width?: number;
  23477. height?: number;
  23478. depth?: number;
  23479. tileSize?: number;
  23480. tileWidth?: number;
  23481. tileHeight?: number;
  23482. alignHorizontal?: number;
  23483. alignVertical?: number;
  23484. faceUV?: Vector4[];
  23485. faceColors?: Color4[];
  23486. sideOrientation?: number;
  23487. }): VertexData;
  23488. /**
  23489. * Creates the VertexData for a tiled plane
  23490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23491. * * pattern a limited pattern arrangement depending on the number
  23492. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23493. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23494. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23496. * * 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)
  23497. * * 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)
  23498. * @returns the VertexData of the tiled plane
  23499. */
  23500. static CreateTiledPlane(options: {
  23501. pattern?: number;
  23502. tileSize?: number;
  23503. tileWidth?: number;
  23504. tileHeight?: number;
  23505. size?: number;
  23506. width?: number;
  23507. height?: number;
  23508. alignHorizontal?: number;
  23509. alignVertical?: number;
  23510. sideOrientation?: number;
  23511. frontUVs?: Vector4;
  23512. backUVs?: Vector4;
  23513. }): VertexData;
  23514. /**
  23515. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23517. * * segments sets the number of horizontal strips optional, default 32
  23518. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23519. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23520. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23521. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23522. * * 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
  23523. * * 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
  23524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23525. * * 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)
  23526. * * 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)
  23527. * @returns the VertexData of the ellipsoid
  23528. */
  23529. static CreateSphere(options: {
  23530. segments?: number;
  23531. diameter?: number;
  23532. diameterX?: number;
  23533. diameterY?: number;
  23534. diameterZ?: number;
  23535. arc?: number;
  23536. slice?: number;
  23537. sideOrientation?: number;
  23538. frontUVs?: Vector4;
  23539. backUVs?: Vector4;
  23540. }): VertexData;
  23541. /**
  23542. * Creates the VertexData for a cylinder, cone or prism
  23543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23544. * * height sets the height (y direction) of the cylinder, optional, default 2
  23545. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23546. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23547. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23548. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23549. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23550. * * 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
  23551. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23552. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23553. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23554. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23556. * * 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)
  23557. * * 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)
  23558. * @returns the VertexData of the cylinder, cone or prism
  23559. */
  23560. static CreateCylinder(options: {
  23561. height?: number;
  23562. diameterTop?: number;
  23563. diameterBottom?: number;
  23564. diameter?: number;
  23565. tessellation?: number;
  23566. subdivisions?: number;
  23567. arc?: number;
  23568. faceColors?: Color4[];
  23569. faceUV?: Vector4[];
  23570. hasRings?: boolean;
  23571. enclose?: boolean;
  23572. sideOrientation?: number;
  23573. frontUVs?: Vector4;
  23574. backUVs?: Vector4;
  23575. }): VertexData;
  23576. /**
  23577. * Creates the VertexData for a torus
  23578. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23579. * * diameter the diameter of the torus, optional default 1
  23580. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23581. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23583. * * 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)
  23584. * * 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)
  23585. * @returns the VertexData of the torus
  23586. */
  23587. static CreateTorus(options: {
  23588. diameter?: number;
  23589. thickness?: number;
  23590. tessellation?: number;
  23591. sideOrientation?: number;
  23592. frontUVs?: Vector4;
  23593. backUVs?: Vector4;
  23594. }): VertexData;
  23595. /**
  23596. * Creates the VertexData of the LineSystem
  23597. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23598. * - lines an array of lines, each line being an array of successive Vector3
  23599. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23600. * @returns the VertexData of the LineSystem
  23601. */
  23602. static CreateLineSystem(options: {
  23603. lines: Vector3[][];
  23604. colors?: Nullable<Color4[][]>;
  23605. }): VertexData;
  23606. /**
  23607. * Create the VertexData for a DashedLines
  23608. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23609. * - points an array successive Vector3
  23610. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23611. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23612. * - dashNb the intended total number of dashes, optional, default 200
  23613. * @returns the VertexData for the DashedLines
  23614. */
  23615. static CreateDashedLines(options: {
  23616. points: Vector3[];
  23617. dashSize?: number;
  23618. gapSize?: number;
  23619. dashNb?: number;
  23620. }): VertexData;
  23621. /**
  23622. * Creates the VertexData for a Ground
  23623. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23624. * - width the width (x direction) of the ground, optional, default 1
  23625. * - height the height (z direction) of the ground, optional, default 1
  23626. * - subdivisions the number of subdivisions per side, optional, default 1
  23627. * @returns the VertexData of the Ground
  23628. */
  23629. static CreateGround(options: {
  23630. width?: number;
  23631. height?: number;
  23632. subdivisions?: number;
  23633. subdivisionsX?: number;
  23634. subdivisionsY?: number;
  23635. }): VertexData;
  23636. /**
  23637. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23638. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23639. * * xmin the ground minimum X coordinate, optional, default -1
  23640. * * zmin the ground minimum Z coordinate, optional, default -1
  23641. * * xmax the ground maximum X coordinate, optional, default 1
  23642. * * zmax the ground maximum Z coordinate, optional, default 1
  23643. * * 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}
  23644. * * 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}
  23645. * @returns the VertexData of the TiledGround
  23646. */
  23647. static CreateTiledGround(options: {
  23648. xmin: number;
  23649. zmin: number;
  23650. xmax: number;
  23651. zmax: number;
  23652. subdivisions?: {
  23653. w: number;
  23654. h: number;
  23655. };
  23656. precision?: {
  23657. w: number;
  23658. h: number;
  23659. };
  23660. }): VertexData;
  23661. /**
  23662. * Creates the VertexData of the Ground designed from a heightmap
  23663. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23664. * * width the width (x direction) of the ground
  23665. * * height the height (z direction) of the ground
  23666. * * subdivisions the number of subdivisions per side
  23667. * * minHeight the minimum altitude on the ground, optional, default 0
  23668. * * maxHeight the maximum altitude on the ground, optional default 1
  23669. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23670. * * buffer the array holding the image color data
  23671. * * bufferWidth the width of image
  23672. * * bufferHeight the height of image
  23673. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23674. * @returns the VertexData of the Ground designed from a heightmap
  23675. */
  23676. static CreateGroundFromHeightMap(options: {
  23677. width: number;
  23678. height: number;
  23679. subdivisions: number;
  23680. minHeight: number;
  23681. maxHeight: number;
  23682. colorFilter: Color3;
  23683. buffer: Uint8Array;
  23684. bufferWidth: number;
  23685. bufferHeight: number;
  23686. alphaFilter: number;
  23687. }): VertexData;
  23688. /**
  23689. * Creates the VertexData for a Plane
  23690. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23691. * * size sets the width and height of the plane to the value of size, optional default 1
  23692. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23693. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23695. * * 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)
  23696. * * 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)
  23697. * @returns the VertexData of the box
  23698. */
  23699. static CreatePlane(options: {
  23700. size?: number;
  23701. width?: number;
  23702. height?: number;
  23703. sideOrientation?: number;
  23704. frontUVs?: Vector4;
  23705. backUVs?: Vector4;
  23706. }): VertexData;
  23707. /**
  23708. * Creates the VertexData of the Disc or regular Polygon
  23709. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23710. * * radius the radius of the disc, optional default 0.5
  23711. * * tessellation the number of polygon sides, optional, default 64
  23712. * * 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
  23713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23714. * * 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)
  23715. * * 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)
  23716. * @returns the VertexData of the box
  23717. */
  23718. static CreateDisc(options: {
  23719. radius?: number;
  23720. tessellation?: number;
  23721. arc?: number;
  23722. sideOrientation?: number;
  23723. frontUVs?: Vector4;
  23724. backUVs?: Vector4;
  23725. }): VertexData;
  23726. /**
  23727. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23728. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23729. * @param polygon a mesh built from polygonTriangulation.build()
  23730. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23731. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23732. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23733. * @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)
  23734. * @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)
  23735. * @returns the VertexData of the Polygon
  23736. */
  23737. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23738. /**
  23739. * Creates the VertexData of the IcoSphere
  23740. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23741. * * radius the radius of the IcoSphere, optional default 1
  23742. * * radiusX allows stretching in the x direction, optional, default radius
  23743. * * radiusY allows stretching in the y direction, optional, default radius
  23744. * * radiusZ allows stretching in the z direction, optional, default radius
  23745. * * flat when true creates a flat shaded mesh, optional, default true
  23746. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23748. * * 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)
  23749. * * 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)
  23750. * @returns the VertexData of the IcoSphere
  23751. */
  23752. static CreateIcoSphere(options: {
  23753. radius?: number;
  23754. radiusX?: number;
  23755. radiusY?: number;
  23756. radiusZ?: number;
  23757. flat?: boolean;
  23758. subdivisions?: number;
  23759. sideOrientation?: number;
  23760. frontUVs?: Vector4;
  23761. backUVs?: Vector4;
  23762. }): VertexData;
  23763. /**
  23764. * Creates the VertexData for a Polyhedron
  23765. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23766. * * type provided types are:
  23767. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23768. * * 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)
  23769. * * size the size of the IcoSphere, optional default 1
  23770. * * sizeX allows stretching in the x direction, optional, default size
  23771. * * sizeY allows stretching in the y direction, optional, default size
  23772. * * sizeZ allows stretching in the z direction, optional, default size
  23773. * * 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
  23774. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23775. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23776. * * flat when true creates a flat shaded mesh, optional, default true
  23777. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23779. * * 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)
  23780. * * 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)
  23781. * @returns the VertexData of the Polyhedron
  23782. */
  23783. static CreatePolyhedron(options: {
  23784. type?: number;
  23785. size?: number;
  23786. sizeX?: number;
  23787. sizeY?: number;
  23788. sizeZ?: number;
  23789. custom?: any;
  23790. faceUV?: Vector4[];
  23791. faceColors?: Color4[];
  23792. flat?: boolean;
  23793. sideOrientation?: number;
  23794. frontUVs?: Vector4;
  23795. backUVs?: Vector4;
  23796. }): VertexData;
  23797. /**
  23798. * Creates the VertexData for a TorusKnot
  23799. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23800. * * radius the radius of the torus knot, optional, default 2
  23801. * * tube the thickness of the tube, optional, default 0.5
  23802. * * radialSegments the number of sides on each tube segments, optional, default 32
  23803. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23804. * * p the number of windings around the z axis, optional, default 2
  23805. * * q the number of windings around the x axis, optional, default 3
  23806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23807. * * 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)
  23808. * * 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)
  23809. * @returns the VertexData of the Torus Knot
  23810. */
  23811. static CreateTorusKnot(options: {
  23812. radius?: number;
  23813. tube?: number;
  23814. radialSegments?: number;
  23815. tubularSegments?: number;
  23816. p?: number;
  23817. q?: number;
  23818. sideOrientation?: number;
  23819. frontUVs?: Vector4;
  23820. backUVs?: Vector4;
  23821. }): VertexData;
  23822. /**
  23823. * Compute normals for given positions and indices
  23824. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23825. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23826. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23827. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23828. * * facetNormals : optional array of facet normals (vector3)
  23829. * * facetPositions : optional array of facet positions (vector3)
  23830. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23831. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23832. * * bInfo : optional bounding info, required for facetPartitioning computation
  23833. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23834. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23835. * * useRightHandedSystem: optional boolean to for right handed system computation
  23836. * * depthSort : optional boolean to enable the facet depth sort computation
  23837. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23838. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23839. */
  23840. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23841. facetNormals?: any;
  23842. facetPositions?: any;
  23843. facetPartitioning?: any;
  23844. ratio?: number;
  23845. bInfo?: any;
  23846. bbSize?: Vector3;
  23847. subDiv?: any;
  23848. useRightHandedSystem?: boolean;
  23849. depthSort?: boolean;
  23850. distanceTo?: Vector3;
  23851. depthSortedFacets?: any;
  23852. }): void;
  23853. /** @hidden */
  23854. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23855. /**
  23856. * Applies VertexData created from the imported parameters to the geometry
  23857. * @param parsedVertexData the parsed data from an imported file
  23858. * @param geometry the geometry to apply the VertexData to
  23859. */
  23860. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23861. }
  23862. }
  23863. declare module BABYLON {
  23864. /**
  23865. * Class containing static functions to help procedurally build meshes
  23866. */
  23867. export class DiscBuilder {
  23868. /**
  23869. * Creates a plane polygonal mesh. By default, this is a disc
  23870. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23871. * * 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
  23872. * * 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
  23873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23874. * * 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
  23875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23876. * @param name defines the name of the mesh
  23877. * @param options defines the options used to create the mesh
  23878. * @param scene defines the hosting scene
  23879. * @returns the plane polygonal mesh
  23880. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23881. */
  23882. static CreateDisc(name: string, options: {
  23883. radius?: number;
  23884. tessellation?: number;
  23885. arc?: number;
  23886. updatable?: boolean;
  23887. sideOrientation?: number;
  23888. frontUVs?: Vector4;
  23889. backUVs?: Vector4;
  23890. }, scene?: Nullable<Scene>): Mesh;
  23891. }
  23892. }
  23893. declare module BABYLON {
  23894. /**
  23895. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23896. *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.
  23897. * The SPS is also a particle system. It provides some methods to manage the particles.
  23898. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23899. *
  23900. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23901. */
  23902. export class SolidParticleSystem implements IDisposable {
  23903. /**
  23904. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23905. * Example : var p = SPS.particles[i];
  23906. */
  23907. particles: SolidParticle[];
  23908. /**
  23909. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23910. */
  23911. nbParticles: number;
  23912. /**
  23913. * If the particles must ever face the camera (default false). Useful for planar particles.
  23914. */
  23915. billboard: boolean;
  23916. /**
  23917. * Recompute normals when adding a shape
  23918. */
  23919. recomputeNormals: boolean;
  23920. /**
  23921. * This a counter ofr your own usage. It's not set by any SPS functions.
  23922. */
  23923. counter: number;
  23924. /**
  23925. * The SPS name. This name is also given to the underlying mesh.
  23926. */
  23927. name: string;
  23928. /**
  23929. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23930. */
  23931. mesh: Mesh;
  23932. /**
  23933. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23934. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23935. */
  23936. vars: any;
  23937. /**
  23938. * This array is populated when the SPS is set as 'pickable'.
  23939. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23940. * Each element of this array is an object `{idx: int, faceId: int}`.
  23941. * `idx` is the picked particle index in the `SPS.particles` array
  23942. * `faceId` is the picked face index counted within this particle.
  23943. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23944. */
  23945. pickedParticles: {
  23946. idx: number;
  23947. faceId: number;
  23948. }[];
  23949. /**
  23950. * This array is populated when `enableDepthSort` is set to true.
  23951. * Each element of this array is an instance of the class DepthSortedParticle.
  23952. */
  23953. depthSortedParticles: DepthSortedParticle[];
  23954. /**
  23955. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23956. * @hidden
  23957. */
  23958. _bSphereOnly: boolean;
  23959. /**
  23960. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23961. * @hidden
  23962. */
  23963. _bSphereRadiusFactor: number;
  23964. private _scene;
  23965. private _positions;
  23966. private _indices;
  23967. private _normals;
  23968. private _colors;
  23969. private _uvs;
  23970. private _indices32;
  23971. private _positions32;
  23972. private _normals32;
  23973. private _fixedNormal32;
  23974. private _colors32;
  23975. private _uvs32;
  23976. private _index;
  23977. private _updatable;
  23978. private _pickable;
  23979. private _isVisibilityBoxLocked;
  23980. private _alwaysVisible;
  23981. private _depthSort;
  23982. private _shapeCounter;
  23983. private _copy;
  23984. private _color;
  23985. private _computeParticleColor;
  23986. private _computeParticleTexture;
  23987. private _computeParticleRotation;
  23988. private _computeParticleVertex;
  23989. private _computeBoundingBox;
  23990. private _depthSortParticles;
  23991. private _camera;
  23992. private _mustUnrotateFixedNormals;
  23993. private _particlesIntersect;
  23994. private _needs32Bits;
  23995. /**
  23996. * Creates a SPS (Solid Particle System) object.
  23997. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23998. * @param scene (Scene) is the scene in which the SPS is added.
  23999. * @param options defines the options of the sps e.g.
  24000. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24001. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24002. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24003. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24004. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24005. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24006. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24007. */
  24008. constructor(name: string, scene: Scene, options?: {
  24009. updatable?: boolean;
  24010. isPickable?: boolean;
  24011. enableDepthSort?: boolean;
  24012. particleIntersection?: boolean;
  24013. boundingSphereOnly?: boolean;
  24014. bSphereRadiusFactor?: number;
  24015. });
  24016. /**
  24017. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24018. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24019. * @returns the created mesh
  24020. */
  24021. buildMesh(): Mesh;
  24022. /**
  24023. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24024. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24025. * Thus the particles generated from `digest()` have their property `position` set yet.
  24026. * @param mesh ( Mesh ) is the mesh to be digested
  24027. * @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
  24028. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24029. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24030. * @returns the current SPS
  24031. */
  24032. digest(mesh: Mesh, options?: {
  24033. facetNb?: number;
  24034. number?: number;
  24035. delta?: number;
  24036. }): SolidParticleSystem;
  24037. private _unrotateFixedNormals;
  24038. private _resetCopy;
  24039. private _meshBuilder;
  24040. private _posToShape;
  24041. private _uvsToShapeUV;
  24042. private _addParticle;
  24043. /**
  24044. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24045. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24046. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24047. * @param nb (positive integer) the number of particles to be created from this model
  24048. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24049. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24050. * @returns the number of shapes in the system
  24051. */
  24052. addShape(mesh: Mesh, nb: number, options?: {
  24053. positionFunction?: any;
  24054. vertexFunction?: any;
  24055. }): number;
  24056. private _rebuildParticle;
  24057. /**
  24058. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24059. * @returns the SPS.
  24060. */
  24061. rebuildMesh(): SolidParticleSystem;
  24062. /**
  24063. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24064. * This method calls `updateParticle()` for each particle of the SPS.
  24065. * For an animated SPS, it is usually called within the render loop.
  24066. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24067. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24068. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24069. * @returns the SPS.
  24070. */
  24071. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24072. /**
  24073. * Disposes the SPS.
  24074. */
  24075. dispose(): void;
  24076. /**
  24077. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24078. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24079. * @returns the SPS.
  24080. */
  24081. refreshVisibleSize(): SolidParticleSystem;
  24082. /**
  24083. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24084. * @param size the size (float) of the visibility box
  24085. * note : this doesn't lock the SPS mesh bounding box.
  24086. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24087. */
  24088. setVisibilityBox(size: number): void;
  24089. /**
  24090. * Gets whether the SPS as always visible or not
  24091. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24092. */
  24093. /**
  24094. * Sets the SPS as always visible or not
  24095. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24096. */
  24097. isAlwaysVisible: boolean;
  24098. /**
  24099. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24100. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24101. */
  24102. /**
  24103. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24104. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24105. */
  24106. isVisibilityBoxLocked: boolean;
  24107. /**
  24108. * Tells to `setParticles()` to compute the particle rotations or not.
  24109. * Default value : true. The SPS is faster when it's set to false.
  24110. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24111. */
  24112. /**
  24113. * Gets if `setParticles()` computes the particle rotations or not.
  24114. * Default value : true. The SPS is faster when it's set to false.
  24115. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24116. */
  24117. computeParticleRotation: boolean;
  24118. /**
  24119. * Tells to `setParticles()` to compute the particle colors or not.
  24120. * Default value : true. The SPS is faster when it's set to false.
  24121. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24122. */
  24123. /**
  24124. * Gets if `setParticles()` computes the particle colors or not.
  24125. * Default value : true. The SPS is faster when it's set to false.
  24126. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24127. */
  24128. computeParticleColor: boolean;
  24129. /**
  24130. * Gets if `setParticles()` computes the particle textures or not.
  24131. * Default value : true. The SPS is faster when it's set to false.
  24132. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24133. */
  24134. computeParticleTexture: boolean;
  24135. /**
  24136. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24137. * Default value : false. The SPS is faster when it's set to false.
  24138. * Note : the particle custom vertex positions aren't stored values.
  24139. */
  24140. /**
  24141. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24142. * Default value : false. The SPS is faster when it's set to false.
  24143. * Note : the particle custom vertex positions aren't stored values.
  24144. */
  24145. computeParticleVertex: boolean;
  24146. /**
  24147. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24148. */
  24149. /**
  24150. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24151. */
  24152. computeBoundingBox: boolean;
  24153. /**
  24154. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24155. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24156. * Default : `true`
  24157. */
  24158. /**
  24159. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24160. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24161. * Default : `true`
  24162. */
  24163. depthSortParticles: boolean;
  24164. /**
  24165. * This function does nothing. It may be overwritten to set all the particle first values.
  24166. * The SPS doesn't call this function, you may have to call it by your own.
  24167. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24168. */
  24169. initParticles(): void;
  24170. /**
  24171. * This function does nothing. It may be overwritten to recycle a particle.
  24172. * The SPS doesn't call this function, you may have to call it by your own.
  24173. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24174. * @param particle The particle to recycle
  24175. * @returns the recycled particle
  24176. */
  24177. recycleParticle(particle: SolidParticle): SolidParticle;
  24178. /**
  24179. * Updates a particle : this function should be overwritten by the user.
  24180. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24181. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24182. * @example : just set a particle position or velocity and recycle conditions
  24183. * @param particle The particle to update
  24184. * @returns the updated particle
  24185. */
  24186. updateParticle(particle: SolidParticle): SolidParticle;
  24187. /**
  24188. * Updates a vertex of a particle : it can be overwritten by the user.
  24189. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24190. * @param particle the current particle
  24191. * @param vertex the current index of the current particle
  24192. * @param pt the index of the current vertex in the particle shape
  24193. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24194. * @example : just set a vertex particle position
  24195. * @returns the updated vertex
  24196. */
  24197. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24198. /**
  24199. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24200. * This does nothing and may be overwritten by the user.
  24201. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24202. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24203. * @param update the boolean update value actually passed to setParticles()
  24204. */
  24205. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24206. /**
  24207. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24208. * This will be passed three parameters.
  24209. * This does nothing and may be overwritten by the user.
  24210. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24211. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24212. * @param update the boolean update value actually passed to setParticles()
  24213. */
  24214. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24215. }
  24216. }
  24217. declare module BABYLON {
  24218. /**
  24219. * Represents one particle of a solid particle system.
  24220. */
  24221. export class SolidParticle {
  24222. /**
  24223. * particle global index
  24224. */
  24225. idx: number;
  24226. /**
  24227. * The color of the particle
  24228. */
  24229. color: Nullable<Color4>;
  24230. /**
  24231. * The world space position of the particle.
  24232. */
  24233. position: Vector3;
  24234. /**
  24235. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24236. */
  24237. rotation: Vector3;
  24238. /**
  24239. * The world space rotation quaternion of the particle.
  24240. */
  24241. rotationQuaternion: Nullable<Quaternion>;
  24242. /**
  24243. * The scaling of the particle.
  24244. */
  24245. scaling: Vector3;
  24246. /**
  24247. * The uvs of the particle.
  24248. */
  24249. uvs: Vector4;
  24250. /**
  24251. * The current speed of the particle.
  24252. */
  24253. velocity: Vector3;
  24254. /**
  24255. * The pivot point in the particle local space.
  24256. */
  24257. pivot: Vector3;
  24258. /**
  24259. * Must the particle be translated from its pivot point in its local space ?
  24260. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24261. * Default : false
  24262. */
  24263. translateFromPivot: boolean;
  24264. /**
  24265. * Is the particle active or not ?
  24266. */
  24267. alive: boolean;
  24268. /**
  24269. * Is the particle visible or not ?
  24270. */
  24271. isVisible: boolean;
  24272. /**
  24273. * Index of this particle in the global "positions" array (Internal use)
  24274. * @hidden
  24275. */
  24276. _pos: number;
  24277. /**
  24278. * @hidden Index of this particle in the global "indices" array (Internal use)
  24279. */
  24280. _ind: number;
  24281. /**
  24282. * @hidden ModelShape of this particle (Internal use)
  24283. */
  24284. _model: ModelShape;
  24285. /**
  24286. * ModelShape id of this particle
  24287. */
  24288. shapeId: number;
  24289. /**
  24290. * Index of the particle in its shape id (Internal use)
  24291. */
  24292. idxInShape: number;
  24293. /**
  24294. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24295. */
  24296. _modelBoundingInfo: BoundingInfo;
  24297. /**
  24298. * @hidden Particle BoundingInfo object (Internal use)
  24299. */
  24300. _boundingInfo: BoundingInfo;
  24301. /**
  24302. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24303. */
  24304. _sps: SolidParticleSystem;
  24305. /**
  24306. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24307. */
  24308. _stillInvisible: boolean;
  24309. /**
  24310. * @hidden Last computed particle rotation matrix
  24311. */
  24312. _rotationMatrix: number[];
  24313. /**
  24314. * Parent particle Id, if any.
  24315. * Default null.
  24316. */
  24317. parentId: Nullable<number>;
  24318. /**
  24319. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24320. * The possible values are :
  24321. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24322. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24323. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24324. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24325. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24326. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24327. * */
  24328. cullingStrategy: number;
  24329. /**
  24330. * @hidden Internal global position in the SPS.
  24331. */
  24332. _globalPosition: Vector3;
  24333. /**
  24334. * Creates a Solid Particle object.
  24335. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24336. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24337. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24338. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24339. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24340. * @param shapeId (integer) is the model shape identifier in the SPS.
  24341. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24342. * @param sps defines the sps it is associated to
  24343. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24344. */
  24345. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24346. /**
  24347. * Legacy support, changed scale to scaling
  24348. */
  24349. /**
  24350. * Legacy support, changed scale to scaling
  24351. */
  24352. scale: Vector3;
  24353. /**
  24354. * Legacy support, changed quaternion to rotationQuaternion
  24355. */
  24356. /**
  24357. * Legacy support, changed quaternion to rotationQuaternion
  24358. */
  24359. quaternion: Nullable<Quaternion>;
  24360. /**
  24361. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24362. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24363. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24364. * @returns true if it intersects
  24365. */
  24366. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24367. /**
  24368. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24369. * A particle is in the frustum if its bounding box intersects the frustum
  24370. * @param frustumPlanes defines the frustum to test
  24371. * @returns true if the particle is in the frustum planes
  24372. */
  24373. isInFrustum(frustumPlanes: Plane[]): boolean;
  24374. /**
  24375. * get the rotation matrix of the particle
  24376. * @hidden
  24377. */
  24378. getRotationMatrix(m: Matrix): void;
  24379. }
  24380. /**
  24381. * Represents the shape of the model used by one particle of a solid particle system.
  24382. * SPS internal tool, don't use it manually.
  24383. */
  24384. export class ModelShape {
  24385. /**
  24386. * The shape id
  24387. * @hidden
  24388. */
  24389. shapeID: number;
  24390. /**
  24391. * flat array of model positions (internal use)
  24392. * @hidden
  24393. */
  24394. _shape: Vector3[];
  24395. /**
  24396. * flat array of model UVs (internal use)
  24397. * @hidden
  24398. */
  24399. _shapeUV: number[];
  24400. /**
  24401. * length of the shape in the model indices array (internal use)
  24402. * @hidden
  24403. */
  24404. _indicesLength: number;
  24405. /**
  24406. * Custom position function (internal use)
  24407. * @hidden
  24408. */
  24409. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24410. /**
  24411. * Custom vertex function (internal use)
  24412. * @hidden
  24413. */
  24414. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24415. /**
  24416. * 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.
  24417. * SPS internal tool, don't use it manually.
  24418. * @hidden
  24419. */
  24420. 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>);
  24421. }
  24422. /**
  24423. * Represents a Depth Sorted Particle in the solid particle system.
  24424. */
  24425. export class DepthSortedParticle {
  24426. /**
  24427. * Index of the particle in the "indices" array
  24428. */
  24429. ind: number;
  24430. /**
  24431. * Length of the particle shape in the "indices" array
  24432. */
  24433. indicesLength: number;
  24434. /**
  24435. * Squared distance from the particle to the camera
  24436. */
  24437. sqDistance: number;
  24438. }
  24439. }
  24440. declare module BABYLON {
  24441. /**
  24442. * @hidden
  24443. */
  24444. export class _MeshCollisionData {
  24445. _checkCollisions: boolean;
  24446. _collisionMask: number;
  24447. _collisionGroup: number;
  24448. _collider: Nullable<Collider>;
  24449. _oldPositionForCollisions: Vector3;
  24450. _diffPositionForCollisions: Vector3;
  24451. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24452. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24453. }
  24454. }
  24455. declare module BABYLON {
  24456. /** @hidden */
  24457. class _FacetDataStorage {
  24458. facetPositions: Vector3[];
  24459. facetNormals: Vector3[];
  24460. facetPartitioning: number[][];
  24461. facetNb: number;
  24462. partitioningSubdivisions: number;
  24463. partitioningBBoxRatio: number;
  24464. facetDataEnabled: boolean;
  24465. facetParameters: any;
  24466. bbSize: Vector3;
  24467. subDiv: {
  24468. max: number;
  24469. X: number;
  24470. Y: number;
  24471. Z: number;
  24472. };
  24473. facetDepthSort: boolean;
  24474. facetDepthSortEnabled: boolean;
  24475. depthSortedIndices: IndicesArray;
  24476. depthSortedFacets: {
  24477. ind: number;
  24478. sqDistance: number;
  24479. }[];
  24480. facetDepthSortFunction: (f1: {
  24481. ind: number;
  24482. sqDistance: number;
  24483. }, f2: {
  24484. ind: number;
  24485. sqDistance: number;
  24486. }) => number;
  24487. facetDepthSortFrom: Vector3;
  24488. facetDepthSortOrigin: Vector3;
  24489. invertedMatrix: Matrix;
  24490. }
  24491. /**
  24492. * @hidden
  24493. **/
  24494. class _InternalAbstractMeshDataInfo {
  24495. _hasVertexAlpha: boolean;
  24496. _useVertexColors: boolean;
  24497. _numBoneInfluencers: number;
  24498. _applyFog: boolean;
  24499. _receiveShadows: boolean;
  24500. _facetData: _FacetDataStorage;
  24501. _visibility: number;
  24502. _skeleton: Nullable<Skeleton>;
  24503. _layerMask: number;
  24504. _computeBonesUsingShaders: boolean;
  24505. _isActive: boolean;
  24506. _onlyForInstances: boolean;
  24507. _isActiveIntermediate: boolean;
  24508. _onlyForInstancesIntermediate: boolean;
  24509. }
  24510. /**
  24511. * Class used to store all common mesh properties
  24512. */
  24513. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24514. /** No occlusion */
  24515. static OCCLUSION_TYPE_NONE: number;
  24516. /** Occlusion set to optimisitic */
  24517. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24518. /** Occlusion set to strict */
  24519. static OCCLUSION_TYPE_STRICT: number;
  24520. /** Use an accurante occlusion algorithm */
  24521. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24522. /** Use a conservative occlusion algorithm */
  24523. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24524. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24525. * Test order :
  24526. * Is the bounding sphere outside the frustum ?
  24527. * If not, are the bounding box vertices outside the frustum ?
  24528. * It not, then the cullable object is in the frustum.
  24529. */
  24530. static readonly CULLINGSTRATEGY_STANDARD: number;
  24531. /** Culling strategy : Bounding Sphere Only.
  24532. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24533. * It's also less accurate than the standard because some not visible objects can still be selected.
  24534. * Test : is the bounding sphere outside the frustum ?
  24535. * If not, then the cullable object is in the frustum.
  24536. */
  24537. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24538. /** Culling strategy : Optimistic Inclusion.
  24539. * This in an inclusion test first, then the standard exclusion test.
  24540. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24541. * 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.
  24542. * Anyway, it's as accurate as the standard strategy.
  24543. * Test :
  24544. * Is the cullable object bounding sphere center in the frustum ?
  24545. * If not, apply the default culling strategy.
  24546. */
  24547. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24548. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24549. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24550. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24551. * 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.
  24552. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24553. * Test :
  24554. * Is the cullable object bounding sphere center in the frustum ?
  24555. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24556. */
  24557. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24558. /**
  24559. * No billboard
  24560. */
  24561. static readonly BILLBOARDMODE_NONE: number;
  24562. /** Billboard on X axis */
  24563. static readonly BILLBOARDMODE_X: number;
  24564. /** Billboard on Y axis */
  24565. static readonly BILLBOARDMODE_Y: number;
  24566. /** Billboard on Z axis */
  24567. static readonly BILLBOARDMODE_Z: number;
  24568. /** Billboard on all axes */
  24569. static readonly BILLBOARDMODE_ALL: number;
  24570. /** @hidden */
  24571. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24572. /**
  24573. * The culling strategy to use to check whether the mesh must be rendered or not.
  24574. * This value can be changed at any time and will be used on the next render mesh selection.
  24575. * The possible values are :
  24576. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24577. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24580. * Please read each static variable documentation to get details about the culling process.
  24581. * */
  24582. cullingStrategy: number;
  24583. /**
  24584. * Gets the number of facets in the mesh
  24585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24586. */
  24587. readonly facetNb: number;
  24588. /**
  24589. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24591. */
  24592. partitioningSubdivisions: number;
  24593. /**
  24594. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24595. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24597. */
  24598. partitioningBBoxRatio: number;
  24599. /**
  24600. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24601. * Works only for updatable meshes.
  24602. * Doesn't work with multi-materials
  24603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24604. */
  24605. mustDepthSortFacets: boolean;
  24606. /**
  24607. * The location (Vector3) where the facet depth sort must be computed from.
  24608. * By default, the active camera position.
  24609. * Used only when facet depth sort is enabled
  24610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24611. */
  24612. facetDepthSortFrom: Vector3;
  24613. /**
  24614. * gets a boolean indicating if facetData is enabled
  24615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24616. */
  24617. readonly isFacetDataEnabled: boolean;
  24618. /** @hidden */
  24619. _updateNonUniformScalingState(value: boolean): boolean;
  24620. /**
  24621. * An event triggered when this mesh collides with another one
  24622. */
  24623. onCollideObservable: Observable<AbstractMesh>;
  24624. /** Set a function to call when this mesh collides with another one */
  24625. onCollide: () => void;
  24626. /**
  24627. * An event triggered when the collision's position changes
  24628. */
  24629. onCollisionPositionChangeObservable: Observable<Vector3>;
  24630. /** Set a function to call when the collision's position changes */
  24631. onCollisionPositionChange: () => void;
  24632. /**
  24633. * An event triggered when material is changed
  24634. */
  24635. onMaterialChangedObservable: Observable<AbstractMesh>;
  24636. /**
  24637. * Gets or sets the orientation for POV movement & rotation
  24638. */
  24639. definedFacingForward: boolean;
  24640. /** @hidden */
  24641. _occlusionQuery: Nullable<WebGLQuery>;
  24642. /** @hidden */
  24643. _renderingGroup: Nullable<RenderingGroup>;
  24644. /**
  24645. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24646. */
  24647. /**
  24648. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24649. */
  24650. visibility: number;
  24651. /** Gets or sets the alpha index used to sort transparent meshes
  24652. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24653. */
  24654. alphaIndex: number;
  24655. /**
  24656. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24657. */
  24658. isVisible: boolean;
  24659. /**
  24660. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24661. */
  24662. isPickable: boolean;
  24663. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24664. showSubMeshesBoundingBox: boolean;
  24665. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24667. */
  24668. isBlocker: boolean;
  24669. /**
  24670. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24671. */
  24672. enablePointerMoveEvents: boolean;
  24673. /**
  24674. * Specifies the rendering group id for this mesh (0 by default)
  24675. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24676. */
  24677. renderingGroupId: number;
  24678. private _material;
  24679. /** Gets or sets current material */
  24680. material: Nullable<Material>;
  24681. /**
  24682. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24683. * @see http://doc.babylonjs.com/babylon101/shadows
  24684. */
  24685. receiveShadows: boolean;
  24686. /** Defines color to use when rendering outline */
  24687. outlineColor: Color3;
  24688. /** Define width to use when rendering outline */
  24689. outlineWidth: number;
  24690. /** Defines color to use when rendering overlay */
  24691. overlayColor: Color3;
  24692. /** Defines alpha to use when rendering overlay */
  24693. overlayAlpha: number;
  24694. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24695. hasVertexAlpha: boolean;
  24696. /** 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) */
  24697. useVertexColors: boolean;
  24698. /**
  24699. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24700. */
  24701. computeBonesUsingShaders: boolean;
  24702. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24703. numBoneInfluencers: number;
  24704. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24705. applyFog: boolean;
  24706. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24707. useOctreeForRenderingSelection: boolean;
  24708. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24709. useOctreeForPicking: boolean;
  24710. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24711. useOctreeForCollisions: boolean;
  24712. /**
  24713. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24714. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24715. */
  24716. layerMask: number;
  24717. /**
  24718. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24719. */
  24720. alwaysSelectAsActiveMesh: boolean;
  24721. /**
  24722. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24723. */
  24724. doNotSyncBoundingInfo: boolean;
  24725. /**
  24726. * Gets or sets the current action manager
  24727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24728. */
  24729. actionManager: Nullable<AbstractActionManager>;
  24730. private _meshCollisionData;
  24731. /**
  24732. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24734. */
  24735. ellipsoid: Vector3;
  24736. /**
  24737. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24739. */
  24740. ellipsoidOffset: Vector3;
  24741. /**
  24742. * Gets or sets a collision mask used to mask collisions (default is -1).
  24743. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24744. */
  24745. collisionMask: number;
  24746. /**
  24747. * Gets or sets the current collision group mask (-1 by default).
  24748. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24749. */
  24750. collisionGroup: number;
  24751. /**
  24752. * Defines edge width used when edgesRenderer is enabled
  24753. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24754. */
  24755. edgesWidth: number;
  24756. /**
  24757. * Defines edge color used when edgesRenderer is enabled
  24758. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24759. */
  24760. edgesColor: Color4;
  24761. /** @hidden */
  24762. _edgesRenderer: Nullable<IEdgesRenderer>;
  24763. /** @hidden */
  24764. _masterMesh: Nullable<AbstractMesh>;
  24765. /** @hidden */
  24766. _boundingInfo: Nullable<BoundingInfo>;
  24767. /** @hidden */
  24768. _renderId: number;
  24769. /**
  24770. * Gets or sets the list of subMeshes
  24771. * @see http://doc.babylonjs.com/how_to/multi_materials
  24772. */
  24773. subMeshes: SubMesh[];
  24774. /** @hidden */
  24775. _intersectionsInProgress: AbstractMesh[];
  24776. /** @hidden */
  24777. _unIndexed: boolean;
  24778. /** @hidden */
  24779. _lightSources: Light[];
  24780. /** Gets the list of lights affecting that mesh */
  24781. readonly lightSources: Light[];
  24782. /** @hidden */
  24783. readonly _positions: Nullable<Vector3[]>;
  24784. /** @hidden */
  24785. _waitingData: {
  24786. lods: Nullable<any>;
  24787. actions: Nullable<any>;
  24788. freezeWorldMatrix: Nullable<boolean>;
  24789. };
  24790. /** @hidden */
  24791. _bonesTransformMatrices: Nullable<Float32Array>;
  24792. /**
  24793. * Gets or sets a skeleton to apply skining transformations
  24794. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24795. */
  24796. skeleton: Nullable<Skeleton>;
  24797. /**
  24798. * An event triggered when the mesh is rebuilt.
  24799. */
  24800. onRebuildObservable: Observable<AbstractMesh>;
  24801. /**
  24802. * Creates a new AbstractMesh
  24803. * @param name defines the name of the mesh
  24804. * @param scene defines the hosting scene
  24805. */
  24806. constructor(name: string, scene?: Nullable<Scene>);
  24807. /**
  24808. * Returns the string "AbstractMesh"
  24809. * @returns "AbstractMesh"
  24810. */
  24811. getClassName(): string;
  24812. /**
  24813. * Gets a string representation of the current mesh
  24814. * @param fullDetails defines a boolean indicating if full details must be included
  24815. * @returns a string representation of the current mesh
  24816. */
  24817. toString(fullDetails?: boolean): string;
  24818. /**
  24819. * @hidden
  24820. */
  24821. protected _getEffectiveParent(): Nullable<Node>;
  24822. /** @hidden */
  24823. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24824. /** @hidden */
  24825. _rebuild(): void;
  24826. /** @hidden */
  24827. _resyncLightSources(): void;
  24828. /** @hidden */
  24829. _resyncLighSource(light: Light): void;
  24830. /** @hidden */
  24831. _unBindEffect(): void;
  24832. /** @hidden */
  24833. _removeLightSource(light: Light): void;
  24834. private _markSubMeshesAsDirty;
  24835. /** @hidden */
  24836. _markSubMeshesAsLightDirty(): void;
  24837. /** @hidden */
  24838. _markSubMeshesAsAttributesDirty(): void;
  24839. /** @hidden */
  24840. _markSubMeshesAsMiscDirty(): void;
  24841. /**
  24842. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24843. */
  24844. scaling: Vector3;
  24845. /**
  24846. * Returns true if the mesh is blocked. Implemented by child classes
  24847. */
  24848. readonly isBlocked: boolean;
  24849. /**
  24850. * Returns the mesh itself by default. Implemented by child classes
  24851. * @param camera defines the camera to use to pick the right LOD level
  24852. * @returns the currentAbstractMesh
  24853. */
  24854. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24855. /**
  24856. * Returns 0 by default. Implemented by child classes
  24857. * @returns an integer
  24858. */
  24859. getTotalVertices(): number;
  24860. /**
  24861. * Returns a positive integer : the total number of indices in this mesh geometry.
  24862. * @returns the numner of indices or zero if the mesh has no geometry.
  24863. */
  24864. getTotalIndices(): number;
  24865. /**
  24866. * Returns null by default. Implemented by child classes
  24867. * @returns null
  24868. */
  24869. getIndices(): Nullable<IndicesArray>;
  24870. /**
  24871. * Returns the array of the requested vertex data kind. Implemented by child classes
  24872. * @param kind defines the vertex data kind to use
  24873. * @returns null
  24874. */
  24875. getVerticesData(kind: string): Nullable<FloatArray>;
  24876. /**
  24877. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24878. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24879. * Note that a new underlying VertexBuffer object is created each call.
  24880. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24881. * @param kind defines vertex data kind:
  24882. * * VertexBuffer.PositionKind
  24883. * * VertexBuffer.UVKind
  24884. * * VertexBuffer.UV2Kind
  24885. * * VertexBuffer.UV3Kind
  24886. * * VertexBuffer.UV4Kind
  24887. * * VertexBuffer.UV5Kind
  24888. * * VertexBuffer.UV6Kind
  24889. * * VertexBuffer.ColorKind
  24890. * * VertexBuffer.MatricesIndicesKind
  24891. * * VertexBuffer.MatricesIndicesExtraKind
  24892. * * VertexBuffer.MatricesWeightsKind
  24893. * * VertexBuffer.MatricesWeightsExtraKind
  24894. * @param data defines the data source
  24895. * @param updatable defines if the data must be flagged as updatable (or static)
  24896. * @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
  24897. * @returns the current mesh
  24898. */
  24899. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24900. /**
  24901. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24902. * If the mesh has no geometry, it is simply returned as it is.
  24903. * @param kind defines vertex data kind:
  24904. * * VertexBuffer.PositionKind
  24905. * * VertexBuffer.UVKind
  24906. * * VertexBuffer.UV2Kind
  24907. * * VertexBuffer.UV3Kind
  24908. * * VertexBuffer.UV4Kind
  24909. * * VertexBuffer.UV5Kind
  24910. * * VertexBuffer.UV6Kind
  24911. * * VertexBuffer.ColorKind
  24912. * * VertexBuffer.MatricesIndicesKind
  24913. * * VertexBuffer.MatricesIndicesExtraKind
  24914. * * VertexBuffer.MatricesWeightsKind
  24915. * * VertexBuffer.MatricesWeightsExtraKind
  24916. * @param data defines the data source
  24917. * @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
  24918. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24919. * @returns the current mesh
  24920. */
  24921. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24922. /**
  24923. * Sets the mesh indices,
  24924. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24925. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24926. * @param totalVertices Defines the total number of vertices
  24927. * @returns the current mesh
  24928. */
  24929. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24930. /**
  24931. * Gets a boolean indicating if specific vertex data is present
  24932. * @param kind defines the vertex data kind to use
  24933. * @returns true is data kind is present
  24934. */
  24935. isVerticesDataPresent(kind: string): boolean;
  24936. /**
  24937. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24938. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24939. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24940. * @returns a BoundingInfo
  24941. */
  24942. getBoundingInfo(): BoundingInfo;
  24943. /**
  24944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24948. * @returns the current mesh
  24949. */
  24950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24951. /**
  24952. * Overwrite the current bounding info
  24953. * @param boundingInfo defines the new bounding info
  24954. * @returns the current mesh
  24955. */
  24956. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24957. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24958. readonly useBones: boolean;
  24959. /** @hidden */
  24960. _preActivate(): void;
  24961. /** @hidden */
  24962. _preActivateForIntermediateRendering(renderId: number): void;
  24963. /** @hidden */
  24964. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24965. /** @hidden */
  24966. _postActivate(): void;
  24967. /** @hidden */
  24968. _freeze(): void;
  24969. /** @hidden */
  24970. _unFreeze(): void;
  24971. /**
  24972. * Gets the current world matrix
  24973. * @returns a Matrix
  24974. */
  24975. getWorldMatrix(): Matrix;
  24976. /** @hidden */
  24977. _getWorldMatrixDeterminant(): number;
  24978. /**
  24979. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24980. */
  24981. readonly isAnInstance: boolean;
  24982. /**
  24983. * Perform relative position change from the point of view of behind the front of the mesh.
  24984. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24985. * Supports definition of mesh facing forward or backward
  24986. * @param amountRight defines the distance on the right axis
  24987. * @param amountUp defines the distance on the up axis
  24988. * @param amountForward defines the distance on the forward axis
  24989. * @returns the current mesh
  24990. */
  24991. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24992. /**
  24993. * Calculate relative position change from the point of view of behind the front of the mesh.
  24994. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24995. * Supports definition of mesh facing forward or backward
  24996. * @param amountRight defines the distance on the right axis
  24997. * @param amountUp defines the distance on the up axis
  24998. * @param amountForward defines the distance on the forward axis
  24999. * @returns the new displacement vector
  25000. */
  25001. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25002. /**
  25003. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25004. * Supports definition of mesh facing forward or backward
  25005. * @param flipBack defines the flip
  25006. * @param twirlClockwise defines the twirl
  25007. * @param tiltRight defines the tilt
  25008. * @returns the current mesh
  25009. */
  25010. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25011. /**
  25012. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25013. * Supports definition of mesh facing forward or backward.
  25014. * @param flipBack defines the flip
  25015. * @param twirlClockwise defines the twirl
  25016. * @param tiltRight defines the tilt
  25017. * @returns the new rotation vector
  25018. */
  25019. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25020. /**
  25021. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25022. * This means the mesh underlying bounding box and sphere are recomputed.
  25023. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25024. * @returns the current mesh
  25025. */
  25026. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25027. /** @hidden */
  25028. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25029. /** @hidden */
  25030. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25031. /** @hidden */
  25032. _updateBoundingInfo(): AbstractMesh;
  25033. /** @hidden */
  25034. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25035. /** @hidden */
  25036. protected _afterComputeWorldMatrix(): void;
  25037. /** @hidden */
  25038. readonly _effectiveMesh: AbstractMesh;
  25039. /**
  25040. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25041. * A mesh is in the frustum if its bounding box intersects the frustum
  25042. * @param frustumPlanes defines the frustum to test
  25043. * @returns true if the mesh is in the frustum planes
  25044. */
  25045. isInFrustum(frustumPlanes: Plane[]): boolean;
  25046. /**
  25047. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25048. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25049. * @param frustumPlanes defines the frustum to test
  25050. * @returns true if the mesh is completely in the frustum planes
  25051. */
  25052. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25053. /**
  25054. * True if the mesh intersects another mesh or a SolidParticle object
  25055. * @param mesh defines a target mesh or SolidParticle to test
  25056. * @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)
  25057. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25058. * @returns true if there is an intersection
  25059. */
  25060. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25061. /**
  25062. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25063. * @param point defines the point to test
  25064. * @returns true if there is an intersection
  25065. */
  25066. intersectsPoint(point: Vector3): boolean;
  25067. /**
  25068. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25070. */
  25071. checkCollisions: boolean;
  25072. /**
  25073. * Gets Collider object used to compute collisions (not physics)
  25074. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25075. */
  25076. readonly collider: Nullable<Collider>;
  25077. /**
  25078. * Move the mesh using collision engine
  25079. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25080. * @param displacement defines the requested displacement vector
  25081. * @returns the current mesh
  25082. */
  25083. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25084. private _onCollisionPositionChange;
  25085. /** @hidden */
  25086. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25087. /** @hidden */
  25088. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25089. /** @hidden */
  25090. _checkCollision(collider: Collider): AbstractMesh;
  25091. /** @hidden */
  25092. _generatePointsArray(): boolean;
  25093. /**
  25094. * Checks if the passed Ray intersects with the mesh
  25095. * @param ray defines the ray to use
  25096. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25098. * @returns the picking info
  25099. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25100. */
  25101. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25102. /**
  25103. * Clones the current mesh
  25104. * @param name defines the mesh name
  25105. * @param newParent defines the new mesh parent
  25106. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25107. * @returns the new mesh
  25108. */
  25109. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25110. /**
  25111. * Disposes all the submeshes of the current meshnp
  25112. * @returns the current mesh
  25113. */
  25114. releaseSubMeshes(): AbstractMesh;
  25115. /**
  25116. * Releases resources associated with this abstract mesh.
  25117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25119. */
  25120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25121. /**
  25122. * Adds the passed mesh as a child to the current mesh
  25123. * @param mesh defines the child mesh
  25124. * @returns the current mesh
  25125. */
  25126. addChild(mesh: AbstractMesh): AbstractMesh;
  25127. /**
  25128. * Removes the passed mesh from the current mesh children list
  25129. * @param mesh defines the child mesh
  25130. * @returns the current mesh
  25131. */
  25132. removeChild(mesh: AbstractMesh): AbstractMesh;
  25133. /** @hidden */
  25134. private _initFacetData;
  25135. /**
  25136. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25137. * This method can be called within the render loop.
  25138. * 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
  25139. * @returns the current mesh
  25140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25141. */
  25142. updateFacetData(): AbstractMesh;
  25143. /**
  25144. * Returns the facetLocalNormals array.
  25145. * The normals are expressed in the mesh local spac
  25146. * @returns an array of Vector3
  25147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25148. */
  25149. getFacetLocalNormals(): Vector3[];
  25150. /**
  25151. * Returns the facetLocalPositions array.
  25152. * The facet positions are expressed in the mesh local space
  25153. * @returns an array of Vector3
  25154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25155. */
  25156. getFacetLocalPositions(): Vector3[];
  25157. /**
  25158. * Returns the facetLocalPartioning array
  25159. * @returns an array of array of numbers
  25160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25161. */
  25162. getFacetLocalPartitioning(): number[][];
  25163. /**
  25164. * Returns the i-th facet position in the world system.
  25165. * This method allocates a new Vector3 per call
  25166. * @param i defines the facet index
  25167. * @returns a new Vector3
  25168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25169. */
  25170. getFacetPosition(i: number): Vector3;
  25171. /**
  25172. * Sets the reference Vector3 with the i-th facet position in the world system
  25173. * @param i defines the facet index
  25174. * @param ref defines the target vector
  25175. * @returns the current mesh
  25176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25177. */
  25178. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25179. /**
  25180. * Returns the i-th facet normal in the world system.
  25181. * This method allocates a new Vector3 per call
  25182. * @param i defines the facet index
  25183. * @returns a new Vector3
  25184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25185. */
  25186. getFacetNormal(i: number): Vector3;
  25187. /**
  25188. * Sets the reference Vector3 with the i-th facet normal in the world system
  25189. * @param i defines the facet index
  25190. * @param ref defines the target vector
  25191. * @returns the current mesh
  25192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25193. */
  25194. getFacetNormalToRef(i: number, ref: Vector3): this;
  25195. /**
  25196. * 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)
  25197. * @param x defines x coordinate
  25198. * @param y defines y coordinate
  25199. * @param z defines z coordinate
  25200. * @returns the array of facet indexes
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25202. */
  25203. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25204. /**
  25205. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25206. * @param projected sets as the (x,y,z) world projection on the facet
  25207. * @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
  25208. * @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
  25209. * @param x defines x coordinate
  25210. * @param y defines y coordinate
  25211. * @param z defines z coordinate
  25212. * @returns the face index if found (or null instead)
  25213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25214. */
  25215. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25216. /**
  25217. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25218. * @param projected sets as the (x,y,z) local projection on the facet
  25219. * @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
  25220. * @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
  25221. * @param x defines x coordinate
  25222. * @param y defines y coordinate
  25223. * @param z defines z coordinate
  25224. * @returns the face index if found (or null instead)
  25225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25226. */
  25227. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25228. /**
  25229. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25230. * @returns the parameters
  25231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25232. */
  25233. getFacetDataParameters(): any;
  25234. /**
  25235. * Disables the feature FacetData and frees the related memory
  25236. * @returns the current mesh
  25237. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25238. */
  25239. disableFacetData(): AbstractMesh;
  25240. /**
  25241. * Updates the AbstractMesh indices array
  25242. * @param indices defines the data source
  25243. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25244. * @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)
  25245. * @returns the current mesh
  25246. */
  25247. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25248. /**
  25249. * Creates new normals data for the mesh
  25250. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25251. * @returns the current mesh
  25252. */
  25253. createNormals(updatable: boolean): AbstractMesh;
  25254. /**
  25255. * Align the mesh with a normal
  25256. * @param normal defines the normal to use
  25257. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25258. * @returns the current mesh
  25259. */
  25260. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25261. /** @hidden */
  25262. _checkOcclusionQuery(): boolean;
  25263. /**
  25264. * Disables the mesh edge rendering mode
  25265. * @returns the currentAbstractMesh
  25266. */
  25267. disableEdgesRendering(): AbstractMesh;
  25268. /**
  25269. * Enables the edge rendering mode on the mesh.
  25270. * This mode makes the mesh edges visible
  25271. * @param epsilon defines the maximal distance between two angles to detect a face
  25272. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25273. * @returns the currentAbstractMesh
  25274. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25275. */
  25276. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25277. }
  25278. }
  25279. declare module BABYLON {
  25280. /**
  25281. * Interface used to define ActionEvent
  25282. */
  25283. export interface IActionEvent {
  25284. /** The mesh or sprite that triggered the action */
  25285. source: any;
  25286. /** The X mouse cursor position at the time of the event */
  25287. pointerX: number;
  25288. /** The Y mouse cursor position at the time of the event */
  25289. pointerY: number;
  25290. /** The mesh that is currently pointed at (can be null) */
  25291. meshUnderPointer: Nullable<AbstractMesh>;
  25292. /** the original (browser) event that triggered the ActionEvent */
  25293. sourceEvent?: any;
  25294. /** additional data for the event */
  25295. additionalData?: any;
  25296. }
  25297. /**
  25298. * ActionEvent is the event being sent when an action is triggered.
  25299. */
  25300. export class ActionEvent implements IActionEvent {
  25301. /** The mesh or sprite that triggered the action */
  25302. source: any;
  25303. /** The X mouse cursor position at the time of the event */
  25304. pointerX: number;
  25305. /** The Y mouse cursor position at the time of the event */
  25306. pointerY: number;
  25307. /** The mesh that is currently pointed at (can be null) */
  25308. meshUnderPointer: Nullable<AbstractMesh>;
  25309. /** the original (browser) event that triggered the ActionEvent */
  25310. sourceEvent?: any;
  25311. /** additional data for the event */
  25312. additionalData?: any;
  25313. /**
  25314. * Creates a new ActionEvent
  25315. * @param source The mesh or sprite that triggered the action
  25316. * @param pointerX The X mouse cursor position at the time of the event
  25317. * @param pointerY The Y mouse cursor position at the time of the event
  25318. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25319. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25320. * @param additionalData additional data for the event
  25321. */
  25322. constructor(
  25323. /** The mesh or sprite that triggered the action */
  25324. source: any,
  25325. /** The X mouse cursor position at the time of the event */
  25326. pointerX: number,
  25327. /** The Y mouse cursor position at the time of the event */
  25328. pointerY: number,
  25329. /** The mesh that is currently pointed at (can be null) */
  25330. meshUnderPointer: Nullable<AbstractMesh>,
  25331. /** the original (browser) event that triggered the ActionEvent */
  25332. sourceEvent?: any,
  25333. /** additional data for the event */
  25334. additionalData?: any);
  25335. /**
  25336. * Helper function to auto-create an ActionEvent from a source mesh.
  25337. * @param source The source mesh that triggered the event
  25338. * @param evt The original (browser) event
  25339. * @param additionalData additional data for the event
  25340. * @returns the new ActionEvent
  25341. */
  25342. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25343. /**
  25344. * Helper function to auto-create an ActionEvent from a source sprite
  25345. * @param source The source sprite that triggered the event
  25346. * @param scene Scene associated with the sprite
  25347. * @param evt The original (browser) event
  25348. * @param additionalData additional data for the event
  25349. * @returns the new ActionEvent
  25350. */
  25351. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25352. /**
  25353. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25354. * @param scene the scene where the event occurred
  25355. * @param evt The original (browser) event
  25356. * @returns the new ActionEvent
  25357. */
  25358. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25359. /**
  25360. * Helper function to auto-create an ActionEvent from a primitive
  25361. * @param prim defines the target primitive
  25362. * @param pointerPos defines the pointer position
  25363. * @param evt The original (browser) event
  25364. * @param additionalData additional data for the event
  25365. * @returns the new ActionEvent
  25366. */
  25367. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25368. }
  25369. }
  25370. declare module BABYLON {
  25371. /**
  25372. * Abstract class used to decouple action Manager from scene and meshes.
  25373. * Do not instantiate.
  25374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25375. */
  25376. export abstract class AbstractActionManager implements IDisposable {
  25377. /** Gets the list of active triggers */
  25378. static Triggers: {
  25379. [key: string]: number;
  25380. };
  25381. /** Gets the cursor to use when hovering items */
  25382. hoverCursor: string;
  25383. /** Gets the list of actions */
  25384. actions: IAction[];
  25385. /**
  25386. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25387. */
  25388. isRecursive: boolean;
  25389. /**
  25390. * Releases all associated resources
  25391. */
  25392. abstract dispose(): void;
  25393. /**
  25394. * Does this action manager has pointer triggers
  25395. */
  25396. abstract readonly hasPointerTriggers: boolean;
  25397. /**
  25398. * Does this action manager has pick triggers
  25399. */
  25400. abstract readonly hasPickTriggers: boolean;
  25401. /**
  25402. * Process a specific trigger
  25403. * @param trigger defines the trigger to process
  25404. * @param evt defines the event details to be processed
  25405. */
  25406. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25407. /**
  25408. * Does this action manager handles actions of any of the given triggers
  25409. * @param triggers defines the triggers to be tested
  25410. * @return a boolean indicating whether one (or more) of the triggers is handled
  25411. */
  25412. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25413. /**
  25414. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25415. * speed.
  25416. * @param triggerA defines the trigger to be tested
  25417. * @param triggerB defines the trigger to be tested
  25418. * @return a boolean indicating whether one (or more) of the triggers is handled
  25419. */
  25420. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25421. /**
  25422. * Does this action manager handles actions of a given trigger
  25423. * @param trigger defines the trigger to be tested
  25424. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25425. * @return whether the trigger is handled
  25426. */
  25427. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25428. /**
  25429. * Serialize this manager to a JSON object
  25430. * @param name defines the property name to store this manager
  25431. * @returns a JSON representation of this manager
  25432. */
  25433. abstract serialize(name: string): any;
  25434. /**
  25435. * Registers an action to this action manager
  25436. * @param action defines the action to be registered
  25437. * @return the action amended (prepared) after registration
  25438. */
  25439. abstract registerAction(action: IAction): Nullable<IAction>;
  25440. /**
  25441. * Unregisters an action to this action manager
  25442. * @param action defines the action to be unregistered
  25443. * @return a boolean indicating whether the action has been unregistered
  25444. */
  25445. abstract unregisterAction(action: IAction): Boolean;
  25446. /**
  25447. * Does exist one action manager with at least one trigger
  25448. **/
  25449. static readonly HasTriggers: boolean;
  25450. /**
  25451. * Does exist one action manager with at least one pick trigger
  25452. **/
  25453. static readonly HasPickTriggers: boolean;
  25454. /**
  25455. * Does exist one action manager that handles actions of a given trigger
  25456. * @param trigger defines the trigger to be tested
  25457. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25458. **/
  25459. static HasSpecificTrigger(trigger: number): boolean;
  25460. }
  25461. }
  25462. declare module BABYLON {
  25463. /**
  25464. * Defines how a node can be built from a string name.
  25465. */
  25466. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25467. /**
  25468. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25469. */
  25470. export class Node implements IBehaviorAware<Node> {
  25471. /** @hidden */
  25472. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25473. private static _NodeConstructors;
  25474. /**
  25475. * Add a new node constructor
  25476. * @param type defines the type name of the node to construct
  25477. * @param constructorFunc defines the constructor function
  25478. */
  25479. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25480. /**
  25481. * Returns a node constructor based on type name
  25482. * @param type defines the type name
  25483. * @param name defines the new node name
  25484. * @param scene defines the hosting scene
  25485. * @param options defines optional options to transmit to constructors
  25486. * @returns the new constructor or null
  25487. */
  25488. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25489. /**
  25490. * Gets or sets the name of the node
  25491. */
  25492. name: string;
  25493. /**
  25494. * Gets or sets the id of the node
  25495. */
  25496. id: string;
  25497. /**
  25498. * Gets or sets the unique id of the node
  25499. */
  25500. uniqueId: number;
  25501. /**
  25502. * Gets or sets a string used to store user defined state for the node
  25503. */
  25504. state: string;
  25505. /**
  25506. * Gets or sets an object used to store user defined information for the node
  25507. */
  25508. metadata: any;
  25509. /**
  25510. * For internal use only. Please do not use.
  25511. */
  25512. reservedDataStore: any;
  25513. /**
  25514. * List of inspectable custom properties (used by the Inspector)
  25515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25516. */
  25517. inspectableCustomProperties: IInspectable[];
  25518. /**
  25519. * Gets or sets a boolean used to define if the node must be serialized
  25520. */
  25521. doNotSerialize: boolean;
  25522. /** @hidden */
  25523. _isDisposed: boolean;
  25524. /**
  25525. * Gets a list of Animations associated with the node
  25526. */
  25527. animations: Animation[];
  25528. protected _ranges: {
  25529. [name: string]: Nullable<AnimationRange>;
  25530. };
  25531. /**
  25532. * Callback raised when the node is ready to be used
  25533. */
  25534. onReady: Nullable<(node: Node) => void>;
  25535. private _isEnabled;
  25536. private _isParentEnabled;
  25537. private _isReady;
  25538. /** @hidden */
  25539. _currentRenderId: number;
  25540. private _parentUpdateId;
  25541. /** @hidden */
  25542. _childUpdateId: number;
  25543. /** @hidden */
  25544. _waitingParentId: Nullable<string>;
  25545. /** @hidden */
  25546. _scene: Scene;
  25547. /** @hidden */
  25548. _cache: any;
  25549. private _parentNode;
  25550. private _children;
  25551. /** @hidden */
  25552. _worldMatrix: Matrix;
  25553. /** @hidden */
  25554. _worldMatrixDeterminant: number;
  25555. /** @hidden */
  25556. _worldMatrixDeterminantIsDirty: boolean;
  25557. /** @hidden */
  25558. private _sceneRootNodesIndex;
  25559. /**
  25560. * Gets a boolean indicating if the node has been disposed
  25561. * @returns true if the node was disposed
  25562. */
  25563. isDisposed(): boolean;
  25564. /**
  25565. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25566. * @see https://doc.babylonjs.com/how_to/parenting
  25567. */
  25568. parent: Nullable<Node>;
  25569. private addToSceneRootNodes;
  25570. private removeFromSceneRootNodes;
  25571. private _animationPropertiesOverride;
  25572. /**
  25573. * Gets or sets the animation properties override
  25574. */
  25575. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25576. /**
  25577. * Gets a string idenfifying the name of the class
  25578. * @returns "Node" string
  25579. */
  25580. getClassName(): string;
  25581. /** @hidden */
  25582. readonly _isNode: boolean;
  25583. /**
  25584. * An event triggered when the mesh is disposed
  25585. */
  25586. onDisposeObservable: Observable<Node>;
  25587. private _onDisposeObserver;
  25588. /**
  25589. * Sets a callback that will be raised when the node will be disposed
  25590. */
  25591. onDispose: () => void;
  25592. /**
  25593. * Creates a new Node
  25594. * @param name the name and id to be given to this node
  25595. * @param scene the scene this node will be added to
  25596. * @param addToRootNodes the node will be added to scene.rootNodes
  25597. */
  25598. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25599. /**
  25600. * Gets the scene of the node
  25601. * @returns a scene
  25602. */
  25603. getScene(): Scene;
  25604. /**
  25605. * Gets the engine of the node
  25606. * @returns a Engine
  25607. */
  25608. getEngine(): Engine;
  25609. private _behaviors;
  25610. /**
  25611. * Attach a behavior to the node
  25612. * @see http://doc.babylonjs.com/features/behaviour
  25613. * @param behavior defines the behavior to attach
  25614. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25615. * @returns the current Node
  25616. */
  25617. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25618. /**
  25619. * Remove an attached behavior
  25620. * @see http://doc.babylonjs.com/features/behaviour
  25621. * @param behavior defines the behavior to attach
  25622. * @returns the current Node
  25623. */
  25624. removeBehavior(behavior: Behavior<Node>): Node;
  25625. /**
  25626. * Gets the list of attached behaviors
  25627. * @see http://doc.babylonjs.com/features/behaviour
  25628. */
  25629. readonly behaviors: Behavior<Node>[];
  25630. /**
  25631. * Gets an attached behavior by name
  25632. * @param name defines the name of the behavior to look for
  25633. * @see http://doc.babylonjs.com/features/behaviour
  25634. * @returns null if behavior was not found else the requested behavior
  25635. */
  25636. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25637. /**
  25638. * Returns the latest update of the World matrix
  25639. * @returns a Matrix
  25640. */
  25641. getWorldMatrix(): Matrix;
  25642. /** @hidden */
  25643. _getWorldMatrixDeterminant(): number;
  25644. /**
  25645. * Returns directly the latest state of the mesh World matrix.
  25646. * A Matrix is returned.
  25647. */
  25648. readonly worldMatrixFromCache: Matrix;
  25649. /** @hidden */
  25650. _initCache(): void;
  25651. /** @hidden */
  25652. updateCache(force?: boolean): void;
  25653. /** @hidden */
  25654. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25655. /** @hidden */
  25656. _updateCache(ignoreParentClass?: boolean): void;
  25657. /** @hidden */
  25658. _isSynchronized(): boolean;
  25659. /** @hidden */
  25660. _markSyncedWithParent(): void;
  25661. /** @hidden */
  25662. isSynchronizedWithParent(): boolean;
  25663. /** @hidden */
  25664. isSynchronized(): boolean;
  25665. /**
  25666. * Is this node ready to be used/rendered
  25667. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25668. * @return true if the node is ready
  25669. */
  25670. isReady(completeCheck?: boolean): boolean;
  25671. /**
  25672. * Is this node enabled?
  25673. * 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
  25674. * @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
  25675. * @return whether this node (and its parent) is enabled
  25676. */
  25677. isEnabled(checkAncestors?: boolean): boolean;
  25678. /** @hidden */
  25679. protected _syncParentEnabledState(): void;
  25680. /**
  25681. * Set the enabled state of this node
  25682. * @param value defines the new enabled state
  25683. */
  25684. setEnabled(value: boolean): void;
  25685. /**
  25686. * Is this node a descendant of the given node?
  25687. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25688. * @param ancestor defines the parent node to inspect
  25689. * @returns a boolean indicating if this node is a descendant of the given node
  25690. */
  25691. isDescendantOf(ancestor: Node): boolean;
  25692. /** @hidden */
  25693. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25694. /**
  25695. * Will return all nodes that have this node as ascendant
  25696. * @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
  25697. * @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
  25698. * @return all children nodes of all types
  25699. */
  25700. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25701. /**
  25702. * Get all child-meshes of this node
  25703. * @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)
  25704. * @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
  25705. * @returns an array of AbstractMesh
  25706. */
  25707. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25708. /**
  25709. * Get all direct children of this node
  25710. * @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
  25711. * @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)
  25712. * @returns an array of Node
  25713. */
  25714. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25715. /** @hidden */
  25716. _setReady(state: boolean): void;
  25717. /**
  25718. * Get an animation by name
  25719. * @param name defines the name of the animation to look for
  25720. * @returns null if not found else the requested animation
  25721. */
  25722. getAnimationByName(name: string): Nullable<Animation>;
  25723. /**
  25724. * Creates an animation range for this node
  25725. * @param name defines the name of the range
  25726. * @param from defines the starting key
  25727. * @param to defines the end key
  25728. */
  25729. createAnimationRange(name: string, from: number, to: number): void;
  25730. /**
  25731. * Delete a specific animation range
  25732. * @param name defines the name of the range to delete
  25733. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25734. */
  25735. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25736. /**
  25737. * Get an animation range by name
  25738. * @param name defines the name of the animation range to look for
  25739. * @returns null if not found else the requested animation range
  25740. */
  25741. getAnimationRange(name: string): Nullable<AnimationRange>;
  25742. /**
  25743. * Gets the list of all animation ranges defined on this node
  25744. * @returns an array
  25745. */
  25746. getAnimationRanges(): Nullable<AnimationRange>[];
  25747. /**
  25748. * Will start the animation sequence
  25749. * @param name defines the range frames for animation sequence
  25750. * @param loop defines if the animation should loop (false by default)
  25751. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25752. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25753. * @returns the object created for this animation. If range does not exist, it will return null
  25754. */
  25755. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25756. /**
  25757. * Serialize animation ranges into a JSON compatible object
  25758. * @returns serialization object
  25759. */
  25760. serializeAnimationRanges(): any;
  25761. /**
  25762. * Computes the world matrix of the node
  25763. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25764. * @returns the world matrix
  25765. */
  25766. computeWorldMatrix(force?: boolean): Matrix;
  25767. /**
  25768. * Releases resources associated with this node.
  25769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25771. */
  25772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25773. /**
  25774. * Parse animation range data from a serialization object and store them into a given node
  25775. * @param node defines where to store the animation ranges
  25776. * @param parsedNode defines the serialization object to read data from
  25777. * @param scene defines the hosting scene
  25778. */
  25779. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25780. /**
  25781. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25782. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25783. * @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
  25784. * @returns the new bounding vectors
  25785. */
  25786. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25787. min: Vector3;
  25788. max: Vector3;
  25789. };
  25790. }
  25791. }
  25792. declare module BABYLON {
  25793. /**
  25794. * @hidden
  25795. */
  25796. export class _IAnimationState {
  25797. key: number;
  25798. repeatCount: number;
  25799. workValue?: any;
  25800. loopMode?: number;
  25801. offsetValue?: any;
  25802. highLimitValue?: any;
  25803. }
  25804. /**
  25805. * Class used to store any kind of animation
  25806. */
  25807. export class Animation {
  25808. /**Name of the animation */
  25809. name: string;
  25810. /**Property to animate */
  25811. targetProperty: string;
  25812. /**The frames per second of the animation */
  25813. framePerSecond: number;
  25814. /**The data type of the animation */
  25815. dataType: number;
  25816. /**The loop mode of the animation */
  25817. loopMode?: number | undefined;
  25818. /**Specifies if blending should be enabled */
  25819. enableBlending?: boolean | undefined;
  25820. /**
  25821. * Use matrix interpolation instead of using direct key value when animating matrices
  25822. */
  25823. static AllowMatricesInterpolation: boolean;
  25824. /**
  25825. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25826. */
  25827. static AllowMatrixDecomposeForInterpolation: boolean;
  25828. /**
  25829. * Stores the key frames of the animation
  25830. */
  25831. private _keys;
  25832. /**
  25833. * Stores the easing function of the animation
  25834. */
  25835. private _easingFunction;
  25836. /**
  25837. * @hidden Internal use only
  25838. */
  25839. _runtimeAnimations: RuntimeAnimation[];
  25840. /**
  25841. * The set of event that will be linked to this animation
  25842. */
  25843. private _events;
  25844. /**
  25845. * Stores an array of target property paths
  25846. */
  25847. targetPropertyPath: string[];
  25848. /**
  25849. * Stores the blending speed of the animation
  25850. */
  25851. blendingSpeed: number;
  25852. /**
  25853. * Stores the animation ranges for the animation
  25854. */
  25855. private _ranges;
  25856. /**
  25857. * @hidden Internal use
  25858. */
  25859. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25860. /**
  25861. * Sets up an animation
  25862. * @param property The property to animate
  25863. * @param animationType The animation type to apply
  25864. * @param framePerSecond The frames per second of the animation
  25865. * @param easingFunction The easing function used in the animation
  25866. * @returns The created animation
  25867. */
  25868. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25869. /**
  25870. * Create and start an animation on a node
  25871. * @param name defines the name of the global animation that will be run on all nodes
  25872. * @param node defines the root node where the animation will take place
  25873. * @param targetProperty defines property to animate
  25874. * @param framePerSecond defines the number of frame per second yo use
  25875. * @param totalFrame defines the number of frames in total
  25876. * @param from defines the initial value
  25877. * @param to defines the final value
  25878. * @param loopMode defines which loop mode you want to use (off by default)
  25879. * @param easingFunction defines the easing function to use (linear by default)
  25880. * @param onAnimationEnd defines the callback to call when animation end
  25881. * @returns the animatable created for this animation
  25882. */
  25883. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25884. /**
  25885. * Create and start an animation on a node and its descendants
  25886. * @param name defines the name of the global animation that will be run on all nodes
  25887. * @param node defines the root node where the animation will take place
  25888. * @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
  25889. * @param targetProperty defines property to animate
  25890. * @param framePerSecond defines the number of frame per second to use
  25891. * @param totalFrame defines the number of frames in total
  25892. * @param from defines the initial value
  25893. * @param to defines the final value
  25894. * @param loopMode defines which loop mode you want to use (off by default)
  25895. * @param easingFunction defines the easing function to use (linear by default)
  25896. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25897. * @returns the list of animatables created for all nodes
  25898. * @example https://www.babylonjs-playground.com/#MH0VLI
  25899. */
  25900. 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[]>;
  25901. /**
  25902. * Creates a new animation, merges it with the existing animations and starts it
  25903. * @param name Name of the animation
  25904. * @param node Node which contains the scene that begins the animations
  25905. * @param targetProperty Specifies which property to animate
  25906. * @param framePerSecond The frames per second of the animation
  25907. * @param totalFrame The total number of frames
  25908. * @param from The frame at the beginning of the animation
  25909. * @param to The frame at the end of the animation
  25910. * @param loopMode Specifies the loop mode of the animation
  25911. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25912. * @param onAnimationEnd Callback to run once the animation is complete
  25913. * @returns Nullable animation
  25914. */
  25915. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25916. /**
  25917. * Transition property of an host to the target Value
  25918. * @param property The property to transition
  25919. * @param targetValue The target Value of the property
  25920. * @param host The object where the property to animate belongs
  25921. * @param scene Scene used to run the animation
  25922. * @param frameRate Framerate (in frame/s) to use
  25923. * @param transition The transition type we want to use
  25924. * @param duration The duration of the animation, in milliseconds
  25925. * @param onAnimationEnd Callback trigger at the end of the animation
  25926. * @returns Nullable animation
  25927. */
  25928. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25929. /**
  25930. * Return the array of runtime animations currently using this animation
  25931. */
  25932. readonly runtimeAnimations: RuntimeAnimation[];
  25933. /**
  25934. * Specifies if any of the runtime animations are currently running
  25935. */
  25936. readonly hasRunningRuntimeAnimations: boolean;
  25937. /**
  25938. * Initializes the animation
  25939. * @param name Name of the animation
  25940. * @param targetProperty Property to animate
  25941. * @param framePerSecond The frames per second of the animation
  25942. * @param dataType The data type of the animation
  25943. * @param loopMode The loop mode of the animation
  25944. * @param enableBlending Specifies if blending should be enabled
  25945. */
  25946. constructor(
  25947. /**Name of the animation */
  25948. name: string,
  25949. /**Property to animate */
  25950. targetProperty: string,
  25951. /**The frames per second of the animation */
  25952. framePerSecond: number,
  25953. /**The data type of the animation */
  25954. dataType: number,
  25955. /**The loop mode of the animation */
  25956. loopMode?: number | undefined,
  25957. /**Specifies if blending should be enabled */
  25958. enableBlending?: boolean | undefined);
  25959. /**
  25960. * Converts the animation to a string
  25961. * @param fullDetails support for multiple levels of logging within scene loading
  25962. * @returns String form of the animation
  25963. */
  25964. toString(fullDetails?: boolean): string;
  25965. /**
  25966. * Add an event to this animation
  25967. * @param event Event to add
  25968. */
  25969. addEvent(event: AnimationEvent): void;
  25970. /**
  25971. * Remove all events found at the given frame
  25972. * @param frame The frame to remove events from
  25973. */
  25974. removeEvents(frame: number): void;
  25975. /**
  25976. * Retrieves all the events from the animation
  25977. * @returns Events from the animation
  25978. */
  25979. getEvents(): AnimationEvent[];
  25980. /**
  25981. * Creates an animation range
  25982. * @param name Name of the animation range
  25983. * @param from Starting frame of the animation range
  25984. * @param to Ending frame of the animation
  25985. */
  25986. createRange(name: string, from: number, to: number): void;
  25987. /**
  25988. * Deletes an animation range by name
  25989. * @param name Name of the animation range to delete
  25990. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25991. */
  25992. deleteRange(name: string, deleteFrames?: boolean): void;
  25993. /**
  25994. * Gets the animation range by name, or null if not defined
  25995. * @param name Name of the animation range
  25996. * @returns Nullable animation range
  25997. */
  25998. getRange(name: string): Nullable<AnimationRange>;
  25999. /**
  26000. * Gets the key frames from the animation
  26001. * @returns The key frames of the animation
  26002. */
  26003. getKeys(): Array<IAnimationKey>;
  26004. /**
  26005. * Gets the highest frame rate of the animation
  26006. * @returns Highest frame rate of the animation
  26007. */
  26008. getHighestFrame(): number;
  26009. /**
  26010. * Gets the easing function of the animation
  26011. * @returns Easing function of the animation
  26012. */
  26013. getEasingFunction(): IEasingFunction;
  26014. /**
  26015. * Sets the easing function of the animation
  26016. * @param easingFunction A custom mathematical formula for animation
  26017. */
  26018. setEasingFunction(easingFunction: EasingFunction): void;
  26019. /**
  26020. * Interpolates a scalar linearly
  26021. * @param startValue Start value of the animation curve
  26022. * @param endValue End value of the animation curve
  26023. * @param gradient Scalar amount to interpolate
  26024. * @returns Interpolated scalar value
  26025. */
  26026. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26027. /**
  26028. * Interpolates a scalar cubically
  26029. * @param startValue Start value of the animation curve
  26030. * @param outTangent End tangent of the animation
  26031. * @param endValue End value of the animation curve
  26032. * @param inTangent Start tangent of the animation curve
  26033. * @param gradient Scalar amount to interpolate
  26034. * @returns Interpolated scalar value
  26035. */
  26036. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26037. /**
  26038. * Interpolates a quaternion using a spherical linear interpolation
  26039. * @param startValue Start value of the animation curve
  26040. * @param endValue End value of the animation curve
  26041. * @param gradient Scalar amount to interpolate
  26042. * @returns Interpolated quaternion value
  26043. */
  26044. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26045. /**
  26046. * Interpolates a quaternion cubically
  26047. * @param startValue Start value of the animation curve
  26048. * @param outTangent End tangent of the animation curve
  26049. * @param endValue End value of the animation curve
  26050. * @param inTangent Start tangent of the animation curve
  26051. * @param gradient Scalar amount to interpolate
  26052. * @returns Interpolated quaternion value
  26053. */
  26054. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26055. /**
  26056. * Interpolates a Vector3 linearl
  26057. * @param startValue Start value of the animation curve
  26058. * @param endValue End value of the animation curve
  26059. * @param gradient Scalar amount to interpolate
  26060. * @returns Interpolated scalar value
  26061. */
  26062. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26063. /**
  26064. * Interpolates a Vector3 cubically
  26065. * @param startValue Start value of the animation curve
  26066. * @param outTangent End tangent of the animation
  26067. * @param endValue End value of the animation curve
  26068. * @param inTangent Start tangent of the animation curve
  26069. * @param gradient Scalar amount to interpolate
  26070. * @returns InterpolatedVector3 value
  26071. */
  26072. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26073. /**
  26074. * Interpolates a Vector2 linearly
  26075. * @param startValue Start value of the animation curve
  26076. * @param endValue End value of the animation curve
  26077. * @param gradient Scalar amount to interpolate
  26078. * @returns Interpolated Vector2 value
  26079. */
  26080. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26081. /**
  26082. * Interpolates a Vector2 cubically
  26083. * @param startValue Start value of the animation curve
  26084. * @param outTangent End tangent of the animation
  26085. * @param endValue End value of the animation curve
  26086. * @param inTangent Start tangent of the animation curve
  26087. * @param gradient Scalar amount to interpolate
  26088. * @returns Interpolated Vector2 value
  26089. */
  26090. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26091. /**
  26092. * Interpolates a size linearly
  26093. * @param startValue Start value of the animation curve
  26094. * @param endValue End value of the animation curve
  26095. * @param gradient Scalar amount to interpolate
  26096. * @returns Interpolated Size value
  26097. */
  26098. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26099. /**
  26100. * Interpolates a Color3 linearly
  26101. * @param startValue Start value of the animation curve
  26102. * @param endValue End value of the animation curve
  26103. * @param gradient Scalar amount to interpolate
  26104. * @returns Interpolated Color3 value
  26105. */
  26106. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26107. /**
  26108. * @hidden Internal use only
  26109. */
  26110. _getKeyValue(value: any): any;
  26111. /**
  26112. * @hidden Internal use only
  26113. */
  26114. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26115. /**
  26116. * Defines the function to use to interpolate matrices
  26117. * @param startValue defines the start matrix
  26118. * @param endValue defines the end matrix
  26119. * @param gradient defines the gradient between both matrices
  26120. * @param result defines an optional target matrix where to store the interpolation
  26121. * @returns the interpolated matrix
  26122. */
  26123. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26124. /**
  26125. * Makes a copy of the animation
  26126. * @returns Cloned animation
  26127. */
  26128. clone(): Animation;
  26129. /**
  26130. * Sets the key frames of the animation
  26131. * @param values The animation key frames to set
  26132. */
  26133. setKeys(values: Array<IAnimationKey>): void;
  26134. /**
  26135. * Serializes the animation to an object
  26136. * @returns Serialized object
  26137. */
  26138. serialize(): any;
  26139. /**
  26140. * Float animation type
  26141. */
  26142. private static _ANIMATIONTYPE_FLOAT;
  26143. /**
  26144. * Vector3 animation type
  26145. */
  26146. private static _ANIMATIONTYPE_VECTOR3;
  26147. /**
  26148. * Quaternion animation type
  26149. */
  26150. private static _ANIMATIONTYPE_QUATERNION;
  26151. /**
  26152. * Matrix animation type
  26153. */
  26154. private static _ANIMATIONTYPE_MATRIX;
  26155. /**
  26156. * Color3 animation type
  26157. */
  26158. private static _ANIMATIONTYPE_COLOR3;
  26159. /**
  26160. * Vector2 animation type
  26161. */
  26162. private static _ANIMATIONTYPE_VECTOR2;
  26163. /**
  26164. * Size animation type
  26165. */
  26166. private static _ANIMATIONTYPE_SIZE;
  26167. /**
  26168. * Relative Loop Mode
  26169. */
  26170. private static _ANIMATIONLOOPMODE_RELATIVE;
  26171. /**
  26172. * Cycle Loop Mode
  26173. */
  26174. private static _ANIMATIONLOOPMODE_CYCLE;
  26175. /**
  26176. * Constant Loop Mode
  26177. */
  26178. private static _ANIMATIONLOOPMODE_CONSTANT;
  26179. /**
  26180. * Get the float animation type
  26181. */
  26182. static readonly ANIMATIONTYPE_FLOAT: number;
  26183. /**
  26184. * Get the Vector3 animation type
  26185. */
  26186. static readonly ANIMATIONTYPE_VECTOR3: number;
  26187. /**
  26188. * Get the Vector2 animation type
  26189. */
  26190. static readonly ANIMATIONTYPE_VECTOR2: number;
  26191. /**
  26192. * Get the Size animation type
  26193. */
  26194. static readonly ANIMATIONTYPE_SIZE: number;
  26195. /**
  26196. * Get the Quaternion animation type
  26197. */
  26198. static readonly ANIMATIONTYPE_QUATERNION: number;
  26199. /**
  26200. * Get the Matrix animation type
  26201. */
  26202. static readonly ANIMATIONTYPE_MATRIX: number;
  26203. /**
  26204. * Get the Color3 animation type
  26205. */
  26206. static readonly ANIMATIONTYPE_COLOR3: number;
  26207. /**
  26208. * Get the Relative Loop Mode
  26209. */
  26210. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26211. /**
  26212. * Get the Cycle Loop Mode
  26213. */
  26214. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26215. /**
  26216. * Get the Constant Loop Mode
  26217. */
  26218. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26219. /** @hidden */
  26220. static _UniversalLerp(left: any, right: any, amount: number): any;
  26221. /**
  26222. * Parses an animation object and creates an animation
  26223. * @param parsedAnimation Parsed animation object
  26224. * @returns Animation object
  26225. */
  26226. static Parse(parsedAnimation: any): Animation;
  26227. /**
  26228. * Appends the serialized animations from the source animations
  26229. * @param source Source containing the animations
  26230. * @param destination Target to store the animations
  26231. */
  26232. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26233. }
  26234. }
  26235. declare module BABYLON {
  26236. /**
  26237. * Base class of all the textures in babylon.
  26238. * It groups all the common properties the materials, post process, lights... might need
  26239. * in order to make a correct use of the texture.
  26240. */
  26241. export class BaseTexture implements IAnimatable {
  26242. /**
  26243. * Default anisotropic filtering level for the application.
  26244. * It is set to 4 as a good tradeoff between perf and quality.
  26245. */
  26246. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26247. /**
  26248. * Gets or sets the unique id of the texture
  26249. */
  26250. uniqueId: number;
  26251. /**
  26252. * Define the name of the texture.
  26253. */
  26254. name: string;
  26255. /**
  26256. * Gets or sets an object used to store user defined information.
  26257. */
  26258. metadata: any;
  26259. /**
  26260. * For internal use only. Please do not use.
  26261. */
  26262. reservedDataStore: any;
  26263. private _hasAlpha;
  26264. /**
  26265. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26266. */
  26267. hasAlpha: boolean;
  26268. /**
  26269. * Defines if the alpha value should be determined via the rgb values.
  26270. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26271. */
  26272. getAlphaFromRGB: boolean;
  26273. /**
  26274. * Intensity or strength of the texture.
  26275. * It is commonly used by materials to fine tune the intensity of the texture
  26276. */
  26277. level: number;
  26278. /**
  26279. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26280. * This is part of the texture as textures usually maps to one uv set.
  26281. */
  26282. coordinatesIndex: number;
  26283. private _coordinatesMode;
  26284. /**
  26285. * How a texture is mapped.
  26286. *
  26287. * | Value | Type | Description |
  26288. * | ----- | ----------------------------------- | ----------- |
  26289. * | 0 | EXPLICIT_MODE | |
  26290. * | 1 | SPHERICAL_MODE | |
  26291. * | 2 | PLANAR_MODE | |
  26292. * | 3 | CUBIC_MODE | |
  26293. * | 4 | PROJECTION_MODE | |
  26294. * | 5 | SKYBOX_MODE | |
  26295. * | 6 | INVCUBIC_MODE | |
  26296. * | 7 | EQUIRECTANGULAR_MODE | |
  26297. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26298. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26299. */
  26300. coordinatesMode: number;
  26301. /**
  26302. * | Value | Type | Description |
  26303. * | ----- | ------------------ | ----------- |
  26304. * | 0 | CLAMP_ADDRESSMODE | |
  26305. * | 1 | WRAP_ADDRESSMODE | |
  26306. * | 2 | MIRROR_ADDRESSMODE | |
  26307. */
  26308. wrapU: number;
  26309. /**
  26310. * | Value | Type | Description |
  26311. * | ----- | ------------------ | ----------- |
  26312. * | 0 | CLAMP_ADDRESSMODE | |
  26313. * | 1 | WRAP_ADDRESSMODE | |
  26314. * | 2 | MIRROR_ADDRESSMODE | |
  26315. */
  26316. wrapV: number;
  26317. /**
  26318. * | Value | Type | Description |
  26319. * | ----- | ------------------ | ----------- |
  26320. * | 0 | CLAMP_ADDRESSMODE | |
  26321. * | 1 | WRAP_ADDRESSMODE | |
  26322. * | 2 | MIRROR_ADDRESSMODE | |
  26323. */
  26324. wrapR: number;
  26325. /**
  26326. * With compliant hardware and browser (supporting anisotropic filtering)
  26327. * this defines the level of anisotropic filtering in the texture.
  26328. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26329. */
  26330. anisotropicFilteringLevel: number;
  26331. /**
  26332. * Define if the texture is a cube texture or if false a 2d texture.
  26333. */
  26334. isCube: boolean;
  26335. /**
  26336. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26337. */
  26338. is3D: boolean;
  26339. /**
  26340. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26341. * HDR texture are usually stored in linear space.
  26342. * This only impacts the PBR and Background materials
  26343. */
  26344. gammaSpace: boolean;
  26345. /**
  26346. * Gets whether or not the texture contains RGBD data.
  26347. */
  26348. readonly isRGBD: boolean;
  26349. /**
  26350. * Is Z inverted in the texture (useful in a cube texture).
  26351. */
  26352. invertZ: boolean;
  26353. /**
  26354. * Are mip maps generated for this texture or not.
  26355. */
  26356. readonly noMipmap: boolean;
  26357. /**
  26358. * @hidden
  26359. */
  26360. lodLevelInAlpha: boolean;
  26361. /**
  26362. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26363. */
  26364. lodGenerationOffset: number;
  26365. /**
  26366. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26367. */
  26368. lodGenerationScale: number;
  26369. /**
  26370. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26371. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26372. * average roughness values.
  26373. */
  26374. linearSpecularLOD: boolean;
  26375. /**
  26376. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26377. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26378. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26379. */
  26380. irradianceTexture: Nullable<BaseTexture>;
  26381. /**
  26382. * Define if the texture is a render target.
  26383. */
  26384. isRenderTarget: boolean;
  26385. /**
  26386. * Define the unique id of the texture in the scene.
  26387. */
  26388. readonly uid: string;
  26389. /**
  26390. * Return a string representation of the texture.
  26391. * @returns the texture as a string
  26392. */
  26393. toString(): string;
  26394. /**
  26395. * Get the class name of the texture.
  26396. * @returns "BaseTexture"
  26397. */
  26398. getClassName(): string;
  26399. /**
  26400. * Define the list of animation attached to the texture.
  26401. */
  26402. animations: Animation[];
  26403. /**
  26404. * An event triggered when the texture is disposed.
  26405. */
  26406. onDisposeObservable: Observable<BaseTexture>;
  26407. private _onDisposeObserver;
  26408. /**
  26409. * Callback triggered when the texture has been disposed.
  26410. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26411. */
  26412. onDispose: () => void;
  26413. /**
  26414. * Define the current state of the loading sequence when in delayed load mode.
  26415. */
  26416. delayLoadState: number;
  26417. private _scene;
  26418. /** @hidden */
  26419. _texture: Nullable<InternalTexture>;
  26420. private _uid;
  26421. /**
  26422. * Define if the texture is preventinga material to render or not.
  26423. * If not and the texture is not ready, the engine will use a default black texture instead.
  26424. */
  26425. readonly isBlocking: boolean;
  26426. /**
  26427. * Instantiates a new BaseTexture.
  26428. * Base class of all the textures in babylon.
  26429. * It groups all the common properties the materials, post process, lights... might need
  26430. * in order to make a correct use of the texture.
  26431. * @param scene Define the scene the texture blongs to
  26432. */
  26433. constructor(scene: Nullable<Scene>);
  26434. /**
  26435. * Get the scene the texture belongs to.
  26436. * @returns the scene or null if undefined
  26437. */
  26438. getScene(): Nullable<Scene>;
  26439. /**
  26440. * Get the texture transform matrix used to offset tile the texture for istance.
  26441. * @returns the transformation matrix
  26442. */
  26443. getTextureMatrix(): Matrix;
  26444. /**
  26445. * Get the texture reflection matrix used to rotate/transform the reflection.
  26446. * @returns the reflection matrix
  26447. */
  26448. getReflectionTextureMatrix(): Matrix;
  26449. /**
  26450. * Get the underlying lower level texture from Babylon.
  26451. * @returns the insternal texture
  26452. */
  26453. getInternalTexture(): Nullable<InternalTexture>;
  26454. /**
  26455. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26456. * @returns true if ready or not blocking
  26457. */
  26458. isReadyOrNotBlocking(): boolean;
  26459. /**
  26460. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26461. * @returns true if fully ready
  26462. */
  26463. isReady(): boolean;
  26464. private _cachedSize;
  26465. /**
  26466. * Get the size of the texture.
  26467. * @returns the texture size.
  26468. */
  26469. getSize(): ISize;
  26470. /**
  26471. * Get the base size of the texture.
  26472. * It can be different from the size if the texture has been resized for POT for instance
  26473. * @returns the base size
  26474. */
  26475. getBaseSize(): ISize;
  26476. /**
  26477. * Update the sampling mode of the texture.
  26478. * Default is Trilinear mode.
  26479. *
  26480. * | Value | Type | Description |
  26481. * | ----- | ------------------ | ----------- |
  26482. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26483. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26484. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26485. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26486. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26487. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26488. * | 7 | NEAREST_LINEAR | |
  26489. * | 8 | NEAREST_NEAREST | |
  26490. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26491. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26492. * | 11 | LINEAR_LINEAR | |
  26493. * | 12 | LINEAR_NEAREST | |
  26494. *
  26495. * > _mag_: magnification filter (close to the viewer)
  26496. * > _min_: minification filter (far from the viewer)
  26497. * > _mip_: filter used between mip map levels
  26498. *@param samplingMode Define the new sampling mode of the texture
  26499. */
  26500. updateSamplingMode(samplingMode: number): void;
  26501. /**
  26502. * Scales the texture if is `canRescale()`
  26503. * @param ratio the resize factor we want to use to rescale
  26504. */
  26505. scale(ratio: number): void;
  26506. /**
  26507. * Get if the texture can rescale.
  26508. */
  26509. readonly canRescale: boolean;
  26510. /** @hidden */
  26511. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26512. /** @hidden */
  26513. _rebuild(): void;
  26514. /**
  26515. * Triggers the load sequence in delayed load mode.
  26516. */
  26517. delayLoad(): void;
  26518. /**
  26519. * Clones the texture.
  26520. * @returns the cloned texture
  26521. */
  26522. clone(): Nullable<BaseTexture>;
  26523. /**
  26524. * Get the texture underlying type (INT, FLOAT...)
  26525. */
  26526. readonly textureType: number;
  26527. /**
  26528. * Get the texture underlying format (RGB, RGBA...)
  26529. */
  26530. readonly textureFormat: number;
  26531. /**
  26532. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26533. * This will returns an RGBA array buffer containing either in values (0-255) or
  26534. * float values (0-1) depending of the underlying buffer type.
  26535. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26536. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26537. * @param buffer defines a user defined buffer to fill with data (can be null)
  26538. * @returns The Array buffer containing the pixels data.
  26539. */
  26540. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26541. /**
  26542. * Release and destroy the underlying lower level texture aka internalTexture.
  26543. */
  26544. releaseInternalTexture(): void;
  26545. /**
  26546. * Get the polynomial representation of the texture data.
  26547. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26548. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26549. */
  26550. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26551. /** @hidden */
  26552. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26553. /** @hidden */
  26554. readonly _lodTextureMid: Nullable<BaseTexture>;
  26555. /** @hidden */
  26556. readonly _lodTextureLow: Nullable<BaseTexture>;
  26557. /**
  26558. * Dispose the texture and release its associated resources.
  26559. */
  26560. dispose(): void;
  26561. /**
  26562. * Serialize the texture into a JSON representation that can be parsed later on.
  26563. * @returns the JSON representation of the texture
  26564. */
  26565. serialize(): any;
  26566. /**
  26567. * Helper function to be called back once a list of texture contains only ready textures.
  26568. * @param textures Define the list of textures to wait for
  26569. * @param callback Define the callback triggered once the entire list will be ready
  26570. */
  26571. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26572. }
  26573. }
  26574. declare module BABYLON {
  26575. /**
  26576. * Uniform buffer objects.
  26577. *
  26578. * Handles blocks of uniform on the GPU.
  26579. *
  26580. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26581. *
  26582. * For more information, please refer to :
  26583. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26584. */
  26585. export class UniformBuffer {
  26586. private _engine;
  26587. private _buffer;
  26588. private _data;
  26589. private _bufferData;
  26590. private _dynamic?;
  26591. private _uniformLocations;
  26592. private _uniformSizes;
  26593. private _uniformLocationPointer;
  26594. private _needSync;
  26595. private _noUBO;
  26596. private _currentEffect;
  26597. private static _MAX_UNIFORM_SIZE;
  26598. private static _tempBuffer;
  26599. /**
  26600. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26601. * This is dynamic to allow compat with webgl 1 and 2.
  26602. * You will need to pass the name of the uniform as well as the value.
  26603. */
  26604. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26605. /**
  26606. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26607. * This is dynamic to allow compat with webgl 1 and 2.
  26608. * You will need to pass the name of the uniform as well as the value.
  26609. */
  26610. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26611. /**
  26612. * Lambda to Update a single float in a uniform buffer.
  26613. * This is dynamic to allow compat with webgl 1 and 2.
  26614. * You will need to pass the name of the uniform as well as the value.
  26615. */
  26616. updateFloat: (name: string, x: number) => void;
  26617. /**
  26618. * Lambda to Update a vec2 of float in a uniform buffer.
  26619. * This is dynamic to allow compat with webgl 1 and 2.
  26620. * You will need to pass the name of the uniform as well as the value.
  26621. */
  26622. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26623. /**
  26624. * Lambda to Update a vec3 of float in a uniform buffer.
  26625. * This is dynamic to allow compat with webgl 1 and 2.
  26626. * You will need to pass the name of the uniform as well as the value.
  26627. */
  26628. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26629. /**
  26630. * Lambda to Update a vec4 of float in a uniform buffer.
  26631. * This is dynamic to allow compat with webgl 1 and 2.
  26632. * You will need to pass the name of the uniform as well as the value.
  26633. */
  26634. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26635. /**
  26636. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26637. * This is dynamic to allow compat with webgl 1 and 2.
  26638. * You will need to pass the name of the uniform as well as the value.
  26639. */
  26640. updateMatrix: (name: string, mat: Matrix) => void;
  26641. /**
  26642. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26643. * This is dynamic to allow compat with webgl 1 and 2.
  26644. * You will need to pass the name of the uniform as well as the value.
  26645. */
  26646. updateVector3: (name: string, vector: Vector3) => void;
  26647. /**
  26648. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26649. * This is dynamic to allow compat with webgl 1 and 2.
  26650. * You will need to pass the name of the uniform as well as the value.
  26651. */
  26652. updateVector4: (name: string, vector: Vector4) => void;
  26653. /**
  26654. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26655. * This is dynamic to allow compat with webgl 1 and 2.
  26656. * You will need to pass the name of the uniform as well as the value.
  26657. */
  26658. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26659. /**
  26660. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26661. * This is dynamic to allow compat with webgl 1 and 2.
  26662. * You will need to pass the name of the uniform as well as the value.
  26663. */
  26664. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26665. /**
  26666. * Instantiates a new Uniform buffer objects.
  26667. *
  26668. * Handles blocks of uniform on the GPU.
  26669. *
  26670. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26671. *
  26672. * For more information, please refer to :
  26673. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26674. * @param engine Define the engine the buffer is associated with
  26675. * @param data Define the data contained in the buffer
  26676. * @param dynamic Define if the buffer is updatable
  26677. */
  26678. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26679. /**
  26680. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26681. * or just falling back on setUniformXXX calls.
  26682. */
  26683. readonly useUbo: boolean;
  26684. /**
  26685. * Indicates if the WebGL underlying uniform buffer is in sync
  26686. * with the javascript cache data.
  26687. */
  26688. readonly isSync: boolean;
  26689. /**
  26690. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26691. * Also, a dynamic UniformBuffer will disable cache verification and always
  26692. * update the underlying WebGL uniform buffer to the GPU.
  26693. * @returns if Dynamic, otherwise false
  26694. */
  26695. isDynamic(): boolean;
  26696. /**
  26697. * The data cache on JS side.
  26698. * @returns the underlying data as a float array
  26699. */
  26700. getData(): Float32Array;
  26701. /**
  26702. * The underlying WebGL Uniform buffer.
  26703. * @returns the webgl buffer
  26704. */
  26705. getBuffer(): Nullable<DataBuffer>;
  26706. /**
  26707. * std140 layout specifies how to align data within an UBO structure.
  26708. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26709. * for specs.
  26710. */
  26711. private _fillAlignment;
  26712. /**
  26713. * Adds an uniform in the buffer.
  26714. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26715. * for the layout to be correct !
  26716. * @param name Name of the uniform, as used in the uniform block in the shader.
  26717. * @param size Data size, or data directly.
  26718. */
  26719. addUniform(name: string, size: number | number[]): void;
  26720. /**
  26721. * Adds a Matrix 4x4 to the uniform buffer.
  26722. * @param name Name of the uniform, as used in the uniform block in the shader.
  26723. * @param mat A 4x4 matrix.
  26724. */
  26725. addMatrix(name: string, mat: Matrix): void;
  26726. /**
  26727. * Adds a vec2 to the uniform buffer.
  26728. * @param name Name of the uniform, as used in the uniform block in the shader.
  26729. * @param x Define the x component value of the vec2
  26730. * @param y Define the y component value of the vec2
  26731. */
  26732. addFloat2(name: string, x: number, y: number): void;
  26733. /**
  26734. * Adds a vec3 to the uniform buffer.
  26735. * @param name Name of the uniform, as used in the uniform block in the shader.
  26736. * @param x Define the x component value of the vec3
  26737. * @param y Define the y component value of the vec3
  26738. * @param z Define the z component value of the vec3
  26739. */
  26740. addFloat3(name: string, x: number, y: number, z: number): void;
  26741. /**
  26742. * Adds a vec3 to the uniform buffer.
  26743. * @param name Name of the uniform, as used in the uniform block in the shader.
  26744. * @param color Define the vec3 from a Color
  26745. */
  26746. addColor3(name: string, color: Color3): void;
  26747. /**
  26748. * Adds a vec4 to the uniform buffer.
  26749. * @param name Name of the uniform, as used in the uniform block in the shader.
  26750. * @param color Define the rgb components from a Color
  26751. * @param alpha Define the a component of the vec4
  26752. */
  26753. addColor4(name: string, color: Color3, alpha: number): void;
  26754. /**
  26755. * Adds a vec3 to the uniform buffer.
  26756. * @param name Name of the uniform, as used in the uniform block in the shader.
  26757. * @param vector Define the vec3 components from a Vector
  26758. */
  26759. addVector3(name: string, vector: Vector3): void;
  26760. /**
  26761. * Adds a Matrix 3x3 to the uniform buffer.
  26762. * @param name Name of the uniform, as used in the uniform block in the shader.
  26763. */
  26764. addMatrix3x3(name: string): void;
  26765. /**
  26766. * Adds a Matrix 2x2 to the uniform buffer.
  26767. * @param name Name of the uniform, as used in the uniform block in the shader.
  26768. */
  26769. addMatrix2x2(name: string): void;
  26770. /**
  26771. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26772. */
  26773. create(): void;
  26774. /** @hidden */
  26775. _rebuild(): void;
  26776. /**
  26777. * Updates the WebGL Uniform Buffer on the GPU.
  26778. * If the `dynamic` flag is set to true, no cache comparison is done.
  26779. * Otherwise, the buffer will be updated only if the cache differs.
  26780. */
  26781. update(): void;
  26782. /**
  26783. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26784. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26785. * @param data Define the flattened data
  26786. * @param size Define the size of the data.
  26787. */
  26788. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26789. private _updateMatrix3x3ForUniform;
  26790. private _updateMatrix3x3ForEffect;
  26791. private _updateMatrix2x2ForEffect;
  26792. private _updateMatrix2x2ForUniform;
  26793. private _updateFloatForEffect;
  26794. private _updateFloatForUniform;
  26795. private _updateFloat2ForEffect;
  26796. private _updateFloat2ForUniform;
  26797. private _updateFloat3ForEffect;
  26798. private _updateFloat3ForUniform;
  26799. private _updateFloat4ForEffect;
  26800. private _updateFloat4ForUniform;
  26801. private _updateMatrixForEffect;
  26802. private _updateMatrixForUniform;
  26803. private _updateVector3ForEffect;
  26804. private _updateVector3ForUniform;
  26805. private _updateVector4ForEffect;
  26806. private _updateVector4ForUniform;
  26807. private _updateColor3ForEffect;
  26808. private _updateColor3ForUniform;
  26809. private _updateColor4ForEffect;
  26810. private _updateColor4ForUniform;
  26811. /**
  26812. * Sets a sampler uniform on the effect.
  26813. * @param name Define the name of the sampler.
  26814. * @param texture Define the texture to set in the sampler
  26815. */
  26816. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26817. /**
  26818. * Directly updates the value of the uniform in the cache AND on the GPU.
  26819. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26820. * @param data Define the flattened data
  26821. */
  26822. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26823. /**
  26824. * Binds this uniform buffer to an effect.
  26825. * @param effect Define the effect to bind the buffer to
  26826. * @param name Name of the uniform block in the shader.
  26827. */
  26828. bindToEffect(effect: Effect, name: string): void;
  26829. /**
  26830. * Disposes the uniform buffer.
  26831. */
  26832. dispose(): void;
  26833. }
  26834. }
  26835. declare module BABYLON {
  26836. /**
  26837. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26839. */
  26840. export class Analyser {
  26841. /**
  26842. * Gets or sets the smoothing
  26843. * @ignorenaming
  26844. */
  26845. SMOOTHING: number;
  26846. /**
  26847. * Gets or sets the FFT table size
  26848. * @ignorenaming
  26849. */
  26850. FFT_SIZE: number;
  26851. /**
  26852. * Gets or sets the bar graph amplitude
  26853. * @ignorenaming
  26854. */
  26855. BARGRAPHAMPLITUDE: number;
  26856. /**
  26857. * Gets or sets the position of the debug canvas
  26858. * @ignorenaming
  26859. */
  26860. DEBUGCANVASPOS: {
  26861. x: number;
  26862. y: number;
  26863. };
  26864. /**
  26865. * Gets or sets the debug canvas size
  26866. * @ignorenaming
  26867. */
  26868. DEBUGCANVASSIZE: {
  26869. width: number;
  26870. height: number;
  26871. };
  26872. private _byteFreqs;
  26873. private _byteTime;
  26874. private _floatFreqs;
  26875. private _webAudioAnalyser;
  26876. private _debugCanvas;
  26877. private _debugCanvasContext;
  26878. private _scene;
  26879. private _registerFunc;
  26880. private _audioEngine;
  26881. /**
  26882. * Creates a new analyser
  26883. * @param scene defines hosting scene
  26884. */
  26885. constructor(scene: Scene);
  26886. /**
  26887. * Get the number of data values you will have to play with for the visualization
  26888. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26889. * @returns a number
  26890. */
  26891. getFrequencyBinCount(): number;
  26892. /**
  26893. * Gets the current frequency data as a byte array
  26894. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26895. * @returns a Uint8Array
  26896. */
  26897. getByteFrequencyData(): Uint8Array;
  26898. /**
  26899. * Gets the current waveform as a byte array
  26900. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26901. * @returns a Uint8Array
  26902. */
  26903. getByteTimeDomainData(): Uint8Array;
  26904. /**
  26905. * Gets the current frequency data as a float array
  26906. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26907. * @returns a Float32Array
  26908. */
  26909. getFloatFrequencyData(): Float32Array;
  26910. /**
  26911. * Renders the debug canvas
  26912. */
  26913. drawDebugCanvas(): void;
  26914. /**
  26915. * Stops rendering the debug canvas and removes it
  26916. */
  26917. stopDebugCanvas(): void;
  26918. /**
  26919. * Connects two audio nodes
  26920. * @param inputAudioNode defines first node to connect
  26921. * @param outputAudioNode defines second node to connect
  26922. */
  26923. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26924. /**
  26925. * Releases all associated resources
  26926. */
  26927. dispose(): void;
  26928. }
  26929. }
  26930. declare module BABYLON {
  26931. /**
  26932. * This represents an audio engine and it is responsible
  26933. * to play, synchronize and analyse sounds throughout the application.
  26934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26935. */
  26936. export interface IAudioEngine extends IDisposable {
  26937. /**
  26938. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26939. */
  26940. readonly canUseWebAudio: boolean;
  26941. /**
  26942. * Gets the current AudioContext if available.
  26943. */
  26944. readonly audioContext: Nullable<AudioContext>;
  26945. /**
  26946. * The master gain node defines the global audio volume of your audio engine.
  26947. */
  26948. readonly masterGain: GainNode;
  26949. /**
  26950. * Gets whether or not mp3 are supported by your browser.
  26951. */
  26952. readonly isMP3supported: boolean;
  26953. /**
  26954. * Gets whether or not ogg are supported by your browser.
  26955. */
  26956. readonly isOGGsupported: boolean;
  26957. /**
  26958. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26959. * @ignoreNaming
  26960. */
  26961. WarnedWebAudioUnsupported: boolean;
  26962. /**
  26963. * Defines if the audio engine relies on a custom unlocked button.
  26964. * In this case, the embedded button will not be displayed.
  26965. */
  26966. useCustomUnlockedButton: boolean;
  26967. /**
  26968. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26969. */
  26970. readonly unlocked: boolean;
  26971. /**
  26972. * Event raised when audio has been unlocked on the browser.
  26973. */
  26974. onAudioUnlockedObservable: Observable<AudioEngine>;
  26975. /**
  26976. * Event raised when audio has been locked on the browser.
  26977. */
  26978. onAudioLockedObservable: Observable<AudioEngine>;
  26979. /**
  26980. * Flags the audio engine in Locked state.
  26981. * This happens due to new browser policies preventing audio to autoplay.
  26982. */
  26983. lock(): void;
  26984. /**
  26985. * Unlocks the audio engine once a user action has been done on the dom.
  26986. * This is helpful to resume play once browser policies have been satisfied.
  26987. */
  26988. unlock(): void;
  26989. }
  26990. /**
  26991. * This represents the default audio engine used in babylon.
  26992. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26994. */
  26995. export class AudioEngine implements IAudioEngine {
  26996. private _audioContext;
  26997. private _audioContextInitialized;
  26998. private _muteButton;
  26999. private _hostElement;
  27000. /**
  27001. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27002. */
  27003. canUseWebAudio: boolean;
  27004. /**
  27005. * The master gain node defines the global audio volume of your audio engine.
  27006. */
  27007. masterGain: GainNode;
  27008. /**
  27009. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27010. * @ignoreNaming
  27011. */
  27012. WarnedWebAudioUnsupported: boolean;
  27013. /**
  27014. * Gets whether or not mp3 are supported by your browser.
  27015. */
  27016. isMP3supported: boolean;
  27017. /**
  27018. * Gets whether or not ogg are supported by your browser.
  27019. */
  27020. isOGGsupported: boolean;
  27021. /**
  27022. * Gets whether audio has been unlocked on the device.
  27023. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27024. * a user interaction has happened.
  27025. */
  27026. unlocked: boolean;
  27027. /**
  27028. * Defines if the audio engine relies on a custom unlocked button.
  27029. * In this case, the embedded button will not be displayed.
  27030. */
  27031. useCustomUnlockedButton: boolean;
  27032. /**
  27033. * Event raised when audio has been unlocked on the browser.
  27034. */
  27035. onAudioUnlockedObservable: Observable<AudioEngine>;
  27036. /**
  27037. * Event raised when audio has been locked on the browser.
  27038. */
  27039. onAudioLockedObservable: Observable<AudioEngine>;
  27040. /**
  27041. * Gets the current AudioContext if available.
  27042. */
  27043. readonly audioContext: Nullable<AudioContext>;
  27044. private _connectedAnalyser;
  27045. /**
  27046. * Instantiates a new audio engine.
  27047. *
  27048. * There should be only one per page as some browsers restrict the number
  27049. * of audio contexts you can create.
  27050. * @param hostElement defines the host element where to display the mute icon if necessary
  27051. */
  27052. constructor(hostElement?: Nullable<HTMLElement>);
  27053. /**
  27054. * Flags the audio engine in Locked state.
  27055. * This happens due to new browser policies preventing audio to autoplay.
  27056. */
  27057. lock(): void;
  27058. /**
  27059. * Unlocks the audio engine once a user action has been done on the dom.
  27060. * This is helpful to resume play once browser policies have been satisfied.
  27061. */
  27062. unlock(): void;
  27063. private _resumeAudioContext;
  27064. private _initializeAudioContext;
  27065. private _tryToRun;
  27066. private _triggerRunningState;
  27067. private _triggerSuspendedState;
  27068. private _displayMuteButton;
  27069. private _moveButtonToTopLeft;
  27070. private _onResize;
  27071. private _hideMuteButton;
  27072. /**
  27073. * Destroy and release the resources associated with the audio ccontext.
  27074. */
  27075. dispose(): void;
  27076. /**
  27077. * Gets the global volume sets on the master gain.
  27078. * @returns the global volume if set or -1 otherwise
  27079. */
  27080. getGlobalVolume(): number;
  27081. /**
  27082. * Sets the global volume of your experience (sets on the master gain).
  27083. * @param newVolume Defines the new global volume of the application
  27084. */
  27085. setGlobalVolume(newVolume: number): void;
  27086. /**
  27087. * Connect the audio engine to an audio analyser allowing some amazing
  27088. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27090. * @param analyser The analyser to connect to the engine
  27091. */
  27092. connectToAnalyser(analyser: Analyser): void;
  27093. }
  27094. }
  27095. declare module BABYLON {
  27096. /**
  27097. * Interface used to present a loading screen while loading a scene
  27098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27099. */
  27100. export interface ILoadingScreen {
  27101. /**
  27102. * Function called to display the loading screen
  27103. */
  27104. displayLoadingUI: () => void;
  27105. /**
  27106. * Function called to hide the loading screen
  27107. */
  27108. hideLoadingUI: () => void;
  27109. /**
  27110. * Gets or sets the color to use for the background
  27111. */
  27112. loadingUIBackgroundColor: string;
  27113. /**
  27114. * Gets or sets the text to display while loading
  27115. */
  27116. loadingUIText: string;
  27117. }
  27118. /**
  27119. * Class used for the default loading screen
  27120. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27121. */
  27122. export class DefaultLoadingScreen implements ILoadingScreen {
  27123. private _renderingCanvas;
  27124. private _loadingText;
  27125. private _loadingDivBackgroundColor;
  27126. private _loadingDiv;
  27127. private _loadingTextDiv;
  27128. /** Gets or sets the logo url to use for the default loading screen */
  27129. static DefaultLogoUrl: string;
  27130. /** Gets or sets the spinner url to use for the default loading screen */
  27131. static DefaultSpinnerUrl: string;
  27132. /**
  27133. * Creates a new default loading screen
  27134. * @param _renderingCanvas defines the canvas used to render the scene
  27135. * @param _loadingText defines the default text to display
  27136. * @param _loadingDivBackgroundColor defines the default background color
  27137. */
  27138. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27139. /**
  27140. * Function called to display the loading screen
  27141. */
  27142. displayLoadingUI(): void;
  27143. /**
  27144. * Function called to hide the loading screen
  27145. */
  27146. hideLoadingUI(): void;
  27147. /**
  27148. * Gets or sets the text to display while loading
  27149. */
  27150. loadingUIText: string;
  27151. /**
  27152. * Gets or sets the color to use for the background
  27153. */
  27154. loadingUIBackgroundColor: string;
  27155. private _resizeLoadingUI;
  27156. }
  27157. }
  27158. declare module BABYLON {
  27159. /** @hidden */
  27160. export class WebGLPipelineContext implements IPipelineContext {
  27161. engine: Engine;
  27162. program: Nullable<WebGLProgram>;
  27163. context?: WebGLRenderingContext;
  27164. vertexShader?: WebGLShader;
  27165. fragmentShader?: WebGLShader;
  27166. isParallelCompiled: boolean;
  27167. onCompiled?: () => void;
  27168. transformFeedback?: WebGLTransformFeedback | null;
  27169. readonly isAsync: boolean;
  27170. readonly isReady: boolean;
  27171. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27172. }
  27173. }
  27174. declare module BABYLON {
  27175. /** @hidden */
  27176. export class WebGLDataBuffer extends DataBuffer {
  27177. private _buffer;
  27178. constructor(resource: WebGLBuffer);
  27179. readonly underlyingResource: any;
  27180. }
  27181. }
  27182. declare module BABYLON {
  27183. /** @hidden */
  27184. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27185. attributeProcessor(attribute: string): string;
  27186. varyingProcessor(varying: string, isFragment: boolean): string;
  27187. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27188. }
  27189. }
  27190. declare module BABYLON {
  27191. /**
  27192. * Settings for finer control over video usage
  27193. */
  27194. export interface VideoTextureSettings {
  27195. /**
  27196. * Applies `autoplay` to video, if specified
  27197. */
  27198. autoPlay?: boolean;
  27199. /**
  27200. * Applies `loop` to video, if specified
  27201. */
  27202. loop?: boolean;
  27203. /**
  27204. * Automatically updates internal texture from video at every frame in the render loop
  27205. */
  27206. autoUpdateTexture: boolean;
  27207. /**
  27208. * Image src displayed during the video loading or until the user interacts with the video.
  27209. */
  27210. poster?: string;
  27211. }
  27212. /**
  27213. * If you want to display a video in your scene, this is the special texture for that.
  27214. * This special texture works similar to other textures, with the exception of a few parameters.
  27215. * @see https://doc.babylonjs.com/how_to/video_texture
  27216. */
  27217. export class VideoTexture extends Texture {
  27218. /**
  27219. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27220. */
  27221. readonly autoUpdateTexture: boolean;
  27222. /**
  27223. * The video instance used by the texture internally
  27224. */
  27225. readonly video: HTMLVideoElement;
  27226. private _onUserActionRequestedObservable;
  27227. /**
  27228. * Event triggerd when a dom action is required by the user to play the video.
  27229. * This happens due to recent changes in browser policies preventing video to auto start.
  27230. */
  27231. readonly onUserActionRequestedObservable: Observable<Texture>;
  27232. private _generateMipMaps;
  27233. private _engine;
  27234. private _stillImageCaptured;
  27235. private _displayingPosterTexture;
  27236. private _settings;
  27237. private _createInternalTextureOnEvent;
  27238. /**
  27239. * Creates a video texture.
  27240. * If you want to display a video in your scene, this is the special texture for that.
  27241. * This special texture works similar to other textures, with the exception of a few parameters.
  27242. * @see https://doc.babylonjs.com/how_to/video_texture
  27243. * @param name optional name, will detect from video source, if not defined
  27244. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27245. * @param scene is obviously the current scene.
  27246. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27247. * @param invertY is false by default but can be used to invert video on Y axis
  27248. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27249. * @param settings allows finer control over video usage
  27250. */
  27251. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27252. private _getName;
  27253. private _getVideo;
  27254. private _createInternalTexture;
  27255. private reset;
  27256. /**
  27257. * @hidden Internal method to initiate `update`.
  27258. */
  27259. _rebuild(): void;
  27260. /**
  27261. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27262. */
  27263. update(): void;
  27264. /**
  27265. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27266. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27267. */
  27268. updateTexture(isVisible: boolean): void;
  27269. protected _updateInternalTexture: () => void;
  27270. /**
  27271. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27272. * @param url New url.
  27273. */
  27274. updateURL(url: string): void;
  27275. /**
  27276. * Dispose the texture and release its associated resources.
  27277. */
  27278. dispose(): void;
  27279. /**
  27280. * Creates a video texture straight from a stream.
  27281. * @param scene Define the scene the texture should be created in
  27282. * @param stream Define the stream the texture should be created from
  27283. * @returns The created video texture as a promise
  27284. */
  27285. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27286. /**
  27287. * Creates a video texture straight from your WebCam video feed.
  27288. * @param scene Define the scene the texture should be created in
  27289. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27290. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27291. * @returns The created video texture as a promise
  27292. */
  27293. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27294. minWidth: number;
  27295. maxWidth: number;
  27296. minHeight: number;
  27297. maxHeight: number;
  27298. deviceId: string;
  27299. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27300. /**
  27301. * Creates a video texture straight from your WebCam video feed.
  27302. * @param scene Define the scene the texture should be created in
  27303. * @param onReady Define a callback to triggered once the texture will be ready
  27304. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27305. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27306. */
  27307. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27308. minWidth: number;
  27309. maxWidth: number;
  27310. minHeight: number;
  27311. maxHeight: number;
  27312. deviceId: string;
  27313. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27314. }
  27315. }
  27316. declare module BABYLON {
  27317. /**
  27318. * Interface for attribute information associated with buffer instanciation
  27319. */
  27320. export class InstancingAttributeInfo {
  27321. /**
  27322. * Index/offset of the attribute in the vertex shader
  27323. */
  27324. index: number;
  27325. /**
  27326. * size of the attribute, 1, 2, 3 or 4
  27327. */
  27328. attributeSize: number;
  27329. /**
  27330. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27331. * default is FLOAT
  27332. */
  27333. attribyteType: number;
  27334. /**
  27335. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27336. */
  27337. normalized: boolean;
  27338. /**
  27339. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27340. */
  27341. offset: number;
  27342. /**
  27343. * Name of the GLSL attribute, for debugging purpose only
  27344. */
  27345. attributeName: string;
  27346. }
  27347. /**
  27348. * Define options used to create a depth texture
  27349. */
  27350. export class DepthTextureCreationOptions {
  27351. /** Specifies whether or not a stencil should be allocated in the texture */
  27352. generateStencil?: boolean;
  27353. /** Specifies whether or not bilinear filtering is enable on the texture */
  27354. bilinearFiltering?: boolean;
  27355. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27356. comparisonFunction?: number;
  27357. /** Specifies if the created texture is a cube texture */
  27358. isCube?: boolean;
  27359. }
  27360. /**
  27361. * Class used to describe the capabilities of the engine relatively to the current browser
  27362. */
  27363. export class EngineCapabilities {
  27364. /** Maximum textures units per fragment shader */
  27365. maxTexturesImageUnits: number;
  27366. /** Maximum texture units per vertex shader */
  27367. maxVertexTextureImageUnits: number;
  27368. /** Maximum textures units in the entire pipeline */
  27369. maxCombinedTexturesImageUnits: number;
  27370. /** Maximum texture size */
  27371. maxTextureSize: number;
  27372. /** Maximum cube texture size */
  27373. maxCubemapTextureSize: number;
  27374. /** Maximum render texture size */
  27375. maxRenderTextureSize: number;
  27376. /** Maximum number of vertex attributes */
  27377. maxVertexAttribs: number;
  27378. /** Maximum number of varyings */
  27379. maxVaryingVectors: number;
  27380. /** Maximum number of uniforms per vertex shader */
  27381. maxVertexUniformVectors: number;
  27382. /** Maximum number of uniforms per fragment shader */
  27383. maxFragmentUniformVectors: number;
  27384. /** Defines if standard derivates (dx/dy) are supported */
  27385. standardDerivatives: boolean;
  27386. /** Defines if s3tc texture compression is supported */
  27387. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27388. /** Defines if pvrtc texture compression is supported */
  27389. pvrtc: any;
  27390. /** Defines if etc1 texture compression is supported */
  27391. etc1: any;
  27392. /** Defines if etc2 texture compression is supported */
  27393. etc2: any;
  27394. /** Defines if astc texture compression is supported */
  27395. astc: any;
  27396. /** Defines if float textures are supported */
  27397. textureFloat: boolean;
  27398. /** Defines if vertex array objects are supported */
  27399. vertexArrayObject: boolean;
  27400. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27401. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27402. /** Gets the maximum level of anisotropy supported */
  27403. maxAnisotropy: number;
  27404. /** Defines if instancing is supported */
  27405. instancedArrays: boolean;
  27406. /** Defines if 32 bits indices are supported */
  27407. uintIndices: boolean;
  27408. /** Defines if high precision shaders are supported */
  27409. highPrecisionShaderSupported: boolean;
  27410. /** Defines if depth reading in the fragment shader is supported */
  27411. fragmentDepthSupported: boolean;
  27412. /** Defines if float texture linear filtering is supported*/
  27413. textureFloatLinearFiltering: boolean;
  27414. /** Defines if rendering to float textures is supported */
  27415. textureFloatRender: boolean;
  27416. /** Defines if half float textures are supported*/
  27417. textureHalfFloat: boolean;
  27418. /** Defines if half float texture linear filtering is supported*/
  27419. textureHalfFloatLinearFiltering: boolean;
  27420. /** Defines if rendering to half float textures is supported */
  27421. textureHalfFloatRender: boolean;
  27422. /** Defines if textureLOD shader command is supported */
  27423. textureLOD: boolean;
  27424. /** Defines if draw buffers extension is supported */
  27425. drawBuffersExtension: boolean;
  27426. /** Defines if depth textures are supported */
  27427. depthTextureExtension: boolean;
  27428. /** Defines if float color buffer are supported */
  27429. colorBufferFloat: boolean;
  27430. /** Gets disjoint timer query extension (null if not supported) */
  27431. timerQuery: EXT_disjoint_timer_query;
  27432. /** Defines if timestamp can be used with timer query */
  27433. canUseTimestampForTimerQuery: boolean;
  27434. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27435. multiview: any;
  27436. /** Function used to let the system compiles shaders in background */
  27437. parallelShaderCompile: {
  27438. COMPLETION_STATUS_KHR: number;
  27439. };
  27440. }
  27441. /** Interface defining initialization parameters for Engine class */
  27442. export interface EngineOptions extends WebGLContextAttributes {
  27443. /**
  27444. * Defines if the engine should no exceed a specified device ratio
  27445. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27446. */
  27447. limitDeviceRatio?: number;
  27448. /**
  27449. * Defines if webvr should be enabled automatically
  27450. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27451. */
  27452. autoEnableWebVR?: boolean;
  27453. /**
  27454. * Defines if webgl2 should be turned off even if supported
  27455. * @see http://doc.babylonjs.com/features/webgl2
  27456. */
  27457. disableWebGL2Support?: boolean;
  27458. /**
  27459. * Defines if webaudio should be initialized as well
  27460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27461. */
  27462. audioEngine?: boolean;
  27463. /**
  27464. * Defines if animations should run using a deterministic lock step
  27465. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27466. */
  27467. deterministicLockstep?: boolean;
  27468. /** Defines the maximum steps to use with deterministic lock step mode */
  27469. lockstepMaxSteps?: number;
  27470. /**
  27471. * Defines that engine should ignore context lost events
  27472. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27473. */
  27474. doNotHandleContextLost?: boolean;
  27475. /**
  27476. * Defines that engine should ignore modifying touch action attribute and style
  27477. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27478. */
  27479. doNotHandleTouchAction?: boolean;
  27480. /**
  27481. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27482. */
  27483. useHighPrecisionFloats?: boolean;
  27484. }
  27485. /**
  27486. * Defines the interface used by display changed events
  27487. */
  27488. export interface IDisplayChangedEventArgs {
  27489. /** Gets the vrDisplay object (if any) */
  27490. vrDisplay: Nullable<any>;
  27491. /** Gets a boolean indicating if webVR is supported */
  27492. vrSupported: boolean;
  27493. }
  27494. /**
  27495. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27496. */
  27497. export class Engine {
  27498. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27499. static ExceptionList: ({
  27500. key: string;
  27501. capture: string;
  27502. captureConstraint: number;
  27503. targets: string[];
  27504. } | {
  27505. key: string;
  27506. capture: null;
  27507. captureConstraint: null;
  27508. targets: string[];
  27509. })[];
  27510. /** Gets the list of created engines */
  27511. static readonly Instances: Engine[];
  27512. /**
  27513. * Gets the latest created engine
  27514. */
  27515. static readonly LastCreatedEngine: Nullable<Engine>;
  27516. /**
  27517. * Gets the latest created scene
  27518. */
  27519. static readonly LastCreatedScene: Nullable<Scene>;
  27520. /**
  27521. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27522. * @param flag defines which part of the materials must be marked as dirty
  27523. * @param predicate defines a predicate used to filter which materials should be affected
  27524. */
  27525. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27526. /** @hidden */
  27527. static _TextureLoaders: IInternalTextureLoader[];
  27528. /** Defines that alpha blending is disabled */
  27529. static readonly ALPHA_DISABLE: number;
  27530. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27531. static readonly ALPHA_ADD: number;
  27532. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27533. static readonly ALPHA_COMBINE: number;
  27534. /** Defines that alpha blending to DEST - SRC * DEST */
  27535. static readonly ALPHA_SUBTRACT: number;
  27536. /** Defines that alpha blending to SRC * DEST */
  27537. static readonly ALPHA_MULTIPLY: number;
  27538. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27539. static readonly ALPHA_MAXIMIZED: number;
  27540. /** Defines that alpha blending to SRC + DEST */
  27541. static readonly ALPHA_ONEONE: number;
  27542. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27543. static readonly ALPHA_PREMULTIPLIED: number;
  27544. /**
  27545. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27546. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27547. */
  27548. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27549. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27550. static readonly ALPHA_INTERPOLATE: number;
  27551. /**
  27552. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27553. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27554. */
  27555. static readonly ALPHA_SCREENMODE: number;
  27556. /** Defines that the ressource is not delayed*/
  27557. static readonly DELAYLOADSTATE_NONE: number;
  27558. /** Defines that the ressource was successfully delay loaded */
  27559. static readonly DELAYLOADSTATE_LOADED: number;
  27560. /** Defines that the ressource is currently delay loading */
  27561. static readonly DELAYLOADSTATE_LOADING: number;
  27562. /** Defines that the ressource is delayed and has not started loading */
  27563. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27564. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27565. static readonly NEVER: number;
  27566. /** 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 */
  27567. static readonly ALWAYS: number;
  27568. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27569. static readonly LESS: number;
  27570. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27571. static readonly EQUAL: number;
  27572. /** 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 */
  27573. static readonly LEQUAL: number;
  27574. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27575. static readonly GREATER: number;
  27576. /** 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 */
  27577. static readonly GEQUAL: number;
  27578. /** 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 */
  27579. static readonly NOTEQUAL: number;
  27580. /** Passed to stencilOperation to specify that stencil value must be kept */
  27581. static readonly KEEP: number;
  27582. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27583. static readonly REPLACE: number;
  27584. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27585. static readonly INCR: number;
  27586. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27587. static readonly DECR: number;
  27588. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27589. static readonly INVERT: number;
  27590. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27591. static readonly INCR_WRAP: number;
  27592. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27593. static readonly DECR_WRAP: number;
  27594. /** Texture is not repeating outside of 0..1 UVs */
  27595. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27596. /** Texture is repeating outside of 0..1 UVs */
  27597. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27598. /** Texture is repeating and mirrored */
  27599. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27600. /** ALPHA */
  27601. static readonly TEXTUREFORMAT_ALPHA: number;
  27602. /** LUMINANCE */
  27603. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27604. /** LUMINANCE_ALPHA */
  27605. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27606. /** RGB */
  27607. static readonly TEXTUREFORMAT_RGB: number;
  27608. /** RGBA */
  27609. static readonly TEXTUREFORMAT_RGBA: number;
  27610. /** RED */
  27611. static readonly TEXTUREFORMAT_RED: number;
  27612. /** RED (2nd reference) */
  27613. static readonly TEXTUREFORMAT_R: number;
  27614. /** RG */
  27615. static readonly TEXTUREFORMAT_RG: number;
  27616. /** RED_INTEGER */
  27617. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27618. /** RED_INTEGER (2nd reference) */
  27619. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27620. /** RG_INTEGER */
  27621. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27622. /** RGB_INTEGER */
  27623. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27624. /** RGBA_INTEGER */
  27625. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27626. /** UNSIGNED_BYTE */
  27627. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27628. /** UNSIGNED_BYTE (2nd reference) */
  27629. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27630. /** FLOAT */
  27631. static readonly TEXTURETYPE_FLOAT: number;
  27632. /** HALF_FLOAT */
  27633. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27634. /** BYTE */
  27635. static readonly TEXTURETYPE_BYTE: number;
  27636. /** SHORT */
  27637. static readonly TEXTURETYPE_SHORT: number;
  27638. /** UNSIGNED_SHORT */
  27639. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27640. /** INT */
  27641. static readonly TEXTURETYPE_INT: number;
  27642. /** UNSIGNED_INT */
  27643. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27644. /** UNSIGNED_SHORT_4_4_4_4 */
  27645. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27646. /** UNSIGNED_SHORT_5_5_5_1 */
  27647. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27648. /** UNSIGNED_SHORT_5_6_5 */
  27649. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27650. /** UNSIGNED_INT_2_10_10_10_REV */
  27651. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27652. /** UNSIGNED_INT_24_8 */
  27653. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27654. /** UNSIGNED_INT_10F_11F_11F_REV */
  27655. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27656. /** UNSIGNED_INT_5_9_9_9_REV */
  27657. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27658. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27659. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27660. /** nearest is mag = nearest and min = nearest and mip = linear */
  27661. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27662. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27663. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27664. /** Trilinear is mag = linear and min = linear and mip = linear */
  27665. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27666. /** nearest is mag = nearest and min = nearest and mip = linear */
  27667. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27668. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27669. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27670. /** Trilinear is mag = linear and min = linear and mip = linear */
  27671. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27672. /** mag = nearest and min = nearest and mip = nearest */
  27673. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27674. /** mag = nearest and min = linear and mip = nearest */
  27675. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27676. /** mag = nearest and min = linear and mip = linear */
  27677. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27678. /** mag = nearest and min = linear and mip = none */
  27679. static readonly TEXTURE_NEAREST_LINEAR: number;
  27680. /** mag = nearest and min = nearest and mip = none */
  27681. static readonly TEXTURE_NEAREST_NEAREST: number;
  27682. /** mag = linear and min = nearest and mip = nearest */
  27683. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27684. /** mag = linear and min = nearest and mip = linear */
  27685. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27686. /** mag = linear and min = linear and mip = none */
  27687. static readonly TEXTURE_LINEAR_LINEAR: number;
  27688. /** mag = linear and min = nearest and mip = none */
  27689. static readonly TEXTURE_LINEAR_NEAREST: number;
  27690. /** Explicit coordinates mode */
  27691. static readonly TEXTURE_EXPLICIT_MODE: number;
  27692. /** Spherical coordinates mode */
  27693. static readonly TEXTURE_SPHERICAL_MODE: number;
  27694. /** Planar coordinates mode */
  27695. static readonly TEXTURE_PLANAR_MODE: number;
  27696. /** Cubic coordinates mode */
  27697. static readonly TEXTURE_CUBIC_MODE: number;
  27698. /** Projection coordinates mode */
  27699. static readonly TEXTURE_PROJECTION_MODE: number;
  27700. /** Skybox coordinates mode */
  27701. static readonly TEXTURE_SKYBOX_MODE: number;
  27702. /** Inverse Cubic coordinates mode */
  27703. static readonly TEXTURE_INVCUBIC_MODE: number;
  27704. /** Equirectangular coordinates mode */
  27705. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27706. /** Equirectangular Fixed coordinates mode */
  27707. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27708. /** Equirectangular Fixed Mirrored coordinates mode */
  27709. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27710. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27711. static readonly SCALEMODE_FLOOR: number;
  27712. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27713. static readonly SCALEMODE_NEAREST: number;
  27714. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27715. static readonly SCALEMODE_CEILING: number;
  27716. /**
  27717. * Returns the current npm package of the sdk
  27718. */
  27719. static readonly NpmPackage: string;
  27720. /**
  27721. * Returns the current version of the framework
  27722. */
  27723. static readonly Version: string;
  27724. /**
  27725. * Returns a string describing the current engine
  27726. */
  27727. readonly description: string;
  27728. /**
  27729. * Gets or sets the epsilon value used by collision engine
  27730. */
  27731. static CollisionsEpsilon: number;
  27732. /**
  27733. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27734. */
  27735. static ShadersRepository: string;
  27736. /**
  27737. * Method called to create the default loading screen.
  27738. * This can be overriden in your own app.
  27739. * @param canvas The rendering canvas element
  27740. * @returns The loading screen
  27741. */
  27742. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27743. /**
  27744. * Method called to create the default rescale post process on each engine.
  27745. */
  27746. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27747. /** @hidden */
  27748. _shaderProcessor: IShaderProcessor;
  27749. /**
  27750. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27751. */
  27752. forcePOTTextures: boolean;
  27753. /**
  27754. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27755. */
  27756. isFullscreen: boolean;
  27757. /**
  27758. * Gets a boolean indicating if the pointer is currently locked
  27759. */
  27760. isPointerLock: boolean;
  27761. /**
  27762. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27763. */
  27764. cullBackFaces: boolean;
  27765. /**
  27766. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27767. */
  27768. renderEvenInBackground: boolean;
  27769. /**
  27770. * Gets or sets a boolean indicating that cache can be kept between frames
  27771. */
  27772. preventCacheWipeBetweenFrames: boolean;
  27773. /**
  27774. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27775. **/
  27776. enableOfflineSupport: boolean;
  27777. /**
  27778. * 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)
  27779. **/
  27780. disableManifestCheck: boolean;
  27781. /**
  27782. * Gets the list of created scenes
  27783. */
  27784. scenes: Scene[];
  27785. /**
  27786. * Event raised when a new scene is created
  27787. */
  27788. onNewSceneAddedObservable: Observable<Scene>;
  27789. /**
  27790. * Gets the list of created postprocesses
  27791. */
  27792. postProcesses: PostProcess[];
  27793. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27794. validateShaderPrograms: boolean;
  27795. /**
  27796. * Observable event triggered each time the rendering canvas is resized
  27797. */
  27798. onResizeObservable: Observable<Engine>;
  27799. /**
  27800. * Observable event triggered each time the canvas loses focus
  27801. */
  27802. onCanvasBlurObservable: Observable<Engine>;
  27803. /**
  27804. * Observable event triggered each time the canvas gains focus
  27805. */
  27806. onCanvasFocusObservable: Observable<Engine>;
  27807. /**
  27808. * Observable event triggered each time the canvas receives pointerout event
  27809. */
  27810. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27811. /**
  27812. * Observable event triggered before each texture is initialized
  27813. */
  27814. onBeforeTextureInitObservable: Observable<Texture>;
  27815. /**
  27816. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27817. */
  27818. disableUniformBuffers: boolean;
  27819. /** @hidden */
  27820. _uniformBuffers: UniformBuffer[];
  27821. /**
  27822. * Gets a boolean indicating that the engine supports uniform buffers
  27823. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27824. */
  27825. readonly supportsUniformBuffers: boolean;
  27826. /**
  27827. * Observable raised when the engine begins a new frame
  27828. */
  27829. onBeginFrameObservable: Observable<Engine>;
  27830. /**
  27831. * If set, will be used to request the next animation frame for the render loop
  27832. */
  27833. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27834. /**
  27835. * Observable raised when the engine ends the current frame
  27836. */
  27837. onEndFrameObservable: Observable<Engine>;
  27838. /**
  27839. * Observable raised when the engine is about to compile a shader
  27840. */
  27841. onBeforeShaderCompilationObservable: Observable<Engine>;
  27842. /**
  27843. * Observable raised when the engine has jsut compiled a shader
  27844. */
  27845. onAfterShaderCompilationObservable: Observable<Engine>;
  27846. /** @hidden */
  27847. _gl: WebGLRenderingContext;
  27848. private _renderingCanvas;
  27849. private _windowIsBackground;
  27850. private _webGLVersion;
  27851. protected _highPrecisionShadersAllowed: boolean;
  27852. /** @hidden */
  27853. readonly _shouldUseHighPrecisionShader: boolean;
  27854. /**
  27855. * Gets a boolean indicating that only power of 2 textures are supported
  27856. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27857. */
  27858. readonly needPOTTextures: boolean;
  27859. /** @hidden */
  27860. _badOS: boolean;
  27861. /** @hidden */
  27862. _badDesktopOS: boolean;
  27863. /**
  27864. * Gets the audio engine
  27865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27866. * @ignorenaming
  27867. */
  27868. static audioEngine: IAudioEngine;
  27869. /**
  27870. * Default AudioEngine factory responsible of creating the Audio Engine.
  27871. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27872. */
  27873. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27874. /**
  27875. * Default offline support factory responsible of creating a tool used to store data locally.
  27876. * By default, this will create a Database object if the workload has been embedded.
  27877. */
  27878. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27879. private _onFocus;
  27880. private _onBlur;
  27881. private _onCanvasPointerOut;
  27882. private _onCanvasBlur;
  27883. private _onCanvasFocus;
  27884. private _onFullscreenChange;
  27885. private _onPointerLockChange;
  27886. private _hardwareScalingLevel;
  27887. /** @hidden */
  27888. _caps: EngineCapabilities;
  27889. private _pointerLockRequested;
  27890. private _isStencilEnable;
  27891. private _colorWrite;
  27892. private _loadingScreen;
  27893. /** @hidden */
  27894. _drawCalls: PerfCounter;
  27895. private _glVersion;
  27896. private _glRenderer;
  27897. private _glVendor;
  27898. private _videoTextureSupported;
  27899. private _renderingQueueLaunched;
  27900. private _activeRenderLoops;
  27901. private _deterministicLockstep;
  27902. private _lockstepMaxSteps;
  27903. /**
  27904. * Observable signaled when a context lost event is raised
  27905. */
  27906. onContextLostObservable: Observable<Engine>;
  27907. /**
  27908. * Observable signaled when a context restored event is raised
  27909. */
  27910. onContextRestoredObservable: Observable<Engine>;
  27911. private _onContextLost;
  27912. private _onContextRestored;
  27913. private _contextWasLost;
  27914. /** @hidden */
  27915. _doNotHandleContextLost: boolean;
  27916. /**
  27917. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27919. */
  27920. doNotHandleContextLost: boolean;
  27921. private _performanceMonitor;
  27922. private _fps;
  27923. private _deltaTime;
  27924. /**
  27925. * Turn this value on if you want to pause FPS computation when in background
  27926. */
  27927. disablePerformanceMonitorInBackground: boolean;
  27928. /**
  27929. * Gets the performance monitor attached to this engine
  27930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27931. */
  27932. readonly performanceMonitor: PerformanceMonitor;
  27933. /**
  27934. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27935. */
  27936. disableVertexArrayObjects: boolean;
  27937. /** @hidden */
  27938. protected _depthCullingState: _DepthCullingState;
  27939. /** @hidden */
  27940. protected _stencilState: _StencilState;
  27941. /** @hidden */
  27942. protected _alphaState: _AlphaState;
  27943. /** @hidden */
  27944. protected _alphaMode: number;
  27945. /** @hidden */
  27946. _internalTexturesCache: InternalTexture[];
  27947. /** @hidden */
  27948. protected _activeChannel: number;
  27949. private _currentTextureChannel;
  27950. /** @hidden */
  27951. protected _boundTexturesCache: {
  27952. [key: string]: Nullable<InternalTexture>;
  27953. };
  27954. /** @hidden */
  27955. protected _currentEffect: Nullable<Effect>;
  27956. /** @hidden */
  27957. protected _currentProgram: Nullable<WebGLProgram>;
  27958. private _compiledEffects;
  27959. private _vertexAttribArraysEnabled;
  27960. /** @hidden */
  27961. protected _cachedViewport: Nullable<Viewport>;
  27962. private _cachedVertexArrayObject;
  27963. /** @hidden */
  27964. protected _cachedVertexBuffers: any;
  27965. /** @hidden */
  27966. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27967. /** @hidden */
  27968. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27969. /** @hidden */
  27970. _currentRenderTarget: Nullable<InternalTexture>;
  27971. private _uintIndicesCurrentlySet;
  27972. private _currentBoundBuffer;
  27973. /** @hidden */
  27974. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27975. private _currentBufferPointers;
  27976. private _currentInstanceLocations;
  27977. private _currentInstanceBuffers;
  27978. private _textureUnits;
  27979. /** @hidden */
  27980. _workingCanvas: Nullable<HTMLCanvasElement>;
  27981. /** @hidden */
  27982. _workingContext: Nullable<CanvasRenderingContext2D>;
  27983. private _rescalePostProcess;
  27984. private _dummyFramebuffer;
  27985. private _externalData;
  27986. /** @hidden */
  27987. _bindedRenderFunction: any;
  27988. private _vaoRecordInProgress;
  27989. private _mustWipeVertexAttributes;
  27990. private _emptyTexture;
  27991. private _emptyCubeTexture;
  27992. private _emptyTexture3D;
  27993. /** @hidden */
  27994. _frameHandler: number;
  27995. private _nextFreeTextureSlots;
  27996. private _maxSimultaneousTextures;
  27997. private _activeRequests;
  27998. private _texturesSupported;
  27999. /** @hidden */
  28000. _textureFormatInUse: Nullable<string>;
  28001. /**
  28002. * Gets the list of texture formats supported
  28003. */
  28004. readonly texturesSupported: Array<string>;
  28005. /**
  28006. * Gets the list of texture formats in use
  28007. */
  28008. readonly textureFormatInUse: Nullable<string>;
  28009. /**
  28010. * Gets the current viewport
  28011. */
  28012. readonly currentViewport: Nullable<Viewport>;
  28013. /**
  28014. * Gets the default empty texture
  28015. */
  28016. readonly emptyTexture: InternalTexture;
  28017. /**
  28018. * Gets the default empty 3D texture
  28019. */
  28020. readonly emptyTexture3D: InternalTexture;
  28021. /**
  28022. * Gets the default empty cube texture
  28023. */
  28024. readonly emptyCubeTexture: InternalTexture;
  28025. /**
  28026. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28027. */
  28028. readonly premultipliedAlpha: boolean;
  28029. /**
  28030. * Creates a new engine
  28031. * @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
  28032. * @param antialias defines enable antialiasing (default: false)
  28033. * @param options defines further options to be sent to the getContext() function
  28034. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28035. */
  28036. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28037. /**
  28038. * Initializes a webVR display and starts listening to display change events
  28039. * The onVRDisplayChangedObservable will be notified upon these changes
  28040. * @returns The onVRDisplayChangedObservable
  28041. */
  28042. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28043. /** @hidden */
  28044. _prepareVRComponent(): void;
  28045. /** @hidden */
  28046. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28047. /** @hidden */
  28048. _submitVRFrame(): void;
  28049. /**
  28050. * Call this function to leave webVR mode
  28051. * Will do nothing if webVR is not supported or if there is no webVR device
  28052. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28053. */
  28054. disableVR(): void;
  28055. /**
  28056. * Gets a boolean indicating that the system is in VR mode and is presenting
  28057. * @returns true if VR mode is engaged
  28058. */
  28059. isVRPresenting(): boolean;
  28060. /** @hidden */
  28061. _requestVRFrame(): void;
  28062. private _disableTouchAction;
  28063. private _rebuildInternalTextures;
  28064. private _rebuildEffects;
  28065. /**
  28066. * Gets a boolean indicating if all created effects are ready
  28067. * @returns true if all effects are ready
  28068. */
  28069. areAllEffectsReady(): boolean;
  28070. private _rebuildBuffers;
  28071. private _initGLContext;
  28072. /**
  28073. * Gets version of the current webGL context
  28074. */
  28075. readonly webGLVersion: number;
  28076. /**
  28077. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28078. */
  28079. readonly isStencilEnable: boolean;
  28080. /** @hidden */
  28081. _prepareWorkingCanvas(): void;
  28082. /**
  28083. * Reset the texture cache to empty state
  28084. */
  28085. resetTextureCache(): void;
  28086. /**
  28087. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28088. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28089. * @returns true if engine is in deterministic lock step mode
  28090. */
  28091. isDeterministicLockStep(): boolean;
  28092. /**
  28093. * Gets the max steps when engine is running in deterministic lock step
  28094. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28095. * @returns the max steps
  28096. */
  28097. getLockstepMaxSteps(): number;
  28098. /**
  28099. * Gets an object containing information about the current webGL context
  28100. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28101. */
  28102. getGlInfo(): {
  28103. vendor: string;
  28104. renderer: string;
  28105. version: string;
  28106. };
  28107. /**
  28108. * Gets current aspect ratio
  28109. * @param camera defines the camera to use to get the aspect ratio
  28110. * @param useScreen defines if screen size must be used (or the current render target if any)
  28111. * @returns a number defining the aspect ratio
  28112. */
  28113. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28114. /**
  28115. * Gets current screen aspect ratio
  28116. * @returns a number defining the aspect ratio
  28117. */
  28118. getScreenAspectRatio(): number;
  28119. /**
  28120. * Gets the current render width
  28121. * @param useScreen defines if screen size must be used (or the current render target if any)
  28122. * @returns a number defining the current render width
  28123. */
  28124. getRenderWidth(useScreen?: boolean): number;
  28125. /**
  28126. * Gets the current render height
  28127. * @param useScreen defines if screen size must be used (or the current render target if any)
  28128. * @returns a number defining the current render height
  28129. */
  28130. getRenderHeight(useScreen?: boolean): number;
  28131. /**
  28132. * Gets the HTML canvas attached with the current webGL context
  28133. * @returns a HTML canvas
  28134. */
  28135. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28136. /**
  28137. * Gets the client rect of the HTML canvas attached with the current webGL context
  28138. * @returns a client rectanglee
  28139. */
  28140. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28141. /**
  28142. * Defines the hardware scaling level.
  28143. * By default the hardware scaling level is computed from the window device ratio.
  28144. * 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.
  28145. * @param level defines the level to use
  28146. */
  28147. setHardwareScalingLevel(level: number): void;
  28148. /**
  28149. * Gets the current hardware scaling level.
  28150. * By default the hardware scaling level is computed from the window device ratio.
  28151. * 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.
  28152. * @returns a number indicating the current hardware scaling level
  28153. */
  28154. getHardwareScalingLevel(): number;
  28155. /**
  28156. * Gets the list of loaded textures
  28157. * @returns an array containing all loaded textures
  28158. */
  28159. getLoadedTexturesCache(): InternalTexture[];
  28160. /**
  28161. * Gets the object containing all engine capabilities
  28162. * @returns the EngineCapabilities object
  28163. */
  28164. getCaps(): EngineCapabilities;
  28165. /**
  28166. * Gets the current depth function
  28167. * @returns a number defining the depth function
  28168. */
  28169. getDepthFunction(): Nullable<number>;
  28170. /**
  28171. * Sets the current depth function
  28172. * @param depthFunc defines the function to use
  28173. */
  28174. setDepthFunction(depthFunc: number): void;
  28175. /**
  28176. * Sets the current depth function to GREATER
  28177. */
  28178. setDepthFunctionToGreater(): void;
  28179. /**
  28180. * Sets the current depth function to GEQUAL
  28181. */
  28182. setDepthFunctionToGreaterOrEqual(): void;
  28183. /**
  28184. * Sets the current depth function to LESS
  28185. */
  28186. setDepthFunctionToLess(): void;
  28187. private _cachedStencilBuffer;
  28188. private _cachedStencilFunction;
  28189. private _cachedStencilMask;
  28190. private _cachedStencilOperationPass;
  28191. private _cachedStencilOperationFail;
  28192. private _cachedStencilOperationDepthFail;
  28193. private _cachedStencilReference;
  28194. /**
  28195. * Caches the the state of the stencil buffer
  28196. */
  28197. cacheStencilState(): void;
  28198. /**
  28199. * Restores the state of the stencil buffer
  28200. */
  28201. restoreStencilState(): void;
  28202. /**
  28203. * Sets the current depth function to LEQUAL
  28204. */
  28205. setDepthFunctionToLessOrEqual(): void;
  28206. /**
  28207. * Gets a boolean indicating if stencil buffer is enabled
  28208. * @returns the current stencil buffer state
  28209. */
  28210. getStencilBuffer(): boolean;
  28211. /**
  28212. * Enable or disable the stencil buffer
  28213. * @param enable defines if the stencil buffer must be enabled or disabled
  28214. */
  28215. setStencilBuffer(enable: boolean): void;
  28216. /**
  28217. * Gets the current stencil mask
  28218. * @returns a number defining the new stencil mask to use
  28219. */
  28220. getStencilMask(): number;
  28221. /**
  28222. * Sets the current stencil mask
  28223. * @param mask defines the new stencil mask to use
  28224. */
  28225. setStencilMask(mask: number): void;
  28226. /**
  28227. * Gets the current stencil function
  28228. * @returns a number defining the stencil function to use
  28229. */
  28230. getStencilFunction(): number;
  28231. /**
  28232. * Gets the current stencil reference value
  28233. * @returns a number defining the stencil reference value to use
  28234. */
  28235. getStencilFunctionReference(): number;
  28236. /**
  28237. * Gets the current stencil mask
  28238. * @returns a number defining the stencil mask to use
  28239. */
  28240. getStencilFunctionMask(): number;
  28241. /**
  28242. * Sets the current stencil function
  28243. * @param stencilFunc defines the new stencil function to use
  28244. */
  28245. setStencilFunction(stencilFunc: number): void;
  28246. /**
  28247. * Sets the current stencil reference
  28248. * @param reference defines the new stencil reference to use
  28249. */
  28250. setStencilFunctionReference(reference: number): void;
  28251. /**
  28252. * Sets the current stencil mask
  28253. * @param mask defines the new stencil mask to use
  28254. */
  28255. setStencilFunctionMask(mask: number): void;
  28256. /**
  28257. * Gets the current stencil operation when stencil fails
  28258. * @returns a number defining stencil operation to use when stencil fails
  28259. */
  28260. getStencilOperationFail(): number;
  28261. /**
  28262. * Gets the current stencil operation when depth fails
  28263. * @returns a number defining stencil operation to use when depth fails
  28264. */
  28265. getStencilOperationDepthFail(): number;
  28266. /**
  28267. * Gets the current stencil operation when stencil passes
  28268. * @returns a number defining stencil operation to use when stencil passes
  28269. */
  28270. getStencilOperationPass(): number;
  28271. /**
  28272. * Sets the stencil operation to use when stencil fails
  28273. * @param operation defines the stencil operation to use when stencil fails
  28274. */
  28275. setStencilOperationFail(operation: number): void;
  28276. /**
  28277. * Sets the stencil operation to use when depth fails
  28278. * @param operation defines the stencil operation to use when depth fails
  28279. */
  28280. setStencilOperationDepthFail(operation: number): void;
  28281. /**
  28282. * Sets the stencil operation to use when stencil passes
  28283. * @param operation defines the stencil operation to use when stencil passes
  28284. */
  28285. setStencilOperationPass(operation: number): void;
  28286. /**
  28287. * Sets a boolean indicating if the dithering state is enabled or disabled
  28288. * @param value defines the dithering state
  28289. */
  28290. setDitheringState(value: boolean): void;
  28291. /**
  28292. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28293. * @param value defines the rasterizer state
  28294. */
  28295. setRasterizerState(value: boolean): void;
  28296. /**
  28297. * stop executing a render loop function and remove it from the execution array
  28298. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28299. */
  28300. stopRenderLoop(renderFunction?: () => void): void;
  28301. /** @hidden */
  28302. _renderLoop(): void;
  28303. /**
  28304. * Register and execute a render loop. The engine can have more than one render function
  28305. * @param renderFunction defines the function to continuously execute
  28306. */
  28307. runRenderLoop(renderFunction: () => void): void;
  28308. /**
  28309. * Toggle full screen mode
  28310. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28311. */
  28312. switchFullscreen(requestPointerLock: boolean): void;
  28313. /**
  28314. * Enters full screen mode
  28315. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28316. */
  28317. enterFullscreen(requestPointerLock: boolean): void;
  28318. /**
  28319. * Exits full screen mode
  28320. */
  28321. exitFullscreen(): void;
  28322. /**
  28323. * Enters Pointerlock mode
  28324. */
  28325. enterPointerlock(): void;
  28326. /**
  28327. * Exits Pointerlock mode
  28328. */
  28329. exitPointerlock(): void;
  28330. /**
  28331. * Clear the current render buffer or the current render target (if any is set up)
  28332. * @param color defines the color to use
  28333. * @param backBuffer defines if the back buffer must be cleared
  28334. * @param depth defines if the depth buffer must be cleared
  28335. * @param stencil defines if the stencil buffer must be cleared
  28336. */
  28337. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28338. /**
  28339. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28340. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28341. * @param y defines the y-coordinate of the corner of the clear rectangle
  28342. * @param width defines the width of the clear rectangle
  28343. * @param height defines the height of the clear rectangle
  28344. * @param clearColor defines the clear color
  28345. */
  28346. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28347. /**
  28348. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28349. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28350. * @param y defines the y-coordinate of the corner of the clear rectangle
  28351. * @param width defines the width of the clear rectangle
  28352. * @param height defines the height of the clear rectangle
  28353. */
  28354. enableScissor(x: number, y: number, width: number, height: number): void;
  28355. /**
  28356. * Disable previously set scissor test rectangle
  28357. */
  28358. disableScissor(): void;
  28359. private _viewportCached;
  28360. /** @hidden */
  28361. _viewport(x: number, y: number, width: number, height: number): void;
  28362. /**
  28363. * Set the WebGL's viewport
  28364. * @param viewport defines the viewport element to be used
  28365. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28366. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28367. */
  28368. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28369. /**
  28370. * Directly set the WebGL Viewport
  28371. * @param x defines the x coordinate of the viewport (in screen space)
  28372. * @param y defines the y coordinate of the viewport (in screen space)
  28373. * @param width defines the width of the viewport (in screen space)
  28374. * @param height defines the height of the viewport (in screen space)
  28375. * @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
  28376. */
  28377. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28378. /**
  28379. * Begin a new frame
  28380. */
  28381. beginFrame(): void;
  28382. /**
  28383. * Enf the current frame
  28384. */
  28385. endFrame(): void;
  28386. /**
  28387. * Resize the view according to the canvas' size
  28388. */
  28389. resize(): void;
  28390. /**
  28391. * Force a specific size of the canvas
  28392. * @param width defines the new canvas' width
  28393. * @param height defines the new canvas' height
  28394. */
  28395. setSize(width: number, height: number): void;
  28396. /**
  28397. * Binds the frame buffer to the specified texture.
  28398. * @param texture The texture to render to or null for the default canvas
  28399. * @param faceIndex The face of the texture to render to in case of cube texture
  28400. * @param requiredWidth The width of the target to render to
  28401. * @param requiredHeight The height of the target to render to
  28402. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28403. * @param depthStencilTexture The depth stencil texture to use to render
  28404. * @param lodLevel defines le lod level to bind to the frame buffer
  28405. */
  28406. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28407. /** @hidden */
  28408. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28409. /**
  28410. * Unbind the current render target texture from the webGL context
  28411. * @param texture defines the render target texture to unbind
  28412. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28413. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28414. */
  28415. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28416. /**
  28417. * Force the mipmap generation for the given render target texture
  28418. * @param texture defines the render target texture to use
  28419. */
  28420. generateMipMapsForCubemap(texture: InternalTexture): void;
  28421. /**
  28422. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28423. */
  28424. flushFramebuffer(): void;
  28425. /**
  28426. * Unbind the current render target and bind the default framebuffer
  28427. */
  28428. restoreDefaultFramebuffer(): void;
  28429. /**
  28430. * Create an uniform buffer
  28431. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28432. * @param elements defines the content of the uniform buffer
  28433. * @returns the webGL uniform buffer
  28434. */
  28435. createUniformBuffer(elements: FloatArray): DataBuffer;
  28436. /**
  28437. * Create a dynamic uniform buffer
  28438. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28439. * @param elements defines the content of the uniform buffer
  28440. * @returns the webGL uniform buffer
  28441. */
  28442. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28443. /**
  28444. * Update an existing uniform buffer
  28445. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28446. * @param uniformBuffer defines the target uniform buffer
  28447. * @param elements defines the content to update
  28448. * @param offset defines the offset in the uniform buffer where update should start
  28449. * @param count defines the size of the data to update
  28450. */
  28451. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28452. private _resetVertexBufferBinding;
  28453. /**
  28454. * Creates a vertex buffer
  28455. * @param data the data for the vertex buffer
  28456. * @returns the new WebGL static buffer
  28457. */
  28458. createVertexBuffer(data: DataArray): DataBuffer;
  28459. /**
  28460. * Creates a dynamic vertex buffer
  28461. * @param data the data for the dynamic vertex buffer
  28462. * @returns the new WebGL dynamic buffer
  28463. */
  28464. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28465. /**
  28466. * Update a dynamic index buffer
  28467. * @param indexBuffer defines the target index buffer
  28468. * @param indices defines the data to update
  28469. * @param offset defines the offset in the target index buffer where update should start
  28470. */
  28471. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28472. /**
  28473. * Updates a dynamic vertex buffer.
  28474. * @param vertexBuffer the vertex buffer to update
  28475. * @param data the data used to update the vertex buffer
  28476. * @param byteOffset the byte offset of the data
  28477. * @param byteLength the byte length of the data
  28478. */
  28479. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28480. private _resetIndexBufferBinding;
  28481. /**
  28482. * Creates a new index buffer
  28483. * @param indices defines the content of the index buffer
  28484. * @param updatable defines if the index buffer must be updatable
  28485. * @returns a new webGL buffer
  28486. */
  28487. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28488. /**
  28489. * Bind a webGL buffer to the webGL context
  28490. * @param buffer defines the buffer to bind
  28491. */
  28492. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28493. /**
  28494. * Bind an uniform buffer to the current webGL context
  28495. * @param buffer defines the buffer to bind
  28496. */
  28497. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28498. /**
  28499. * Bind a buffer to the current webGL context at a given location
  28500. * @param buffer defines the buffer to bind
  28501. * @param location defines the index where to bind the buffer
  28502. */
  28503. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28504. /**
  28505. * Bind a specific block at a given index in a specific shader program
  28506. * @param pipelineContext defines the pipeline context to use
  28507. * @param blockName defines the block name
  28508. * @param index defines the index where to bind the block
  28509. */
  28510. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28511. private bindIndexBuffer;
  28512. private bindBuffer;
  28513. /**
  28514. * update the bound buffer with the given data
  28515. * @param data defines the data to update
  28516. */
  28517. updateArrayBuffer(data: Float32Array): void;
  28518. private _vertexAttribPointer;
  28519. private _bindIndexBufferWithCache;
  28520. private _bindVertexBuffersAttributes;
  28521. /**
  28522. * Records a vertex array object
  28523. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28524. * @param vertexBuffers defines the list of vertex buffers to store
  28525. * @param indexBuffer defines the index buffer to store
  28526. * @param effect defines the effect to store
  28527. * @returns the new vertex array object
  28528. */
  28529. recordVertexArrayObject(vertexBuffers: {
  28530. [key: string]: VertexBuffer;
  28531. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28532. /**
  28533. * Bind a specific vertex array object
  28534. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28535. * @param vertexArrayObject defines the vertex array object to bind
  28536. * @param indexBuffer defines the index buffer to bind
  28537. */
  28538. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28539. /**
  28540. * Bind webGl buffers directly to the webGL context
  28541. * @param vertexBuffer defines the vertex buffer to bind
  28542. * @param indexBuffer defines the index buffer to bind
  28543. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28544. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28545. * @param effect defines the effect associated with the vertex buffer
  28546. */
  28547. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28548. private _unbindVertexArrayObject;
  28549. /**
  28550. * Bind a list of vertex buffers to the webGL context
  28551. * @param vertexBuffers defines the list of vertex buffers to bind
  28552. * @param indexBuffer defines the index buffer to bind
  28553. * @param effect defines the effect associated with the vertex buffers
  28554. */
  28555. bindBuffers(vertexBuffers: {
  28556. [key: string]: Nullable<VertexBuffer>;
  28557. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28558. /**
  28559. * Unbind all instance attributes
  28560. */
  28561. unbindInstanceAttributes(): void;
  28562. /**
  28563. * Release and free the memory of a vertex array object
  28564. * @param vao defines the vertex array object to delete
  28565. */
  28566. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28567. /** @hidden */
  28568. _releaseBuffer(buffer: DataBuffer): boolean;
  28569. /**
  28570. * Creates a webGL buffer to use with instanciation
  28571. * @param capacity defines the size of the buffer
  28572. * @returns the webGL buffer
  28573. */
  28574. createInstancesBuffer(capacity: number): DataBuffer;
  28575. /**
  28576. * Delete a webGL buffer used with instanciation
  28577. * @param buffer defines the webGL buffer to delete
  28578. */
  28579. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28580. /**
  28581. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28582. * @param instancesBuffer defines the webGL buffer to update and bind
  28583. * @param data defines the data to store in the buffer
  28584. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28585. */
  28586. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28587. /**
  28588. * Apply all cached states (depth, culling, stencil and alpha)
  28589. */
  28590. applyStates(): void;
  28591. /**
  28592. * Send a draw order
  28593. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28594. * @param indexStart defines the starting index
  28595. * @param indexCount defines the number of index to draw
  28596. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28597. */
  28598. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28599. /**
  28600. * Draw a list of points
  28601. * @param verticesStart defines the index of first vertex to draw
  28602. * @param verticesCount defines the count of vertices to draw
  28603. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28604. */
  28605. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28606. /**
  28607. * Draw a list of unindexed primitives
  28608. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28609. * @param verticesStart defines the index of first vertex to draw
  28610. * @param verticesCount defines the count of vertices to draw
  28611. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28612. */
  28613. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28614. /**
  28615. * Draw a list of indexed primitives
  28616. * @param fillMode defines the primitive to use
  28617. * @param indexStart defines the starting index
  28618. * @param indexCount defines the number of index to draw
  28619. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28620. */
  28621. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28622. /**
  28623. * Draw a list of unindexed primitives
  28624. * @param fillMode defines the primitive to use
  28625. * @param verticesStart defines the index of first vertex to draw
  28626. * @param verticesCount defines the count of vertices to draw
  28627. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28628. */
  28629. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28630. private _drawMode;
  28631. /** @hidden */
  28632. _releaseEffect(effect: Effect): void;
  28633. /** @hidden */
  28634. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28635. /**
  28636. * Create a new effect (used to store vertex/fragment shaders)
  28637. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28638. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28639. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28640. * @param samplers defines an array of string used to represent textures
  28641. * @param defines defines the string containing the defines to use to compile the shaders
  28642. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28643. * @param onCompiled defines a function to call when the effect creation is successful
  28644. * @param onError defines a function to call when the effect creation has failed
  28645. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28646. * @returns the new Effect
  28647. */
  28648. 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;
  28649. private _compileShader;
  28650. private _compileRawShader;
  28651. /**
  28652. * Directly creates a webGL program
  28653. * @param pipelineContext defines the pipeline context to attach to
  28654. * @param vertexCode defines the vertex shader code to use
  28655. * @param fragmentCode defines the fragment shader code to use
  28656. * @param context defines the webGL context to use (if not set, the current one will be used)
  28657. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28658. * @returns the new webGL program
  28659. */
  28660. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28661. /**
  28662. * Creates a webGL program
  28663. * @param pipelineContext defines the pipeline context to attach to
  28664. * @param vertexCode defines the vertex shader code to use
  28665. * @param fragmentCode defines the fragment shader code to use
  28666. * @param defines defines the string containing the defines to use to compile the shaders
  28667. * @param context defines the webGL context to use (if not set, the current one will be used)
  28668. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28669. * @returns the new webGL program
  28670. */
  28671. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28672. /**
  28673. * Creates a new pipeline context
  28674. * @returns the new pipeline
  28675. */
  28676. createPipelineContext(): WebGLPipelineContext;
  28677. private _createShaderProgram;
  28678. private _finalizePipelineContext;
  28679. /** @hidden */
  28680. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28681. /** @hidden */
  28682. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28683. /** @hidden */
  28684. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28685. /**
  28686. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28687. * @param pipelineContext defines the pipeline context to use
  28688. * @param uniformsNames defines the list of uniform names
  28689. * @returns an array of webGL uniform locations
  28690. */
  28691. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28692. /**
  28693. * Gets the lsit of active attributes for a given webGL program
  28694. * @param pipelineContext defines the pipeline context to use
  28695. * @param attributesNames defines the list of attribute names to get
  28696. * @returns an array of indices indicating the offset of each attribute
  28697. */
  28698. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28699. /**
  28700. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28701. * @param effect defines the effect to activate
  28702. */
  28703. enableEffect(effect: Nullable<Effect>): void;
  28704. /**
  28705. * Set the value of an uniform to an array of int32
  28706. * @param uniform defines the webGL uniform location where to store the value
  28707. * @param array defines the array of int32 to store
  28708. */
  28709. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28710. /**
  28711. * Set the value of an uniform to an array of int32 (stored as vec2)
  28712. * @param uniform defines the webGL uniform location where to store the value
  28713. * @param array defines the array of int32 to store
  28714. */
  28715. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28716. /**
  28717. * Set the value of an uniform to an array of int32 (stored as vec3)
  28718. * @param uniform defines the webGL uniform location where to store the value
  28719. * @param array defines the array of int32 to store
  28720. */
  28721. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28722. /**
  28723. * Set the value of an uniform to an array of int32 (stored as vec4)
  28724. * @param uniform defines the webGL uniform location where to store the value
  28725. * @param array defines the array of int32 to store
  28726. */
  28727. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28728. /**
  28729. * Set the value of an uniform to an array of float32
  28730. * @param uniform defines the webGL uniform location where to store the value
  28731. * @param array defines the array of float32 to store
  28732. */
  28733. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28734. /**
  28735. * Set the value of an uniform to an array of float32 (stored as vec2)
  28736. * @param uniform defines the webGL uniform location where to store the value
  28737. * @param array defines the array of float32 to store
  28738. */
  28739. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28740. /**
  28741. * Set the value of an uniform to an array of float32 (stored as vec3)
  28742. * @param uniform defines the webGL uniform location where to store the value
  28743. * @param array defines the array of float32 to store
  28744. */
  28745. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28746. /**
  28747. * Set the value of an uniform to an array of float32 (stored as vec4)
  28748. * @param uniform defines the webGL uniform location where to store the value
  28749. * @param array defines the array of float32 to store
  28750. */
  28751. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28752. /**
  28753. * Set the value of an uniform to an array of number
  28754. * @param uniform defines the webGL uniform location where to store the value
  28755. * @param array defines the array of number to store
  28756. */
  28757. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28758. /**
  28759. * Set the value of an uniform to an array of number (stored as vec2)
  28760. * @param uniform defines the webGL uniform location where to store the value
  28761. * @param array defines the array of number to store
  28762. */
  28763. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28764. /**
  28765. * Set the value of an uniform to an array of number (stored as vec3)
  28766. * @param uniform defines the webGL uniform location where to store the value
  28767. * @param array defines the array of number to store
  28768. */
  28769. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28770. /**
  28771. * Set the value of an uniform to an array of number (stored as vec4)
  28772. * @param uniform defines the webGL uniform location where to store the value
  28773. * @param array defines the array of number to store
  28774. */
  28775. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28776. /**
  28777. * Set the value of an uniform to an array of float32 (stored as matrices)
  28778. * @param uniform defines the webGL uniform location where to store the value
  28779. * @param matrices defines the array of float32 to store
  28780. */
  28781. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28782. /**
  28783. * Set the value of an uniform to a matrix
  28784. * @param uniform defines the webGL uniform location where to store the value
  28785. * @param matrix defines the matrix to store
  28786. */
  28787. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28788. /**
  28789. * Set the value of an uniform to a matrix (3x3)
  28790. * @param uniform defines the webGL uniform location where to store the value
  28791. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28792. */
  28793. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28794. /**
  28795. * Set the value of an uniform to a matrix (2x2)
  28796. * @param uniform defines the webGL uniform location where to store the value
  28797. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28798. */
  28799. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28800. /**
  28801. * Set the value of an uniform to a number (int)
  28802. * @param uniform defines the webGL uniform location where to store the value
  28803. * @param value defines the int number to store
  28804. */
  28805. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28806. /**
  28807. * Set the value of an uniform to a number (float)
  28808. * @param uniform defines the webGL uniform location where to store the value
  28809. * @param value defines the float number to store
  28810. */
  28811. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28812. /**
  28813. * Set the value of an uniform to a vec2
  28814. * @param uniform defines the webGL uniform location where to store the value
  28815. * @param x defines the 1st component of the value
  28816. * @param y defines the 2nd component of the value
  28817. */
  28818. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28819. /**
  28820. * Set the value of an uniform to a vec3
  28821. * @param uniform defines the webGL uniform location where to store the value
  28822. * @param x defines the 1st component of the value
  28823. * @param y defines the 2nd component of the value
  28824. * @param z defines the 3rd component of the value
  28825. */
  28826. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28827. /**
  28828. * Set the value of an uniform to a boolean
  28829. * @param uniform defines the webGL uniform location where to store the value
  28830. * @param bool defines the boolean to store
  28831. */
  28832. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28833. /**
  28834. * Set the value of an uniform to a vec4
  28835. * @param uniform defines the webGL uniform location where to store the value
  28836. * @param x defines the 1st component of the value
  28837. * @param y defines the 2nd component of the value
  28838. * @param z defines the 3rd component of the value
  28839. * @param w defines the 4th component of the value
  28840. */
  28841. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28842. /**
  28843. * Set the value of an uniform to a Color3
  28844. * @param uniform defines the webGL uniform location where to store the value
  28845. * @param color3 defines the color to store
  28846. */
  28847. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28848. /**
  28849. * Set the value of an uniform to a Color3 and an alpha value
  28850. * @param uniform defines the webGL uniform location where to store the value
  28851. * @param color3 defines the color to store
  28852. * @param alpha defines the alpha component to store
  28853. */
  28854. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28855. /**
  28856. * Sets a Color4 on a uniform variable
  28857. * @param uniform defines the uniform location
  28858. * @param color4 defines the value to be set
  28859. */
  28860. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28861. /**
  28862. * Set various states to the webGL context
  28863. * @param culling defines backface culling state
  28864. * @param zOffset defines the value to apply to zOffset (0 by default)
  28865. * @param force defines if states must be applied even if cache is up to date
  28866. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28867. */
  28868. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28869. /**
  28870. * Set the z offset to apply to current rendering
  28871. * @param value defines the offset to apply
  28872. */
  28873. setZOffset(value: number): void;
  28874. /**
  28875. * Gets the current value of the zOffset
  28876. * @returns the current zOffset state
  28877. */
  28878. getZOffset(): number;
  28879. /**
  28880. * Enable or disable depth buffering
  28881. * @param enable defines the state to set
  28882. */
  28883. setDepthBuffer(enable: boolean): void;
  28884. /**
  28885. * Gets a boolean indicating if depth writing is enabled
  28886. * @returns the current depth writing state
  28887. */
  28888. getDepthWrite(): boolean;
  28889. /**
  28890. * Enable or disable depth writing
  28891. * @param enable defines the state to set
  28892. */
  28893. setDepthWrite(enable: boolean): void;
  28894. /**
  28895. * Enable or disable color writing
  28896. * @param enable defines the state to set
  28897. */
  28898. setColorWrite(enable: boolean): void;
  28899. /**
  28900. * Gets a boolean indicating if color writing is enabled
  28901. * @returns the current color writing state
  28902. */
  28903. getColorWrite(): boolean;
  28904. /**
  28905. * Sets alpha constants used by some alpha blending modes
  28906. * @param r defines the red component
  28907. * @param g defines the green component
  28908. * @param b defines the blue component
  28909. * @param a defines the alpha component
  28910. */
  28911. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28912. /**
  28913. * Sets the current alpha mode
  28914. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28915. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28916. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28917. */
  28918. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28919. /**
  28920. * Gets the current alpha mode
  28921. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28922. * @returns the current alpha mode
  28923. */
  28924. getAlphaMode(): number;
  28925. /**
  28926. * Clears the list of texture accessible through engine.
  28927. * This can help preventing texture load conflict due to name collision.
  28928. */
  28929. clearInternalTexturesCache(): void;
  28930. /**
  28931. * Force the entire cache to be cleared
  28932. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28933. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28934. */
  28935. wipeCaches(bruteForce?: boolean): void;
  28936. /**
  28937. * Set the compressed texture format to use, based on the formats you have, and the formats
  28938. * supported by the hardware / browser.
  28939. *
  28940. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28941. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28942. * to API arguments needed to compressed textures. This puts the burden on the container
  28943. * generator to house the arcane code for determining these for current & future formats.
  28944. *
  28945. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28946. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28947. *
  28948. * Note: The result of this call is not taken into account when a texture is base64.
  28949. *
  28950. * @param formatsAvailable defines the list of those format families you have created
  28951. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28952. *
  28953. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28954. * @returns The extension selected.
  28955. */
  28956. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28957. /** @hidden */
  28958. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28959. min: number;
  28960. mag: number;
  28961. };
  28962. /** @hidden */
  28963. _createTexture(): WebGLTexture;
  28964. /**
  28965. * Usually called from Texture.ts.
  28966. * Passed information to create a WebGLTexture
  28967. * @param urlArg defines a value which contains one of the following:
  28968. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28969. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28970. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28971. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28972. * @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)
  28973. * @param scene needed for loading to the correct scene
  28974. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28975. * @param onLoad optional callback to be called upon successful completion
  28976. * @param onError optional callback to be called upon failure
  28977. * @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
  28978. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28979. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28980. * @param forcedExtension defines the extension to use to pick the right loader
  28981. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28982. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28983. */
  28984. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28985. /**
  28986. * @hidden
  28987. * Rescales a texture
  28988. * @param source input texutre
  28989. * @param destination destination texture
  28990. * @param scene scene to use to render the resize
  28991. * @param internalFormat format to use when resizing
  28992. * @param onComplete callback to be called when resize has completed
  28993. */
  28994. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28995. private _unpackFlipYCached;
  28996. /**
  28997. * In case you are sharing the context with other applications, it might
  28998. * be interested to not cache the unpack flip y state to ensure a consistent
  28999. * value would be set.
  29000. */
  29001. enableUnpackFlipYCached: boolean;
  29002. /** @hidden */
  29003. _unpackFlipY(value: boolean): void;
  29004. /** @hidden */
  29005. _getUnpackAlignement(): number;
  29006. /**
  29007. * Creates a dynamic texture
  29008. * @param width defines the width of the texture
  29009. * @param height defines the height of the texture
  29010. * @param generateMipMaps defines if the engine should generate the mip levels
  29011. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29012. * @returns the dynamic texture inside an InternalTexture
  29013. */
  29014. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29015. /**
  29016. * Update the sampling mode of a given texture
  29017. * @param samplingMode defines the required sampling mode
  29018. * @param texture defines the texture to update
  29019. */
  29020. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29021. /**
  29022. * Update the content of a dynamic texture
  29023. * @param texture defines the texture to update
  29024. * @param canvas defines the canvas containing the source
  29025. * @param invertY defines if data must be stored with Y axis inverted
  29026. * @param premulAlpha defines if alpha is stored as premultiplied
  29027. * @param format defines the format of the data
  29028. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29029. */
  29030. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29031. /**
  29032. * Update a video texture
  29033. * @param texture defines the texture to update
  29034. * @param video defines the video element to use
  29035. * @param invertY defines if data must be stored with Y axis inverted
  29036. */
  29037. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29038. /**
  29039. * Updates a depth texture Comparison Mode and Function.
  29040. * If the comparison Function is equal to 0, the mode will be set to none.
  29041. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29042. * @param texture The texture to set the comparison function for
  29043. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29044. */
  29045. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29046. /** @hidden */
  29047. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29048. width: number;
  29049. height: number;
  29050. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29051. /**
  29052. * Creates a depth stencil texture.
  29053. * This is only available in WebGL 2 or with the depth texture extension available.
  29054. * @param size The size of face edge in the texture.
  29055. * @param options The options defining the texture.
  29056. * @returns The texture
  29057. */
  29058. createDepthStencilTexture(size: number | {
  29059. width: number;
  29060. height: number;
  29061. }, options: DepthTextureCreationOptions): InternalTexture;
  29062. /**
  29063. * Creates a depth stencil texture.
  29064. * This is only available in WebGL 2 or with the depth texture extension available.
  29065. * @param size The size of face edge in the texture.
  29066. * @param options The options defining the texture.
  29067. * @returns The texture
  29068. */
  29069. private _createDepthStencilTexture;
  29070. /**
  29071. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29072. * @param renderTarget The render target to set the frame buffer for
  29073. */
  29074. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29075. /**
  29076. * Creates a new render target texture
  29077. * @param size defines the size of the texture
  29078. * @param options defines the options used to create the texture
  29079. * @returns a new render target texture stored in an InternalTexture
  29080. */
  29081. createRenderTargetTexture(size: number | {
  29082. width: number;
  29083. height: number;
  29084. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29085. /** @hidden */
  29086. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29087. /**
  29088. * Updates the sample count of a render target texture
  29089. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29090. * @param texture defines the texture to update
  29091. * @param samples defines the sample count to set
  29092. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29093. */
  29094. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29095. /** @hidden */
  29096. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29097. /** @hidden */
  29098. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29099. /** @hidden */
  29100. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29101. /** @hidden */
  29102. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29103. /**
  29104. * @hidden
  29105. */
  29106. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29107. private _prepareWebGLTextureContinuation;
  29108. private _prepareWebGLTexture;
  29109. /** @hidden */
  29110. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29111. /** @hidden */
  29112. _releaseFramebufferObjects(texture: InternalTexture): void;
  29113. /** @hidden */
  29114. _releaseTexture(texture: InternalTexture): void;
  29115. private setProgram;
  29116. private _boundUniforms;
  29117. /**
  29118. * Binds an effect to the webGL context
  29119. * @param effect defines the effect to bind
  29120. */
  29121. bindSamplers(effect: Effect): void;
  29122. private _activateCurrentTexture;
  29123. /** @hidden */
  29124. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29125. /** @hidden */
  29126. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29127. /**
  29128. * Sets a texture to the webGL context from a postprocess
  29129. * @param channel defines the channel to use
  29130. * @param postProcess defines the source postprocess
  29131. */
  29132. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29133. /**
  29134. * Binds the output of the passed in post process to the texture channel specified
  29135. * @param channel The channel the texture should be bound to
  29136. * @param postProcess The post process which's output should be bound
  29137. */
  29138. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29139. /**
  29140. * Unbind all textures from the webGL context
  29141. */
  29142. unbindAllTextures(): void;
  29143. /**
  29144. * Sets a texture to the according uniform.
  29145. * @param channel The texture channel
  29146. * @param uniform The uniform to set
  29147. * @param texture The texture to apply
  29148. */
  29149. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29150. /**
  29151. * Sets a depth stencil texture from a render target to the according uniform.
  29152. * @param channel The texture channel
  29153. * @param uniform The uniform to set
  29154. * @param texture The render target texture containing the depth stencil texture to apply
  29155. */
  29156. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29157. private _bindSamplerUniformToChannel;
  29158. private _getTextureWrapMode;
  29159. private _setTexture;
  29160. /**
  29161. * Sets an array of texture to the webGL context
  29162. * @param channel defines the channel where the texture array must be set
  29163. * @param uniform defines the associated uniform location
  29164. * @param textures defines the array of textures to bind
  29165. */
  29166. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29167. /** @hidden */
  29168. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29169. private _setTextureParameterFloat;
  29170. private _setTextureParameterInteger;
  29171. /**
  29172. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29173. * @param x defines the x coordinate of the rectangle where pixels must be read
  29174. * @param y defines the y coordinate of the rectangle where pixels must be read
  29175. * @param width defines the width of the rectangle where pixels must be read
  29176. * @param height defines the height of the rectangle where pixels must be read
  29177. * @returns a Uint8Array containing RGBA colors
  29178. */
  29179. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29180. /**
  29181. * Add an externaly attached data from its key.
  29182. * This method call will fail and return false, if such key already exists.
  29183. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29184. * @param key the unique key that identifies the data
  29185. * @param data the data object to associate to the key for this Engine instance
  29186. * @return true if no such key were already present and the data was added successfully, false otherwise
  29187. */
  29188. addExternalData<T>(key: string, data: T): boolean;
  29189. /**
  29190. * Get an externaly attached data from its key
  29191. * @param key the unique key that identifies the data
  29192. * @return the associated data, if present (can be null), or undefined if not present
  29193. */
  29194. getExternalData<T>(key: string): T;
  29195. /**
  29196. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29197. * @param key the unique key that identifies the data
  29198. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29199. * @return the associated data, can be null if the factory returned null.
  29200. */
  29201. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29202. /**
  29203. * Remove an externaly attached data from the Engine instance
  29204. * @param key the unique key that identifies the data
  29205. * @return true if the data was successfully removed, false if it doesn't exist
  29206. */
  29207. removeExternalData(key: string): boolean;
  29208. /**
  29209. * Unbind all vertex attributes from the webGL context
  29210. */
  29211. unbindAllAttributes(): void;
  29212. /**
  29213. * 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
  29214. */
  29215. releaseEffects(): void;
  29216. /**
  29217. * Dispose and release all associated resources
  29218. */
  29219. dispose(): void;
  29220. /**
  29221. * Display the loading screen
  29222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29223. */
  29224. displayLoadingUI(): void;
  29225. /**
  29226. * Hide the loading screen
  29227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29228. */
  29229. hideLoadingUI(): void;
  29230. /**
  29231. * Gets the current loading screen object
  29232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29233. */
  29234. /**
  29235. * Sets the current loading screen object
  29236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29237. */
  29238. loadingScreen: ILoadingScreen;
  29239. /**
  29240. * Sets the current loading screen text
  29241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29242. */
  29243. loadingUIText: string;
  29244. /**
  29245. * Sets the current loading screen background color
  29246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29247. */
  29248. loadingUIBackgroundColor: string;
  29249. /**
  29250. * Attach a new callback raised when context lost event is fired
  29251. * @param callback defines the callback to call
  29252. */
  29253. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29254. /**
  29255. * Attach a new callback raised when context restored event is fired
  29256. * @param callback defines the callback to call
  29257. */
  29258. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29259. /**
  29260. * Gets the source code of the vertex shader associated with a specific webGL program
  29261. * @param program defines the program to use
  29262. * @returns a string containing the source code of the vertex shader associated with the program
  29263. */
  29264. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29265. /**
  29266. * Gets the source code of the fragment shader associated with a specific webGL program
  29267. * @param program defines the program to use
  29268. * @returns a string containing the source code of the fragment shader associated with the program
  29269. */
  29270. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29271. /**
  29272. * Get the current error code of the webGL context
  29273. * @returns the error code
  29274. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29275. */
  29276. getError(): number;
  29277. /**
  29278. * Gets the current framerate
  29279. * @returns a number representing the framerate
  29280. */
  29281. getFps(): number;
  29282. /**
  29283. * Gets the time spent between current and previous frame
  29284. * @returns a number representing the delta time in ms
  29285. */
  29286. getDeltaTime(): number;
  29287. private _measureFps;
  29288. /** @hidden */
  29289. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29290. private _canRenderToFloatFramebuffer;
  29291. private _canRenderToHalfFloatFramebuffer;
  29292. private _canRenderToFramebuffer;
  29293. /** @hidden */
  29294. _getWebGLTextureType(type: number): number;
  29295. /** @hidden */
  29296. _getInternalFormat(format: number): number;
  29297. /** @hidden */
  29298. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29299. /** @hidden */
  29300. _getRGBAMultiSampleBufferFormat(type: number): number;
  29301. /** @hidden */
  29302. _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;
  29303. /** @hidden */
  29304. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29305. /**
  29306. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29307. * @returns true if the engine can be created
  29308. * @ignorenaming
  29309. */
  29310. static isSupported(): boolean;
  29311. }
  29312. }
  29313. declare module BABYLON {
  29314. /**
  29315. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29316. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29317. */
  29318. export class EffectFallbacks {
  29319. private _defines;
  29320. private _currentRank;
  29321. private _maxRank;
  29322. private _mesh;
  29323. /**
  29324. * Removes the fallback from the bound mesh.
  29325. */
  29326. unBindMesh(): void;
  29327. /**
  29328. * Adds a fallback on the specified property.
  29329. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29330. * @param define The name of the define in the shader
  29331. */
  29332. addFallback(rank: number, define: string): void;
  29333. /**
  29334. * Sets the mesh to use CPU skinning when needing to fallback.
  29335. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29336. * @param mesh The mesh to use the fallbacks.
  29337. */
  29338. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29339. /**
  29340. * Checks to see if more fallbacks are still availible.
  29341. */
  29342. readonly isMoreFallbacks: boolean;
  29343. /**
  29344. * Removes the defines that should be removed when falling back.
  29345. * @param currentDefines defines the current define statements for the shader.
  29346. * @param effect defines the current effect we try to compile
  29347. * @returns The resulting defines with defines of the current rank removed.
  29348. */
  29349. reduce(currentDefines: string, effect: Effect): string;
  29350. }
  29351. /**
  29352. * Options to be used when creating an effect.
  29353. */
  29354. export class EffectCreationOptions {
  29355. /**
  29356. * Atrributes that will be used in the shader.
  29357. */
  29358. attributes: string[];
  29359. /**
  29360. * Uniform varible names that will be set in the shader.
  29361. */
  29362. uniformsNames: string[];
  29363. /**
  29364. * Uniform buffer varible names that will be set in the shader.
  29365. */
  29366. uniformBuffersNames: string[];
  29367. /**
  29368. * Sampler texture variable names that will be set in the shader.
  29369. */
  29370. samplers: string[];
  29371. /**
  29372. * Define statements that will be set in the shader.
  29373. */
  29374. defines: any;
  29375. /**
  29376. * Possible fallbacks for this effect to improve performance when needed.
  29377. */
  29378. fallbacks: Nullable<EffectFallbacks>;
  29379. /**
  29380. * Callback that will be called when the shader is compiled.
  29381. */
  29382. onCompiled: Nullable<(effect: Effect) => void>;
  29383. /**
  29384. * Callback that will be called if an error occurs during shader compilation.
  29385. */
  29386. onError: Nullable<(effect: Effect, errors: string) => void>;
  29387. /**
  29388. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29389. */
  29390. indexParameters: any;
  29391. /**
  29392. * Max number of lights that can be used in the shader.
  29393. */
  29394. maxSimultaneousLights: number;
  29395. /**
  29396. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29397. */
  29398. transformFeedbackVaryings: Nullable<string[]>;
  29399. }
  29400. /**
  29401. * Effect containing vertex and fragment shader that can be executed on an object.
  29402. */
  29403. export class Effect implements IDisposable {
  29404. /**
  29405. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29406. */
  29407. static ShadersRepository: string;
  29408. /**
  29409. * Name of the effect.
  29410. */
  29411. name: any;
  29412. /**
  29413. * String container all the define statements that should be set on the shader.
  29414. */
  29415. defines: string;
  29416. /**
  29417. * Callback that will be called when the shader is compiled.
  29418. */
  29419. onCompiled: Nullable<(effect: Effect) => void>;
  29420. /**
  29421. * Callback that will be called if an error occurs during shader compilation.
  29422. */
  29423. onError: Nullable<(effect: Effect, errors: string) => void>;
  29424. /**
  29425. * Callback that will be called when effect is bound.
  29426. */
  29427. onBind: Nullable<(effect: Effect) => void>;
  29428. /**
  29429. * Unique ID of the effect.
  29430. */
  29431. uniqueId: number;
  29432. /**
  29433. * Observable that will be called when the shader is compiled.
  29434. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29435. */
  29436. onCompileObservable: Observable<Effect>;
  29437. /**
  29438. * Observable that will be called if an error occurs during shader compilation.
  29439. */
  29440. onErrorObservable: Observable<Effect>;
  29441. /** @hidden */
  29442. _onBindObservable: Nullable<Observable<Effect>>;
  29443. /**
  29444. * Observable that will be called when effect is bound.
  29445. */
  29446. readonly onBindObservable: Observable<Effect>;
  29447. /** @hidden */
  29448. _bonesComputationForcedToCPU: boolean;
  29449. private static _uniqueIdSeed;
  29450. private _engine;
  29451. private _uniformBuffersNames;
  29452. private _uniformsNames;
  29453. private _samplerList;
  29454. private _samplers;
  29455. private _isReady;
  29456. private _compilationError;
  29457. private _attributesNames;
  29458. private _attributes;
  29459. private _uniforms;
  29460. /**
  29461. * Key for the effect.
  29462. * @hidden
  29463. */
  29464. _key: string;
  29465. private _indexParameters;
  29466. private _fallbacks;
  29467. private _vertexSourceCode;
  29468. private _fragmentSourceCode;
  29469. private _vertexSourceCodeOverride;
  29470. private _fragmentSourceCodeOverride;
  29471. private _transformFeedbackVaryings;
  29472. /**
  29473. * Compiled shader to webGL program.
  29474. * @hidden
  29475. */
  29476. _pipelineContext: Nullable<IPipelineContext>;
  29477. private _valueCache;
  29478. private static _baseCache;
  29479. /**
  29480. * Instantiates an effect.
  29481. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29482. * @param baseName Name of the effect.
  29483. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29484. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29485. * @param samplers List of sampler variables that will be passed to the shader.
  29486. * @param engine Engine to be used to render the effect
  29487. * @param defines Define statements to be added to the shader.
  29488. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29489. * @param onCompiled Callback that will be called when the shader is compiled.
  29490. * @param onError Callback that will be called if an error occurs during shader compilation.
  29491. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29492. */
  29493. 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);
  29494. private _useFinalCode;
  29495. /**
  29496. * Unique key for this effect
  29497. */
  29498. readonly key: string;
  29499. /**
  29500. * If the effect has been compiled and prepared.
  29501. * @returns if the effect is compiled and prepared.
  29502. */
  29503. isReady(): boolean;
  29504. /**
  29505. * The engine the effect was initialized with.
  29506. * @returns the engine.
  29507. */
  29508. getEngine(): Engine;
  29509. /**
  29510. * The pipeline context for this effect
  29511. * @returns the associated pipeline context
  29512. */
  29513. getPipelineContext(): Nullable<IPipelineContext>;
  29514. /**
  29515. * The set of names of attribute variables for the shader.
  29516. * @returns An array of attribute names.
  29517. */
  29518. getAttributesNames(): string[];
  29519. /**
  29520. * Returns the attribute at the given index.
  29521. * @param index The index of the attribute.
  29522. * @returns The location of the attribute.
  29523. */
  29524. getAttributeLocation(index: number): number;
  29525. /**
  29526. * Returns the attribute based on the name of the variable.
  29527. * @param name of the attribute to look up.
  29528. * @returns the attribute location.
  29529. */
  29530. getAttributeLocationByName(name: string): number;
  29531. /**
  29532. * The number of attributes.
  29533. * @returns the numnber of attributes.
  29534. */
  29535. getAttributesCount(): number;
  29536. /**
  29537. * Gets the index of a uniform variable.
  29538. * @param uniformName of the uniform to look up.
  29539. * @returns the index.
  29540. */
  29541. getUniformIndex(uniformName: string): number;
  29542. /**
  29543. * Returns the attribute based on the name of the variable.
  29544. * @param uniformName of the uniform to look up.
  29545. * @returns the location of the uniform.
  29546. */
  29547. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29548. /**
  29549. * Returns an array of sampler variable names
  29550. * @returns The array of sampler variable neames.
  29551. */
  29552. getSamplers(): string[];
  29553. /**
  29554. * The error from the last compilation.
  29555. * @returns the error string.
  29556. */
  29557. getCompilationError(): string;
  29558. /**
  29559. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29560. * @param func The callback to be used.
  29561. */
  29562. executeWhenCompiled(func: (effect: Effect) => void): void;
  29563. private _checkIsReady;
  29564. /** @hidden */
  29565. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29566. /** @hidden */
  29567. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29568. /** @hidden */
  29569. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29570. /**
  29571. * Recompiles the webGL program
  29572. * @param vertexSourceCode The source code for the vertex shader.
  29573. * @param fragmentSourceCode The source code for the fragment shader.
  29574. * @param onCompiled Callback called when completed.
  29575. * @param onError Callback called on error.
  29576. * @hidden
  29577. */
  29578. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29579. /**
  29580. * Prepares the effect
  29581. * @hidden
  29582. */
  29583. _prepareEffect(): void;
  29584. /**
  29585. * Checks if the effect is supported. (Must be called after compilation)
  29586. */
  29587. readonly isSupported: boolean;
  29588. /**
  29589. * Binds a texture to the engine to be used as output of the shader.
  29590. * @param channel Name of the output variable.
  29591. * @param texture Texture to bind.
  29592. * @hidden
  29593. */
  29594. _bindTexture(channel: string, texture: InternalTexture): void;
  29595. /**
  29596. * Sets a texture on the engine to be used in the shader.
  29597. * @param channel Name of the sampler variable.
  29598. * @param texture Texture to set.
  29599. */
  29600. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29601. /**
  29602. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29603. * @param channel Name of the sampler variable.
  29604. * @param texture Texture to set.
  29605. */
  29606. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29607. /**
  29608. * Sets an array of textures on the engine to be used in the shader.
  29609. * @param channel Name of the variable.
  29610. * @param textures Textures to set.
  29611. */
  29612. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29613. /**
  29614. * 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)
  29615. * @param channel Name of the sampler variable.
  29616. * @param postProcess Post process to get the input texture from.
  29617. */
  29618. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29619. /**
  29620. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29621. * 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)
  29622. * @param channel Name of the sampler variable.
  29623. * @param postProcess Post process to get the output texture from.
  29624. */
  29625. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29626. /** @hidden */
  29627. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29628. /** @hidden */
  29629. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29630. /** @hidden */
  29631. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29632. /** @hidden */
  29633. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29634. /**
  29635. * Binds a buffer to a uniform.
  29636. * @param buffer Buffer to bind.
  29637. * @param name Name of the uniform variable to bind to.
  29638. */
  29639. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29640. /**
  29641. * Binds block to a uniform.
  29642. * @param blockName Name of the block to bind.
  29643. * @param index Index to bind.
  29644. */
  29645. bindUniformBlock(blockName: string, index: number): void;
  29646. /**
  29647. * Sets an interger value on a uniform variable.
  29648. * @param uniformName Name of the variable.
  29649. * @param value Value to be set.
  29650. * @returns this effect.
  29651. */
  29652. setInt(uniformName: string, value: number): Effect;
  29653. /**
  29654. * Sets an int array on a uniform variable.
  29655. * @param uniformName Name of the variable.
  29656. * @param array array to be set.
  29657. * @returns this effect.
  29658. */
  29659. setIntArray(uniformName: string, array: Int32Array): Effect;
  29660. /**
  29661. * 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)
  29662. * @param uniformName Name of the variable.
  29663. * @param array array to be set.
  29664. * @returns this effect.
  29665. */
  29666. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29667. /**
  29668. * 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)
  29669. * @param uniformName Name of the variable.
  29670. * @param array array to be set.
  29671. * @returns this effect.
  29672. */
  29673. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29674. /**
  29675. * 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)
  29676. * @param uniformName Name of the variable.
  29677. * @param array array to be set.
  29678. * @returns this effect.
  29679. */
  29680. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29681. /**
  29682. * Sets an float array on a uniform variable.
  29683. * @param uniformName Name of the variable.
  29684. * @param array array to be set.
  29685. * @returns this effect.
  29686. */
  29687. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29688. /**
  29689. * 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)
  29690. * @param uniformName Name of the variable.
  29691. * @param array array to be set.
  29692. * @returns this effect.
  29693. */
  29694. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29695. /**
  29696. * 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)
  29697. * @param uniformName Name of the variable.
  29698. * @param array array to be set.
  29699. * @returns this effect.
  29700. */
  29701. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29702. /**
  29703. * 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)
  29704. * @param uniformName Name of the variable.
  29705. * @param array array to be set.
  29706. * @returns this effect.
  29707. */
  29708. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29709. /**
  29710. * Sets an array on a uniform variable.
  29711. * @param uniformName Name of the variable.
  29712. * @param array array to be set.
  29713. * @returns this effect.
  29714. */
  29715. setArray(uniformName: string, array: number[]): Effect;
  29716. /**
  29717. * 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)
  29718. * @param uniformName Name of the variable.
  29719. * @param array array to be set.
  29720. * @returns this effect.
  29721. */
  29722. setArray2(uniformName: string, array: number[]): Effect;
  29723. /**
  29724. * 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)
  29725. * @param uniformName Name of the variable.
  29726. * @param array array to be set.
  29727. * @returns this effect.
  29728. */
  29729. setArray3(uniformName: string, array: number[]): Effect;
  29730. /**
  29731. * 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)
  29732. * @param uniformName Name of the variable.
  29733. * @param array array to be set.
  29734. * @returns this effect.
  29735. */
  29736. setArray4(uniformName: string, array: number[]): Effect;
  29737. /**
  29738. * Sets matrices on a uniform variable.
  29739. * @param uniformName Name of the variable.
  29740. * @param matrices matrices to be set.
  29741. * @returns this effect.
  29742. */
  29743. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29744. /**
  29745. * Sets matrix on a uniform variable.
  29746. * @param uniformName Name of the variable.
  29747. * @param matrix matrix to be set.
  29748. * @returns this effect.
  29749. */
  29750. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29751. /**
  29752. * 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)
  29753. * @param uniformName Name of the variable.
  29754. * @param matrix matrix to be set.
  29755. * @returns this effect.
  29756. */
  29757. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29758. /**
  29759. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29760. * @param uniformName Name of the variable.
  29761. * @param matrix matrix to be set.
  29762. * @returns this effect.
  29763. */
  29764. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29765. /**
  29766. * Sets a float on a uniform variable.
  29767. * @param uniformName Name of the variable.
  29768. * @param value value to be set.
  29769. * @returns this effect.
  29770. */
  29771. setFloat(uniformName: string, value: number): Effect;
  29772. /**
  29773. * Sets a boolean on a uniform variable.
  29774. * @param uniformName Name of the variable.
  29775. * @param bool value to be set.
  29776. * @returns this effect.
  29777. */
  29778. setBool(uniformName: string, bool: boolean): Effect;
  29779. /**
  29780. * Sets a Vector2 on a uniform variable.
  29781. * @param uniformName Name of the variable.
  29782. * @param vector2 vector2 to be set.
  29783. * @returns this effect.
  29784. */
  29785. setVector2(uniformName: string, vector2: Vector2): Effect;
  29786. /**
  29787. * Sets a float2 on a uniform variable.
  29788. * @param uniformName Name of the variable.
  29789. * @param x First float in float2.
  29790. * @param y Second float in float2.
  29791. * @returns this effect.
  29792. */
  29793. setFloat2(uniformName: string, x: number, y: number): Effect;
  29794. /**
  29795. * Sets a Vector3 on a uniform variable.
  29796. * @param uniformName Name of the variable.
  29797. * @param vector3 Value to be set.
  29798. * @returns this effect.
  29799. */
  29800. setVector3(uniformName: string, vector3: Vector3): Effect;
  29801. /**
  29802. * Sets a float3 on a uniform variable.
  29803. * @param uniformName Name of the variable.
  29804. * @param x First float in float3.
  29805. * @param y Second float in float3.
  29806. * @param z Third float in float3.
  29807. * @returns this effect.
  29808. */
  29809. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29810. /**
  29811. * Sets a Vector4 on a uniform variable.
  29812. * @param uniformName Name of the variable.
  29813. * @param vector4 Value to be set.
  29814. * @returns this effect.
  29815. */
  29816. setVector4(uniformName: string, vector4: Vector4): Effect;
  29817. /**
  29818. * Sets a float4 on a uniform variable.
  29819. * @param uniformName Name of the variable.
  29820. * @param x First float in float4.
  29821. * @param y Second float in float4.
  29822. * @param z Third float in float4.
  29823. * @param w Fourth float in float4.
  29824. * @returns this effect.
  29825. */
  29826. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29827. /**
  29828. * Sets a Color3 on a uniform variable.
  29829. * @param uniformName Name of the variable.
  29830. * @param color3 Value to be set.
  29831. * @returns this effect.
  29832. */
  29833. setColor3(uniformName: string, color3: Color3): Effect;
  29834. /**
  29835. * Sets a Color4 on a uniform variable.
  29836. * @param uniformName Name of the variable.
  29837. * @param color3 Value to be set.
  29838. * @param alpha Alpha value to be set.
  29839. * @returns this effect.
  29840. */
  29841. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29842. /**
  29843. * Sets a Color4 on a uniform variable
  29844. * @param uniformName defines the name of the variable
  29845. * @param color4 defines the value to be set
  29846. * @returns this effect.
  29847. */
  29848. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29849. /** Release all associated resources */
  29850. dispose(): void;
  29851. /**
  29852. * This function will add a new shader to the shader store
  29853. * @param name the name of the shader
  29854. * @param pixelShader optional pixel shader content
  29855. * @param vertexShader optional vertex shader content
  29856. */
  29857. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29858. /**
  29859. * Store of each shader (The can be looked up using effect.key)
  29860. */
  29861. static ShadersStore: {
  29862. [key: string]: string;
  29863. };
  29864. /**
  29865. * Store of each included file for a shader (The can be looked up using effect.key)
  29866. */
  29867. static IncludesShadersStore: {
  29868. [key: string]: string;
  29869. };
  29870. /**
  29871. * Resets the cache of effects.
  29872. */
  29873. static ResetCache(): void;
  29874. }
  29875. }
  29876. declare module BABYLON {
  29877. /**
  29878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29880. * 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;
  29881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29882. */
  29883. export class ColorCurves {
  29884. private _dirty;
  29885. private _tempColor;
  29886. private _globalCurve;
  29887. private _highlightsCurve;
  29888. private _midtonesCurve;
  29889. private _shadowsCurve;
  29890. private _positiveCurve;
  29891. private _negativeCurve;
  29892. private _globalHue;
  29893. private _globalDensity;
  29894. private _globalSaturation;
  29895. private _globalExposure;
  29896. /**
  29897. * Gets the global Hue value.
  29898. * 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).
  29899. */
  29900. /**
  29901. * Sets the global Hue value.
  29902. * 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).
  29903. */
  29904. globalHue: number;
  29905. /**
  29906. * Gets the global Density value.
  29907. * 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.
  29908. * Values less than zero provide a filter of opposite hue.
  29909. */
  29910. /**
  29911. * Sets the global Density value.
  29912. * 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.
  29913. * Values less than zero provide a filter of opposite hue.
  29914. */
  29915. globalDensity: number;
  29916. /**
  29917. * Gets the global Saturation value.
  29918. * 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.
  29919. */
  29920. /**
  29921. * Sets the global Saturation value.
  29922. * 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.
  29923. */
  29924. globalSaturation: number;
  29925. /**
  29926. * Gets the global Exposure value.
  29927. * 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.
  29928. */
  29929. /**
  29930. * Sets the global Exposure value.
  29931. * 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.
  29932. */
  29933. globalExposure: number;
  29934. private _highlightsHue;
  29935. private _highlightsDensity;
  29936. private _highlightsSaturation;
  29937. private _highlightsExposure;
  29938. /**
  29939. * Gets the highlights Hue value.
  29940. * 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).
  29941. */
  29942. /**
  29943. * Sets the highlights Hue value.
  29944. * 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).
  29945. */
  29946. highlightsHue: number;
  29947. /**
  29948. * Gets the highlights Density value.
  29949. * 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.
  29950. * Values less than zero provide a filter of opposite hue.
  29951. */
  29952. /**
  29953. * Sets the highlights Density value.
  29954. * 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.
  29955. * Values less than zero provide a filter of opposite hue.
  29956. */
  29957. highlightsDensity: number;
  29958. /**
  29959. * Gets the highlights Saturation value.
  29960. * 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.
  29961. */
  29962. /**
  29963. * Sets the highlights Saturation value.
  29964. * 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.
  29965. */
  29966. highlightsSaturation: number;
  29967. /**
  29968. * Gets the highlights Exposure value.
  29969. * 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.
  29970. */
  29971. /**
  29972. * Sets the highlights Exposure value.
  29973. * 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.
  29974. */
  29975. highlightsExposure: number;
  29976. private _midtonesHue;
  29977. private _midtonesDensity;
  29978. private _midtonesSaturation;
  29979. private _midtonesExposure;
  29980. /**
  29981. * Gets the midtones Hue value.
  29982. * 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).
  29983. */
  29984. /**
  29985. * Sets the midtones Hue value.
  29986. * 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).
  29987. */
  29988. midtonesHue: number;
  29989. /**
  29990. * Gets the midtones Density value.
  29991. * 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.
  29992. * Values less than zero provide a filter of opposite hue.
  29993. */
  29994. /**
  29995. * Sets the midtones Density value.
  29996. * 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.
  29997. * Values less than zero provide a filter of opposite hue.
  29998. */
  29999. midtonesDensity: number;
  30000. /**
  30001. * Gets the midtones Saturation value.
  30002. * 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.
  30003. */
  30004. /**
  30005. * Sets the midtones Saturation value.
  30006. * 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.
  30007. */
  30008. midtonesSaturation: number;
  30009. /**
  30010. * Gets the midtones Exposure value.
  30011. * 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.
  30012. */
  30013. /**
  30014. * Sets the midtones Exposure value.
  30015. * 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.
  30016. */
  30017. midtonesExposure: number;
  30018. private _shadowsHue;
  30019. private _shadowsDensity;
  30020. private _shadowsSaturation;
  30021. private _shadowsExposure;
  30022. /**
  30023. * Gets the shadows Hue value.
  30024. * 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).
  30025. */
  30026. /**
  30027. * Sets the shadows Hue value.
  30028. * 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).
  30029. */
  30030. shadowsHue: number;
  30031. /**
  30032. * Gets the shadows Density value.
  30033. * 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.
  30034. * Values less than zero provide a filter of opposite hue.
  30035. */
  30036. /**
  30037. * Sets the shadows Density value.
  30038. * 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.
  30039. * Values less than zero provide a filter of opposite hue.
  30040. */
  30041. shadowsDensity: number;
  30042. /**
  30043. * Gets the shadows Saturation value.
  30044. * 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.
  30045. */
  30046. /**
  30047. * Sets the shadows Saturation value.
  30048. * 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.
  30049. */
  30050. shadowsSaturation: number;
  30051. /**
  30052. * Gets the shadows Exposure value.
  30053. * 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.
  30054. */
  30055. /**
  30056. * Sets the shadows Exposure value.
  30057. * 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.
  30058. */
  30059. shadowsExposure: number;
  30060. /**
  30061. * Returns the class name
  30062. * @returns The class name
  30063. */
  30064. getClassName(): string;
  30065. /**
  30066. * Binds the color curves to the shader.
  30067. * @param colorCurves The color curve to bind
  30068. * @param effect The effect to bind to
  30069. * @param positiveUniform The positive uniform shader parameter
  30070. * @param neutralUniform The neutral uniform shader parameter
  30071. * @param negativeUniform The negative uniform shader parameter
  30072. */
  30073. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30074. /**
  30075. * Prepare the list of uniforms associated with the ColorCurves effects.
  30076. * @param uniformsList The list of uniforms used in the effect
  30077. */
  30078. static PrepareUniforms(uniformsList: string[]): void;
  30079. /**
  30080. * Returns color grading data based on a hue, density, saturation and exposure value.
  30081. * @param filterHue The hue of the color filter.
  30082. * @param filterDensity The density of the color filter.
  30083. * @param saturation The saturation.
  30084. * @param exposure The exposure.
  30085. * @param result The result data container.
  30086. */
  30087. private getColorGradingDataToRef;
  30088. /**
  30089. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30090. * @param value The input slider value in range [-100,100].
  30091. * @returns Adjusted value.
  30092. */
  30093. private static applyColorGradingSliderNonlinear;
  30094. /**
  30095. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30096. * @param hue The hue (H) input.
  30097. * @param saturation The saturation (S) input.
  30098. * @param brightness The brightness (B) input.
  30099. * @result An RGBA color represented as Vector4.
  30100. */
  30101. private static fromHSBToRef;
  30102. /**
  30103. * Returns a value clamped between min and max
  30104. * @param value The value to clamp
  30105. * @param min The minimum of value
  30106. * @param max The maximum of value
  30107. * @returns The clamped value.
  30108. */
  30109. private static clamp;
  30110. /**
  30111. * Clones the current color curve instance.
  30112. * @return The cloned curves
  30113. */
  30114. clone(): ColorCurves;
  30115. /**
  30116. * Serializes the current color curve instance to a json representation.
  30117. * @return a JSON representation
  30118. */
  30119. serialize(): any;
  30120. /**
  30121. * Parses the color curve from a json representation.
  30122. * @param source the JSON source to parse
  30123. * @return The parsed curves
  30124. */
  30125. static Parse(source: any): ColorCurves;
  30126. }
  30127. }
  30128. declare module BABYLON {
  30129. /**
  30130. * Interface to follow in your material defines to integrate easily the
  30131. * Image proccessing functions.
  30132. * @hidden
  30133. */
  30134. export interface IImageProcessingConfigurationDefines {
  30135. IMAGEPROCESSING: boolean;
  30136. VIGNETTE: boolean;
  30137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30138. VIGNETTEBLENDMODEOPAQUE: boolean;
  30139. TONEMAPPING: boolean;
  30140. TONEMAPPING_ACES: boolean;
  30141. CONTRAST: boolean;
  30142. EXPOSURE: boolean;
  30143. COLORCURVES: boolean;
  30144. COLORGRADING: boolean;
  30145. COLORGRADING3D: boolean;
  30146. SAMPLER3DGREENDEPTH: boolean;
  30147. SAMPLER3DBGRMAP: boolean;
  30148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30149. }
  30150. /**
  30151. * @hidden
  30152. */
  30153. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30154. IMAGEPROCESSING: boolean;
  30155. VIGNETTE: boolean;
  30156. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30157. VIGNETTEBLENDMODEOPAQUE: boolean;
  30158. TONEMAPPING: boolean;
  30159. TONEMAPPING_ACES: boolean;
  30160. CONTRAST: boolean;
  30161. COLORCURVES: boolean;
  30162. COLORGRADING: boolean;
  30163. COLORGRADING3D: boolean;
  30164. SAMPLER3DGREENDEPTH: boolean;
  30165. SAMPLER3DBGRMAP: boolean;
  30166. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30167. EXPOSURE: boolean;
  30168. constructor();
  30169. }
  30170. /**
  30171. * This groups together the common properties used for image processing either in direct forward pass
  30172. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30173. * or not.
  30174. */
  30175. export class ImageProcessingConfiguration {
  30176. /**
  30177. * Default tone mapping applied in BabylonJS.
  30178. */
  30179. static readonly TONEMAPPING_STANDARD: number;
  30180. /**
  30181. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30182. * to other engines rendering to increase portability.
  30183. */
  30184. static readonly TONEMAPPING_ACES: number;
  30185. /**
  30186. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30187. */
  30188. colorCurves: Nullable<ColorCurves>;
  30189. private _colorCurvesEnabled;
  30190. /**
  30191. * Gets wether the color curves effect is enabled.
  30192. */
  30193. /**
  30194. * Sets wether the color curves effect is enabled.
  30195. */
  30196. colorCurvesEnabled: boolean;
  30197. private _colorGradingTexture;
  30198. /**
  30199. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30200. */
  30201. /**
  30202. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30203. */
  30204. colorGradingTexture: Nullable<BaseTexture>;
  30205. private _colorGradingEnabled;
  30206. /**
  30207. * Gets wether the color grading effect is enabled.
  30208. */
  30209. /**
  30210. * Sets wether the color grading effect is enabled.
  30211. */
  30212. colorGradingEnabled: boolean;
  30213. private _colorGradingWithGreenDepth;
  30214. /**
  30215. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30216. */
  30217. /**
  30218. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30219. */
  30220. colorGradingWithGreenDepth: boolean;
  30221. private _colorGradingBGR;
  30222. /**
  30223. * Gets wether the color grading texture contains BGR values.
  30224. */
  30225. /**
  30226. * Sets wether the color grading texture contains BGR values.
  30227. */
  30228. colorGradingBGR: boolean;
  30229. /** @hidden */
  30230. _exposure: number;
  30231. /**
  30232. * Gets the Exposure used in the effect.
  30233. */
  30234. /**
  30235. * Sets the Exposure used in the effect.
  30236. */
  30237. exposure: number;
  30238. private _toneMappingEnabled;
  30239. /**
  30240. * Gets wether the tone mapping effect is enabled.
  30241. */
  30242. /**
  30243. * Sets wether the tone mapping effect is enabled.
  30244. */
  30245. toneMappingEnabled: boolean;
  30246. private _toneMappingType;
  30247. /**
  30248. * Gets the type of tone mapping effect.
  30249. */
  30250. /**
  30251. * Sets the type of tone mapping effect used in BabylonJS.
  30252. */
  30253. toneMappingType: number;
  30254. protected _contrast: number;
  30255. /**
  30256. * Gets the contrast used in the effect.
  30257. */
  30258. /**
  30259. * Sets the contrast used in the effect.
  30260. */
  30261. contrast: number;
  30262. /**
  30263. * Vignette stretch size.
  30264. */
  30265. vignetteStretch: number;
  30266. /**
  30267. * Vignette centre X Offset.
  30268. */
  30269. vignetteCentreX: number;
  30270. /**
  30271. * Vignette centre Y Offset.
  30272. */
  30273. vignetteCentreY: number;
  30274. /**
  30275. * Vignette weight or intensity of the vignette effect.
  30276. */
  30277. vignetteWeight: number;
  30278. /**
  30279. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30280. * if vignetteEnabled is set to true.
  30281. */
  30282. vignetteColor: Color4;
  30283. /**
  30284. * Camera field of view used by the Vignette effect.
  30285. */
  30286. vignetteCameraFov: number;
  30287. private _vignetteBlendMode;
  30288. /**
  30289. * Gets the vignette blend mode allowing different kind of effect.
  30290. */
  30291. /**
  30292. * Sets the vignette blend mode allowing different kind of effect.
  30293. */
  30294. vignetteBlendMode: number;
  30295. private _vignetteEnabled;
  30296. /**
  30297. * Gets wether the vignette effect is enabled.
  30298. */
  30299. /**
  30300. * Sets wether the vignette effect is enabled.
  30301. */
  30302. vignetteEnabled: boolean;
  30303. private _applyByPostProcess;
  30304. /**
  30305. * Gets wether the image processing is applied through a post process or not.
  30306. */
  30307. /**
  30308. * Sets wether the image processing is applied through a post process or not.
  30309. */
  30310. applyByPostProcess: boolean;
  30311. private _isEnabled;
  30312. /**
  30313. * Gets wether the image processing is enabled or not.
  30314. */
  30315. /**
  30316. * Sets wether the image processing is enabled or not.
  30317. */
  30318. isEnabled: boolean;
  30319. /**
  30320. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30321. */
  30322. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30323. /**
  30324. * Method called each time the image processing information changes requires to recompile the effect.
  30325. */
  30326. protected _updateParameters(): void;
  30327. /**
  30328. * Gets the current class name.
  30329. * @return "ImageProcessingConfiguration"
  30330. */
  30331. getClassName(): string;
  30332. /**
  30333. * Prepare the list of uniforms associated with the Image Processing effects.
  30334. * @param uniforms The list of uniforms used in the effect
  30335. * @param defines the list of defines currently in use
  30336. */
  30337. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30338. /**
  30339. * Prepare the list of samplers associated with the Image Processing effects.
  30340. * @param samplersList The list of uniforms used in the effect
  30341. * @param defines the list of defines currently in use
  30342. */
  30343. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30344. /**
  30345. * Prepare the list of defines associated to the shader.
  30346. * @param defines the list of defines to complete
  30347. * @param forPostProcess Define if we are currently in post process mode or not
  30348. */
  30349. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30350. /**
  30351. * Returns true if all the image processing information are ready.
  30352. * @returns True if ready, otherwise, false
  30353. */
  30354. isReady(): boolean;
  30355. /**
  30356. * Binds the image processing to the shader.
  30357. * @param effect The effect to bind to
  30358. * @param aspectRatio Define the current aspect ratio of the effect
  30359. */
  30360. bind(effect: Effect, aspectRatio?: number): void;
  30361. /**
  30362. * Clones the current image processing instance.
  30363. * @return The cloned image processing
  30364. */
  30365. clone(): ImageProcessingConfiguration;
  30366. /**
  30367. * Serializes the current image processing instance to a json representation.
  30368. * @return a JSON representation
  30369. */
  30370. serialize(): any;
  30371. /**
  30372. * Parses the image processing from a json representation.
  30373. * @param source the JSON source to parse
  30374. * @return The parsed image processing
  30375. */
  30376. static Parse(source: any): ImageProcessingConfiguration;
  30377. private static _VIGNETTEMODE_MULTIPLY;
  30378. private static _VIGNETTEMODE_OPAQUE;
  30379. /**
  30380. * Used to apply the vignette as a mix with the pixel color.
  30381. */
  30382. static readonly VIGNETTEMODE_MULTIPLY: number;
  30383. /**
  30384. * Used to apply the vignette as a replacement of the pixel color.
  30385. */
  30386. static readonly VIGNETTEMODE_OPAQUE: number;
  30387. }
  30388. }
  30389. declare module BABYLON {
  30390. /**
  30391. * This represents all the required information to add a fresnel effect on a material:
  30392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30393. */
  30394. export class FresnelParameters {
  30395. private _isEnabled;
  30396. /**
  30397. * Define if the fresnel effect is enable or not.
  30398. */
  30399. isEnabled: boolean;
  30400. /**
  30401. * Define the color used on edges (grazing angle)
  30402. */
  30403. leftColor: Color3;
  30404. /**
  30405. * Define the color used on center
  30406. */
  30407. rightColor: Color3;
  30408. /**
  30409. * Define bias applied to computed fresnel term
  30410. */
  30411. bias: number;
  30412. /**
  30413. * Defined the power exponent applied to fresnel term
  30414. */
  30415. power: number;
  30416. /**
  30417. * Clones the current fresnel and its valuues
  30418. * @returns a clone fresnel configuration
  30419. */
  30420. clone(): FresnelParameters;
  30421. /**
  30422. * Serializes the current fresnel parameters to a JSON representation.
  30423. * @return the JSON serialization
  30424. */
  30425. serialize(): any;
  30426. /**
  30427. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30428. * @param parsedFresnelParameters Define the JSON representation
  30429. * @returns the parsed parameters
  30430. */
  30431. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30432. }
  30433. }
  30434. declare module BABYLON {
  30435. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30436. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30437. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30446. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30447. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30448. /**
  30449. * Decorator used to define property that can be serialized as reference to a camera
  30450. * @param sourceName defines the name of the property to decorate
  30451. */
  30452. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30453. /**
  30454. * Class used to help serialization objects
  30455. */
  30456. export class SerializationHelper {
  30457. /** @hidden */
  30458. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30459. /** @hidden */
  30460. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30461. /** @hidden */
  30462. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30463. /** @hidden */
  30464. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30465. /**
  30466. * Appends the serialized animations from the source animations
  30467. * @param source Source containing the animations
  30468. * @param destination Target to store the animations
  30469. */
  30470. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30471. /**
  30472. * Static function used to serialized a specific entity
  30473. * @param entity defines the entity to serialize
  30474. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30475. * @returns a JSON compatible object representing the serialization of the entity
  30476. */
  30477. static Serialize<T>(entity: T, serializationObject?: any): any;
  30478. /**
  30479. * Creates a new entity from a serialization data object
  30480. * @param creationFunction defines a function used to instanciated the new entity
  30481. * @param source defines the source serialization data
  30482. * @param scene defines the hosting scene
  30483. * @param rootUrl defines the root url for resources
  30484. * @returns a new entity
  30485. */
  30486. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30487. /**
  30488. * Clones an object
  30489. * @param creationFunction defines the function used to instanciate the new object
  30490. * @param source defines the source object
  30491. * @returns the cloned object
  30492. */
  30493. static Clone<T>(creationFunction: () => T, source: T): T;
  30494. /**
  30495. * Instanciates a new object based on a source one (some data will be shared between both object)
  30496. * @param creationFunction defines the function used to instanciate the new object
  30497. * @param source defines the source object
  30498. * @returns the new object
  30499. */
  30500. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30501. }
  30502. }
  30503. declare module BABYLON {
  30504. /**
  30505. * This is the base class of all the camera used in the application.
  30506. * @see http://doc.babylonjs.com/features/cameras
  30507. */
  30508. export class Camera extends Node {
  30509. /** @hidden */
  30510. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30511. /**
  30512. * This is the default projection mode used by the cameras.
  30513. * It helps recreating a feeling of perspective and better appreciate depth.
  30514. * This is the best way to simulate real life cameras.
  30515. */
  30516. static readonly PERSPECTIVE_CAMERA: number;
  30517. /**
  30518. * This helps creating camera with an orthographic mode.
  30519. * 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.
  30520. */
  30521. static readonly ORTHOGRAPHIC_CAMERA: number;
  30522. /**
  30523. * This is the default FOV mode for perspective cameras.
  30524. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30525. */
  30526. static readonly FOVMODE_VERTICAL_FIXED: number;
  30527. /**
  30528. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30529. */
  30530. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30531. /**
  30532. * This specifies ther is no need for a camera rig.
  30533. * Basically only one eye is rendered corresponding to the camera.
  30534. */
  30535. static readonly RIG_MODE_NONE: number;
  30536. /**
  30537. * Simulates a camera Rig with one blue eye and one red eye.
  30538. * This can be use with 3d blue and red glasses.
  30539. */
  30540. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30541. /**
  30542. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30543. */
  30544. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30545. /**
  30546. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30547. */
  30548. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30549. /**
  30550. * Defines that both eyes of the camera will be rendered over under each other.
  30551. */
  30552. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30553. /**
  30554. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30555. */
  30556. static readonly RIG_MODE_VR: number;
  30557. /**
  30558. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30559. */
  30560. static readonly RIG_MODE_WEBVR: number;
  30561. /**
  30562. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30563. */
  30564. static readonly RIG_MODE_CUSTOM: number;
  30565. /**
  30566. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30567. */
  30568. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30569. /**
  30570. * Define the input manager associated with the camera.
  30571. */
  30572. inputs: CameraInputsManager<Camera>;
  30573. /** @hidden */
  30574. _position: Vector3;
  30575. /**
  30576. * Define the current local position of the camera in the scene
  30577. */
  30578. position: Vector3;
  30579. /**
  30580. * The vector the camera should consider as up.
  30581. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30582. */
  30583. upVector: Vector3;
  30584. /**
  30585. * Define the current limit on the left side for an orthographic camera
  30586. * In scene unit
  30587. */
  30588. orthoLeft: Nullable<number>;
  30589. /**
  30590. * Define the current limit on the right side for an orthographic camera
  30591. * In scene unit
  30592. */
  30593. orthoRight: Nullable<number>;
  30594. /**
  30595. * Define the current limit on the bottom side for an orthographic camera
  30596. * In scene unit
  30597. */
  30598. orthoBottom: Nullable<number>;
  30599. /**
  30600. * Define the current limit on the top side for an orthographic camera
  30601. * In scene unit
  30602. */
  30603. orthoTop: Nullable<number>;
  30604. /**
  30605. * Field Of View is set in Radians. (default is 0.8)
  30606. */
  30607. fov: number;
  30608. /**
  30609. * Define the minimum distance the camera can see from.
  30610. * This is important to note that the depth buffer are not infinite and the closer it starts
  30611. * the more your scene might encounter depth fighting issue.
  30612. */
  30613. minZ: number;
  30614. /**
  30615. * Define the maximum distance the camera can see to.
  30616. * This is important to note that the depth buffer are not infinite and the further it end
  30617. * the more your scene might encounter depth fighting issue.
  30618. */
  30619. maxZ: number;
  30620. /**
  30621. * Define the default inertia of the camera.
  30622. * This helps giving a smooth feeling to the camera movement.
  30623. */
  30624. inertia: number;
  30625. /**
  30626. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30627. */
  30628. mode: number;
  30629. /**
  30630. * Define wether the camera is intermediate.
  30631. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30632. */
  30633. isIntermediate: boolean;
  30634. /**
  30635. * Define the viewport of the camera.
  30636. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30637. */
  30638. viewport: Viewport;
  30639. /**
  30640. * Restricts the camera to viewing objects with the same layerMask.
  30641. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30642. */
  30643. layerMask: number;
  30644. /**
  30645. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30646. */
  30647. fovMode: number;
  30648. /**
  30649. * Rig mode of the camera.
  30650. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30651. * This is normally controlled byt the camera themselves as internal use.
  30652. */
  30653. cameraRigMode: number;
  30654. /**
  30655. * Defines the distance between both "eyes" in case of a RIG
  30656. */
  30657. interaxialDistance: number;
  30658. /**
  30659. * Defines if stereoscopic rendering is done side by side or over under.
  30660. */
  30661. isStereoscopicSideBySide: boolean;
  30662. /**
  30663. * 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
  30664. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30665. * else in the scene.
  30666. */
  30667. customRenderTargets: RenderTargetTexture[];
  30668. /**
  30669. * When set, the camera will render to this render target instead of the default canvas
  30670. */
  30671. outputRenderTarget: Nullable<RenderTargetTexture>;
  30672. /**
  30673. * Observable triggered when the camera view matrix has changed.
  30674. */
  30675. onViewMatrixChangedObservable: Observable<Camera>;
  30676. /**
  30677. * Observable triggered when the camera Projection matrix has changed.
  30678. */
  30679. onProjectionMatrixChangedObservable: Observable<Camera>;
  30680. /**
  30681. * Observable triggered when the inputs have been processed.
  30682. */
  30683. onAfterCheckInputsObservable: Observable<Camera>;
  30684. /**
  30685. * Observable triggered when reset has been called and applied to the camera.
  30686. */
  30687. onRestoreStateObservable: Observable<Camera>;
  30688. /** @hidden */
  30689. _cameraRigParams: any;
  30690. /** @hidden */
  30691. _rigCameras: Camera[];
  30692. /** @hidden */
  30693. _rigPostProcess: Nullable<PostProcess>;
  30694. protected _webvrViewMatrix: Matrix;
  30695. /** @hidden */
  30696. _skipRendering: boolean;
  30697. /** @hidden */
  30698. _projectionMatrix: Matrix;
  30699. /** @hidden */
  30700. _postProcesses: Nullable<PostProcess>[];
  30701. /** @hidden */
  30702. _activeMeshes: SmartArray<AbstractMesh>;
  30703. protected _globalPosition: Vector3;
  30704. /** @hidden */
  30705. _computedViewMatrix: Matrix;
  30706. private _doNotComputeProjectionMatrix;
  30707. private _transformMatrix;
  30708. private _frustumPlanes;
  30709. private _refreshFrustumPlanes;
  30710. private _storedFov;
  30711. private _stateStored;
  30712. /**
  30713. * Instantiates a new camera object.
  30714. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30715. * @see http://doc.babylonjs.com/features/cameras
  30716. * @param name Defines the name of the camera in the scene
  30717. * @param position Defines the position of the camera
  30718. * @param scene Defines the scene the camera belongs too
  30719. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30720. */
  30721. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30722. /**
  30723. * Store current camera state (fov, position, etc..)
  30724. * @returns the camera
  30725. */
  30726. storeState(): Camera;
  30727. /**
  30728. * Restores the camera state values if it has been stored. You must call storeState() first
  30729. */
  30730. protected _restoreStateValues(): boolean;
  30731. /**
  30732. * Restored camera state. You must call storeState() first.
  30733. * @returns true if restored and false otherwise
  30734. */
  30735. restoreState(): boolean;
  30736. /**
  30737. * Gets the class name of the camera.
  30738. * @returns the class name
  30739. */
  30740. getClassName(): string;
  30741. /** @hidden */
  30742. readonly _isCamera: boolean;
  30743. /**
  30744. * Gets a string representation of the camera useful for debug purpose.
  30745. * @param fullDetails Defines that a more verboe level of logging is required
  30746. * @returns the string representation
  30747. */
  30748. toString(fullDetails?: boolean): string;
  30749. /**
  30750. * Gets the current world space position of the camera.
  30751. */
  30752. readonly globalPosition: Vector3;
  30753. /**
  30754. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30755. * @returns the active meshe list
  30756. */
  30757. getActiveMeshes(): SmartArray<AbstractMesh>;
  30758. /**
  30759. * Check wether a mesh is part of the current active mesh list of the camera
  30760. * @param mesh Defines the mesh to check
  30761. * @returns true if active, false otherwise
  30762. */
  30763. isActiveMesh(mesh: Mesh): boolean;
  30764. /**
  30765. * Is this camera ready to be used/rendered
  30766. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30767. * @return true if the camera is ready
  30768. */
  30769. isReady(completeCheck?: boolean): boolean;
  30770. /** @hidden */
  30771. _initCache(): void;
  30772. /** @hidden */
  30773. _updateCache(ignoreParentClass?: boolean): void;
  30774. /** @hidden */
  30775. _isSynchronized(): boolean;
  30776. /** @hidden */
  30777. _isSynchronizedViewMatrix(): boolean;
  30778. /** @hidden */
  30779. _isSynchronizedProjectionMatrix(): boolean;
  30780. /**
  30781. * Attach the input controls to a specific dom element to get the input from.
  30782. * @param element Defines the element the controls should be listened from
  30783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30784. */
  30785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30786. /**
  30787. * Detach the current controls from the specified dom element.
  30788. * @param element Defines the element to stop listening the inputs from
  30789. */
  30790. detachControl(element: HTMLElement): void;
  30791. /**
  30792. * Update the camera state according to the different inputs gathered during the frame.
  30793. */
  30794. update(): void;
  30795. /** @hidden */
  30796. _checkInputs(): void;
  30797. /** @hidden */
  30798. readonly rigCameras: Camera[];
  30799. /**
  30800. * Gets the post process used by the rig cameras
  30801. */
  30802. readonly rigPostProcess: Nullable<PostProcess>;
  30803. /**
  30804. * Internal, gets the first post proces.
  30805. * @returns the first post process to be run on this camera.
  30806. */
  30807. _getFirstPostProcess(): Nullable<PostProcess>;
  30808. private _cascadePostProcessesToRigCams;
  30809. /**
  30810. * Attach a post process to the camera.
  30811. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30812. * @param postProcess The post process to attach to the camera
  30813. * @param insertAt The position of the post process in case several of them are in use in the scene
  30814. * @returns the position the post process has been inserted at
  30815. */
  30816. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30817. /**
  30818. * Detach a post process to the camera.
  30819. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30820. * @param postProcess The post process to detach from the camera
  30821. */
  30822. detachPostProcess(postProcess: PostProcess): void;
  30823. /**
  30824. * Gets the current world matrix of the camera
  30825. */
  30826. getWorldMatrix(): Matrix;
  30827. /** @hidden */
  30828. _getViewMatrix(): Matrix;
  30829. /**
  30830. * Gets the current view matrix of the camera.
  30831. * @param force forces the camera to recompute the matrix without looking at the cached state
  30832. * @returns the view matrix
  30833. */
  30834. getViewMatrix(force?: boolean): Matrix;
  30835. /**
  30836. * Freeze the projection matrix.
  30837. * It will prevent the cache check of the camera projection compute and can speed up perf
  30838. * if no parameter of the camera are meant to change
  30839. * @param projection Defines manually a projection if necessary
  30840. */
  30841. freezeProjectionMatrix(projection?: Matrix): void;
  30842. /**
  30843. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30844. */
  30845. unfreezeProjectionMatrix(): void;
  30846. /**
  30847. * Gets the current projection matrix of the camera.
  30848. * @param force forces the camera to recompute the matrix without looking at the cached state
  30849. * @returns the projection matrix
  30850. */
  30851. getProjectionMatrix(force?: boolean): Matrix;
  30852. /**
  30853. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30854. * @returns a Matrix
  30855. */
  30856. getTransformationMatrix(): Matrix;
  30857. private _updateFrustumPlanes;
  30858. /**
  30859. * Checks if a cullable object (mesh...) is in the camera frustum
  30860. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30861. * @param target The object to check
  30862. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30863. * @returns true if the object is in frustum otherwise false
  30864. */
  30865. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30866. /**
  30867. * Checks if a cullable object (mesh...) is in the camera frustum
  30868. * Unlike isInFrustum this cheks the full bounding box
  30869. * @param target The object to check
  30870. * @returns true if the object is in frustum otherwise false
  30871. */
  30872. isCompletelyInFrustum(target: ICullable): boolean;
  30873. /**
  30874. * Gets a ray in the forward direction from the camera.
  30875. * @param length Defines the length of the ray to create
  30876. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30877. * @param origin Defines the start point of the ray which defaults to the camera position
  30878. * @returns the forward ray
  30879. */
  30880. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30881. /**
  30882. * Releases resources associated with this node.
  30883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30885. */
  30886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30887. /** @hidden */
  30888. _isLeftCamera: boolean;
  30889. /**
  30890. * Gets the left camera of a rig setup in case of Rigged Camera
  30891. */
  30892. readonly isLeftCamera: boolean;
  30893. /** @hidden */
  30894. _isRightCamera: boolean;
  30895. /**
  30896. * Gets the right camera of a rig setup in case of Rigged Camera
  30897. */
  30898. readonly isRightCamera: boolean;
  30899. /**
  30900. * Gets the left camera of a rig setup in case of Rigged Camera
  30901. */
  30902. readonly leftCamera: Nullable<FreeCamera>;
  30903. /**
  30904. * Gets the right camera of a rig setup in case of Rigged Camera
  30905. */
  30906. readonly rightCamera: Nullable<FreeCamera>;
  30907. /**
  30908. * Gets the left camera target of a rig setup in case of Rigged Camera
  30909. * @returns the target position
  30910. */
  30911. getLeftTarget(): Nullable<Vector3>;
  30912. /**
  30913. * Gets the right camera target of a rig setup in case of Rigged Camera
  30914. * @returns the target position
  30915. */
  30916. getRightTarget(): Nullable<Vector3>;
  30917. /**
  30918. * @hidden
  30919. */
  30920. setCameraRigMode(mode: number, rigParams: any): void;
  30921. /** @hidden */
  30922. static _setStereoscopicRigMode(camera: Camera): void;
  30923. /** @hidden */
  30924. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30925. /** @hidden */
  30926. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30927. /** @hidden */
  30928. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30929. /** @hidden */
  30930. _getVRProjectionMatrix(): Matrix;
  30931. protected _updateCameraRotationMatrix(): void;
  30932. protected _updateWebVRCameraRotationMatrix(): void;
  30933. /**
  30934. * This function MUST be overwritten by the different WebVR cameras available.
  30935. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30936. * @hidden
  30937. */
  30938. _getWebVRProjectionMatrix(): Matrix;
  30939. /**
  30940. * This function MUST be overwritten by the different WebVR cameras available.
  30941. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30942. * @hidden
  30943. */
  30944. _getWebVRViewMatrix(): Matrix;
  30945. /** @hidden */
  30946. setCameraRigParameter(name: string, value: any): void;
  30947. /**
  30948. * needs to be overridden by children so sub has required properties to be copied
  30949. * @hidden
  30950. */
  30951. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30952. /**
  30953. * May need to be overridden by children
  30954. * @hidden
  30955. */
  30956. _updateRigCameras(): void;
  30957. /** @hidden */
  30958. _setupInputs(): void;
  30959. /**
  30960. * Serialiaze the camera setup to a json represention
  30961. * @returns the JSON representation
  30962. */
  30963. serialize(): any;
  30964. /**
  30965. * Clones the current camera.
  30966. * @param name The cloned camera name
  30967. * @returns the cloned camera
  30968. */
  30969. clone(name: string): Camera;
  30970. /**
  30971. * Gets the direction of the camera relative to a given local axis.
  30972. * @param localAxis Defines the reference axis to provide a relative direction.
  30973. * @return the direction
  30974. */
  30975. getDirection(localAxis: Vector3): Vector3;
  30976. /**
  30977. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30978. * @param localAxis Defines the reference axis to provide a relative direction.
  30979. * @param result Defines the vector to store the result in
  30980. */
  30981. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30982. /**
  30983. * Gets a camera constructor for a given camera type
  30984. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30985. * @param name The name of the camera the result will be able to instantiate
  30986. * @param scene The scene the result will construct the camera in
  30987. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30988. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30989. * @returns a factory method to construc the camera
  30990. */
  30991. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30992. /**
  30993. * Compute the world matrix of the camera.
  30994. * @returns the camera workd matrix
  30995. */
  30996. computeWorldMatrix(): Matrix;
  30997. /**
  30998. * Parse a JSON and creates the camera from the parsed information
  30999. * @param parsedCamera The JSON to parse
  31000. * @param scene The scene to instantiate the camera in
  31001. * @returns the newly constructed camera
  31002. */
  31003. static Parse(parsedCamera: any, scene: Scene): Camera;
  31004. }
  31005. }
  31006. declare module BABYLON {
  31007. /**
  31008. * Interface for any object that can request an animation frame
  31009. */
  31010. export interface ICustomAnimationFrameRequester {
  31011. /**
  31012. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31013. */
  31014. renderFunction?: Function;
  31015. /**
  31016. * Called to request the next frame to render to
  31017. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31018. */
  31019. requestAnimationFrame: Function;
  31020. /**
  31021. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31022. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31023. */
  31024. requestID?: number;
  31025. }
  31026. /**
  31027. * Interface containing an array of animations
  31028. */
  31029. export interface IAnimatable {
  31030. /**
  31031. * Array of animations
  31032. */
  31033. animations: Nullable<Array<Animation>>;
  31034. }
  31035. /** Interface used by value gradients (color, factor, ...) */
  31036. export interface IValueGradient {
  31037. /**
  31038. * Gets or sets the gradient value (between 0 and 1)
  31039. */
  31040. gradient: number;
  31041. }
  31042. /** Class used to store color4 gradient */
  31043. export class ColorGradient implements IValueGradient {
  31044. /**
  31045. * Gets or sets the gradient value (between 0 and 1)
  31046. */
  31047. gradient: number;
  31048. /**
  31049. * Gets or sets first associated color
  31050. */
  31051. color1: Color4;
  31052. /**
  31053. * Gets or sets second associated color
  31054. */
  31055. color2?: Color4;
  31056. /**
  31057. * Will get a color picked randomly between color1 and color2.
  31058. * If color2 is undefined then color1 will be used
  31059. * @param result defines the target Color4 to store the result in
  31060. */
  31061. getColorToRef(result: Color4): void;
  31062. }
  31063. /** Class used to store color 3 gradient */
  31064. export class Color3Gradient implements IValueGradient {
  31065. /**
  31066. * Gets or sets the gradient value (between 0 and 1)
  31067. */
  31068. gradient: number;
  31069. /**
  31070. * Gets or sets the associated color
  31071. */
  31072. color: Color3;
  31073. }
  31074. /** Class used to store factor gradient */
  31075. export class FactorGradient implements IValueGradient {
  31076. /**
  31077. * Gets or sets the gradient value (between 0 and 1)
  31078. */
  31079. gradient: number;
  31080. /**
  31081. * Gets or sets first associated factor
  31082. */
  31083. factor1: number;
  31084. /**
  31085. * Gets or sets second associated factor
  31086. */
  31087. factor2?: number;
  31088. /**
  31089. * Will get a number picked randomly between factor1 and factor2.
  31090. * If factor2 is undefined then factor1 will be used
  31091. * @returns the picked number
  31092. */
  31093. getFactor(): number;
  31094. }
  31095. /**
  31096. * @ignore
  31097. * Application error to support additional information when loading a file
  31098. */
  31099. export class LoadFileError extends Error {
  31100. /** defines the optional web request */
  31101. request?: WebRequest | undefined;
  31102. private static _setPrototypeOf;
  31103. /**
  31104. * Creates a new LoadFileError
  31105. * @param message defines the message of the error
  31106. * @param request defines the optional web request
  31107. */
  31108. constructor(message: string,
  31109. /** defines the optional web request */
  31110. request?: WebRequest | undefined);
  31111. }
  31112. /**
  31113. * Class used to define a retry strategy when error happens while loading assets
  31114. */
  31115. export class RetryStrategy {
  31116. /**
  31117. * Function used to defines an exponential back off strategy
  31118. * @param maxRetries defines the maximum number of retries (3 by default)
  31119. * @param baseInterval defines the interval between retries
  31120. * @returns the strategy function to use
  31121. */
  31122. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31123. }
  31124. /**
  31125. * File request interface
  31126. */
  31127. export interface IFileRequest {
  31128. /**
  31129. * Raised when the request is complete (success or error).
  31130. */
  31131. onCompleteObservable: Observable<IFileRequest>;
  31132. /**
  31133. * Aborts the request for a file.
  31134. */
  31135. abort: () => void;
  31136. }
  31137. /**
  31138. * Class containing a set of static utilities functions
  31139. */
  31140. export class Tools {
  31141. /**
  31142. * Gets or sets the base URL to use to load assets
  31143. */
  31144. static BaseUrl: string;
  31145. /**
  31146. * Enable/Disable Custom HTTP Request Headers globally.
  31147. * default = false
  31148. * @see CustomRequestHeaders
  31149. */
  31150. static UseCustomRequestHeaders: boolean;
  31151. /**
  31152. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31153. * i.e. when loading files, where the server/service expects an Authorization header
  31154. */
  31155. static CustomRequestHeaders: {
  31156. [key: string]: string;
  31157. };
  31158. /**
  31159. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31160. */
  31161. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31162. /**
  31163. * Default behaviour for cors in the application.
  31164. * It can be a string if the expected behavior is identical in the entire app.
  31165. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31166. */
  31167. static CorsBehavior: string | ((url: string | string[]) => string);
  31168. /**
  31169. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31170. * @ignorenaming
  31171. */
  31172. static UseFallbackTexture: boolean;
  31173. /**
  31174. * Use this object to register external classes like custom textures or material
  31175. * to allow the laoders to instantiate them
  31176. */
  31177. static RegisteredExternalClasses: {
  31178. [key: string]: Object;
  31179. };
  31180. /**
  31181. * Texture content used if a texture cannot loaded
  31182. * @ignorenaming
  31183. */
  31184. static fallbackTexture: string;
  31185. /**
  31186. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31187. * @param u defines the coordinate on X axis
  31188. * @param v defines the coordinate on Y axis
  31189. * @param width defines the width of the source data
  31190. * @param height defines the height of the source data
  31191. * @param pixels defines the source byte array
  31192. * @param color defines the output color
  31193. */
  31194. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31195. /**
  31196. * Interpolates between a and b via alpha
  31197. * @param a The lower value (returned when alpha = 0)
  31198. * @param b The upper value (returned when alpha = 1)
  31199. * @param alpha The interpolation-factor
  31200. * @return The mixed value
  31201. */
  31202. static Mix(a: number, b: number, alpha: number): number;
  31203. /**
  31204. * Tries to instantiate a new object from a given class name
  31205. * @param className defines the class name to instantiate
  31206. * @returns the new object or null if the system was not able to do the instantiation
  31207. */
  31208. static Instantiate(className: string): any;
  31209. /**
  31210. * Provides a slice function that will work even on IE
  31211. * @param data defines the array to slice
  31212. * @param start defines the start of the data (optional)
  31213. * @param end defines the end of the data (optional)
  31214. * @returns the new sliced array
  31215. */
  31216. static Slice<T>(data: T, start?: number, end?: number): T;
  31217. /**
  31218. * Polyfill for setImmediate
  31219. * @param action defines the action to execute after the current execution block
  31220. */
  31221. static SetImmediate(action: () => void): void;
  31222. /**
  31223. * Function indicating if a number is an exponent of 2
  31224. * @param value defines the value to test
  31225. * @returns true if the value is an exponent of 2
  31226. */
  31227. static IsExponentOfTwo(value: number): boolean;
  31228. private static _tmpFloatArray;
  31229. /**
  31230. * Returns the nearest 32-bit single precision float representation of a Number
  31231. * @param value A Number. If the parameter is of a different type, it will get converted
  31232. * to a number or to NaN if it cannot be converted
  31233. * @returns number
  31234. */
  31235. static FloatRound(value: number): number;
  31236. /**
  31237. * Find the next highest power of two.
  31238. * @param x Number to start search from.
  31239. * @return Next highest power of two.
  31240. */
  31241. static CeilingPOT(x: number): number;
  31242. /**
  31243. * Find the next lowest power of two.
  31244. * @param x Number to start search from.
  31245. * @return Next lowest power of two.
  31246. */
  31247. static FloorPOT(x: number): number;
  31248. /**
  31249. * Find the nearest power of two.
  31250. * @param x Number to start search from.
  31251. * @return Next nearest power of two.
  31252. */
  31253. static NearestPOT(x: number): number;
  31254. /**
  31255. * Get the closest exponent of two
  31256. * @param value defines the value to approximate
  31257. * @param max defines the maximum value to return
  31258. * @param mode defines how to define the closest value
  31259. * @returns closest exponent of two of the given value
  31260. */
  31261. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31262. /**
  31263. * Extracts the filename from a path
  31264. * @param path defines the path to use
  31265. * @returns the filename
  31266. */
  31267. static GetFilename(path: string): string;
  31268. /**
  31269. * Extracts the "folder" part of a path (everything before the filename).
  31270. * @param uri The URI to extract the info from
  31271. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31272. * @returns The "folder" part of the path
  31273. */
  31274. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31275. /**
  31276. * Extracts text content from a DOM element hierarchy
  31277. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31278. */
  31279. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31280. /**
  31281. * Convert an angle in radians to degrees
  31282. * @param angle defines the angle to convert
  31283. * @returns the angle in degrees
  31284. */
  31285. static ToDegrees(angle: number): number;
  31286. /**
  31287. * Convert an angle in degrees to radians
  31288. * @param angle defines the angle to convert
  31289. * @returns the angle in radians
  31290. */
  31291. static ToRadians(angle: number): number;
  31292. /**
  31293. * Encode a buffer to a base64 string
  31294. * @param buffer defines the buffer to encode
  31295. * @returns the encoded string
  31296. */
  31297. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31298. /**
  31299. * Extracts minimum and maximum values from a list of indexed positions
  31300. * @param positions defines the positions to use
  31301. * @param indices defines the indices to the positions
  31302. * @param indexStart defines the start index
  31303. * @param indexCount defines the end index
  31304. * @param bias defines bias value to add to the result
  31305. * @return minimum and maximum values
  31306. */
  31307. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31308. minimum: Vector3;
  31309. maximum: Vector3;
  31310. };
  31311. /**
  31312. * Extracts minimum and maximum values from a list of positions
  31313. * @param positions defines the positions to use
  31314. * @param start defines the start index in the positions array
  31315. * @param count defines the number of positions to handle
  31316. * @param bias defines bias value to add to the result
  31317. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31318. * @return minimum and maximum values
  31319. */
  31320. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31321. minimum: Vector3;
  31322. maximum: Vector3;
  31323. };
  31324. /**
  31325. * Returns an array if obj is not an array
  31326. * @param obj defines the object to evaluate as an array
  31327. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31328. * @returns either obj directly if obj is an array or a new array containing obj
  31329. */
  31330. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31331. /**
  31332. * Gets the pointer prefix to use
  31333. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31334. */
  31335. static GetPointerPrefix(): string;
  31336. /**
  31337. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31338. * @param func - the function to be called
  31339. * @param requester - the object that will request the next frame. Falls back to window.
  31340. * @returns frame number
  31341. */
  31342. static QueueNewFrame(func: () => void, requester?: any): number;
  31343. /**
  31344. * Ask the browser to promote the current element to fullscreen rendering mode
  31345. * @param element defines the DOM element to promote
  31346. */
  31347. static RequestFullscreen(element: HTMLElement): void;
  31348. /**
  31349. * Asks the browser to exit fullscreen mode
  31350. */
  31351. static ExitFullscreen(): void;
  31352. /**
  31353. * Ask the browser to promote the current element to pointerlock mode
  31354. * @param element defines the DOM element to promote
  31355. */
  31356. static RequestPointerlock(element: HTMLElement): void;
  31357. /**
  31358. * Asks the browser to exit pointerlock mode
  31359. */
  31360. static ExitPointerlock(): void;
  31361. /**
  31362. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31363. * @param url define the url we are trying
  31364. * @param element define the dom element where to configure the cors policy
  31365. */
  31366. static SetCorsBehavior(url: string | string[], element: {
  31367. crossOrigin: string | null;
  31368. }): void;
  31369. /**
  31370. * Removes unwanted characters from an url
  31371. * @param url defines the url to clean
  31372. * @returns the cleaned url
  31373. */
  31374. static CleanUrl(url: string): string;
  31375. /**
  31376. * Gets or sets a function used to pre-process url before using them to load assets
  31377. */
  31378. static PreprocessUrl: (url: string) => string;
  31379. /**
  31380. * Loads an image as an HTMLImageElement.
  31381. * @param input url string, ArrayBuffer, or Blob to load
  31382. * @param onLoad callback called when the image successfully loads
  31383. * @param onError callback called when the image fails to load
  31384. * @param offlineProvider offline provider for caching
  31385. * @returns the HTMLImageElement of the loaded image
  31386. */
  31387. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31388. /**
  31389. * Loads a file
  31390. * @param url url string, ArrayBuffer, or Blob to load
  31391. * @param onSuccess callback called when the file successfully loads
  31392. * @param onProgress callback called while file is loading (if the server supports this mode)
  31393. * @param offlineProvider defines the offline provider for caching
  31394. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31395. * @param onError callback called when the file fails to load
  31396. * @returns a file request object
  31397. */
  31398. 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;
  31399. /**
  31400. * Loads a file from a url
  31401. * @param url the file url to load
  31402. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31403. */
  31404. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31405. /**
  31406. * Load a script (identified by an url). When the url returns, the
  31407. * content of this file is added into a new script element, attached to the DOM (body element)
  31408. * @param scriptUrl defines the url of the script to laod
  31409. * @param onSuccess defines the callback called when the script is loaded
  31410. * @param onError defines the callback to call if an error occurs
  31411. * @param scriptId defines the id of the script element
  31412. */
  31413. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31414. /**
  31415. * Load an asynchronous script (identified by an url). When the url returns, the
  31416. * content of this file is added into a new script element, attached to the DOM (body element)
  31417. * @param scriptUrl defines the url of the script to laod
  31418. * @param scriptId defines the id of the script element
  31419. * @returns a promise request object
  31420. */
  31421. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31422. /**
  31423. * Loads a file from a blob
  31424. * @param fileToLoad defines the blob to use
  31425. * @param callback defines the callback to call when data is loaded
  31426. * @param progressCallback defines the callback to call during loading process
  31427. * @returns a file request object
  31428. */
  31429. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31430. /**
  31431. * Loads a file
  31432. * @param fileToLoad defines the file to load
  31433. * @param callback defines the callback to call when data is loaded
  31434. * @param progressCallBack defines the callback to call during loading process
  31435. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31436. * @returns a file request object
  31437. */
  31438. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31439. /**
  31440. * Creates a data url from a given string content
  31441. * @param content defines the content to convert
  31442. * @returns the new data url link
  31443. */
  31444. static FileAsURL(content: string): string;
  31445. /**
  31446. * Format the given number to a specific decimal format
  31447. * @param value defines the number to format
  31448. * @param decimals defines the number of decimals to use
  31449. * @returns the formatted string
  31450. */
  31451. static Format(value: number, decimals?: number): string;
  31452. /**
  31453. * Checks if a given vector is inside a specific range
  31454. * @param v defines the vector to test
  31455. * @param min defines the minimum range
  31456. * @param max defines the maximum range
  31457. */
  31458. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31459. /**
  31460. * Tries to copy an object by duplicating every property
  31461. * @param source defines the source object
  31462. * @param destination defines the target object
  31463. * @param doNotCopyList defines a list of properties to avoid
  31464. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31465. */
  31466. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31467. /**
  31468. * Gets a boolean indicating if the given object has no own property
  31469. * @param obj defines the object to test
  31470. * @returns true if object has no own property
  31471. */
  31472. static IsEmpty(obj: any): boolean;
  31473. /**
  31474. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31475. * @param str Source string
  31476. * @param suffix Suffix to search for in the source string
  31477. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31478. */
  31479. static EndsWith(str: string, suffix: string): boolean;
  31480. /**
  31481. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31482. * @param str Source string
  31483. * @param suffix Suffix to search for in the source string
  31484. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31485. */
  31486. static StartsWith(str: string, suffix: string): boolean;
  31487. /**
  31488. * Function used to register events at window level
  31489. * @param events defines the events to register
  31490. */
  31491. static RegisterTopRootEvents(events: {
  31492. name: string;
  31493. handler: Nullable<(e: FocusEvent) => any>;
  31494. }[]): void;
  31495. /**
  31496. * Function used to unregister events from window level
  31497. * @param events defines the events to unregister
  31498. */
  31499. static UnregisterTopRootEvents(events: {
  31500. name: string;
  31501. handler: Nullable<(e: FocusEvent) => any>;
  31502. }[]): void;
  31503. /**
  31504. * @ignore
  31505. */
  31506. static _ScreenshotCanvas: HTMLCanvasElement;
  31507. /**
  31508. * Dumps the current bound framebuffer
  31509. * @param width defines the rendering width
  31510. * @param height defines the rendering height
  31511. * @param engine defines the hosting engine
  31512. * @param successCallback defines the callback triggered once the data are available
  31513. * @param mimeType defines the mime type of the result
  31514. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31515. */
  31516. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31517. /**
  31518. * Converts the canvas data to blob.
  31519. * This acts as a polyfill for browsers not supporting the to blob function.
  31520. * @param canvas Defines the canvas to extract the data from
  31521. * @param successCallback Defines the callback triggered once the data are available
  31522. * @param mimeType Defines the mime type of the result
  31523. */
  31524. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31525. /**
  31526. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31527. * @param successCallback defines the callback triggered once the data are available
  31528. * @param mimeType defines the mime type of the result
  31529. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31530. */
  31531. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31532. /**
  31533. * Downloads a blob in the browser
  31534. * @param blob defines the blob to download
  31535. * @param fileName defines the name of the downloaded file
  31536. */
  31537. static Download(blob: Blob, fileName: string): void;
  31538. /**
  31539. * Captures a screenshot of the current rendering
  31540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31541. * @param engine defines the rendering engine
  31542. * @param camera defines the source camera
  31543. * @param size This parameter can be set to a single number or to an object with the
  31544. * following (optional) properties: precision, width, height. If a single number is passed,
  31545. * it will be used for both width and height. If an object is passed, the screenshot size
  31546. * will be derived from the parameters. The precision property is a multiplier allowing
  31547. * rendering at a higher or lower resolution
  31548. * @param successCallback defines the callback receives a single parameter which contains the
  31549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31550. * src parameter of an <img> to display it
  31551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31552. * Check your browser for supported MIME types
  31553. */
  31554. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31555. /**
  31556. * Generates an image screenshot from the specified camera.
  31557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31558. * @param engine The engine to use for rendering
  31559. * @param camera The camera to use for rendering
  31560. * @param size This parameter can be set to a single number or to an object with the
  31561. * following (optional) properties: precision, width, height. If a single number is passed,
  31562. * it will be used for both width and height. If an object is passed, the screenshot size
  31563. * will be derived from the parameters. The precision property is a multiplier allowing
  31564. * rendering at a higher or lower resolution
  31565. * @param successCallback The callback receives a single parameter which contains the
  31566. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31567. * src parameter of an <img> to display it
  31568. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31569. * Check your browser for supported MIME types
  31570. * @param samples Texture samples (default: 1)
  31571. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31572. * @param fileName A name for for the downloaded file.
  31573. */
  31574. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31575. /**
  31576. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31577. * Be aware Math.random() could cause collisions, but:
  31578. * "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"
  31579. * @returns a pseudo random id
  31580. */
  31581. static RandomId(): string;
  31582. /**
  31583. * Test if the given uri is a base64 string
  31584. * @param uri The uri to test
  31585. * @return True if the uri is a base64 string or false otherwise
  31586. */
  31587. static IsBase64(uri: string): boolean;
  31588. /**
  31589. * Decode the given base64 uri.
  31590. * @param uri The uri to decode
  31591. * @return The decoded base64 data.
  31592. */
  31593. static DecodeBase64(uri: string): ArrayBuffer;
  31594. /**
  31595. * Gets the absolute url.
  31596. * @param url the input url
  31597. * @return the absolute url
  31598. */
  31599. static GetAbsoluteUrl(url: string): string;
  31600. /**
  31601. * No log
  31602. */
  31603. static readonly NoneLogLevel: number;
  31604. /**
  31605. * Only message logs
  31606. */
  31607. static readonly MessageLogLevel: number;
  31608. /**
  31609. * Only warning logs
  31610. */
  31611. static readonly WarningLogLevel: number;
  31612. /**
  31613. * Only error logs
  31614. */
  31615. static readonly ErrorLogLevel: number;
  31616. /**
  31617. * All logs
  31618. */
  31619. static readonly AllLogLevel: number;
  31620. /**
  31621. * Gets a value indicating the number of loading errors
  31622. * @ignorenaming
  31623. */
  31624. static readonly errorsCount: number;
  31625. /**
  31626. * Callback called when a new log is added
  31627. */
  31628. static OnNewCacheEntry: (entry: string) => void;
  31629. /**
  31630. * Log a message to the console
  31631. * @param message defines the message to log
  31632. */
  31633. static Log(message: string): void;
  31634. /**
  31635. * Write a warning message to the console
  31636. * @param message defines the message to log
  31637. */
  31638. static Warn(message: string): void;
  31639. /**
  31640. * Write an error message to the console
  31641. * @param message defines the message to log
  31642. */
  31643. static Error(message: string): void;
  31644. /**
  31645. * Gets current log cache (list of logs)
  31646. */
  31647. static readonly LogCache: string;
  31648. /**
  31649. * Clears the log cache
  31650. */
  31651. static ClearLogCache(): void;
  31652. /**
  31653. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31654. */
  31655. static LogLevels: number;
  31656. /**
  31657. * Checks if the loaded document was accessed via `file:`-Protocol.
  31658. * @returns boolean
  31659. */
  31660. static IsFileURL(): boolean;
  31661. /**
  31662. * Checks if the window object exists
  31663. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31664. */
  31665. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31666. /**
  31667. * No performance log
  31668. */
  31669. static readonly PerformanceNoneLogLevel: number;
  31670. /**
  31671. * Use user marks to log performance
  31672. */
  31673. static readonly PerformanceUserMarkLogLevel: number;
  31674. /**
  31675. * Log performance to the console
  31676. */
  31677. static readonly PerformanceConsoleLogLevel: number;
  31678. private static _performance;
  31679. /**
  31680. * Sets the current performance log level
  31681. */
  31682. static PerformanceLogLevel: number;
  31683. private static _StartPerformanceCounterDisabled;
  31684. private static _EndPerformanceCounterDisabled;
  31685. private static _StartUserMark;
  31686. private static _EndUserMark;
  31687. private static _StartPerformanceConsole;
  31688. private static _EndPerformanceConsole;
  31689. /**
  31690. * Starts a performance counter
  31691. */
  31692. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31693. /**
  31694. * Ends a specific performance coutner
  31695. */
  31696. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31697. /**
  31698. * Gets either window.performance.now() if supported or Date.now() else
  31699. */
  31700. static readonly Now: number;
  31701. /**
  31702. * This method will return the name of the class used to create the instance of the given object.
  31703. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31704. * @param object the object to get the class name from
  31705. * @param isType defines if the object is actually a type
  31706. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31707. */
  31708. static GetClassName(object: any, isType?: boolean): string;
  31709. /**
  31710. * Gets the first element of an array satisfying a given predicate
  31711. * @param array defines the array to browse
  31712. * @param predicate defines the predicate to use
  31713. * @returns null if not found or the element
  31714. */
  31715. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31716. /**
  31717. * This method will return the name of the full name of the class, including its owning module (if any).
  31718. * 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).
  31719. * @param object the object to get the class name from
  31720. * @param isType defines if the object is actually a type
  31721. * @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.
  31722. * @ignorenaming
  31723. */
  31724. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31725. /**
  31726. * Returns a promise that resolves after the given amount of time.
  31727. * @param delay Number of milliseconds to delay
  31728. * @returns Promise that resolves after the given amount of time
  31729. */
  31730. static DelayAsync(delay: number): Promise<void>;
  31731. /**
  31732. * Gets the current gradient from an array of IValueGradient
  31733. * @param ratio defines the current ratio to get
  31734. * @param gradients defines the array of IValueGradient
  31735. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31736. */
  31737. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31738. }
  31739. /**
  31740. * This class is used to track a performance counter which is number based.
  31741. * The user has access to many properties which give statistics of different nature.
  31742. *
  31743. * The implementer can track two kinds of Performance Counter: time and count.
  31744. * 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.
  31745. * 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.
  31746. */
  31747. export class PerfCounter {
  31748. /**
  31749. * Gets or sets a global boolean to turn on and off all the counters
  31750. */
  31751. static Enabled: boolean;
  31752. /**
  31753. * Returns the smallest value ever
  31754. */
  31755. readonly min: number;
  31756. /**
  31757. * Returns the biggest value ever
  31758. */
  31759. readonly max: number;
  31760. /**
  31761. * Returns the average value since the performance counter is running
  31762. */
  31763. readonly average: number;
  31764. /**
  31765. * Returns the average value of the last second the counter was monitored
  31766. */
  31767. readonly lastSecAverage: number;
  31768. /**
  31769. * Returns the current value
  31770. */
  31771. readonly current: number;
  31772. /**
  31773. * Gets the accumulated total
  31774. */
  31775. readonly total: number;
  31776. /**
  31777. * Gets the total value count
  31778. */
  31779. readonly count: number;
  31780. /**
  31781. * Creates a new counter
  31782. */
  31783. constructor();
  31784. /**
  31785. * Call this method to start monitoring a new frame.
  31786. * 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.
  31787. */
  31788. fetchNewFrame(): void;
  31789. /**
  31790. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31791. * @param newCount the count value to add to the monitored count
  31792. * @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.
  31793. */
  31794. addCount(newCount: number, fetchResult: boolean): void;
  31795. /**
  31796. * Start monitoring this performance counter
  31797. */
  31798. beginMonitoring(): void;
  31799. /**
  31800. * Compute the time lapsed since the previous beginMonitoring() call.
  31801. * @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
  31802. */
  31803. endMonitoring(newFrame?: boolean): void;
  31804. private _fetchResult;
  31805. private _startMonitoringTime;
  31806. private _min;
  31807. private _max;
  31808. private _average;
  31809. private _current;
  31810. private _totalValueCount;
  31811. private _totalAccumulated;
  31812. private _lastSecAverage;
  31813. private _lastSecAccumulated;
  31814. private _lastSecTime;
  31815. private _lastSecValueCount;
  31816. }
  31817. /**
  31818. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31819. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31820. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31821. * @param name The name of the class, case should be preserved
  31822. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31823. */
  31824. export function className(name: string, module?: string): (target: Object) => void;
  31825. /**
  31826. * An implementation of a loop for asynchronous functions.
  31827. */
  31828. export class AsyncLoop {
  31829. /**
  31830. * Defines the number of iterations for the loop
  31831. */
  31832. iterations: number;
  31833. /**
  31834. * Defines the current index of the loop.
  31835. */
  31836. index: number;
  31837. private _done;
  31838. private _fn;
  31839. private _successCallback;
  31840. /**
  31841. * Constructor.
  31842. * @param iterations the number of iterations.
  31843. * @param func the function to run each iteration
  31844. * @param successCallback the callback that will be called upon succesful execution
  31845. * @param offset starting offset.
  31846. */
  31847. constructor(
  31848. /**
  31849. * Defines the number of iterations for the loop
  31850. */
  31851. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31852. /**
  31853. * Execute the next iteration. Must be called after the last iteration was finished.
  31854. */
  31855. executeNext(): void;
  31856. /**
  31857. * Break the loop and run the success callback.
  31858. */
  31859. breakLoop(): void;
  31860. /**
  31861. * Create and run an async loop.
  31862. * @param iterations the number of iterations.
  31863. * @param fn the function to run each iteration
  31864. * @param successCallback the callback that will be called upon succesful execution
  31865. * @param offset starting offset.
  31866. * @returns the created async loop object
  31867. */
  31868. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31869. /**
  31870. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31871. * @param iterations total number of iterations
  31872. * @param syncedIterations number of synchronous iterations in each async iteration.
  31873. * @param fn the function to call each iteration.
  31874. * @param callback a success call back that will be called when iterating stops.
  31875. * @param breakFunction a break condition (optional)
  31876. * @param timeout timeout settings for the setTimeout function. default - 0.
  31877. * @returns the created async loop object
  31878. */
  31879. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31880. }
  31881. }
  31882. declare module BABYLON {
  31883. /** @hidden */
  31884. export interface ICollisionCoordinator {
  31885. createCollider(): Collider;
  31886. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31887. init(scene: Scene): void;
  31888. }
  31889. /** @hidden */
  31890. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31891. private _scene;
  31892. private _scaledPosition;
  31893. private _scaledVelocity;
  31894. private _finalPosition;
  31895. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31896. createCollider(): Collider;
  31897. init(scene: Scene): void;
  31898. private _collideWithWorld;
  31899. }
  31900. }
  31901. declare module BABYLON {
  31902. /**
  31903. * Class used to manage all inputs for the scene.
  31904. */
  31905. export class InputManager {
  31906. /** The distance in pixel that you have to move to prevent some events */
  31907. static DragMovementThreshold: number;
  31908. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31909. static LongPressDelay: number;
  31910. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31911. static DoubleClickDelay: number;
  31912. /** If you need to check double click without raising a single click at first click, enable this flag */
  31913. static ExclusiveDoubleClickMode: boolean;
  31914. private _wheelEventName;
  31915. private _onPointerMove;
  31916. private _onPointerDown;
  31917. private _onPointerUp;
  31918. private _initClickEvent;
  31919. private _initActionManager;
  31920. private _delayedSimpleClick;
  31921. private _delayedSimpleClickTimeout;
  31922. private _previousDelayedSimpleClickTimeout;
  31923. private _meshPickProceed;
  31924. private _previousButtonPressed;
  31925. private _currentPickResult;
  31926. private _previousPickResult;
  31927. private _totalPointersPressed;
  31928. private _doubleClickOccured;
  31929. private _pointerOverMesh;
  31930. private _pickedDownMesh;
  31931. private _pickedUpMesh;
  31932. private _pointerX;
  31933. private _pointerY;
  31934. private _unTranslatedPointerX;
  31935. private _unTranslatedPointerY;
  31936. private _startingPointerPosition;
  31937. private _previousStartingPointerPosition;
  31938. private _startingPointerTime;
  31939. private _previousStartingPointerTime;
  31940. private _pointerCaptures;
  31941. private _onKeyDown;
  31942. private _onKeyUp;
  31943. private _onCanvasFocusObserver;
  31944. private _onCanvasBlurObserver;
  31945. private _scene;
  31946. /**
  31947. * Creates a new InputManager
  31948. * @param scene defines the hosting scene
  31949. */
  31950. constructor(scene: Scene);
  31951. /**
  31952. * Gets the mesh that is currently under the pointer
  31953. */
  31954. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31955. /**
  31956. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31957. */
  31958. readonly unTranslatedPointer: Vector2;
  31959. /**
  31960. * Gets or sets the current on-screen X position of the pointer
  31961. */
  31962. pointerX: number;
  31963. /**
  31964. * Gets or sets the current on-screen Y position of the pointer
  31965. */
  31966. pointerY: number;
  31967. private _updatePointerPosition;
  31968. private _processPointerMove;
  31969. private _setRayOnPointerInfo;
  31970. private _checkPrePointerObservable;
  31971. /**
  31972. * Use this method to simulate a pointer move on a mesh
  31973. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31974. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31975. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31976. */
  31977. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31978. /**
  31979. * Use this method to simulate a pointer down on a mesh
  31980. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31981. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31982. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31983. */
  31984. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31985. private _processPointerDown;
  31986. /** @hidden */
  31987. _isPointerSwiping(): boolean;
  31988. /**
  31989. * Use this method to simulate a pointer up on a mesh
  31990. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31991. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31992. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31993. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31994. */
  31995. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31996. private _processPointerUp;
  31997. /**
  31998. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31999. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32000. * @returns true if the pointer was captured
  32001. */
  32002. isPointerCaptured(pointerId?: number): boolean;
  32003. /**
  32004. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32005. * @param attachUp defines if you want to attach events to pointerup
  32006. * @param attachDown defines if you want to attach events to pointerdown
  32007. * @param attachMove defines if you want to attach events to pointermove
  32008. */
  32009. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32010. /**
  32011. * Detaches all event handlers
  32012. */
  32013. detachControl(): void;
  32014. /**
  32015. * Force the value of meshUnderPointer
  32016. * @param mesh defines the mesh to use
  32017. */
  32018. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32019. /**
  32020. * Gets the mesh under the pointer
  32021. * @returns a Mesh or null if no mesh is under the pointer
  32022. */
  32023. getPointerOverMesh(): Nullable<AbstractMesh>;
  32024. }
  32025. }
  32026. declare module BABYLON {
  32027. /**
  32028. * This class defines the direct association between an animation and a target
  32029. */
  32030. export class TargetedAnimation {
  32031. /**
  32032. * Animation to perform
  32033. */
  32034. animation: Animation;
  32035. /**
  32036. * Target to animate
  32037. */
  32038. target: any;
  32039. /**
  32040. * Serialize the object
  32041. * @returns the JSON object representing the current entity
  32042. */
  32043. serialize(): any;
  32044. }
  32045. /**
  32046. * Use this class to create coordinated animations on multiple targets
  32047. */
  32048. export class AnimationGroup implements IDisposable {
  32049. /** The name of the animation group */
  32050. name: string;
  32051. private _scene;
  32052. private _targetedAnimations;
  32053. private _animatables;
  32054. private _from;
  32055. private _to;
  32056. private _isStarted;
  32057. private _isPaused;
  32058. private _speedRatio;
  32059. private _loopAnimation;
  32060. /**
  32061. * Gets or sets the unique id of the node
  32062. */
  32063. uniqueId: number;
  32064. /**
  32065. * This observable will notify when one animation have ended
  32066. */
  32067. onAnimationEndObservable: Observable<TargetedAnimation>;
  32068. /**
  32069. * Observer raised when one animation loops
  32070. */
  32071. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32072. /**
  32073. * This observable will notify when all animations have ended.
  32074. */
  32075. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32076. /**
  32077. * This observable will notify when all animations have paused.
  32078. */
  32079. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32080. /**
  32081. * This observable will notify when all animations are playing.
  32082. */
  32083. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32084. /**
  32085. * Gets the first frame
  32086. */
  32087. readonly from: number;
  32088. /**
  32089. * Gets the last frame
  32090. */
  32091. readonly to: number;
  32092. /**
  32093. * Define if the animations are started
  32094. */
  32095. readonly isStarted: boolean;
  32096. /**
  32097. * Gets a value indicating that the current group is playing
  32098. */
  32099. readonly isPlaying: boolean;
  32100. /**
  32101. * Gets or sets the speed ratio to use for all animations
  32102. */
  32103. /**
  32104. * Gets or sets the speed ratio to use for all animations
  32105. */
  32106. speedRatio: number;
  32107. /**
  32108. * Gets or sets if all animations should loop or not
  32109. */
  32110. loopAnimation: boolean;
  32111. /**
  32112. * Gets the targeted animations for this animation group
  32113. */
  32114. readonly targetedAnimations: Array<TargetedAnimation>;
  32115. /**
  32116. * returning the list of animatables controlled by this animation group.
  32117. */
  32118. readonly animatables: Array<Animatable>;
  32119. /**
  32120. * Instantiates a new Animation Group.
  32121. * This helps managing several animations at once.
  32122. * @see http://doc.babylonjs.com/how_to/group
  32123. * @param name Defines the name of the group
  32124. * @param scene Defines the scene the group belongs to
  32125. */
  32126. constructor(
  32127. /** The name of the animation group */
  32128. name: string, scene?: Nullable<Scene>);
  32129. /**
  32130. * Add an animation (with its target) in the group
  32131. * @param animation defines the animation we want to add
  32132. * @param target defines the target of the animation
  32133. * @returns the TargetedAnimation object
  32134. */
  32135. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32136. /**
  32137. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32138. * It can add constant keys at begin or end
  32139. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32140. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32141. * @returns the animation group
  32142. */
  32143. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32144. /**
  32145. * Start all animations on given targets
  32146. * @param loop defines if animations must loop
  32147. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32148. * @param from defines the from key (optional)
  32149. * @param to defines the to key (optional)
  32150. * @returns the current animation group
  32151. */
  32152. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32153. /**
  32154. * Pause all animations
  32155. * @returns the animation group
  32156. */
  32157. pause(): AnimationGroup;
  32158. /**
  32159. * Play all animations to initial state
  32160. * This function will start() the animations if they were not started or will restart() them if they were paused
  32161. * @param loop defines if animations must loop
  32162. * @returns the animation group
  32163. */
  32164. play(loop?: boolean): AnimationGroup;
  32165. /**
  32166. * Reset all animations to initial state
  32167. * @returns the animation group
  32168. */
  32169. reset(): AnimationGroup;
  32170. /**
  32171. * Restart animations from key 0
  32172. * @returns the animation group
  32173. */
  32174. restart(): AnimationGroup;
  32175. /**
  32176. * Stop all animations
  32177. * @returns the animation group
  32178. */
  32179. stop(): AnimationGroup;
  32180. /**
  32181. * Set animation weight for all animatables
  32182. * @param weight defines the weight to use
  32183. * @return the animationGroup
  32184. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32185. */
  32186. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32187. /**
  32188. * Synchronize and normalize all animatables with a source animatable
  32189. * @param root defines the root animatable to synchronize with
  32190. * @return the animationGroup
  32191. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32192. */
  32193. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32194. /**
  32195. * Goes to a specific frame in this animation group
  32196. * @param frame the frame number to go to
  32197. * @return the animationGroup
  32198. */
  32199. goToFrame(frame: number): AnimationGroup;
  32200. /**
  32201. * Dispose all associated resources
  32202. */
  32203. dispose(): void;
  32204. private _checkAnimationGroupEnded;
  32205. /**
  32206. * Clone the current animation group and returns a copy
  32207. * @param newName defines the name of the new group
  32208. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32209. * @returns the new aniamtion group
  32210. */
  32211. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32212. /**
  32213. * Serializes the animationGroup to an object
  32214. * @returns Serialized object
  32215. */
  32216. serialize(): any;
  32217. /**
  32218. * Returns a new AnimationGroup object parsed from the source provided.
  32219. * @param parsedAnimationGroup defines the source
  32220. * @param scene defines the scene that will receive the animationGroup
  32221. * @returns a new AnimationGroup
  32222. */
  32223. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32224. /**
  32225. * Returns the string "AnimationGroup"
  32226. * @returns "AnimationGroup"
  32227. */
  32228. getClassName(): string;
  32229. /**
  32230. * Creates a detailled string about the object
  32231. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32232. * @returns a string representing the object
  32233. */
  32234. toString(fullDetails?: boolean): string;
  32235. }
  32236. }
  32237. declare module BABYLON {
  32238. /**
  32239. * Define an interface for all classes that will hold resources
  32240. */
  32241. export interface IDisposable {
  32242. /**
  32243. * Releases all held resources
  32244. */
  32245. dispose(): void;
  32246. }
  32247. /** Interface defining initialization parameters for Scene class */
  32248. export interface SceneOptions {
  32249. /**
  32250. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32251. * It will improve performance when the number of geometries becomes important.
  32252. */
  32253. useGeometryUniqueIdsMap?: boolean;
  32254. /**
  32255. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32256. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32257. */
  32258. useMaterialMeshMap?: boolean;
  32259. /**
  32260. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32261. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32262. */
  32263. useClonedMeshhMap?: boolean;
  32264. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32265. virtual?: boolean;
  32266. }
  32267. /**
  32268. * Represents a scene to be rendered by the engine.
  32269. * @see http://doc.babylonjs.com/features/scene
  32270. */
  32271. export class Scene extends AbstractScene implements IAnimatable {
  32272. private static _uniqueIdCounter;
  32273. /** The fog is deactivated */
  32274. static readonly FOGMODE_NONE: number;
  32275. /** The fog density is following an exponential function */
  32276. static readonly FOGMODE_EXP: number;
  32277. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32278. static readonly FOGMODE_EXP2: number;
  32279. /** The fog density is following a linear function. */
  32280. static readonly FOGMODE_LINEAR: number;
  32281. /**
  32282. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32284. */
  32285. static MinDeltaTime: number;
  32286. /**
  32287. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32288. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32289. */
  32290. static MaxDeltaTime: number;
  32291. /**
  32292. * Factory used to create the default material.
  32293. * @param name The name of the material to create
  32294. * @param scene The scene to create the material for
  32295. * @returns The default material
  32296. */
  32297. static DefaultMaterialFactory(scene: Scene): Material;
  32298. /**
  32299. * Factory used to create the a collision coordinator.
  32300. * @returns The collision coordinator
  32301. */
  32302. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32303. /** @hidden */
  32304. _inputManager: InputManager;
  32305. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32306. cameraToUseForPointers: Nullable<Camera>;
  32307. /** @hidden */
  32308. readonly _isScene: boolean;
  32309. /**
  32310. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32311. */
  32312. autoClear: boolean;
  32313. /**
  32314. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32315. */
  32316. autoClearDepthAndStencil: boolean;
  32317. /**
  32318. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32319. */
  32320. clearColor: Color4;
  32321. /**
  32322. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32323. */
  32324. ambientColor: Color3;
  32325. /**
  32326. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32327. * It should only be one of the following (if not the default embedded one):
  32328. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32329. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32330. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32331. * The material properties need to be setup according to the type of texture in use.
  32332. */
  32333. environmentBRDFTexture: BaseTexture;
  32334. /** @hidden */
  32335. protected _environmentTexture: Nullable<BaseTexture>;
  32336. /**
  32337. * Texture used in all pbr material as the reflection texture.
  32338. * As in the majority of the scene they are the same (exception for multi room and so on),
  32339. * this is easier to reference from here than from all the materials.
  32340. */
  32341. /**
  32342. * Texture used in all pbr material as the reflection texture.
  32343. * As in the majority of the scene they are the same (exception for multi room and so on),
  32344. * this is easier to set here than in all the materials.
  32345. */
  32346. environmentTexture: Nullable<BaseTexture>;
  32347. /** @hidden */
  32348. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32349. /**
  32350. * Default image processing configuration used either in the rendering
  32351. * Forward main pass or through the imageProcessingPostProcess if present.
  32352. * As in the majority of the scene they are the same (exception for multi camera),
  32353. * this is easier to reference from here than from all the materials and post process.
  32354. *
  32355. * No setter as we it is a shared configuration, you can set the values instead.
  32356. */
  32357. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32358. private _forceWireframe;
  32359. /**
  32360. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32361. */
  32362. forceWireframe: boolean;
  32363. private _forcePointsCloud;
  32364. /**
  32365. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32366. */
  32367. forcePointsCloud: boolean;
  32368. /**
  32369. * Gets or sets the active clipplane 1
  32370. */
  32371. clipPlane: Nullable<Plane>;
  32372. /**
  32373. * Gets or sets the active clipplane 2
  32374. */
  32375. clipPlane2: Nullable<Plane>;
  32376. /**
  32377. * Gets or sets the active clipplane 3
  32378. */
  32379. clipPlane3: Nullable<Plane>;
  32380. /**
  32381. * Gets or sets the active clipplane 4
  32382. */
  32383. clipPlane4: Nullable<Plane>;
  32384. /**
  32385. * Gets or sets a boolean indicating if animations are enabled
  32386. */
  32387. animationsEnabled: boolean;
  32388. private _animationPropertiesOverride;
  32389. /**
  32390. * Gets or sets the animation properties override
  32391. */
  32392. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32393. /**
  32394. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32395. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32396. */
  32397. useConstantAnimationDeltaTime: boolean;
  32398. /**
  32399. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32400. * Please note that it requires to run a ray cast through the scene on every frame
  32401. */
  32402. constantlyUpdateMeshUnderPointer: boolean;
  32403. /**
  32404. * Defines the HTML cursor to use when hovering over interactive elements
  32405. */
  32406. hoverCursor: string;
  32407. /**
  32408. * Defines the HTML default cursor to use (empty by default)
  32409. */
  32410. defaultCursor: string;
  32411. /**
  32412. * This is used to call preventDefault() on pointer down
  32413. * in order to block unwanted artifacts like system double clicks
  32414. */
  32415. preventDefaultOnPointerDown: boolean;
  32416. /**
  32417. * This is used to call preventDefault() on pointer up
  32418. * in order to block unwanted artifacts like system double clicks
  32419. */
  32420. preventDefaultOnPointerUp: boolean;
  32421. /**
  32422. * Gets or sets user defined metadata
  32423. */
  32424. metadata: any;
  32425. /**
  32426. * For internal use only. Please do not use.
  32427. */
  32428. reservedDataStore: any;
  32429. /**
  32430. * Gets the name of the plugin used to load this scene (null by default)
  32431. */
  32432. loadingPluginName: string;
  32433. /**
  32434. * Use this array to add regular expressions used to disable offline support for specific urls
  32435. */
  32436. disableOfflineSupportExceptionRules: RegExp[];
  32437. /**
  32438. * An event triggered when the scene is disposed.
  32439. */
  32440. onDisposeObservable: Observable<Scene>;
  32441. private _onDisposeObserver;
  32442. /** Sets a function to be executed when this scene is disposed. */
  32443. onDispose: () => void;
  32444. /**
  32445. * An event triggered before rendering the scene (right after animations and physics)
  32446. */
  32447. onBeforeRenderObservable: Observable<Scene>;
  32448. private _onBeforeRenderObserver;
  32449. /** Sets a function to be executed before rendering this scene */
  32450. beforeRender: Nullable<() => void>;
  32451. /**
  32452. * An event triggered after rendering the scene
  32453. */
  32454. onAfterRenderObservable: Observable<Scene>;
  32455. /**
  32456. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32457. */
  32458. onAfterRenderCameraObservable: Observable<Camera>;
  32459. private _onAfterRenderObserver;
  32460. /** Sets a function to be executed after rendering this scene */
  32461. afterRender: Nullable<() => void>;
  32462. /**
  32463. * An event triggered before animating the scene
  32464. */
  32465. onBeforeAnimationsObservable: Observable<Scene>;
  32466. /**
  32467. * An event triggered after animations processing
  32468. */
  32469. onAfterAnimationsObservable: Observable<Scene>;
  32470. /**
  32471. * An event triggered before draw calls are ready to be sent
  32472. */
  32473. onBeforeDrawPhaseObservable: Observable<Scene>;
  32474. /**
  32475. * An event triggered after draw calls have been sent
  32476. */
  32477. onAfterDrawPhaseObservable: Observable<Scene>;
  32478. /**
  32479. * An event triggered when the scene is ready
  32480. */
  32481. onReadyObservable: Observable<Scene>;
  32482. /**
  32483. * An event triggered before rendering a camera
  32484. */
  32485. onBeforeCameraRenderObservable: Observable<Camera>;
  32486. private _onBeforeCameraRenderObserver;
  32487. /** Sets a function to be executed before rendering a camera*/
  32488. beforeCameraRender: () => void;
  32489. /**
  32490. * An event triggered after rendering a camera
  32491. */
  32492. onAfterCameraRenderObservable: Observable<Camera>;
  32493. private _onAfterCameraRenderObserver;
  32494. /** Sets a function to be executed after rendering a camera*/
  32495. afterCameraRender: () => void;
  32496. /**
  32497. * An event triggered when active meshes evaluation is about to start
  32498. */
  32499. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32500. /**
  32501. * An event triggered when active meshes evaluation is done
  32502. */
  32503. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32504. /**
  32505. * An event triggered when particles rendering is about to start
  32506. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32507. */
  32508. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32509. /**
  32510. * An event triggered when particles rendering is done
  32511. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32512. */
  32513. onAfterParticlesRenderingObservable: Observable<Scene>;
  32514. /**
  32515. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32516. */
  32517. onDataLoadedObservable: Observable<Scene>;
  32518. /**
  32519. * An event triggered when a camera is created
  32520. */
  32521. onNewCameraAddedObservable: Observable<Camera>;
  32522. /**
  32523. * An event triggered when a camera is removed
  32524. */
  32525. onCameraRemovedObservable: Observable<Camera>;
  32526. /**
  32527. * An event triggered when a light is created
  32528. */
  32529. onNewLightAddedObservable: Observable<Light>;
  32530. /**
  32531. * An event triggered when a light is removed
  32532. */
  32533. onLightRemovedObservable: Observable<Light>;
  32534. /**
  32535. * An event triggered when a geometry is created
  32536. */
  32537. onNewGeometryAddedObservable: Observable<Geometry>;
  32538. /**
  32539. * An event triggered when a geometry is removed
  32540. */
  32541. onGeometryRemovedObservable: Observable<Geometry>;
  32542. /**
  32543. * An event triggered when a transform node is created
  32544. */
  32545. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32546. /**
  32547. * An event triggered when a transform node is removed
  32548. */
  32549. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32550. /**
  32551. * An event triggered when a mesh is created
  32552. */
  32553. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32554. /**
  32555. * An event triggered when a mesh is removed
  32556. */
  32557. onMeshRemovedObservable: Observable<AbstractMesh>;
  32558. /**
  32559. * An event triggered when a skeleton is created
  32560. */
  32561. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32562. /**
  32563. * An event triggered when a skeleton is removed
  32564. */
  32565. onSkeletonRemovedObservable: Observable<Skeleton>;
  32566. /**
  32567. * An event triggered when a material is created
  32568. */
  32569. onNewMaterialAddedObservable: Observable<Material>;
  32570. /**
  32571. * An event triggered when a material is removed
  32572. */
  32573. onMaterialRemovedObservable: Observable<Material>;
  32574. /**
  32575. * An event triggered when a texture is created
  32576. */
  32577. onNewTextureAddedObservable: Observable<BaseTexture>;
  32578. /**
  32579. * An event triggered when a texture is removed
  32580. */
  32581. onTextureRemovedObservable: Observable<BaseTexture>;
  32582. /**
  32583. * An event triggered when render targets are about to be rendered
  32584. * Can happen multiple times per frame.
  32585. */
  32586. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32587. /**
  32588. * An event triggered when render targets were rendered.
  32589. * Can happen multiple times per frame.
  32590. */
  32591. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32592. /**
  32593. * An event triggered before calculating deterministic simulation step
  32594. */
  32595. onBeforeStepObservable: Observable<Scene>;
  32596. /**
  32597. * An event triggered after calculating deterministic simulation step
  32598. */
  32599. onAfterStepObservable: Observable<Scene>;
  32600. /**
  32601. * An event triggered when the activeCamera property is updated
  32602. */
  32603. onActiveCameraChanged: Observable<Scene>;
  32604. /**
  32605. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32606. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32607. * 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)
  32608. */
  32609. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32610. /**
  32611. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32612. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32613. * 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)
  32614. */
  32615. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32616. /**
  32617. * This Observable will when a mesh has been imported into the scene.
  32618. */
  32619. onMeshImportedObservable: Observable<AbstractMesh>;
  32620. /**
  32621. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32622. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32623. */
  32624. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32625. /** @hidden */
  32626. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32627. /**
  32628. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32629. */
  32630. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32631. /**
  32632. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32633. */
  32634. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32635. /**
  32636. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32637. */
  32638. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32639. /** Callback called when a pointer move is detected */
  32640. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32641. /** Callback called when a pointer down is detected */
  32642. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32643. /** Callback called when a pointer up is detected */
  32644. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32645. /** Callback called when a pointer pick is detected */
  32646. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32647. /**
  32648. * 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).
  32649. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32650. */
  32651. onPrePointerObservable: Observable<PointerInfoPre>;
  32652. /**
  32653. * Observable event triggered each time an input event is received from the rendering canvas
  32654. */
  32655. onPointerObservable: Observable<PointerInfo>;
  32656. /**
  32657. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32658. */
  32659. readonly unTranslatedPointer: Vector2;
  32660. /**
  32661. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32662. */
  32663. static DragMovementThreshold: number;
  32664. /**
  32665. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32666. */
  32667. static LongPressDelay: number;
  32668. /**
  32669. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32670. */
  32671. static DoubleClickDelay: number;
  32672. /** If you need to check double click without raising a single click at first click, enable this flag */
  32673. static ExclusiveDoubleClickMode: boolean;
  32674. /** @hidden */
  32675. _mirroredCameraPosition: Nullable<Vector3>;
  32676. /**
  32677. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32678. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32679. */
  32680. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32681. /**
  32682. * Observable event triggered each time an keyboard event is received from the hosting window
  32683. */
  32684. onKeyboardObservable: Observable<KeyboardInfo>;
  32685. private _useRightHandedSystem;
  32686. /**
  32687. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32688. */
  32689. useRightHandedSystem: boolean;
  32690. private _timeAccumulator;
  32691. private _currentStepId;
  32692. private _currentInternalStep;
  32693. /**
  32694. * Sets the step Id used by deterministic lock step
  32695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32696. * @param newStepId defines the step Id
  32697. */
  32698. setStepId(newStepId: number): void;
  32699. /**
  32700. * Gets the step Id used by deterministic lock step
  32701. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32702. * @returns the step Id
  32703. */
  32704. getStepId(): number;
  32705. /**
  32706. * Gets the internal step used by deterministic lock step
  32707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32708. * @returns the internal step
  32709. */
  32710. getInternalStep(): number;
  32711. private _fogEnabled;
  32712. /**
  32713. * Gets or sets a boolean indicating if fog is enabled on this scene
  32714. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32715. * (Default is true)
  32716. */
  32717. fogEnabled: boolean;
  32718. private _fogMode;
  32719. /**
  32720. * Gets or sets the fog mode to use
  32721. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32722. * | mode | value |
  32723. * | --- | --- |
  32724. * | FOGMODE_NONE | 0 |
  32725. * | FOGMODE_EXP | 1 |
  32726. * | FOGMODE_EXP2 | 2 |
  32727. * | FOGMODE_LINEAR | 3 |
  32728. */
  32729. fogMode: number;
  32730. /**
  32731. * Gets or sets the fog color to use
  32732. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32733. * (Default is Color3(0.2, 0.2, 0.3))
  32734. */
  32735. fogColor: Color3;
  32736. /**
  32737. * Gets or sets the fog density to use
  32738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32739. * (Default is 0.1)
  32740. */
  32741. fogDensity: number;
  32742. /**
  32743. * Gets or sets the fog start distance to use
  32744. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32745. * (Default is 0)
  32746. */
  32747. fogStart: number;
  32748. /**
  32749. * Gets or sets the fog end distance to use
  32750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32751. * (Default is 1000)
  32752. */
  32753. fogEnd: number;
  32754. private _shadowsEnabled;
  32755. /**
  32756. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32757. */
  32758. shadowsEnabled: boolean;
  32759. private _lightsEnabled;
  32760. /**
  32761. * Gets or sets a boolean indicating if lights are enabled on this scene
  32762. */
  32763. lightsEnabled: boolean;
  32764. /** All of the active cameras added to this scene. */
  32765. activeCameras: Camera[];
  32766. /** @hidden */
  32767. _activeCamera: Nullable<Camera>;
  32768. /** Gets or sets the current active camera */
  32769. activeCamera: Nullable<Camera>;
  32770. private _defaultMaterial;
  32771. /** The default material used on meshes when no material is affected */
  32772. /** The default material used on meshes when no material is affected */
  32773. defaultMaterial: Material;
  32774. private _texturesEnabled;
  32775. /**
  32776. * Gets or sets a boolean indicating if textures are enabled on this scene
  32777. */
  32778. texturesEnabled: boolean;
  32779. /**
  32780. * Gets or sets a boolean indicating if particles are enabled on this scene
  32781. */
  32782. particlesEnabled: boolean;
  32783. /**
  32784. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32785. */
  32786. spritesEnabled: boolean;
  32787. private _skeletonsEnabled;
  32788. /**
  32789. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32790. */
  32791. skeletonsEnabled: boolean;
  32792. /**
  32793. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32794. */
  32795. lensFlaresEnabled: boolean;
  32796. /**
  32797. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32799. */
  32800. collisionsEnabled: boolean;
  32801. private _collisionCoordinator;
  32802. /** @hidden */
  32803. readonly collisionCoordinator: ICollisionCoordinator;
  32804. /**
  32805. * Defines the gravity applied to this scene (used only for collisions)
  32806. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32807. */
  32808. gravity: Vector3;
  32809. /**
  32810. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32811. */
  32812. postProcessesEnabled: boolean;
  32813. /**
  32814. * The list of postprocesses added to the scene
  32815. */
  32816. postProcesses: PostProcess[];
  32817. /**
  32818. * Gets the current postprocess manager
  32819. */
  32820. postProcessManager: PostProcessManager;
  32821. /**
  32822. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32823. */
  32824. renderTargetsEnabled: boolean;
  32825. /**
  32826. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32827. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32828. */
  32829. dumpNextRenderTargets: boolean;
  32830. /**
  32831. * The list of user defined render targets added to the scene
  32832. */
  32833. customRenderTargets: RenderTargetTexture[];
  32834. /**
  32835. * Defines if texture loading must be delayed
  32836. * If true, textures will only be loaded when they need to be rendered
  32837. */
  32838. useDelayedTextureLoading: boolean;
  32839. /**
  32840. * Gets the list of meshes imported to the scene through SceneLoader
  32841. */
  32842. importedMeshesFiles: String[];
  32843. /**
  32844. * Gets or sets a boolean indicating if probes are enabled on this scene
  32845. */
  32846. probesEnabled: boolean;
  32847. /**
  32848. * Gets or sets the current offline provider to use to store scene data
  32849. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32850. */
  32851. offlineProvider: IOfflineProvider;
  32852. /**
  32853. * Gets or sets the action manager associated with the scene
  32854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32855. */
  32856. actionManager: AbstractActionManager;
  32857. private _meshesForIntersections;
  32858. /**
  32859. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32860. */
  32861. proceduralTexturesEnabled: boolean;
  32862. private _engine;
  32863. private _totalVertices;
  32864. /** @hidden */
  32865. _activeIndices: PerfCounter;
  32866. /** @hidden */
  32867. _activeParticles: PerfCounter;
  32868. /** @hidden */
  32869. _activeBones: PerfCounter;
  32870. private _animationRatio;
  32871. /** @hidden */
  32872. _animationTimeLast: number;
  32873. /** @hidden */
  32874. _animationTime: number;
  32875. /**
  32876. * Gets or sets a general scale for animation speed
  32877. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32878. */
  32879. animationTimeScale: number;
  32880. /** @hidden */
  32881. _cachedMaterial: Nullable<Material>;
  32882. /** @hidden */
  32883. _cachedEffect: Nullable<Effect>;
  32884. /** @hidden */
  32885. _cachedVisibility: Nullable<number>;
  32886. private _renderId;
  32887. private _frameId;
  32888. private _executeWhenReadyTimeoutId;
  32889. private _intermediateRendering;
  32890. private _viewUpdateFlag;
  32891. private _projectionUpdateFlag;
  32892. /** @hidden */
  32893. _toBeDisposed: Nullable<IDisposable>[];
  32894. private _activeRequests;
  32895. /** @hidden */
  32896. _pendingData: any[];
  32897. private _isDisposed;
  32898. /**
  32899. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32900. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32901. */
  32902. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32903. private _activeMeshes;
  32904. private _processedMaterials;
  32905. private _renderTargets;
  32906. /** @hidden */
  32907. _activeParticleSystems: SmartArray<IParticleSystem>;
  32908. private _activeSkeletons;
  32909. private _softwareSkinnedMeshes;
  32910. private _renderingManager;
  32911. /** @hidden */
  32912. _activeAnimatables: Animatable[];
  32913. private _transformMatrix;
  32914. private _sceneUbo;
  32915. /** @hidden */
  32916. _viewMatrix: Matrix;
  32917. private _projectionMatrix;
  32918. /** @hidden */
  32919. _forcedViewPosition: Nullable<Vector3>;
  32920. /** @hidden */
  32921. _frustumPlanes: Plane[];
  32922. /**
  32923. * Gets the list of frustum planes (built from the active camera)
  32924. */
  32925. readonly frustumPlanes: Plane[];
  32926. /**
  32927. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32928. * This is useful if there are more lights that the maximum simulteanous authorized
  32929. */
  32930. requireLightSorting: boolean;
  32931. /** @hidden */
  32932. readonly useMaterialMeshMap: boolean;
  32933. /** @hidden */
  32934. readonly useClonedMeshhMap: boolean;
  32935. private _externalData;
  32936. private _uid;
  32937. /**
  32938. * @hidden
  32939. * Backing store of defined scene components.
  32940. */
  32941. _components: ISceneComponent[];
  32942. /**
  32943. * @hidden
  32944. * Backing store of defined scene components.
  32945. */
  32946. _serializableComponents: ISceneSerializableComponent[];
  32947. /**
  32948. * List of components to register on the next registration step.
  32949. */
  32950. private _transientComponents;
  32951. /**
  32952. * Registers the transient components if needed.
  32953. */
  32954. private _registerTransientComponents;
  32955. /**
  32956. * @hidden
  32957. * Add a component to the scene.
  32958. * Note that the ccomponent could be registered on th next frame if this is called after
  32959. * the register component stage.
  32960. * @param component Defines the component to add to the scene
  32961. */
  32962. _addComponent(component: ISceneComponent): void;
  32963. /**
  32964. * @hidden
  32965. * Gets a component from the scene.
  32966. * @param name defines the name of the component to retrieve
  32967. * @returns the component or null if not present
  32968. */
  32969. _getComponent(name: string): Nullable<ISceneComponent>;
  32970. /**
  32971. * @hidden
  32972. * Defines the actions happening before camera updates.
  32973. */
  32974. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32975. /**
  32976. * @hidden
  32977. * Defines the actions happening before clear the canvas.
  32978. */
  32979. _beforeClearStage: Stage<SimpleStageAction>;
  32980. /**
  32981. * @hidden
  32982. * Defines the actions when collecting render targets for the frame.
  32983. */
  32984. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32985. /**
  32986. * @hidden
  32987. * Defines the actions happening for one camera in the frame.
  32988. */
  32989. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32990. /**
  32991. * @hidden
  32992. * Defines the actions happening during the per mesh ready checks.
  32993. */
  32994. _isReadyForMeshStage: Stage<MeshStageAction>;
  32995. /**
  32996. * @hidden
  32997. * Defines the actions happening before evaluate active mesh checks.
  32998. */
  32999. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33000. /**
  33001. * @hidden
  33002. * Defines the actions happening during the evaluate sub mesh checks.
  33003. */
  33004. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33005. /**
  33006. * @hidden
  33007. * Defines the actions happening during the active mesh stage.
  33008. */
  33009. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33010. /**
  33011. * @hidden
  33012. * Defines the actions happening during the per camera render target step.
  33013. */
  33014. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33015. /**
  33016. * @hidden
  33017. * Defines the actions happening just before the active camera is drawing.
  33018. */
  33019. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33020. /**
  33021. * @hidden
  33022. * Defines the actions happening just before a render target is drawing.
  33023. */
  33024. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33025. /**
  33026. * @hidden
  33027. * Defines the actions happening just before a rendering group is drawing.
  33028. */
  33029. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33030. /**
  33031. * @hidden
  33032. * Defines the actions happening just before a mesh is drawing.
  33033. */
  33034. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33035. /**
  33036. * @hidden
  33037. * Defines the actions happening just after a mesh has been drawn.
  33038. */
  33039. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33040. /**
  33041. * @hidden
  33042. * Defines the actions happening just after a rendering group has been drawn.
  33043. */
  33044. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33045. /**
  33046. * @hidden
  33047. * Defines the actions happening just after the active camera has been drawn.
  33048. */
  33049. _afterCameraDrawStage: Stage<CameraStageAction>;
  33050. /**
  33051. * @hidden
  33052. * Defines the actions happening just after a render target has been drawn.
  33053. */
  33054. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33055. /**
  33056. * @hidden
  33057. * Defines the actions happening just after rendering all cameras and computing intersections.
  33058. */
  33059. _afterRenderStage: Stage<SimpleStageAction>;
  33060. /**
  33061. * @hidden
  33062. * Defines the actions happening when a pointer move event happens.
  33063. */
  33064. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33065. /**
  33066. * @hidden
  33067. * Defines the actions happening when a pointer down event happens.
  33068. */
  33069. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33070. /**
  33071. * @hidden
  33072. * Defines the actions happening when a pointer up event happens.
  33073. */
  33074. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33075. /**
  33076. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33077. */
  33078. private geometriesByUniqueId;
  33079. /**
  33080. * Creates a new Scene
  33081. * @param engine defines the engine to use to render this scene
  33082. * @param options defines the scene options
  33083. */
  33084. constructor(engine: Engine, options?: SceneOptions);
  33085. /**
  33086. * Gets a string idenfifying the name of the class
  33087. * @returns "Scene" string
  33088. */
  33089. getClassName(): string;
  33090. private _defaultMeshCandidates;
  33091. /**
  33092. * @hidden
  33093. */
  33094. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33095. private _defaultSubMeshCandidates;
  33096. /**
  33097. * @hidden
  33098. */
  33099. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33100. /**
  33101. * Sets the default candidate providers for the scene.
  33102. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33103. * and getCollidingSubMeshCandidates to their default function
  33104. */
  33105. setDefaultCandidateProviders(): void;
  33106. /**
  33107. * Gets the mesh that is currently under the pointer
  33108. */
  33109. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33110. /**
  33111. * Gets or sets the current on-screen X position of the pointer
  33112. */
  33113. pointerX: number;
  33114. /**
  33115. * Gets or sets the current on-screen Y position of the pointer
  33116. */
  33117. pointerY: number;
  33118. /**
  33119. * Gets the cached material (ie. the latest rendered one)
  33120. * @returns the cached material
  33121. */
  33122. getCachedMaterial(): Nullable<Material>;
  33123. /**
  33124. * Gets the cached effect (ie. the latest rendered one)
  33125. * @returns the cached effect
  33126. */
  33127. getCachedEffect(): Nullable<Effect>;
  33128. /**
  33129. * Gets the cached visibility state (ie. the latest rendered one)
  33130. * @returns the cached visibility state
  33131. */
  33132. getCachedVisibility(): Nullable<number>;
  33133. /**
  33134. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33135. * @param material defines the current material
  33136. * @param effect defines the current effect
  33137. * @param visibility defines the current visibility state
  33138. * @returns true if one parameter is not cached
  33139. */
  33140. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33141. /**
  33142. * Gets the engine associated with the scene
  33143. * @returns an Engine
  33144. */
  33145. getEngine(): Engine;
  33146. /**
  33147. * Gets the total number of vertices rendered per frame
  33148. * @returns the total number of vertices rendered per frame
  33149. */
  33150. getTotalVertices(): number;
  33151. /**
  33152. * Gets the performance counter for total vertices
  33153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33154. */
  33155. readonly totalVerticesPerfCounter: PerfCounter;
  33156. /**
  33157. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33158. * @returns the total number of active indices rendered per frame
  33159. */
  33160. getActiveIndices(): number;
  33161. /**
  33162. * Gets the performance counter for active indices
  33163. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33164. */
  33165. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33166. /**
  33167. * Gets the total number of active particles rendered per frame
  33168. * @returns the total number of active particles rendered per frame
  33169. */
  33170. getActiveParticles(): number;
  33171. /**
  33172. * Gets the performance counter for active particles
  33173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33174. */
  33175. readonly activeParticlesPerfCounter: PerfCounter;
  33176. /**
  33177. * Gets the total number of active bones rendered per frame
  33178. * @returns the total number of active bones rendered per frame
  33179. */
  33180. getActiveBones(): number;
  33181. /**
  33182. * Gets the performance counter for active bones
  33183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33184. */
  33185. readonly activeBonesPerfCounter: PerfCounter;
  33186. /**
  33187. * Gets the array of active meshes
  33188. * @returns an array of AbstractMesh
  33189. */
  33190. getActiveMeshes(): SmartArray<AbstractMesh>;
  33191. /**
  33192. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33193. * @returns a number
  33194. */
  33195. getAnimationRatio(): number;
  33196. /**
  33197. * Gets an unique Id for the current render phase
  33198. * @returns a number
  33199. */
  33200. getRenderId(): number;
  33201. /**
  33202. * Gets an unique Id for the current frame
  33203. * @returns a number
  33204. */
  33205. getFrameId(): number;
  33206. /** Call this function if you want to manually increment the render Id*/
  33207. incrementRenderId(): void;
  33208. private _createUbo;
  33209. /**
  33210. * Use this method to simulate a pointer move on a mesh
  33211. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33212. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33213. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33214. * @returns the current scene
  33215. */
  33216. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33217. /**
  33218. * Use this method to simulate a pointer down on a mesh
  33219. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33220. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33221. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33222. * @returns the current scene
  33223. */
  33224. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33225. /**
  33226. * Use this method to simulate a pointer up on a mesh
  33227. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33228. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33229. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33230. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33231. * @returns the current scene
  33232. */
  33233. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33234. /**
  33235. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33236. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33237. * @returns true if the pointer was captured
  33238. */
  33239. isPointerCaptured(pointerId?: number): boolean;
  33240. /**
  33241. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33242. * @param attachUp defines if you want to attach events to pointerup
  33243. * @param attachDown defines if you want to attach events to pointerdown
  33244. * @param attachMove defines if you want to attach events to pointermove
  33245. */
  33246. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33247. /** Detaches all event handlers*/
  33248. detachControl(): void;
  33249. /**
  33250. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33251. * Delay loaded resources are not taking in account
  33252. * @return true if all required resources are ready
  33253. */
  33254. isReady(): boolean;
  33255. /** Resets all cached information relative to material (including effect and visibility) */
  33256. resetCachedMaterial(): void;
  33257. /**
  33258. * Registers a function to be called before every frame render
  33259. * @param func defines the function to register
  33260. */
  33261. registerBeforeRender(func: () => void): void;
  33262. /**
  33263. * Unregisters a function called before every frame render
  33264. * @param func defines the function to unregister
  33265. */
  33266. unregisterBeforeRender(func: () => void): void;
  33267. /**
  33268. * Registers a function to be called after every frame render
  33269. * @param func defines the function to register
  33270. */
  33271. registerAfterRender(func: () => void): void;
  33272. /**
  33273. * Unregisters a function called after every frame render
  33274. * @param func defines the function to unregister
  33275. */
  33276. unregisterAfterRender(func: () => void): void;
  33277. private _executeOnceBeforeRender;
  33278. /**
  33279. * The provided function will run before render once and will be disposed afterwards.
  33280. * A timeout delay can be provided so that the function will be executed in N ms.
  33281. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33282. * @param func The function to be executed.
  33283. * @param timeout optional delay in ms
  33284. */
  33285. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33286. /** @hidden */
  33287. _addPendingData(data: any): void;
  33288. /** @hidden */
  33289. _removePendingData(data: any): void;
  33290. /**
  33291. * Returns the number of items waiting to be loaded
  33292. * @returns the number of items waiting to be loaded
  33293. */
  33294. getWaitingItemsCount(): number;
  33295. /**
  33296. * Returns a boolean indicating if the scene is still loading data
  33297. */
  33298. readonly isLoading: boolean;
  33299. /**
  33300. * Registers a function to be executed when the scene is ready
  33301. * @param {Function} func - the function to be executed
  33302. */
  33303. executeWhenReady(func: () => void): void;
  33304. /**
  33305. * Returns a promise that resolves when the scene is ready
  33306. * @returns A promise that resolves when the scene is ready
  33307. */
  33308. whenReadyAsync(): Promise<void>;
  33309. /** @hidden */
  33310. _checkIsReady(): void;
  33311. /**
  33312. * Gets all animatable attached to the scene
  33313. */
  33314. readonly animatables: Animatable[];
  33315. /**
  33316. * Resets the last animation time frame.
  33317. * Useful to override when animations start running when loading a scene for the first time.
  33318. */
  33319. resetLastAnimationTimeFrame(): void;
  33320. /**
  33321. * Gets the current view matrix
  33322. * @returns a Matrix
  33323. */
  33324. getViewMatrix(): Matrix;
  33325. /**
  33326. * Gets the current projection matrix
  33327. * @returns a Matrix
  33328. */
  33329. getProjectionMatrix(): Matrix;
  33330. /**
  33331. * Gets the current transform matrix
  33332. * @returns a Matrix made of View * Projection
  33333. */
  33334. getTransformMatrix(): Matrix;
  33335. /**
  33336. * Sets the current transform matrix
  33337. * @param viewL defines the View matrix to use
  33338. * @param projectionL defines the Projection matrix to use
  33339. * @param viewR defines the right View matrix to use (if provided)
  33340. * @param projectionR defines the right Projection matrix to use (if provided)
  33341. */
  33342. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33343. /**
  33344. * Gets the uniform buffer used to store scene data
  33345. * @returns a UniformBuffer
  33346. */
  33347. getSceneUniformBuffer(): UniformBuffer;
  33348. /**
  33349. * Gets an unique (relatively to the current scene) Id
  33350. * @returns an unique number for the scene
  33351. */
  33352. getUniqueId(): number;
  33353. /**
  33354. * Add a mesh to the list of scene's meshes
  33355. * @param newMesh defines the mesh to add
  33356. * @param recursive if all child meshes should also be added to the scene
  33357. */
  33358. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33359. /**
  33360. * Remove a mesh for the list of scene's meshes
  33361. * @param toRemove defines the mesh to remove
  33362. * @param recursive if all child meshes should also be removed from the scene
  33363. * @returns the index where the mesh was in the mesh list
  33364. */
  33365. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33366. /**
  33367. * Add a transform node to the list of scene's transform nodes
  33368. * @param newTransformNode defines the transform node to add
  33369. */
  33370. addTransformNode(newTransformNode: TransformNode): void;
  33371. /**
  33372. * Remove a transform node for the list of scene's transform nodes
  33373. * @param toRemove defines the transform node to remove
  33374. * @returns the index where the transform node was in the transform node list
  33375. */
  33376. removeTransformNode(toRemove: TransformNode): number;
  33377. /**
  33378. * Remove a skeleton for the list of scene's skeletons
  33379. * @param toRemove defines the skeleton to remove
  33380. * @returns the index where the skeleton was in the skeleton list
  33381. */
  33382. removeSkeleton(toRemove: Skeleton): number;
  33383. /**
  33384. * Remove a morph target for the list of scene's morph targets
  33385. * @param toRemove defines the morph target to remove
  33386. * @returns the index where the morph target was in the morph target list
  33387. */
  33388. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33389. /**
  33390. * Remove a light for the list of scene's lights
  33391. * @param toRemove defines the light to remove
  33392. * @returns the index where the light was in the light list
  33393. */
  33394. removeLight(toRemove: Light): number;
  33395. /**
  33396. * Remove a camera for the list of scene's cameras
  33397. * @param toRemove defines the camera to remove
  33398. * @returns the index where the camera was in the camera list
  33399. */
  33400. removeCamera(toRemove: Camera): number;
  33401. /**
  33402. * Remove a particle system for the list of scene's particle systems
  33403. * @param toRemove defines the particle system to remove
  33404. * @returns the index where the particle system was in the particle system list
  33405. */
  33406. removeParticleSystem(toRemove: IParticleSystem): number;
  33407. /**
  33408. * Remove a animation for the list of scene's animations
  33409. * @param toRemove defines the animation to remove
  33410. * @returns the index where the animation was in the animation list
  33411. */
  33412. removeAnimation(toRemove: Animation): number;
  33413. /**
  33414. * Will stop the animation of the given target
  33415. * @param target - the target
  33416. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33417. * @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)
  33418. */
  33419. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33420. /**
  33421. * Removes the given animation group from this scene.
  33422. * @param toRemove The animation group to remove
  33423. * @returns The index of the removed animation group
  33424. */
  33425. removeAnimationGroup(toRemove: AnimationGroup): number;
  33426. /**
  33427. * Removes the given multi-material from this scene.
  33428. * @param toRemove The multi-material to remove
  33429. * @returns The index of the removed multi-material
  33430. */
  33431. removeMultiMaterial(toRemove: MultiMaterial): number;
  33432. /**
  33433. * Removes the given material from this scene.
  33434. * @param toRemove The material to remove
  33435. * @returns The index of the removed material
  33436. */
  33437. removeMaterial(toRemove: Material): number;
  33438. /**
  33439. * Removes the given action manager from this scene.
  33440. * @param toRemove The action manager to remove
  33441. * @returns The index of the removed action manager
  33442. */
  33443. removeActionManager(toRemove: AbstractActionManager): number;
  33444. /**
  33445. * Removes the given texture from this scene.
  33446. * @param toRemove The texture to remove
  33447. * @returns The index of the removed texture
  33448. */
  33449. removeTexture(toRemove: BaseTexture): number;
  33450. /**
  33451. * Adds the given light to this scene
  33452. * @param newLight The light to add
  33453. */
  33454. addLight(newLight: Light): void;
  33455. /**
  33456. * Sorts the list list based on light priorities
  33457. */
  33458. sortLightsByPriority(): void;
  33459. /**
  33460. * Adds the given camera to this scene
  33461. * @param newCamera The camera to add
  33462. */
  33463. addCamera(newCamera: Camera): void;
  33464. /**
  33465. * Adds the given skeleton to this scene
  33466. * @param newSkeleton The skeleton to add
  33467. */
  33468. addSkeleton(newSkeleton: Skeleton): void;
  33469. /**
  33470. * Adds the given particle system to this scene
  33471. * @param newParticleSystem The particle system to add
  33472. */
  33473. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33474. /**
  33475. * Adds the given animation to this scene
  33476. * @param newAnimation The animation to add
  33477. */
  33478. addAnimation(newAnimation: Animation): void;
  33479. /**
  33480. * Adds the given animation group to this scene.
  33481. * @param newAnimationGroup The animation group to add
  33482. */
  33483. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33484. /**
  33485. * Adds the given multi-material to this scene
  33486. * @param newMultiMaterial The multi-material to add
  33487. */
  33488. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33489. /**
  33490. * Adds the given material to this scene
  33491. * @param newMaterial The material to add
  33492. */
  33493. addMaterial(newMaterial: Material): void;
  33494. /**
  33495. * Adds the given morph target to this scene
  33496. * @param newMorphTargetManager The morph target to add
  33497. */
  33498. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33499. /**
  33500. * Adds the given geometry to this scene
  33501. * @param newGeometry The geometry to add
  33502. */
  33503. addGeometry(newGeometry: Geometry): void;
  33504. /**
  33505. * Adds the given action manager to this scene
  33506. * @param newActionManager The action manager to add
  33507. */
  33508. addActionManager(newActionManager: AbstractActionManager): void;
  33509. /**
  33510. * Adds the given texture to this scene.
  33511. * @param newTexture The texture to add
  33512. */
  33513. addTexture(newTexture: BaseTexture): void;
  33514. /**
  33515. * Switch active camera
  33516. * @param newCamera defines the new active camera
  33517. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33518. */
  33519. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33520. /**
  33521. * sets the active camera of the scene using its ID
  33522. * @param id defines the camera's ID
  33523. * @return the new active camera or null if none found.
  33524. */
  33525. setActiveCameraByID(id: string): Nullable<Camera>;
  33526. /**
  33527. * sets the active camera of the scene using its name
  33528. * @param name defines the camera's name
  33529. * @returns the new active camera or null if none found.
  33530. */
  33531. setActiveCameraByName(name: string): Nullable<Camera>;
  33532. /**
  33533. * get an animation group using its name
  33534. * @param name defines the material's name
  33535. * @return the animation group or null if none found.
  33536. */
  33537. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33538. /**
  33539. * Get a material using its unique id
  33540. * @param uniqueId defines the material's unique id
  33541. * @return the material or null if none found.
  33542. */
  33543. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33544. /**
  33545. * get a material using its id
  33546. * @param id defines the material's ID
  33547. * @return the material or null if none found.
  33548. */
  33549. getMaterialByID(id: string): Nullable<Material>;
  33550. /**
  33551. * Gets a the last added material using a given id
  33552. * @param id defines the material's ID
  33553. * @return the last material with the given id or null if none found.
  33554. */
  33555. getLastMaterialByID(id: string): Nullable<Material>;
  33556. /**
  33557. * Gets a material using its name
  33558. * @param name defines the material's name
  33559. * @return the material or null if none found.
  33560. */
  33561. getMaterialByName(name: string): Nullable<Material>;
  33562. /**
  33563. * Gets a camera using its id
  33564. * @param id defines the id to look for
  33565. * @returns the camera or null if not found
  33566. */
  33567. getCameraByID(id: string): Nullable<Camera>;
  33568. /**
  33569. * Gets a camera using its unique id
  33570. * @param uniqueId defines the unique id to look for
  33571. * @returns the camera or null if not found
  33572. */
  33573. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33574. /**
  33575. * Gets a camera using its name
  33576. * @param name defines the camera's name
  33577. * @return the camera or null if none found.
  33578. */
  33579. getCameraByName(name: string): Nullable<Camera>;
  33580. /**
  33581. * Gets a bone using its id
  33582. * @param id defines the bone's id
  33583. * @return the bone or null if not found
  33584. */
  33585. getBoneByID(id: string): Nullable<Bone>;
  33586. /**
  33587. * Gets a bone using its id
  33588. * @param name defines the bone's name
  33589. * @return the bone or null if not found
  33590. */
  33591. getBoneByName(name: string): Nullable<Bone>;
  33592. /**
  33593. * Gets a light node using its name
  33594. * @param name defines the the light's name
  33595. * @return the light or null if none found.
  33596. */
  33597. getLightByName(name: string): Nullable<Light>;
  33598. /**
  33599. * Gets a light node using its id
  33600. * @param id defines the light's id
  33601. * @return the light or null if none found.
  33602. */
  33603. getLightByID(id: string): Nullable<Light>;
  33604. /**
  33605. * Gets a light node using its scene-generated unique ID
  33606. * @param uniqueId defines the light's unique id
  33607. * @return the light or null if none found.
  33608. */
  33609. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33610. /**
  33611. * Gets a particle system by id
  33612. * @param id defines the particle system id
  33613. * @return the corresponding system or null if none found
  33614. */
  33615. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33616. /**
  33617. * Gets a geometry using its ID
  33618. * @param id defines the geometry's id
  33619. * @return the geometry or null if none found.
  33620. */
  33621. getGeometryByID(id: string): Nullable<Geometry>;
  33622. private _getGeometryByUniqueID;
  33623. /**
  33624. * Add a new geometry to this scene
  33625. * @param geometry defines the geometry to be added to the scene.
  33626. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33627. * @return a boolean defining if the geometry was added or not
  33628. */
  33629. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33630. /**
  33631. * Removes an existing geometry
  33632. * @param geometry defines the geometry to be removed from the scene
  33633. * @return a boolean defining if the geometry was removed or not
  33634. */
  33635. removeGeometry(geometry: Geometry): boolean;
  33636. /**
  33637. * Gets the list of geometries attached to the scene
  33638. * @returns an array of Geometry
  33639. */
  33640. getGeometries(): Geometry[];
  33641. /**
  33642. * Gets the first added mesh found of a given ID
  33643. * @param id defines the id to search for
  33644. * @return the mesh found or null if not found at all
  33645. */
  33646. getMeshByID(id: string): Nullable<AbstractMesh>;
  33647. /**
  33648. * Gets a list of meshes using their id
  33649. * @param id defines the id to search for
  33650. * @returns a list of meshes
  33651. */
  33652. getMeshesByID(id: string): Array<AbstractMesh>;
  33653. /**
  33654. * Gets the first added transform node found of a given ID
  33655. * @param id defines the id to search for
  33656. * @return the found transform node or null if not found at all.
  33657. */
  33658. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33659. /**
  33660. * Gets a transform node with its auto-generated unique id
  33661. * @param uniqueId efines the unique id to search for
  33662. * @return the found transform node or null if not found at all.
  33663. */
  33664. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33665. /**
  33666. * Gets a list of transform nodes using their id
  33667. * @param id defines the id to search for
  33668. * @returns a list of transform nodes
  33669. */
  33670. getTransformNodesByID(id: string): Array<TransformNode>;
  33671. /**
  33672. * Gets a mesh with its auto-generated unique id
  33673. * @param uniqueId defines the unique id to search for
  33674. * @return the found mesh or null if not found at all.
  33675. */
  33676. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33677. /**
  33678. * Gets a the last added mesh using a given id
  33679. * @param id defines the id to search for
  33680. * @return the found mesh or null if not found at all.
  33681. */
  33682. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33683. /**
  33684. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33685. * @param id defines the id to search for
  33686. * @return the found node or null if not found at all
  33687. */
  33688. getLastEntryByID(id: string): Nullable<Node>;
  33689. /**
  33690. * Gets a node (Mesh, Camera, Light) using a given id
  33691. * @param id defines the id to search for
  33692. * @return the found node or null if not found at all
  33693. */
  33694. getNodeByID(id: string): Nullable<Node>;
  33695. /**
  33696. * Gets a node (Mesh, Camera, Light) using a given name
  33697. * @param name defines the name to search for
  33698. * @return the found node or null if not found at all.
  33699. */
  33700. getNodeByName(name: string): Nullable<Node>;
  33701. /**
  33702. * Gets a mesh using a given name
  33703. * @param name defines the name to search for
  33704. * @return the found mesh or null if not found at all.
  33705. */
  33706. getMeshByName(name: string): Nullable<AbstractMesh>;
  33707. /**
  33708. * Gets a transform node using a given name
  33709. * @param name defines the name to search for
  33710. * @return the found transform node or null if not found at all.
  33711. */
  33712. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33713. /**
  33714. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33715. * @param id defines the id to search for
  33716. * @return the found skeleton or null if not found at all.
  33717. */
  33718. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33719. /**
  33720. * Gets a skeleton using a given auto generated unique id
  33721. * @param uniqueId defines the unique id to search for
  33722. * @return the found skeleton or null if not found at all.
  33723. */
  33724. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33725. /**
  33726. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33727. * @param id defines the id to search for
  33728. * @return the found skeleton or null if not found at all.
  33729. */
  33730. getSkeletonById(id: string): Nullable<Skeleton>;
  33731. /**
  33732. * Gets a skeleton using a given name
  33733. * @param name defines the name to search for
  33734. * @return the found skeleton or null if not found at all.
  33735. */
  33736. getSkeletonByName(name: string): Nullable<Skeleton>;
  33737. /**
  33738. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33739. * @param id defines the id to search for
  33740. * @return the found morph target manager or null if not found at all.
  33741. */
  33742. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33743. /**
  33744. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33745. * @param id defines the id to search for
  33746. * @return the found morph target or null if not found at all.
  33747. */
  33748. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33749. /**
  33750. * Gets a boolean indicating if the given mesh is active
  33751. * @param mesh defines the mesh to look for
  33752. * @returns true if the mesh is in the active list
  33753. */
  33754. isActiveMesh(mesh: AbstractMesh): boolean;
  33755. /**
  33756. * Return a unique id as a string which can serve as an identifier for the scene
  33757. */
  33758. readonly uid: string;
  33759. /**
  33760. * Add an externaly attached data from its key.
  33761. * This method call will fail and return false, if such key already exists.
  33762. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33763. * @param key the unique key that identifies the data
  33764. * @param data the data object to associate to the key for this Engine instance
  33765. * @return true if no such key were already present and the data was added successfully, false otherwise
  33766. */
  33767. addExternalData<T>(key: string, data: T): boolean;
  33768. /**
  33769. * Get an externaly attached data from its key
  33770. * @param key the unique key that identifies the data
  33771. * @return the associated data, if present (can be null), or undefined if not present
  33772. */
  33773. getExternalData<T>(key: string): Nullable<T>;
  33774. /**
  33775. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33776. * @param key the unique key that identifies the data
  33777. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33778. * @return the associated data, can be null if the factory returned null.
  33779. */
  33780. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33781. /**
  33782. * Remove an externaly attached data from the Engine instance
  33783. * @param key the unique key that identifies the data
  33784. * @return true if the data was successfully removed, false if it doesn't exist
  33785. */
  33786. removeExternalData(key: string): boolean;
  33787. private _evaluateSubMesh;
  33788. /**
  33789. * Clear the processed materials smart array preventing retention point in material dispose.
  33790. */
  33791. freeProcessedMaterials(): void;
  33792. private _preventFreeActiveMeshesAndRenderingGroups;
  33793. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33794. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33795. * when disposing several meshes in a row or a hierarchy of meshes.
  33796. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33797. */
  33798. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33799. /**
  33800. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33801. */
  33802. freeActiveMeshes(): void;
  33803. /**
  33804. * Clear the info related to rendering groups preventing retention points during dispose.
  33805. */
  33806. freeRenderingGroups(): void;
  33807. /** @hidden */
  33808. _isInIntermediateRendering(): boolean;
  33809. /**
  33810. * Lambda returning the list of potentially active meshes.
  33811. */
  33812. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33813. /**
  33814. * Lambda returning the list of potentially active sub meshes.
  33815. */
  33816. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33817. /**
  33818. * Lambda returning the list of potentially intersecting sub meshes.
  33819. */
  33820. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33821. /**
  33822. * Lambda returning the list of potentially colliding sub meshes.
  33823. */
  33824. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33825. private _activeMeshesFrozen;
  33826. /**
  33827. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33828. * @returns the current scene
  33829. */
  33830. freezeActiveMeshes(): Scene;
  33831. /**
  33832. * Use this function to restart evaluating active meshes on every frame
  33833. * @returns the current scene
  33834. */
  33835. unfreezeActiveMeshes(): Scene;
  33836. private _evaluateActiveMeshes;
  33837. private _activeMesh;
  33838. /**
  33839. * Update the transform matrix to update from the current active camera
  33840. * @param force defines a boolean used to force the update even if cache is up to date
  33841. */
  33842. updateTransformMatrix(force?: boolean): void;
  33843. private _bindFrameBuffer;
  33844. /** @hidden */
  33845. _allowPostProcessClearColor: boolean;
  33846. /** @hidden */
  33847. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33848. private _processSubCameras;
  33849. private _checkIntersections;
  33850. /** @hidden */
  33851. _advancePhysicsEngineStep(step: number): void;
  33852. /**
  33853. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33854. */
  33855. getDeterministicFrameTime: () => number;
  33856. /** @hidden */
  33857. _animate(): void;
  33858. /** Execute all animations (for a frame) */
  33859. animate(): void;
  33860. /**
  33861. * Render the scene
  33862. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33863. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33864. */
  33865. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33866. /**
  33867. * Freeze all materials
  33868. * A frozen material will not be updatable but should be faster to render
  33869. */
  33870. freezeMaterials(): void;
  33871. /**
  33872. * Unfreeze all materials
  33873. * A frozen material will not be updatable but should be faster to render
  33874. */
  33875. unfreezeMaterials(): void;
  33876. /**
  33877. * Releases all held ressources
  33878. */
  33879. dispose(): void;
  33880. /**
  33881. * Gets if the scene is already disposed
  33882. */
  33883. readonly isDisposed: boolean;
  33884. /**
  33885. * Call this function to reduce memory footprint of the scene.
  33886. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33887. */
  33888. clearCachedVertexData(): void;
  33889. /**
  33890. * This function will remove the local cached buffer data from texture.
  33891. * It will save memory but will prevent the texture from being rebuilt
  33892. */
  33893. cleanCachedTextureBuffer(): void;
  33894. /**
  33895. * Get the world extend vectors with an optional filter
  33896. *
  33897. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33898. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33899. */
  33900. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33901. min: Vector3;
  33902. max: Vector3;
  33903. };
  33904. /**
  33905. * Creates a ray that can be used to pick in the scene
  33906. * @param x defines the x coordinate of the origin (on-screen)
  33907. * @param y defines the y coordinate of the origin (on-screen)
  33908. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33909. * @param camera defines the camera to use for the picking
  33910. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33911. * @returns a Ray
  33912. */
  33913. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33914. /**
  33915. * Creates a ray that can be used to pick in the scene
  33916. * @param x defines the x coordinate of the origin (on-screen)
  33917. * @param y defines the y coordinate of the origin (on-screen)
  33918. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33919. * @param result defines the ray where to store the picking ray
  33920. * @param camera defines the camera to use for the picking
  33921. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33922. * @returns the current scene
  33923. */
  33924. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33925. /**
  33926. * Creates a ray that can be used to pick in the scene
  33927. * @param x defines the x coordinate of the origin (on-screen)
  33928. * @param y defines the y coordinate of the origin (on-screen)
  33929. * @param camera defines the camera to use for the picking
  33930. * @returns a Ray
  33931. */
  33932. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33933. /**
  33934. * Creates a ray that can be used to pick in the scene
  33935. * @param x defines the x coordinate of the origin (on-screen)
  33936. * @param y defines the y coordinate of the origin (on-screen)
  33937. * @param result defines the ray where to store the picking ray
  33938. * @param camera defines the camera to use for the picking
  33939. * @returns the current scene
  33940. */
  33941. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33942. /** Launch a ray to try to pick a mesh in the scene
  33943. * @param x position on screen
  33944. * @param y position on screen
  33945. * @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
  33946. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33947. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33948. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33949. * @returns a PickingInfo
  33950. */
  33951. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33952. /** Use the given ray to pick a mesh in the scene
  33953. * @param ray The ray to use to pick meshes
  33954. * @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
  33955. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33956. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33957. * @returns a PickingInfo
  33958. */
  33959. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33960. /**
  33961. * Launch a ray to try to pick a mesh in the scene
  33962. * @param x X position on screen
  33963. * @param y Y position on screen
  33964. * @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
  33965. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33966. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33967. * @returns an array of PickingInfo
  33968. */
  33969. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33970. /**
  33971. * Launch a ray to try to pick a mesh in the scene
  33972. * @param ray Ray to use
  33973. * @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
  33974. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33975. * @returns an array of PickingInfo
  33976. */
  33977. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33978. /**
  33979. * Force the value of meshUnderPointer
  33980. * @param mesh defines the mesh to use
  33981. */
  33982. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33983. /**
  33984. * Gets the mesh under the pointer
  33985. * @returns a Mesh or null if no mesh is under the pointer
  33986. */
  33987. getPointerOverMesh(): Nullable<AbstractMesh>;
  33988. /** @hidden */
  33989. _rebuildGeometries(): void;
  33990. /** @hidden */
  33991. _rebuildTextures(): void;
  33992. private _getByTags;
  33993. /**
  33994. * Get a list of meshes by tags
  33995. * @param tagsQuery defines the tags query to use
  33996. * @param forEach defines a predicate used to filter results
  33997. * @returns an array of Mesh
  33998. */
  33999. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34000. /**
  34001. * Get a list of cameras by tags
  34002. * @param tagsQuery defines the tags query to use
  34003. * @param forEach defines a predicate used to filter results
  34004. * @returns an array of Camera
  34005. */
  34006. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34007. /**
  34008. * Get a list of lights by tags
  34009. * @param tagsQuery defines the tags query to use
  34010. * @param forEach defines a predicate used to filter results
  34011. * @returns an array of Light
  34012. */
  34013. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34014. /**
  34015. * Get a list of materials by tags
  34016. * @param tagsQuery defines the tags query to use
  34017. * @param forEach defines a predicate used to filter results
  34018. * @returns an array of Material
  34019. */
  34020. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34021. /**
  34022. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34023. * This allowed control for front to back rendering or reversly depending of the special needs.
  34024. *
  34025. * @param renderingGroupId The rendering group id corresponding to its index
  34026. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34027. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34028. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34029. */
  34030. 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;
  34031. /**
  34032. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34033. *
  34034. * @param renderingGroupId The rendering group id corresponding to its index
  34035. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34036. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34037. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34038. */
  34039. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34040. /**
  34041. * Gets the current auto clear configuration for one rendering group of the rendering
  34042. * manager.
  34043. * @param index the rendering group index to get the information for
  34044. * @returns The auto clear setup for the requested rendering group
  34045. */
  34046. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34047. private _blockMaterialDirtyMechanism;
  34048. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34049. blockMaterialDirtyMechanism: boolean;
  34050. /**
  34051. * Will flag all materials as dirty to trigger new shader compilation
  34052. * @param flag defines the flag used to specify which material part must be marked as dirty
  34053. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34054. */
  34055. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34056. /** @hidden */
  34057. _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;
  34058. /** @hidden */
  34059. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34060. }
  34061. }
  34062. declare module BABYLON {
  34063. /**
  34064. * Set of assets to keep when moving a scene into an asset container.
  34065. */
  34066. export class KeepAssets extends AbstractScene {
  34067. }
  34068. /**
  34069. * Container with a set of assets that can be added or removed from a scene.
  34070. */
  34071. export class AssetContainer extends AbstractScene {
  34072. /**
  34073. * The scene the AssetContainer belongs to.
  34074. */
  34075. scene: Scene;
  34076. /**
  34077. * Instantiates an AssetContainer.
  34078. * @param scene The scene the AssetContainer belongs to.
  34079. */
  34080. constructor(scene: Scene);
  34081. /**
  34082. * Adds all the assets from the container to the scene.
  34083. */
  34084. addAllToScene(): void;
  34085. /**
  34086. * Removes all the assets in the container from the scene
  34087. */
  34088. removeAllFromScene(): void;
  34089. /**
  34090. * Disposes all the assets in the container
  34091. */
  34092. dispose(): void;
  34093. private _moveAssets;
  34094. /**
  34095. * Removes all the assets contained in the scene and adds them to the container.
  34096. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34097. */
  34098. moveAllFromScene(keepAssets?: KeepAssets): void;
  34099. /**
  34100. * 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.
  34101. * @returns the root mesh
  34102. */
  34103. createRootMesh(): Mesh;
  34104. }
  34105. }
  34106. declare module BABYLON {
  34107. /**
  34108. * Defines how the parser contract is defined.
  34109. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34110. */
  34111. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34112. /**
  34113. * Defines how the individual parser contract is defined.
  34114. * These parser can parse an individual asset
  34115. */
  34116. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34117. /**
  34118. * Base class of the scene acting as a container for the different elements composing a scene.
  34119. * This class is dynamically extended by the different components of the scene increasing
  34120. * flexibility and reducing coupling
  34121. */
  34122. export abstract class AbstractScene {
  34123. /**
  34124. * Stores the list of available parsers in the application.
  34125. */
  34126. private static _BabylonFileParsers;
  34127. /**
  34128. * Stores the list of available individual parsers in the application.
  34129. */
  34130. private static _IndividualBabylonFileParsers;
  34131. /**
  34132. * Adds a parser in the list of available ones
  34133. * @param name Defines the name of the parser
  34134. * @param parser Defines the parser to add
  34135. */
  34136. static AddParser(name: string, parser: BabylonFileParser): void;
  34137. /**
  34138. * Gets a general parser from the list of avaialble ones
  34139. * @param name Defines the name of the parser
  34140. * @returns the requested parser or null
  34141. */
  34142. static GetParser(name: string): Nullable<BabylonFileParser>;
  34143. /**
  34144. * Adds n individual parser in the list of available ones
  34145. * @param name Defines the name of the parser
  34146. * @param parser Defines the parser to add
  34147. */
  34148. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34149. /**
  34150. * Gets an individual parser from the list of avaialble ones
  34151. * @param name Defines the name of the parser
  34152. * @returns the requested parser or null
  34153. */
  34154. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34155. /**
  34156. * Parser json data and populate both a scene and its associated container object
  34157. * @param jsonData Defines the data to parse
  34158. * @param scene Defines the scene to parse the data for
  34159. * @param container Defines the container attached to the parsing sequence
  34160. * @param rootUrl Defines the root url of the data
  34161. */
  34162. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34163. /**
  34164. * Gets the list of root nodes (ie. nodes with no parent)
  34165. */
  34166. rootNodes: Node[];
  34167. /** All of the cameras added to this scene
  34168. * @see http://doc.babylonjs.com/babylon101/cameras
  34169. */
  34170. cameras: Camera[];
  34171. /**
  34172. * All of the lights added to this scene
  34173. * @see http://doc.babylonjs.com/babylon101/lights
  34174. */
  34175. lights: Light[];
  34176. /**
  34177. * All of the (abstract) meshes added to this scene
  34178. */
  34179. meshes: AbstractMesh[];
  34180. /**
  34181. * The list of skeletons added to the scene
  34182. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34183. */
  34184. skeletons: Skeleton[];
  34185. /**
  34186. * All of the particle systems added to this scene
  34187. * @see http://doc.babylonjs.com/babylon101/particles
  34188. */
  34189. particleSystems: IParticleSystem[];
  34190. /**
  34191. * Gets a list of Animations associated with the scene
  34192. */
  34193. animations: Animation[];
  34194. /**
  34195. * All of the animation groups added to this scene
  34196. * @see http://doc.babylonjs.com/how_to/group
  34197. */
  34198. animationGroups: AnimationGroup[];
  34199. /**
  34200. * All of the multi-materials added to this scene
  34201. * @see http://doc.babylonjs.com/how_to/multi_materials
  34202. */
  34203. multiMaterials: MultiMaterial[];
  34204. /**
  34205. * All of the materials added to this scene
  34206. * In the context of a Scene, it is not supposed to be modified manually.
  34207. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34208. * Note also that the order of the Material wihin the array is not significant and might change.
  34209. * @see http://doc.babylonjs.com/babylon101/materials
  34210. */
  34211. materials: Material[];
  34212. /**
  34213. * The list of morph target managers added to the scene
  34214. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34215. */
  34216. morphTargetManagers: MorphTargetManager[];
  34217. /**
  34218. * The list of geometries used in the scene.
  34219. */
  34220. geometries: Geometry[];
  34221. /**
  34222. * All of the tranform nodes added to this scene
  34223. * In the context of a Scene, it is not supposed to be modified manually.
  34224. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34225. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34226. * @see http://doc.babylonjs.com/how_to/transformnode
  34227. */
  34228. transformNodes: TransformNode[];
  34229. /**
  34230. * ActionManagers available on the scene.
  34231. */
  34232. actionManagers: AbstractActionManager[];
  34233. /**
  34234. * Textures to keep.
  34235. */
  34236. textures: BaseTexture[];
  34237. /**
  34238. * Environment texture for the scene
  34239. */
  34240. environmentTexture: Nullable<BaseTexture>;
  34241. }
  34242. }
  34243. declare module BABYLON {
  34244. /**
  34245. * Interface used to define options for Sound class
  34246. */
  34247. export interface ISoundOptions {
  34248. /**
  34249. * Does the sound autoplay once loaded.
  34250. */
  34251. autoplay?: boolean;
  34252. /**
  34253. * Does the sound loop after it finishes playing once.
  34254. */
  34255. loop?: boolean;
  34256. /**
  34257. * Sound's volume
  34258. */
  34259. volume?: number;
  34260. /**
  34261. * Is it a spatial sound?
  34262. */
  34263. spatialSound?: boolean;
  34264. /**
  34265. * Maximum distance to hear that sound
  34266. */
  34267. maxDistance?: number;
  34268. /**
  34269. * Uses user defined attenuation function
  34270. */
  34271. useCustomAttenuation?: boolean;
  34272. /**
  34273. * Define the roll off factor of spatial sounds.
  34274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34275. */
  34276. rolloffFactor?: number;
  34277. /**
  34278. * Define the reference distance the sound should be heard perfectly.
  34279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34280. */
  34281. refDistance?: number;
  34282. /**
  34283. * Define the distance attenuation model the sound will follow.
  34284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34285. */
  34286. distanceModel?: string;
  34287. /**
  34288. * Defines the playback speed (1 by default)
  34289. */
  34290. playbackRate?: number;
  34291. /**
  34292. * Defines if the sound is from a streaming source
  34293. */
  34294. streaming?: boolean;
  34295. /**
  34296. * Defines an optional length (in seconds) inside the sound file
  34297. */
  34298. length?: number;
  34299. /**
  34300. * Defines an optional offset (in seconds) inside the sound file
  34301. */
  34302. offset?: number;
  34303. }
  34304. /**
  34305. * Defines a sound that can be played in the application.
  34306. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34308. */
  34309. export class Sound {
  34310. /**
  34311. * The name of the sound in the scene.
  34312. */
  34313. name: string;
  34314. /**
  34315. * Does the sound autoplay once loaded.
  34316. */
  34317. autoplay: boolean;
  34318. /**
  34319. * Does the sound loop after it finishes playing once.
  34320. */
  34321. loop: boolean;
  34322. /**
  34323. * Does the sound use a custom attenuation curve to simulate the falloff
  34324. * happening when the source gets further away from the camera.
  34325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34326. */
  34327. useCustomAttenuation: boolean;
  34328. /**
  34329. * The sound track id this sound belongs to.
  34330. */
  34331. soundTrackId: number;
  34332. /**
  34333. * Is this sound currently played.
  34334. */
  34335. isPlaying: boolean;
  34336. /**
  34337. * Is this sound currently paused.
  34338. */
  34339. isPaused: boolean;
  34340. /**
  34341. * Does this sound enables spatial sound.
  34342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34343. */
  34344. spatialSound: boolean;
  34345. /**
  34346. * Define the reference distance the sound should be heard perfectly.
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34348. */
  34349. refDistance: number;
  34350. /**
  34351. * Define the roll off factor of spatial sounds.
  34352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34353. */
  34354. rolloffFactor: number;
  34355. /**
  34356. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34358. */
  34359. maxDistance: number;
  34360. /**
  34361. * Define the distance attenuation model the sound will follow.
  34362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34363. */
  34364. distanceModel: string;
  34365. /**
  34366. * @hidden
  34367. * Back Compat
  34368. **/
  34369. onended: () => any;
  34370. /**
  34371. * Observable event when the current playing sound finishes.
  34372. */
  34373. onEndedObservable: Observable<Sound>;
  34374. private _panningModel;
  34375. private _playbackRate;
  34376. private _streaming;
  34377. private _startTime;
  34378. private _startOffset;
  34379. private _position;
  34380. /** @hidden */
  34381. _positionInEmitterSpace: boolean;
  34382. private _localDirection;
  34383. private _volume;
  34384. private _isReadyToPlay;
  34385. private _isDirectional;
  34386. private _readyToPlayCallback;
  34387. private _audioBuffer;
  34388. private _soundSource;
  34389. private _streamingSource;
  34390. private _soundPanner;
  34391. private _soundGain;
  34392. private _inputAudioNode;
  34393. private _outputAudioNode;
  34394. private _coneInnerAngle;
  34395. private _coneOuterAngle;
  34396. private _coneOuterGain;
  34397. private _scene;
  34398. private _connectedTransformNode;
  34399. private _customAttenuationFunction;
  34400. private _registerFunc;
  34401. private _isOutputConnected;
  34402. private _htmlAudioElement;
  34403. private _urlType;
  34404. private _length?;
  34405. private _offset?;
  34406. /** @hidden */
  34407. static _SceneComponentInitialization: (scene: Scene) => void;
  34408. /**
  34409. * Create a sound and attach it to a scene
  34410. * @param name Name of your sound
  34411. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34412. * @param scene defines the scene the sound belongs to
  34413. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34414. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34415. */
  34416. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34417. /**
  34418. * Release the sound and its associated resources
  34419. */
  34420. dispose(): void;
  34421. /**
  34422. * Gets if the sounds is ready to be played or not.
  34423. * @returns true if ready, otherwise false
  34424. */
  34425. isReady(): boolean;
  34426. private _soundLoaded;
  34427. /**
  34428. * Sets the data of the sound from an audiobuffer
  34429. * @param audioBuffer The audioBuffer containing the data
  34430. */
  34431. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34432. /**
  34433. * Updates the current sounds options such as maxdistance, loop...
  34434. * @param options A JSON object containing values named as the object properties
  34435. */
  34436. updateOptions(options: ISoundOptions): void;
  34437. private _createSpatialParameters;
  34438. private _updateSpatialParameters;
  34439. /**
  34440. * Switch the panning model to HRTF:
  34441. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34443. */
  34444. switchPanningModelToHRTF(): void;
  34445. /**
  34446. * Switch the panning model to Equal Power:
  34447. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34449. */
  34450. switchPanningModelToEqualPower(): void;
  34451. private _switchPanningModel;
  34452. /**
  34453. * Connect this sound to a sound track audio node like gain...
  34454. * @param soundTrackAudioNode the sound track audio node to connect to
  34455. */
  34456. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34457. /**
  34458. * Transform this sound into a directional source
  34459. * @param coneInnerAngle Size of the inner cone in degree
  34460. * @param coneOuterAngle Size of the outer cone in degree
  34461. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34462. */
  34463. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34464. /**
  34465. * Gets or sets the inner angle for the directional cone.
  34466. */
  34467. /**
  34468. * Gets or sets the inner angle for the directional cone.
  34469. */
  34470. directionalConeInnerAngle: number;
  34471. /**
  34472. * Gets or sets the outer angle for the directional cone.
  34473. */
  34474. /**
  34475. * Gets or sets the outer angle for the directional cone.
  34476. */
  34477. directionalConeOuterAngle: number;
  34478. /**
  34479. * Sets the position of the emitter if spatial sound is enabled
  34480. * @param newPosition Defines the new posisiton
  34481. */
  34482. setPosition(newPosition: Vector3): void;
  34483. /**
  34484. * Sets the local direction of the emitter if spatial sound is enabled
  34485. * @param newLocalDirection Defines the new local direction
  34486. */
  34487. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34488. private _updateDirection;
  34489. /** @hidden */
  34490. updateDistanceFromListener(): void;
  34491. /**
  34492. * Sets a new custom attenuation function for the sound.
  34493. * @param callback Defines the function used for the attenuation
  34494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34495. */
  34496. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34497. /**
  34498. * Play the sound
  34499. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34500. * @param offset (optional) Start the sound at a specific time in seconds
  34501. * @param length (optional) Sound duration (in seconds)
  34502. */
  34503. play(time?: number, offset?: number, length?: number): void;
  34504. private _onended;
  34505. /**
  34506. * Stop the sound
  34507. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34508. */
  34509. stop(time?: number): void;
  34510. /**
  34511. * Put the sound in pause
  34512. */
  34513. pause(): void;
  34514. /**
  34515. * Sets a dedicated volume for this sounds
  34516. * @param newVolume Define the new volume of the sound
  34517. * @param time Define time for gradual change to new volume
  34518. */
  34519. setVolume(newVolume: number, time?: number): void;
  34520. /**
  34521. * Set the sound play back rate
  34522. * @param newPlaybackRate Define the playback rate the sound should be played at
  34523. */
  34524. setPlaybackRate(newPlaybackRate: number): void;
  34525. /**
  34526. * Gets the volume of the sound.
  34527. * @returns the volume of the sound
  34528. */
  34529. getVolume(): number;
  34530. /**
  34531. * Attach the sound to a dedicated mesh
  34532. * @param transformNode The transform node to connect the sound with
  34533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34534. */
  34535. attachToMesh(transformNode: TransformNode): void;
  34536. /**
  34537. * Detach the sound from the previously attached mesh
  34538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34539. */
  34540. detachFromMesh(): void;
  34541. private _onRegisterAfterWorldMatrixUpdate;
  34542. /**
  34543. * Clone the current sound in the scene.
  34544. * @returns the new sound clone
  34545. */
  34546. clone(): Nullable<Sound>;
  34547. /**
  34548. * Gets the current underlying audio buffer containing the data
  34549. * @returns the audio buffer
  34550. */
  34551. getAudioBuffer(): Nullable<AudioBuffer>;
  34552. /**
  34553. * Serializes the Sound in a JSON representation
  34554. * @returns the JSON representation of the sound
  34555. */
  34556. serialize(): any;
  34557. /**
  34558. * Parse a JSON representation of a sound to innstantiate in a given scene
  34559. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34560. * @param scene Define the scene the new parsed sound should be created in
  34561. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34562. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34563. * @returns the newly parsed sound
  34564. */
  34565. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. /**
  34570. * This defines an action helpful to play a defined sound on a triggered action.
  34571. */
  34572. export class PlaySoundAction extends Action {
  34573. private _sound;
  34574. /**
  34575. * Instantiate the action
  34576. * @param triggerOptions defines the trigger options
  34577. * @param sound defines the sound to play
  34578. * @param condition defines the trigger related conditions
  34579. */
  34580. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34581. /** @hidden */
  34582. _prepare(): void;
  34583. /**
  34584. * Execute the action and play the sound.
  34585. */
  34586. execute(): void;
  34587. /**
  34588. * Serializes the actions and its related information.
  34589. * @param parent defines the object to serialize in
  34590. * @returns the serialized object
  34591. */
  34592. serialize(parent: any): any;
  34593. }
  34594. /**
  34595. * This defines an action helpful to stop a defined sound on a triggered action.
  34596. */
  34597. export class StopSoundAction extends Action {
  34598. private _sound;
  34599. /**
  34600. * Instantiate the action
  34601. * @param triggerOptions defines the trigger options
  34602. * @param sound defines the sound to stop
  34603. * @param condition defines the trigger related conditions
  34604. */
  34605. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34606. /** @hidden */
  34607. _prepare(): void;
  34608. /**
  34609. * Execute the action and stop the sound.
  34610. */
  34611. execute(): void;
  34612. /**
  34613. * Serializes the actions and its related information.
  34614. * @param parent defines the object to serialize in
  34615. * @returns the serialized object
  34616. */
  34617. serialize(parent: any): any;
  34618. }
  34619. }
  34620. declare module BABYLON {
  34621. /**
  34622. * This defines an action responsible to change the value of a property
  34623. * by interpolating between its current value and the newly set one once triggered.
  34624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34625. */
  34626. export class InterpolateValueAction extends Action {
  34627. /**
  34628. * Defines the path of the property where the value should be interpolated
  34629. */
  34630. propertyPath: string;
  34631. /**
  34632. * Defines the target value at the end of the interpolation.
  34633. */
  34634. value: any;
  34635. /**
  34636. * Defines the time it will take for the property to interpolate to the value.
  34637. */
  34638. duration: number;
  34639. /**
  34640. * Defines if the other scene animations should be stopped when the action has been triggered
  34641. */
  34642. stopOtherAnimations?: boolean;
  34643. /**
  34644. * Defines a callback raised once the interpolation animation has been done.
  34645. */
  34646. onInterpolationDone?: () => void;
  34647. /**
  34648. * Observable triggered once the interpolation animation has been done.
  34649. */
  34650. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34651. private _target;
  34652. private _effectiveTarget;
  34653. private _property;
  34654. /**
  34655. * Instantiate the action
  34656. * @param triggerOptions defines the trigger options
  34657. * @param target defines the object containing the value to interpolate
  34658. * @param propertyPath defines the path to the property in the target object
  34659. * @param value defines the target value at the end of the interpolation
  34660. * @param duration deines the time it will take for the property to interpolate to the value.
  34661. * @param condition defines the trigger related conditions
  34662. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34663. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34664. */
  34665. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34666. /** @hidden */
  34667. _prepare(): void;
  34668. /**
  34669. * Execute the action starts the value interpolation.
  34670. */
  34671. execute(): void;
  34672. /**
  34673. * Serializes the actions and its related information.
  34674. * @param parent defines the object to serialize in
  34675. * @returns the serialized object
  34676. */
  34677. serialize(parent: any): any;
  34678. }
  34679. }
  34680. declare module BABYLON {
  34681. /**
  34682. * Options allowed during the creation of a sound track.
  34683. */
  34684. export interface ISoundTrackOptions {
  34685. /**
  34686. * The volume the sound track should take during creation
  34687. */
  34688. volume?: number;
  34689. /**
  34690. * Define if the sound track is the main sound track of the scene
  34691. */
  34692. mainTrack?: boolean;
  34693. }
  34694. /**
  34695. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34696. * It will be also used in a future release to apply effects on a specific track.
  34697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34698. */
  34699. export class SoundTrack {
  34700. /**
  34701. * The unique identifier of the sound track in the scene.
  34702. */
  34703. id: number;
  34704. /**
  34705. * The list of sounds included in the sound track.
  34706. */
  34707. soundCollection: Array<Sound>;
  34708. private _outputAudioNode;
  34709. private _scene;
  34710. private _isMainTrack;
  34711. private _connectedAnalyser;
  34712. private _options;
  34713. private _isInitialized;
  34714. /**
  34715. * Creates a new sound track.
  34716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34717. * @param scene Define the scene the sound track belongs to
  34718. * @param options
  34719. */
  34720. constructor(scene: Scene, options?: ISoundTrackOptions);
  34721. private _initializeSoundTrackAudioGraph;
  34722. /**
  34723. * Release the sound track and its associated resources
  34724. */
  34725. dispose(): void;
  34726. /**
  34727. * Adds a sound to this sound track
  34728. * @param sound define the cound to add
  34729. * @ignoreNaming
  34730. */
  34731. AddSound(sound: Sound): void;
  34732. /**
  34733. * Removes a sound to this sound track
  34734. * @param sound define the cound to remove
  34735. * @ignoreNaming
  34736. */
  34737. RemoveSound(sound: Sound): void;
  34738. /**
  34739. * Set a global volume for the full sound track.
  34740. * @param newVolume Define the new volume of the sound track
  34741. */
  34742. setVolume(newVolume: number): void;
  34743. /**
  34744. * Switch the panning model to HRTF:
  34745. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34747. */
  34748. switchPanningModelToHRTF(): void;
  34749. /**
  34750. * Switch the panning model to Equal Power:
  34751. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34753. */
  34754. switchPanningModelToEqualPower(): void;
  34755. /**
  34756. * Connect the sound track to an audio analyser allowing some amazing
  34757. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34759. * @param analyser The analyser to connect to the engine
  34760. */
  34761. connectToAnalyser(analyser: Analyser): void;
  34762. }
  34763. }
  34764. declare module BABYLON {
  34765. interface AbstractScene {
  34766. /**
  34767. * The list of sounds used in the scene.
  34768. */
  34769. sounds: Nullable<Array<Sound>>;
  34770. }
  34771. interface Scene {
  34772. /**
  34773. * @hidden
  34774. * Backing field
  34775. */
  34776. _mainSoundTrack: SoundTrack;
  34777. /**
  34778. * The main sound track played by the scene.
  34779. * It cotains your primary collection of sounds.
  34780. */
  34781. mainSoundTrack: SoundTrack;
  34782. /**
  34783. * The list of sound tracks added to the scene
  34784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34785. */
  34786. soundTracks: Nullable<Array<SoundTrack>>;
  34787. /**
  34788. * Gets a sound using a given name
  34789. * @param name defines the name to search for
  34790. * @return the found sound or null if not found at all.
  34791. */
  34792. getSoundByName(name: string): Nullable<Sound>;
  34793. /**
  34794. * Gets or sets if audio support is enabled
  34795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34796. */
  34797. audioEnabled: boolean;
  34798. /**
  34799. * Gets or sets if audio will be output to headphones
  34800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34801. */
  34802. headphone: boolean;
  34803. }
  34804. /**
  34805. * Defines the sound scene component responsible to manage any sounds
  34806. * in a given scene.
  34807. */
  34808. export class AudioSceneComponent implements ISceneSerializableComponent {
  34809. /**
  34810. * The component name helpfull to identify the component in the list of scene components.
  34811. */
  34812. readonly name: string;
  34813. /**
  34814. * The scene the component belongs to.
  34815. */
  34816. scene: Scene;
  34817. private _audioEnabled;
  34818. /**
  34819. * Gets whether audio is enabled or not.
  34820. * Please use related enable/disable method to switch state.
  34821. */
  34822. readonly audioEnabled: boolean;
  34823. private _headphone;
  34824. /**
  34825. * Gets whether audio is outputing to headphone or not.
  34826. * Please use the according Switch methods to change output.
  34827. */
  34828. readonly headphone: boolean;
  34829. /**
  34830. * Creates a new instance of the component for the given scene
  34831. * @param scene Defines the scene to register the component in
  34832. */
  34833. constructor(scene: Scene);
  34834. /**
  34835. * Registers the component in a given scene
  34836. */
  34837. register(): void;
  34838. /**
  34839. * Rebuilds the elements related to this component in case of
  34840. * context lost for instance.
  34841. */
  34842. rebuild(): void;
  34843. /**
  34844. * Serializes the component data to the specified json object
  34845. * @param serializationObject The object to serialize to
  34846. */
  34847. serialize(serializationObject: any): void;
  34848. /**
  34849. * Adds all the elements from the container to the scene
  34850. * @param container the container holding the elements
  34851. */
  34852. addFromContainer(container: AbstractScene): void;
  34853. /**
  34854. * Removes all the elements in the container from the scene
  34855. * @param container contains the elements to remove
  34856. * @param dispose if the removed element should be disposed (default: false)
  34857. */
  34858. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34859. /**
  34860. * Disposes the component and the associated ressources.
  34861. */
  34862. dispose(): void;
  34863. /**
  34864. * Disables audio in the associated scene.
  34865. */
  34866. disableAudio(): void;
  34867. /**
  34868. * Enables audio in the associated scene.
  34869. */
  34870. enableAudio(): void;
  34871. /**
  34872. * Switch audio to headphone output.
  34873. */
  34874. switchAudioModeForHeadphones(): void;
  34875. /**
  34876. * Switch audio to normal speakers.
  34877. */
  34878. switchAudioModeForNormalSpeakers(): void;
  34879. private _afterRender;
  34880. }
  34881. }
  34882. declare module BABYLON {
  34883. /**
  34884. * Wraps one or more Sound objects and selects one with random weight for playback.
  34885. */
  34886. export class WeightedSound {
  34887. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34888. loop: boolean;
  34889. private _coneInnerAngle;
  34890. private _coneOuterAngle;
  34891. private _volume;
  34892. /** A Sound is currently playing. */
  34893. isPlaying: boolean;
  34894. /** A Sound is currently paused. */
  34895. isPaused: boolean;
  34896. private _sounds;
  34897. private _weights;
  34898. private _currentIndex?;
  34899. /**
  34900. * Creates a new WeightedSound from the list of sounds given.
  34901. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34902. * @param sounds Array of Sounds that will be selected from.
  34903. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34904. */
  34905. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34906. /**
  34907. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34908. */
  34909. /**
  34910. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34911. */
  34912. directionalConeInnerAngle: number;
  34913. /**
  34914. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34915. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34916. */
  34917. /**
  34918. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34919. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34920. */
  34921. directionalConeOuterAngle: number;
  34922. /**
  34923. * Playback volume.
  34924. */
  34925. /**
  34926. * Playback volume.
  34927. */
  34928. volume: number;
  34929. private _onended;
  34930. /**
  34931. * Suspend playback
  34932. */
  34933. pause(): void;
  34934. /**
  34935. * Stop playback
  34936. */
  34937. stop(): void;
  34938. /**
  34939. * Start playback.
  34940. * @param startOffset Position the clip head at a specific time in seconds.
  34941. */
  34942. play(startOffset?: number): void;
  34943. }
  34944. }
  34945. declare module BABYLON {
  34946. /**
  34947. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34948. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34949. */
  34950. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34951. /**
  34952. * Gets the name of the behavior.
  34953. */
  34954. readonly name: string;
  34955. /**
  34956. * The easing function used by animations
  34957. */
  34958. static EasingFunction: BackEase;
  34959. /**
  34960. * The easing mode used by animations
  34961. */
  34962. static EasingMode: number;
  34963. /**
  34964. * The duration of the animation, in milliseconds
  34965. */
  34966. transitionDuration: number;
  34967. /**
  34968. * Length of the distance animated by the transition when lower radius is reached
  34969. */
  34970. lowerRadiusTransitionRange: number;
  34971. /**
  34972. * Length of the distance animated by the transition when upper radius is reached
  34973. */
  34974. upperRadiusTransitionRange: number;
  34975. private _autoTransitionRange;
  34976. /**
  34977. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34978. */
  34979. /**
  34980. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34981. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34982. */
  34983. autoTransitionRange: boolean;
  34984. private _attachedCamera;
  34985. private _onAfterCheckInputsObserver;
  34986. private _onMeshTargetChangedObserver;
  34987. /**
  34988. * Initializes the behavior.
  34989. */
  34990. init(): void;
  34991. /**
  34992. * Attaches the behavior to its arc rotate camera.
  34993. * @param camera Defines the camera to attach the behavior to
  34994. */
  34995. attach(camera: ArcRotateCamera): void;
  34996. /**
  34997. * Detaches the behavior from its current arc rotate camera.
  34998. */
  34999. detach(): void;
  35000. private _radiusIsAnimating;
  35001. private _radiusBounceTransition;
  35002. private _animatables;
  35003. private _cachedWheelPrecision;
  35004. /**
  35005. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35006. * @param radiusLimit The limit to check against.
  35007. * @return Bool to indicate if at limit.
  35008. */
  35009. private _isRadiusAtLimit;
  35010. /**
  35011. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35012. * @param radiusDelta The delta by which to animate to. Can be negative.
  35013. */
  35014. private _applyBoundRadiusAnimation;
  35015. /**
  35016. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35017. */
  35018. protected _clearAnimationLocks(): void;
  35019. /**
  35020. * Stops and removes all animations that have been applied to the camera
  35021. */
  35022. stopAllAnimations(): void;
  35023. }
  35024. }
  35025. declare module BABYLON {
  35026. /**
  35027. * 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.
  35028. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35029. */
  35030. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35031. /**
  35032. * Gets the name of the behavior.
  35033. */
  35034. readonly name: string;
  35035. private _mode;
  35036. private _radiusScale;
  35037. private _positionScale;
  35038. private _defaultElevation;
  35039. private _elevationReturnTime;
  35040. private _elevationReturnWaitTime;
  35041. private _zoomStopsAnimation;
  35042. private _framingTime;
  35043. /**
  35044. * The easing function used by animations
  35045. */
  35046. static EasingFunction: ExponentialEase;
  35047. /**
  35048. * The easing mode used by animations
  35049. */
  35050. static EasingMode: number;
  35051. /**
  35052. * Sets the current mode used by the behavior
  35053. */
  35054. /**
  35055. * Gets current mode used by the behavior.
  35056. */
  35057. mode: number;
  35058. /**
  35059. * Sets the scale applied to the radius (1 by default)
  35060. */
  35061. /**
  35062. * Gets the scale applied to the radius
  35063. */
  35064. radiusScale: number;
  35065. /**
  35066. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35067. */
  35068. /**
  35069. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35070. */
  35071. positionScale: number;
  35072. /**
  35073. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35074. * behaviour is triggered, in radians.
  35075. */
  35076. /**
  35077. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35078. * behaviour is triggered, in radians.
  35079. */
  35080. defaultElevation: number;
  35081. /**
  35082. * Sets the time (in milliseconds) taken to return to the default beta position.
  35083. * Negative value indicates camera should not return to default.
  35084. */
  35085. /**
  35086. * Gets the time (in milliseconds) taken to return to the default beta position.
  35087. * Negative value indicates camera should not return to default.
  35088. */
  35089. elevationReturnTime: number;
  35090. /**
  35091. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35092. */
  35093. /**
  35094. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35095. */
  35096. elevationReturnWaitTime: number;
  35097. /**
  35098. * Sets the flag that indicates if user zooming should stop animation.
  35099. */
  35100. /**
  35101. * Gets the flag that indicates if user zooming should stop animation.
  35102. */
  35103. zoomStopsAnimation: boolean;
  35104. /**
  35105. * Sets the transition time when framing the mesh, in milliseconds
  35106. */
  35107. /**
  35108. * Gets the transition time when framing the mesh, in milliseconds
  35109. */
  35110. framingTime: number;
  35111. /**
  35112. * Define if the behavior should automatically change the configured
  35113. * camera limits and sensibilities.
  35114. */
  35115. autoCorrectCameraLimitsAndSensibility: boolean;
  35116. private _onPrePointerObservableObserver;
  35117. private _onAfterCheckInputsObserver;
  35118. private _onMeshTargetChangedObserver;
  35119. private _attachedCamera;
  35120. private _isPointerDown;
  35121. private _lastInteractionTime;
  35122. /**
  35123. * Initializes the behavior.
  35124. */
  35125. init(): void;
  35126. /**
  35127. * Attaches the behavior to its arc rotate camera.
  35128. * @param camera Defines the camera to attach the behavior to
  35129. */
  35130. attach(camera: ArcRotateCamera): void;
  35131. /**
  35132. * Detaches the behavior from its current arc rotate camera.
  35133. */
  35134. detach(): void;
  35135. private _animatables;
  35136. private _betaIsAnimating;
  35137. private _betaTransition;
  35138. private _radiusTransition;
  35139. private _vectorTransition;
  35140. /**
  35141. * Targets the given mesh and updates zoom level accordingly.
  35142. * @param mesh The mesh to target.
  35143. * @param radius Optional. If a cached radius position already exists, overrides default.
  35144. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35145. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35146. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35147. */
  35148. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35149. /**
  35150. * Targets the given mesh with its children and updates zoom level accordingly.
  35151. * @param mesh The mesh to target.
  35152. * @param radius Optional. If a cached radius position already exists, overrides default.
  35153. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35154. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35155. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35156. */
  35157. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35158. /**
  35159. * Targets the given meshes with their children and updates zoom level accordingly.
  35160. * @param meshes The mesh to target.
  35161. * @param radius Optional. If a cached radius position already exists, overrides default.
  35162. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35165. */
  35166. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35167. /**
  35168. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35169. * @param minimumWorld Determines the smaller position of the bounding box extend
  35170. * @param maximumWorld Determines the bigger position of the bounding box extend
  35171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35173. */
  35174. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35175. /**
  35176. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35177. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35178. * frustum width.
  35179. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35180. * to fully enclose the mesh in the viewing frustum.
  35181. */
  35182. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35183. /**
  35184. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35185. * is automatically returned to its default position (expected to be above ground plane).
  35186. */
  35187. private _maintainCameraAboveGround;
  35188. /**
  35189. * Returns the frustum slope based on the canvas ratio and camera FOV
  35190. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35191. */
  35192. private _getFrustumSlope;
  35193. /**
  35194. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35195. */
  35196. private _clearAnimationLocks;
  35197. /**
  35198. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35199. */
  35200. private _applyUserInteraction;
  35201. /**
  35202. * Stops and removes all animations that have been applied to the camera
  35203. */
  35204. stopAllAnimations(): void;
  35205. /**
  35206. * Gets a value indicating if the user is moving the camera
  35207. */
  35208. readonly isUserIsMoving: boolean;
  35209. /**
  35210. * The camera can move all the way towards the mesh.
  35211. */
  35212. static IgnoreBoundsSizeMode: number;
  35213. /**
  35214. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35215. */
  35216. static FitFrustumSidesMode: number;
  35217. }
  35218. }
  35219. declare module BABYLON {
  35220. /**
  35221. * Base class for Camera Pointer Inputs.
  35222. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35223. * for example usage.
  35224. */
  35225. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35226. /**
  35227. * Defines the camera the input is attached to.
  35228. */
  35229. abstract camera: Camera;
  35230. /**
  35231. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35232. */
  35233. protected _altKey: boolean;
  35234. protected _ctrlKey: boolean;
  35235. protected _metaKey: boolean;
  35236. protected _shiftKey: boolean;
  35237. /**
  35238. * Which mouse buttons were pressed at time of last mouse event.
  35239. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35240. */
  35241. protected _buttonsPressed: number;
  35242. /**
  35243. * Defines the buttons associated with the input to handle camera move.
  35244. */
  35245. buttons: number[];
  35246. /**
  35247. * Attach the input controls to a specific dom element to get the input from.
  35248. * @param element Defines the element the controls should be listened from
  35249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35250. */
  35251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35252. /**
  35253. * Detach the current controls from the specified dom element.
  35254. * @param element Defines the element to stop listening the inputs from
  35255. */
  35256. detachControl(element: Nullable<HTMLElement>): void;
  35257. /**
  35258. * Gets the class name of the current input.
  35259. * @returns the class name
  35260. */
  35261. getClassName(): string;
  35262. /**
  35263. * Get the friendly name associated with the input class.
  35264. * @returns the input friendly name
  35265. */
  35266. getSimpleName(): string;
  35267. /**
  35268. * Called on pointer POINTERDOUBLETAP event.
  35269. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35270. */
  35271. protected onDoubleTap(type: string): void;
  35272. /**
  35273. * Called on pointer POINTERMOVE event if only a single touch is active.
  35274. * Override this method to provide functionality.
  35275. */
  35276. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35277. /**
  35278. * Called on pointer POINTERMOVE event if multiple touches are active.
  35279. * Override this method to provide functionality.
  35280. */
  35281. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35282. /**
  35283. * Called on JS contextmenu event.
  35284. * Override this method to provide functionality.
  35285. */
  35286. protected onContextMenu(evt: PointerEvent): void;
  35287. /**
  35288. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35289. * press.
  35290. * Override this method to provide functionality.
  35291. */
  35292. protected onButtonDown(evt: PointerEvent): void;
  35293. /**
  35294. * Called each time a new POINTERUP event occurs. Ie, for each button
  35295. * release.
  35296. * Override this method to provide functionality.
  35297. */
  35298. protected onButtonUp(evt: PointerEvent): void;
  35299. /**
  35300. * Called when window becomes inactive.
  35301. * Override this method to provide functionality.
  35302. */
  35303. protected onLostFocus(): void;
  35304. private _pointerInput;
  35305. private _observer;
  35306. private _onLostFocus;
  35307. private pointA;
  35308. private pointB;
  35309. }
  35310. }
  35311. declare module BABYLON {
  35312. /**
  35313. * Manage the pointers inputs to control an arc rotate camera.
  35314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35315. */
  35316. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35317. /**
  35318. * Defines the camera the input is attached to.
  35319. */
  35320. camera: ArcRotateCamera;
  35321. /**
  35322. * Gets the class name of the current input.
  35323. * @returns the class name
  35324. */
  35325. getClassName(): string;
  35326. /**
  35327. * Defines the buttons associated with the input to handle camera move.
  35328. */
  35329. buttons: number[];
  35330. /**
  35331. * Defines the pointer angular sensibility along the X axis or how fast is
  35332. * the camera rotating.
  35333. */
  35334. angularSensibilityX: number;
  35335. /**
  35336. * Defines the pointer angular sensibility along the Y axis or how fast is
  35337. * the camera rotating.
  35338. */
  35339. angularSensibilityY: number;
  35340. /**
  35341. * Defines the pointer pinch precision or how fast is the camera zooming.
  35342. */
  35343. pinchPrecision: number;
  35344. /**
  35345. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35346. * from 0.
  35347. * It defines the percentage of current camera.radius to use as delta when
  35348. * pinch zoom is used.
  35349. */
  35350. pinchDeltaPercentage: number;
  35351. /**
  35352. * Defines the pointer panning sensibility or how fast is the camera moving.
  35353. */
  35354. panningSensibility: number;
  35355. /**
  35356. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35357. */
  35358. multiTouchPanning: boolean;
  35359. /**
  35360. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35361. * zoom (pinch) through multitouch.
  35362. */
  35363. multiTouchPanAndZoom: boolean;
  35364. /**
  35365. * Revers pinch action direction.
  35366. */
  35367. pinchInwards: boolean;
  35368. private _isPanClick;
  35369. private _twoFingerActivityCount;
  35370. private _isPinching;
  35371. /**
  35372. * Called on pointer POINTERMOVE event if only a single touch is active.
  35373. */
  35374. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35375. /**
  35376. * Called on pointer POINTERDOUBLETAP event.
  35377. */
  35378. protected onDoubleTap(type: string): void;
  35379. /**
  35380. * Called on pointer POINTERMOVE event if multiple touches are active.
  35381. */
  35382. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35383. /**
  35384. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35385. * press.
  35386. */
  35387. protected onButtonDown(evt: PointerEvent): void;
  35388. /**
  35389. * Called each time a new POINTERUP event occurs. Ie, for each button
  35390. * release.
  35391. */
  35392. protected onButtonUp(evt: PointerEvent): void;
  35393. /**
  35394. * Called when window becomes inactive.
  35395. */
  35396. protected onLostFocus(): void;
  35397. }
  35398. }
  35399. declare module BABYLON {
  35400. /**
  35401. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35403. */
  35404. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35405. /**
  35406. * Defines the camera the input is attached to.
  35407. */
  35408. camera: ArcRotateCamera;
  35409. /**
  35410. * Defines the list of key codes associated with the up action (increase alpha)
  35411. */
  35412. keysUp: number[];
  35413. /**
  35414. * Defines the list of key codes associated with the down action (decrease alpha)
  35415. */
  35416. keysDown: number[];
  35417. /**
  35418. * Defines the list of key codes associated with the left action (increase beta)
  35419. */
  35420. keysLeft: number[];
  35421. /**
  35422. * Defines the list of key codes associated with the right action (decrease beta)
  35423. */
  35424. keysRight: number[];
  35425. /**
  35426. * Defines the list of key codes associated with the reset action.
  35427. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35428. */
  35429. keysReset: number[];
  35430. /**
  35431. * Defines the panning sensibility of the inputs.
  35432. * (How fast is the camera paning)
  35433. */
  35434. panningSensibility: number;
  35435. /**
  35436. * Defines the zooming sensibility of the inputs.
  35437. * (How fast is the camera zooming)
  35438. */
  35439. zoomingSensibility: number;
  35440. /**
  35441. * Defines wether maintaining the alt key down switch the movement mode from
  35442. * orientation to zoom.
  35443. */
  35444. useAltToZoom: boolean;
  35445. /**
  35446. * Rotation speed of the camera
  35447. */
  35448. angularSpeed: number;
  35449. private _keys;
  35450. private _ctrlPressed;
  35451. private _altPressed;
  35452. private _onCanvasBlurObserver;
  35453. private _onKeyboardObserver;
  35454. private _engine;
  35455. private _scene;
  35456. /**
  35457. * Attach the input controls to a specific dom element to get the input from.
  35458. * @param element Defines the element the controls should be listened from
  35459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35460. */
  35461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35462. /**
  35463. * Detach the current controls from the specified dom element.
  35464. * @param element Defines the element to stop listening the inputs from
  35465. */
  35466. detachControl(element: Nullable<HTMLElement>): void;
  35467. /**
  35468. * Update the current camera state depending on the inputs that have been used this frame.
  35469. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35470. */
  35471. checkInputs(): void;
  35472. /**
  35473. * Gets the class name of the current intput.
  35474. * @returns the class name
  35475. */
  35476. getClassName(): string;
  35477. /**
  35478. * Get the friendly name associated with the input class.
  35479. * @returns the input friendly name
  35480. */
  35481. getSimpleName(): string;
  35482. }
  35483. }
  35484. declare module BABYLON {
  35485. /**
  35486. * Manage the mouse wheel inputs to control an arc rotate camera.
  35487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35488. */
  35489. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35490. /**
  35491. * Defines the camera the input is attached to.
  35492. */
  35493. camera: ArcRotateCamera;
  35494. /**
  35495. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35496. */
  35497. wheelPrecision: number;
  35498. /**
  35499. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35500. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35501. */
  35502. wheelDeltaPercentage: number;
  35503. private _wheel;
  35504. private _observer;
  35505. private computeDeltaFromMouseWheelLegacyEvent;
  35506. /**
  35507. * Attach the input controls to a specific dom element to get the input from.
  35508. * @param element Defines the element the controls should be listened from
  35509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35510. */
  35511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35512. /**
  35513. * Detach the current controls from the specified dom element.
  35514. * @param element Defines the element to stop listening the inputs from
  35515. */
  35516. detachControl(element: Nullable<HTMLElement>): void;
  35517. /**
  35518. * Gets the class name of the current intput.
  35519. * @returns the class name
  35520. */
  35521. getClassName(): string;
  35522. /**
  35523. * Get the friendly name associated with the input class.
  35524. * @returns the input friendly name
  35525. */
  35526. getSimpleName(): string;
  35527. }
  35528. }
  35529. declare module BABYLON {
  35530. /**
  35531. * Default Inputs manager for the ArcRotateCamera.
  35532. * It groups all the default supported inputs for ease of use.
  35533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35534. */
  35535. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35536. /**
  35537. * Instantiates a new ArcRotateCameraInputsManager.
  35538. * @param camera Defines the camera the inputs belong to
  35539. */
  35540. constructor(camera: ArcRotateCamera);
  35541. /**
  35542. * Add mouse wheel input support to the input manager.
  35543. * @returns the current input manager
  35544. */
  35545. addMouseWheel(): ArcRotateCameraInputsManager;
  35546. /**
  35547. * Add pointers input support to the input manager.
  35548. * @returns the current input manager
  35549. */
  35550. addPointers(): ArcRotateCameraInputsManager;
  35551. /**
  35552. * Add keyboard input support to the input manager.
  35553. * @returns the current input manager
  35554. */
  35555. addKeyboard(): ArcRotateCameraInputsManager;
  35556. }
  35557. }
  35558. declare module BABYLON {
  35559. /**
  35560. * This represents an orbital type of camera.
  35561. *
  35562. * 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.
  35563. * 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.
  35564. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35565. */
  35566. export class ArcRotateCamera extends TargetCamera {
  35567. /**
  35568. * Defines the rotation angle of the camera along the longitudinal axis.
  35569. */
  35570. alpha: number;
  35571. /**
  35572. * Defines the rotation angle of the camera along the latitudinal axis.
  35573. */
  35574. beta: number;
  35575. /**
  35576. * Defines the radius of the camera from it s target point.
  35577. */
  35578. radius: number;
  35579. protected _target: Vector3;
  35580. protected _targetHost: Nullable<AbstractMesh>;
  35581. /**
  35582. * Defines the target point of the camera.
  35583. * The camera looks towards it form the radius distance.
  35584. */
  35585. target: Vector3;
  35586. /**
  35587. * Define the current local position of the camera in the scene
  35588. */
  35589. position: Vector3;
  35590. protected _upVector: Vector3;
  35591. protected _upToYMatrix: Matrix;
  35592. protected _YToUpMatrix: Matrix;
  35593. /**
  35594. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35595. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35596. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35597. */
  35598. upVector: Vector3;
  35599. /**
  35600. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35601. */
  35602. setMatUp(): void;
  35603. /**
  35604. * Current inertia value on the longitudinal axis.
  35605. * The bigger this number the longer it will take for the camera to stop.
  35606. */
  35607. inertialAlphaOffset: number;
  35608. /**
  35609. * Current inertia value on the latitudinal axis.
  35610. * The bigger this number the longer it will take for the camera to stop.
  35611. */
  35612. inertialBetaOffset: number;
  35613. /**
  35614. * Current inertia value on the radius axis.
  35615. * The bigger this number the longer it will take for the camera to stop.
  35616. */
  35617. inertialRadiusOffset: number;
  35618. /**
  35619. * Minimum allowed angle on the longitudinal axis.
  35620. * This can help limiting how the Camera is able to move in the scene.
  35621. */
  35622. lowerAlphaLimit: Nullable<number>;
  35623. /**
  35624. * Maximum allowed angle on the longitudinal axis.
  35625. * This can help limiting how the Camera is able to move in the scene.
  35626. */
  35627. upperAlphaLimit: Nullable<number>;
  35628. /**
  35629. * Minimum allowed angle on the latitudinal axis.
  35630. * This can help limiting how the Camera is able to move in the scene.
  35631. */
  35632. lowerBetaLimit: number;
  35633. /**
  35634. * Maximum allowed angle on the latitudinal axis.
  35635. * This can help limiting how the Camera is able to move in the scene.
  35636. */
  35637. upperBetaLimit: number;
  35638. /**
  35639. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35640. * This can help limiting how the Camera is able to move in the scene.
  35641. */
  35642. lowerRadiusLimit: Nullable<number>;
  35643. /**
  35644. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35645. * This can help limiting how the Camera is able to move in the scene.
  35646. */
  35647. upperRadiusLimit: Nullable<number>;
  35648. /**
  35649. * Defines the current inertia value used during panning of the camera along the X axis.
  35650. */
  35651. inertialPanningX: number;
  35652. /**
  35653. * Defines the current inertia value used during panning of the camera along the Y axis.
  35654. */
  35655. inertialPanningY: number;
  35656. /**
  35657. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35658. * Basically if your fingers moves away from more than this distance you will be considered
  35659. * in pinch mode.
  35660. */
  35661. pinchToPanMaxDistance: number;
  35662. /**
  35663. * Defines the maximum distance the camera can pan.
  35664. * This could help keeping the cammera always in your scene.
  35665. */
  35666. panningDistanceLimit: Nullable<number>;
  35667. /**
  35668. * Defines the target of the camera before paning.
  35669. */
  35670. panningOriginTarget: Vector3;
  35671. /**
  35672. * Defines the value of the inertia used during panning.
  35673. * 0 would mean stop inertia and one would mean no decelleration at all.
  35674. */
  35675. panningInertia: number;
  35676. /**
  35677. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35678. */
  35679. angularSensibilityX: number;
  35680. /**
  35681. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35682. */
  35683. angularSensibilityY: number;
  35684. /**
  35685. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35686. */
  35687. pinchPrecision: number;
  35688. /**
  35689. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35690. * It will be used instead of pinchDeltaPrecision if different from 0.
  35691. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35692. */
  35693. pinchDeltaPercentage: number;
  35694. /**
  35695. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35696. */
  35697. panningSensibility: number;
  35698. /**
  35699. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35700. */
  35701. keysUp: number[];
  35702. /**
  35703. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35704. */
  35705. keysDown: number[];
  35706. /**
  35707. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35708. */
  35709. keysLeft: number[];
  35710. /**
  35711. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35712. */
  35713. keysRight: number[];
  35714. /**
  35715. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35716. */
  35717. wheelPrecision: number;
  35718. /**
  35719. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35720. * It will be used instead of pinchDeltaPrecision if different from 0.
  35721. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35722. */
  35723. wheelDeltaPercentage: number;
  35724. /**
  35725. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35726. */
  35727. zoomOnFactor: number;
  35728. /**
  35729. * Defines a screen offset for the camera position.
  35730. */
  35731. targetScreenOffset: Vector2;
  35732. /**
  35733. * Allows the camera to be completely reversed.
  35734. * If false the camera can not arrive upside down.
  35735. */
  35736. allowUpsideDown: boolean;
  35737. /**
  35738. * Define if double tap/click is used to restore the previously saved state of the camera.
  35739. */
  35740. useInputToRestoreState: boolean;
  35741. /** @hidden */
  35742. _viewMatrix: Matrix;
  35743. /** @hidden */
  35744. _useCtrlForPanning: boolean;
  35745. /** @hidden */
  35746. _panningMouseButton: number;
  35747. /**
  35748. * Defines the input associated to the camera.
  35749. */
  35750. inputs: ArcRotateCameraInputsManager;
  35751. /** @hidden */
  35752. _reset: () => void;
  35753. /**
  35754. * Defines the allowed panning axis.
  35755. */
  35756. panningAxis: Vector3;
  35757. protected _localDirection: Vector3;
  35758. protected _transformedDirection: Vector3;
  35759. private _bouncingBehavior;
  35760. /**
  35761. * Gets the bouncing behavior of the camera if it has been enabled.
  35762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35763. */
  35764. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35765. /**
  35766. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35767. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35768. */
  35769. useBouncingBehavior: boolean;
  35770. private _framingBehavior;
  35771. /**
  35772. * Gets the framing behavior of the camera if it has been enabled.
  35773. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35774. */
  35775. readonly framingBehavior: Nullable<FramingBehavior>;
  35776. /**
  35777. * Defines if the framing behavior of the camera is enabled on the camera.
  35778. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35779. */
  35780. useFramingBehavior: boolean;
  35781. private _autoRotationBehavior;
  35782. /**
  35783. * Gets the auto rotation behavior of the camera if it has been enabled.
  35784. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35785. */
  35786. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35787. /**
  35788. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35789. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35790. */
  35791. useAutoRotationBehavior: boolean;
  35792. /**
  35793. * Observable triggered when the mesh target has been changed on the camera.
  35794. */
  35795. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35796. /**
  35797. * Event raised when the camera is colliding with a mesh.
  35798. */
  35799. onCollide: (collidedMesh: AbstractMesh) => void;
  35800. /**
  35801. * Defines whether the camera should check collision with the objects oh the scene.
  35802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35803. */
  35804. checkCollisions: boolean;
  35805. /**
  35806. * Defines the collision radius of the camera.
  35807. * This simulates a sphere around the camera.
  35808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35809. */
  35810. collisionRadius: Vector3;
  35811. protected _collider: Collider;
  35812. protected _previousPosition: Vector3;
  35813. protected _collisionVelocity: Vector3;
  35814. protected _newPosition: Vector3;
  35815. protected _previousAlpha: number;
  35816. protected _previousBeta: number;
  35817. protected _previousRadius: number;
  35818. protected _collisionTriggered: boolean;
  35819. protected _targetBoundingCenter: Nullable<Vector3>;
  35820. private _computationVector;
  35821. /**
  35822. * Instantiates a new ArcRotateCamera in a given scene
  35823. * @param name Defines the name of the camera
  35824. * @param alpha Defines the camera rotation along the logitudinal axis
  35825. * @param beta Defines the camera rotation along the latitudinal axis
  35826. * @param radius Defines the camera distance from its target
  35827. * @param target Defines the camera target
  35828. * @param scene Defines the scene the camera belongs to
  35829. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35830. */
  35831. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35832. /** @hidden */
  35833. _initCache(): void;
  35834. /** @hidden */
  35835. _updateCache(ignoreParentClass?: boolean): void;
  35836. protected _getTargetPosition(): Vector3;
  35837. private _storedAlpha;
  35838. private _storedBeta;
  35839. private _storedRadius;
  35840. private _storedTarget;
  35841. /**
  35842. * Stores the current state of the camera (alpha, beta, radius and target)
  35843. * @returns the camera itself
  35844. */
  35845. storeState(): Camera;
  35846. /**
  35847. * @hidden
  35848. * Restored camera state. You must call storeState() first
  35849. */
  35850. _restoreStateValues(): boolean;
  35851. /** @hidden */
  35852. _isSynchronizedViewMatrix(): boolean;
  35853. /**
  35854. * Attached controls to the current camera.
  35855. * @param element Defines the element the controls should be listened from
  35856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35857. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35858. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35859. */
  35860. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35861. /**
  35862. * Detach the current controls from the camera.
  35863. * The camera will stop reacting to inputs.
  35864. * @param element Defines the element to stop listening the inputs from
  35865. */
  35866. detachControl(element: HTMLElement): void;
  35867. /** @hidden */
  35868. _checkInputs(): void;
  35869. protected _checkLimits(): void;
  35870. /**
  35871. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35872. */
  35873. rebuildAnglesAndRadius(): void;
  35874. /**
  35875. * Use a position to define the current camera related information like aplha, beta and radius
  35876. * @param position Defines the position to set the camera at
  35877. */
  35878. setPosition(position: Vector3): void;
  35879. /**
  35880. * Defines the target the camera should look at.
  35881. * This will automatically adapt alpha beta and radius to fit within the new target.
  35882. * @param target Defines the new target as a Vector or a mesh
  35883. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35884. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35885. */
  35886. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35887. /** @hidden */
  35888. _getViewMatrix(): Matrix;
  35889. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35890. /**
  35891. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35892. * @param meshes Defines the mesh to zoom on
  35893. * @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)
  35894. */
  35895. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35896. /**
  35897. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35898. * The target will be changed but the radius
  35899. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35900. * @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)
  35901. */
  35902. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35903. min: Vector3;
  35904. max: Vector3;
  35905. distance: number;
  35906. }, doNotUpdateMaxZ?: boolean): void;
  35907. /**
  35908. * @override
  35909. * Override Camera.createRigCamera
  35910. */
  35911. createRigCamera(name: string, cameraIndex: number): Camera;
  35912. /**
  35913. * @hidden
  35914. * @override
  35915. * Override Camera._updateRigCameras
  35916. */
  35917. _updateRigCameras(): void;
  35918. /**
  35919. * Destroy the camera and release the current resources hold by it.
  35920. */
  35921. dispose(): void;
  35922. /**
  35923. * Gets the current object class name.
  35924. * @return the class name
  35925. */
  35926. getClassName(): string;
  35927. }
  35928. }
  35929. declare module BABYLON {
  35930. /**
  35931. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35932. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35933. */
  35934. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35935. /**
  35936. * Gets the name of the behavior.
  35937. */
  35938. readonly name: string;
  35939. private _zoomStopsAnimation;
  35940. private _idleRotationSpeed;
  35941. private _idleRotationWaitTime;
  35942. private _idleRotationSpinupTime;
  35943. /**
  35944. * Sets the flag that indicates if user zooming should stop animation.
  35945. */
  35946. /**
  35947. * Gets the flag that indicates if user zooming should stop animation.
  35948. */
  35949. zoomStopsAnimation: boolean;
  35950. /**
  35951. * Sets the default speed at which the camera rotates around the model.
  35952. */
  35953. /**
  35954. * Gets the default speed at which the camera rotates around the model.
  35955. */
  35956. idleRotationSpeed: number;
  35957. /**
  35958. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35959. */
  35960. /**
  35961. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35962. */
  35963. idleRotationWaitTime: number;
  35964. /**
  35965. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35966. */
  35967. /**
  35968. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35969. */
  35970. idleRotationSpinupTime: number;
  35971. /**
  35972. * Gets a value indicating if the camera is currently rotating because of this behavior
  35973. */
  35974. readonly rotationInProgress: boolean;
  35975. private _onPrePointerObservableObserver;
  35976. private _onAfterCheckInputsObserver;
  35977. private _attachedCamera;
  35978. private _isPointerDown;
  35979. private _lastFrameTime;
  35980. private _lastInteractionTime;
  35981. private _cameraRotationSpeed;
  35982. /**
  35983. * Initializes the behavior.
  35984. */
  35985. init(): void;
  35986. /**
  35987. * Attaches the behavior to its arc rotate camera.
  35988. * @param camera Defines the camera to attach the behavior to
  35989. */
  35990. attach(camera: ArcRotateCamera): void;
  35991. /**
  35992. * Detaches the behavior from its current arc rotate camera.
  35993. */
  35994. detach(): void;
  35995. /**
  35996. * Returns true if user is scrolling.
  35997. * @return true if user is scrolling.
  35998. */
  35999. private _userIsZooming;
  36000. private _lastFrameRadius;
  36001. private _shouldAnimationStopForInteraction;
  36002. /**
  36003. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36004. */
  36005. private _applyUserInteraction;
  36006. private _userIsMoving;
  36007. }
  36008. }
  36009. declare module BABYLON {
  36010. /**
  36011. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36012. */
  36013. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36014. private ui;
  36015. /**
  36016. * The name of the behavior
  36017. */
  36018. name: string;
  36019. /**
  36020. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36021. */
  36022. distanceAwayFromFace: number;
  36023. /**
  36024. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36025. */
  36026. distanceAwayFromBottomOfFace: number;
  36027. private _faceVectors;
  36028. private _target;
  36029. private _scene;
  36030. private _onRenderObserver;
  36031. private _tmpMatrix;
  36032. private _tmpVector;
  36033. /**
  36034. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36035. * @param ui The transform node that should be attched to the mesh
  36036. */
  36037. constructor(ui: TransformNode);
  36038. /**
  36039. * Initializes the behavior
  36040. */
  36041. init(): void;
  36042. private _closestFace;
  36043. private _zeroVector;
  36044. private _lookAtTmpMatrix;
  36045. private _lookAtToRef;
  36046. /**
  36047. * Attaches the AttachToBoxBehavior to the passed in mesh
  36048. * @param target The mesh that the specified node will be attached to
  36049. */
  36050. attach(target: Mesh): void;
  36051. /**
  36052. * Detaches the behavior from the mesh
  36053. */
  36054. detach(): void;
  36055. }
  36056. }
  36057. declare module BABYLON {
  36058. /**
  36059. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36060. */
  36061. export class FadeInOutBehavior implements Behavior<Mesh> {
  36062. /**
  36063. * Time in milliseconds to delay before fading in (Default: 0)
  36064. */
  36065. delay: number;
  36066. /**
  36067. * Time in milliseconds for the mesh to fade in (Default: 300)
  36068. */
  36069. fadeInTime: number;
  36070. private _millisecondsPerFrame;
  36071. private _hovered;
  36072. private _hoverValue;
  36073. private _ownerNode;
  36074. /**
  36075. * Instatiates the FadeInOutBehavior
  36076. */
  36077. constructor();
  36078. /**
  36079. * The name of the behavior
  36080. */
  36081. readonly name: string;
  36082. /**
  36083. * Initializes the behavior
  36084. */
  36085. init(): void;
  36086. /**
  36087. * Attaches the fade behavior on the passed in mesh
  36088. * @param ownerNode The mesh that will be faded in/out once attached
  36089. */
  36090. attach(ownerNode: Mesh): void;
  36091. /**
  36092. * Detaches the behavior from the mesh
  36093. */
  36094. detach(): void;
  36095. /**
  36096. * Triggers the mesh to begin fading in or out
  36097. * @param value if the object should fade in or out (true to fade in)
  36098. */
  36099. fadeIn(value: boolean): void;
  36100. private _update;
  36101. private _setAllVisibility;
  36102. }
  36103. }
  36104. declare module BABYLON {
  36105. /**
  36106. * Class containing a set of static utilities functions for managing Pivots
  36107. * @hidden
  36108. */
  36109. export class PivotTools {
  36110. private static _PivotCached;
  36111. private static _OldPivotPoint;
  36112. private static _PivotTranslation;
  36113. private static _PivotTmpVector;
  36114. /** @hidden */
  36115. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36116. /** @hidden */
  36117. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36118. }
  36119. }
  36120. declare module BABYLON {
  36121. /**
  36122. * Class containing static functions to help procedurally build meshes
  36123. */
  36124. export class PlaneBuilder {
  36125. /**
  36126. * Creates a plane mesh
  36127. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36128. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36129. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36131. * * 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
  36132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36133. * @param name defines the name of the mesh
  36134. * @param options defines the options used to create the mesh
  36135. * @param scene defines the hosting scene
  36136. * @returns the plane mesh
  36137. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36138. */
  36139. static CreatePlane(name: string, options: {
  36140. size?: number;
  36141. width?: number;
  36142. height?: number;
  36143. sideOrientation?: number;
  36144. frontUVs?: Vector4;
  36145. backUVs?: Vector4;
  36146. updatable?: boolean;
  36147. sourcePlane?: Plane;
  36148. }, scene?: Nullable<Scene>): Mesh;
  36149. }
  36150. }
  36151. declare module BABYLON {
  36152. /**
  36153. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36154. */
  36155. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36156. private static _AnyMouseID;
  36157. /**
  36158. * Abstract mesh the behavior is set on
  36159. */
  36160. attachedNode: AbstractMesh;
  36161. private _dragPlane;
  36162. private _scene;
  36163. private _pointerObserver;
  36164. private _beforeRenderObserver;
  36165. private static _planeScene;
  36166. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36167. /**
  36168. * 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)
  36169. */
  36170. maxDragAngle: number;
  36171. /**
  36172. * @hidden
  36173. */
  36174. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36175. /**
  36176. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36177. */
  36178. currentDraggingPointerID: number;
  36179. /**
  36180. * The last position where the pointer hit the drag plane in world space
  36181. */
  36182. lastDragPosition: Vector3;
  36183. /**
  36184. * If the behavior is currently in a dragging state
  36185. */
  36186. dragging: boolean;
  36187. /**
  36188. * 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)
  36189. */
  36190. dragDeltaRatio: number;
  36191. /**
  36192. * If the drag plane orientation should be updated during the dragging (Default: true)
  36193. */
  36194. updateDragPlane: boolean;
  36195. private _debugMode;
  36196. private _moving;
  36197. /**
  36198. * Fires each time the attached mesh is dragged with the pointer
  36199. * * delta between last drag position and current drag position in world space
  36200. * * dragDistance along the drag axis
  36201. * * dragPlaneNormal normal of the current drag plane used during the drag
  36202. * * dragPlanePoint in world space where the drag intersects the drag plane
  36203. */
  36204. onDragObservable: Observable<{
  36205. delta: Vector3;
  36206. dragPlanePoint: Vector3;
  36207. dragPlaneNormal: Vector3;
  36208. dragDistance: number;
  36209. pointerId: number;
  36210. }>;
  36211. /**
  36212. * Fires each time a drag begins (eg. mouse down on mesh)
  36213. */
  36214. onDragStartObservable: Observable<{
  36215. dragPlanePoint: Vector3;
  36216. pointerId: number;
  36217. }>;
  36218. /**
  36219. * Fires each time a drag ends (eg. mouse release after drag)
  36220. */
  36221. onDragEndObservable: Observable<{
  36222. dragPlanePoint: Vector3;
  36223. pointerId: number;
  36224. }>;
  36225. /**
  36226. * If the attached mesh should be moved when dragged
  36227. */
  36228. moveAttached: boolean;
  36229. /**
  36230. * If the drag behavior will react to drag events (Default: true)
  36231. */
  36232. enabled: boolean;
  36233. /**
  36234. * If camera controls should be detached during the drag
  36235. */
  36236. detachCameraControls: boolean;
  36237. /**
  36238. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36239. */
  36240. useObjectOrienationForDragging: boolean;
  36241. private _options;
  36242. /**
  36243. * Creates a pointer drag behavior that can be attached to a mesh
  36244. * @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)
  36245. */
  36246. constructor(options?: {
  36247. dragAxis?: Vector3;
  36248. dragPlaneNormal?: Vector3;
  36249. });
  36250. /**
  36251. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36252. */
  36253. validateDrag: (targetPosition: Vector3) => boolean;
  36254. /**
  36255. * The name of the behavior
  36256. */
  36257. readonly name: string;
  36258. /**
  36259. * Initializes the behavior
  36260. */
  36261. init(): void;
  36262. private _tmpVector;
  36263. private _alternatePickedPoint;
  36264. private _worldDragAxis;
  36265. private _targetPosition;
  36266. private _attachedElement;
  36267. /**
  36268. * Attaches the drag behavior the passed in mesh
  36269. * @param ownerNode The mesh that will be dragged around once attached
  36270. */
  36271. attach(ownerNode: AbstractMesh): void;
  36272. /**
  36273. * Force relase the drag action by code.
  36274. */
  36275. releaseDrag(): void;
  36276. private _startDragRay;
  36277. private _lastPointerRay;
  36278. /**
  36279. * Simulates the start of a pointer drag event on the behavior
  36280. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36281. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36282. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36283. */
  36284. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36285. private _startDrag;
  36286. private _dragDelta;
  36287. private _moveDrag;
  36288. private _pickWithRayOnDragPlane;
  36289. private _pointA;
  36290. private _pointB;
  36291. private _pointC;
  36292. private _lineA;
  36293. private _lineB;
  36294. private _localAxis;
  36295. private _lookAt;
  36296. private _updateDragPlanePosition;
  36297. /**
  36298. * Detaches the behavior from the mesh
  36299. */
  36300. detach(): void;
  36301. }
  36302. }
  36303. declare module BABYLON {
  36304. /**
  36305. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36306. */
  36307. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36308. private _dragBehaviorA;
  36309. private _dragBehaviorB;
  36310. private _startDistance;
  36311. private _initialScale;
  36312. private _targetScale;
  36313. private _ownerNode;
  36314. private _sceneRenderObserver;
  36315. /**
  36316. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36317. */
  36318. constructor();
  36319. /**
  36320. * The name of the behavior
  36321. */
  36322. readonly name: string;
  36323. /**
  36324. * Initializes the behavior
  36325. */
  36326. init(): void;
  36327. private _getCurrentDistance;
  36328. /**
  36329. * Attaches the scale behavior the passed in mesh
  36330. * @param ownerNode The mesh that will be scaled around once attached
  36331. */
  36332. attach(ownerNode: Mesh): void;
  36333. /**
  36334. * Detaches the behavior from the mesh
  36335. */
  36336. detach(): void;
  36337. }
  36338. }
  36339. declare module BABYLON {
  36340. /**
  36341. * 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
  36342. */
  36343. export class SixDofDragBehavior implements Behavior<Mesh> {
  36344. private static _virtualScene;
  36345. private _ownerNode;
  36346. private _sceneRenderObserver;
  36347. private _scene;
  36348. private _targetPosition;
  36349. private _virtualOriginMesh;
  36350. private _virtualDragMesh;
  36351. private _pointerObserver;
  36352. private _moving;
  36353. private _startingOrientation;
  36354. /**
  36355. * 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)
  36356. */
  36357. private zDragFactor;
  36358. /**
  36359. * If the object should rotate to face the drag origin
  36360. */
  36361. rotateDraggedObject: boolean;
  36362. /**
  36363. * If the behavior is currently in a dragging state
  36364. */
  36365. dragging: boolean;
  36366. /**
  36367. * 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)
  36368. */
  36369. dragDeltaRatio: number;
  36370. /**
  36371. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36372. */
  36373. currentDraggingPointerID: number;
  36374. /**
  36375. * If camera controls should be detached during the drag
  36376. */
  36377. detachCameraControls: boolean;
  36378. /**
  36379. * Fires each time a drag starts
  36380. */
  36381. onDragStartObservable: Observable<{}>;
  36382. /**
  36383. * Fires each time a drag ends (eg. mouse release after drag)
  36384. */
  36385. onDragEndObservable: Observable<{}>;
  36386. /**
  36387. * 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
  36388. */
  36389. constructor();
  36390. /**
  36391. * The name of the behavior
  36392. */
  36393. readonly name: string;
  36394. /**
  36395. * Initializes the behavior
  36396. */
  36397. init(): void;
  36398. /**
  36399. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36400. */
  36401. private readonly _pointerCamera;
  36402. /**
  36403. * Attaches the scale behavior the passed in mesh
  36404. * @param ownerNode The mesh that will be scaled around once attached
  36405. */
  36406. attach(ownerNode: Mesh): void;
  36407. /**
  36408. * Detaches the behavior from the mesh
  36409. */
  36410. detach(): void;
  36411. }
  36412. }
  36413. declare module BABYLON {
  36414. /**
  36415. * Class used to apply inverse kinematics to bones
  36416. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36417. */
  36418. export class BoneIKController {
  36419. private static _tmpVecs;
  36420. private static _tmpQuat;
  36421. private static _tmpMats;
  36422. /**
  36423. * Gets or sets the target mesh
  36424. */
  36425. targetMesh: AbstractMesh;
  36426. /** Gets or sets the mesh used as pole */
  36427. poleTargetMesh: AbstractMesh;
  36428. /**
  36429. * Gets or sets the bone used as pole
  36430. */
  36431. poleTargetBone: Nullable<Bone>;
  36432. /**
  36433. * Gets or sets the target position
  36434. */
  36435. targetPosition: Vector3;
  36436. /**
  36437. * Gets or sets the pole target position
  36438. */
  36439. poleTargetPosition: Vector3;
  36440. /**
  36441. * Gets or sets the pole target local offset
  36442. */
  36443. poleTargetLocalOffset: Vector3;
  36444. /**
  36445. * Gets or sets the pole angle
  36446. */
  36447. poleAngle: number;
  36448. /**
  36449. * Gets or sets the mesh associated with the controller
  36450. */
  36451. mesh: AbstractMesh;
  36452. /**
  36453. * 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)
  36454. */
  36455. slerpAmount: number;
  36456. private _bone1Quat;
  36457. private _bone1Mat;
  36458. private _bone2Ang;
  36459. private _bone1;
  36460. private _bone2;
  36461. private _bone1Length;
  36462. private _bone2Length;
  36463. private _maxAngle;
  36464. private _maxReach;
  36465. private _rightHandedSystem;
  36466. private _bendAxis;
  36467. private _slerping;
  36468. private _adjustRoll;
  36469. /**
  36470. * Gets or sets maximum allowed angle
  36471. */
  36472. maxAngle: number;
  36473. /**
  36474. * Creates a new BoneIKController
  36475. * @param mesh defines the mesh to control
  36476. * @param bone defines the bone to control
  36477. * @param options defines options to set up the controller
  36478. */
  36479. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36480. targetMesh?: AbstractMesh;
  36481. poleTargetMesh?: AbstractMesh;
  36482. poleTargetBone?: Bone;
  36483. poleTargetLocalOffset?: Vector3;
  36484. poleAngle?: number;
  36485. bendAxis?: Vector3;
  36486. maxAngle?: number;
  36487. slerpAmount?: number;
  36488. });
  36489. private _setMaxAngle;
  36490. /**
  36491. * Force the controller to update the bones
  36492. */
  36493. update(): void;
  36494. }
  36495. }
  36496. declare module BABYLON {
  36497. /**
  36498. * Class used to make a bone look toward a point in space
  36499. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36500. */
  36501. export class BoneLookController {
  36502. private static _tmpVecs;
  36503. private static _tmpQuat;
  36504. private static _tmpMats;
  36505. /**
  36506. * The target Vector3 that the bone will look at
  36507. */
  36508. target: Vector3;
  36509. /**
  36510. * The mesh that the bone is attached to
  36511. */
  36512. mesh: AbstractMesh;
  36513. /**
  36514. * The bone that will be looking to the target
  36515. */
  36516. bone: Bone;
  36517. /**
  36518. * The up axis of the coordinate system that is used when the bone is rotated
  36519. */
  36520. upAxis: Vector3;
  36521. /**
  36522. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36523. */
  36524. upAxisSpace: Space;
  36525. /**
  36526. * Used to make an adjustment to the yaw of the bone
  36527. */
  36528. adjustYaw: number;
  36529. /**
  36530. * Used to make an adjustment to the pitch of the bone
  36531. */
  36532. adjustPitch: number;
  36533. /**
  36534. * Used to make an adjustment to the roll of the bone
  36535. */
  36536. adjustRoll: number;
  36537. /**
  36538. * 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)
  36539. */
  36540. slerpAmount: number;
  36541. private _minYaw;
  36542. private _maxYaw;
  36543. private _minPitch;
  36544. private _maxPitch;
  36545. private _minYawSin;
  36546. private _minYawCos;
  36547. private _maxYawSin;
  36548. private _maxYawCos;
  36549. private _midYawConstraint;
  36550. private _minPitchTan;
  36551. private _maxPitchTan;
  36552. private _boneQuat;
  36553. private _slerping;
  36554. private _transformYawPitch;
  36555. private _transformYawPitchInv;
  36556. private _firstFrameSkipped;
  36557. private _yawRange;
  36558. private _fowardAxis;
  36559. /**
  36560. * Gets or sets the minimum yaw angle that the bone can look to
  36561. */
  36562. minYaw: number;
  36563. /**
  36564. * Gets or sets the maximum yaw angle that the bone can look to
  36565. */
  36566. maxYaw: number;
  36567. /**
  36568. * Gets or sets the minimum pitch angle that the bone can look to
  36569. */
  36570. minPitch: number;
  36571. /**
  36572. * Gets or sets the maximum pitch angle that the bone can look to
  36573. */
  36574. maxPitch: number;
  36575. /**
  36576. * Create a BoneLookController
  36577. * @param mesh the mesh that the bone belongs to
  36578. * @param bone the bone that will be looking to the target
  36579. * @param target the target Vector3 to look at
  36580. * @param options optional settings:
  36581. * * maxYaw: the maximum angle the bone will yaw to
  36582. * * minYaw: the minimum angle the bone will yaw to
  36583. * * maxPitch: the maximum angle the bone will pitch to
  36584. * * minPitch: the minimum angle the bone will yaw to
  36585. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36586. * * upAxis: the up axis of the coordinate system
  36587. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36588. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36589. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36590. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36591. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36592. * * adjustRoll: used to make an adjustment to the roll of the bone
  36593. **/
  36594. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36595. maxYaw?: number;
  36596. minYaw?: number;
  36597. maxPitch?: number;
  36598. minPitch?: number;
  36599. slerpAmount?: number;
  36600. upAxis?: Vector3;
  36601. upAxisSpace?: Space;
  36602. yawAxis?: Vector3;
  36603. pitchAxis?: Vector3;
  36604. adjustYaw?: number;
  36605. adjustPitch?: number;
  36606. adjustRoll?: number;
  36607. });
  36608. /**
  36609. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36610. */
  36611. update(): void;
  36612. private _getAngleDiff;
  36613. private _getAngleBetween;
  36614. private _isAngleBetween;
  36615. }
  36616. }
  36617. declare module BABYLON {
  36618. /**
  36619. * Manage the gamepad inputs to control an arc rotate camera.
  36620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36621. */
  36622. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36623. /**
  36624. * Defines the camera the input is attached to.
  36625. */
  36626. camera: ArcRotateCamera;
  36627. /**
  36628. * Defines the gamepad the input is gathering event from.
  36629. */
  36630. gamepad: Nullable<Gamepad>;
  36631. /**
  36632. * Defines the gamepad rotation sensiblity.
  36633. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36634. */
  36635. gamepadRotationSensibility: number;
  36636. /**
  36637. * Defines the gamepad move sensiblity.
  36638. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36639. */
  36640. gamepadMoveSensibility: number;
  36641. private _onGamepadConnectedObserver;
  36642. private _onGamepadDisconnectedObserver;
  36643. /**
  36644. * Attach the input controls to a specific dom element to get the input from.
  36645. * @param element Defines the element the controls should be listened from
  36646. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36647. */
  36648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36649. /**
  36650. * Detach the current controls from the specified dom element.
  36651. * @param element Defines the element to stop listening the inputs from
  36652. */
  36653. detachControl(element: Nullable<HTMLElement>): void;
  36654. /**
  36655. * Update the current camera state depending on the inputs that have been used this frame.
  36656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36657. */
  36658. checkInputs(): void;
  36659. /**
  36660. * Gets the class name of the current intput.
  36661. * @returns the class name
  36662. */
  36663. getClassName(): string;
  36664. /**
  36665. * Get the friendly name associated with the input class.
  36666. * @returns the input friendly name
  36667. */
  36668. getSimpleName(): string;
  36669. }
  36670. }
  36671. declare module BABYLON {
  36672. interface ArcRotateCameraInputsManager {
  36673. /**
  36674. * Add orientation input support to the input manager.
  36675. * @returns the current input manager
  36676. */
  36677. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36678. }
  36679. /**
  36680. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36682. */
  36683. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36684. /**
  36685. * Defines the camera the input is attached to.
  36686. */
  36687. camera: ArcRotateCamera;
  36688. /**
  36689. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36690. */
  36691. alphaCorrection: number;
  36692. /**
  36693. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36694. */
  36695. gammaCorrection: number;
  36696. private _alpha;
  36697. private _gamma;
  36698. private _dirty;
  36699. private _deviceOrientationHandler;
  36700. /**
  36701. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36702. */
  36703. constructor();
  36704. /**
  36705. * Attach the input controls to a specific dom element to get the input from.
  36706. * @param element Defines the element the controls should be listened from
  36707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36708. */
  36709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36710. /** @hidden */
  36711. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36712. /**
  36713. * Update the current camera state depending on the inputs that have been used this frame.
  36714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36715. */
  36716. checkInputs(): void;
  36717. /**
  36718. * Detach the current controls from the specified dom element.
  36719. * @param element Defines the element to stop listening the inputs from
  36720. */
  36721. detachControl(element: Nullable<HTMLElement>): void;
  36722. /**
  36723. * Gets the class name of the current intput.
  36724. * @returns the class name
  36725. */
  36726. getClassName(): string;
  36727. /**
  36728. * Get the friendly name associated with the input class.
  36729. * @returns the input friendly name
  36730. */
  36731. getSimpleName(): string;
  36732. }
  36733. }
  36734. declare module BABYLON {
  36735. /**
  36736. * Listen to mouse events to control the camera.
  36737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36738. */
  36739. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36740. /**
  36741. * Defines the camera the input is attached to.
  36742. */
  36743. camera: FlyCamera;
  36744. /**
  36745. * Defines if touch is enabled. (Default is true.)
  36746. */
  36747. touchEnabled: boolean;
  36748. /**
  36749. * Defines the buttons associated with the input to handle camera rotation.
  36750. */
  36751. buttons: number[];
  36752. /**
  36753. * Assign buttons for Yaw control.
  36754. */
  36755. buttonsYaw: number[];
  36756. /**
  36757. * Assign buttons for Pitch control.
  36758. */
  36759. buttonsPitch: number[];
  36760. /**
  36761. * Assign buttons for Roll control.
  36762. */
  36763. buttonsRoll: number[];
  36764. /**
  36765. * Detect if any button is being pressed while mouse is moved.
  36766. * -1 = Mouse locked.
  36767. * 0 = Left button.
  36768. * 1 = Middle Button.
  36769. * 2 = Right Button.
  36770. */
  36771. activeButton: number;
  36772. /**
  36773. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36774. * Higher values reduce its sensitivity.
  36775. */
  36776. angularSensibility: number;
  36777. private _mousemoveCallback;
  36778. private _observer;
  36779. private _rollObserver;
  36780. private previousPosition;
  36781. private noPreventDefault;
  36782. private element;
  36783. /**
  36784. * Listen to mouse events to control the camera.
  36785. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36787. */
  36788. constructor(touchEnabled?: boolean);
  36789. /**
  36790. * Attach the mouse control to the HTML DOM element.
  36791. * @param element Defines the element that listens to the input events.
  36792. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36793. */
  36794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36795. /**
  36796. * Detach the current controls from the specified dom element.
  36797. * @param element Defines the element to stop listening the inputs from
  36798. */
  36799. detachControl(element: Nullable<HTMLElement>): void;
  36800. /**
  36801. * Gets the class name of the current input.
  36802. * @returns the class name.
  36803. */
  36804. getClassName(): string;
  36805. /**
  36806. * Get the friendly name associated with the input class.
  36807. * @returns the input's friendly name.
  36808. */
  36809. getSimpleName(): string;
  36810. private _pointerInput;
  36811. private _onMouseMove;
  36812. /**
  36813. * Rotate camera by mouse offset.
  36814. */
  36815. private rotateCamera;
  36816. }
  36817. }
  36818. declare module BABYLON {
  36819. /**
  36820. * Default Inputs manager for the FlyCamera.
  36821. * It groups all the default supported inputs for ease of use.
  36822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36823. */
  36824. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36825. /**
  36826. * Instantiates a new FlyCameraInputsManager.
  36827. * @param camera Defines the camera the inputs belong to.
  36828. */
  36829. constructor(camera: FlyCamera);
  36830. /**
  36831. * Add keyboard input support to the input manager.
  36832. * @returns the new FlyCameraKeyboardMoveInput().
  36833. */
  36834. addKeyboard(): FlyCameraInputsManager;
  36835. /**
  36836. * Add mouse input support to the input manager.
  36837. * @param touchEnabled Enable touch screen support.
  36838. * @returns the new FlyCameraMouseInput().
  36839. */
  36840. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36841. }
  36842. }
  36843. declare module BABYLON {
  36844. /**
  36845. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36846. * such as in a 3D Space Shooter or a Flight Simulator.
  36847. */
  36848. export class FlyCamera extends TargetCamera {
  36849. /**
  36850. * Define the collision ellipsoid of the camera.
  36851. * This is helpful for simulating a camera body, like a player's body.
  36852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36853. */
  36854. ellipsoid: Vector3;
  36855. /**
  36856. * Define an offset for the position of the ellipsoid around the camera.
  36857. * This can be helpful if the camera is attached away from the player's body center,
  36858. * such as at its head.
  36859. */
  36860. ellipsoidOffset: Vector3;
  36861. /**
  36862. * Enable or disable collisions of the camera with the rest of the scene objects.
  36863. */
  36864. checkCollisions: boolean;
  36865. /**
  36866. * Enable or disable gravity on the camera.
  36867. */
  36868. applyGravity: boolean;
  36869. /**
  36870. * Define the current direction the camera is moving to.
  36871. */
  36872. cameraDirection: Vector3;
  36873. /**
  36874. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36875. * This overrides and empties cameraRotation.
  36876. */
  36877. rotationQuaternion: Quaternion;
  36878. /**
  36879. * Track Roll to maintain the wanted Rolling when looking around.
  36880. */
  36881. _trackRoll: number;
  36882. /**
  36883. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36884. */
  36885. rollCorrect: number;
  36886. /**
  36887. * Mimic a banked turn, Rolling the camera when Yawing.
  36888. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36889. */
  36890. bankedTurn: boolean;
  36891. /**
  36892. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36893. */
  36894. bankedTurnLimit: number;
  36895. /**
  36896. * Value of 0 disables the banked Roll.
  36897. * Value of 1 is equal to the Yaw angle in radians.
  36898. */
  36899. bankedTurnMultiplier: number;
  36900. /**
  36901. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36902. */
  36903. inputs: FlyCameraInputsManager;
  36904. /**
  36905. * Gets the input sensibility for mouse input.
  36906. * Higher values reduce sensitivity.
  36907. */
  36908. /**
  36909. * Sets the input sensibility for a mouse input.
  36910. * Higher values reduce sensitivity.
  36911. */
  36912. angularSensibility: number;
  36913. /**
  36914. * Get the keys for camera movement forward.
  36915. */
  36916. /**
  36917. * Set the keys for camera movement forward.
  36918. */
  36919. keysForward: number[];
  36920. /**
  36921. * Get the keys for camera movement backward.
  36922. */
  36923. keysBackward: number[];
  36924. /**
  36925. * Get the keys for camera movement up.
  36926. */
  36927. /**
  36928. * Set the keys for camera movement up.
  36929. */
  36930. keysUp: number[];
  36931. /**
  36932. * Get the keys for camera movement down.
  36933. */
  36934. /**
  36935. * Set the keys for camera movement down.
  36936. */
  36937. keysDown: number[];
  36938. /**
  36939. * Get the keys for camera movement left.
  36940. */
  36941. /**
  36942. * Set the keys for camera movement left.
  36943. */
  36944. keysLeft: number[];
  36945. /**
  36946. * Set the keys for camera movement right.
  36947. */
  36948. /**
  36949. * Set the keys for camera movement right.
  36950. */
  36951. keysRight: number[];
  36952. /**
  36953. * Event raised when the camera collides with a mesh in the scene.
  36954. */
  36955. onCollide: (collidedMesh: AbstractMesh) => void;
  36956. private _collider;
  36957. private _needMoveForGravity;
  36958. private _oldPosition;
  36959. private _diffPosition;
  36960. private _newPosition;
  36961. /** @hidden */
  36962. _localDirection: Vector3;
  36963. /** @hidden */
  36964. _transformedDirection: Vector3;
  36965. /**
  36966. * Instantiates a FlyCamera.
  36967. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36968. * such as in a 3D Space Shooter or a Flight Simulator.
  36969. * @param name Define the name of the camera in the scene.
  36970. * @param position Define the starting position of the camera in the scene.
  36971. * @param scene Define the scene the camera belongs to.
  36972. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36973. */
  36974. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36975. /**
  36976. * Attach a control to the HTML DOM element.
  36977. * @param element Defines the element that listens to the input events.
  36978. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36979. */
  36980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36981. /**
  36982. * Detach a control from the HTML DOM element.
  36983. * The camera will stop reacting to that input.
  36984. * @param element Defines the element that listens to the input events.
  36985. */
  36986. detachControl(element: HTMLElement): void;
  36987. private _collisionMask;
  36988. /**
  36989. * Get the mask that the camera ignores in collision events.
  36990. */
  36991. /**
  36992. * Set the mask that the camera ignores in collision events.
  36993. */
  36994. collisionMask: number;
  36995. /** @hidden */
  36996. _collideWithWorld(displacement: Vector3): void;
  36997. /** @hidden */
  36998. private _onCollisionPositionChange;
  36999. /** @hidden */
  37000. _checkInputs(): void;
  37001. /** @hidden */
  37002. _decideIfNeedsToMove(): boolean;
  37003. /** @hidden */
  37004. _updatePosition(): void;
  37005. /**
  37006. * Restore the Roll to its target value at the rate specified.
  37007. * @param rate - Higher means slower restoring.
  37008. * @hidden
  37009. */
  37010. restoreRoll(rate: number): void;
  37011. /**
  37012. * Destroy the camera and release the current resources held by it.
  37013. */
  37014. dispose(): void;
  37015. /**
  37016. * Get the current object class name.
  37017. * @returns the class name.
  37018. */
  37019. getClassName(): string;
  37020. }
  37021. }
  37022. declare module BABYLON {
  37023. /**
  37024. * Listen to keyboard events to control the camera.
  37025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37026. */
  37027. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37028. /**
  37029. * Defines the camera the input is attached to.
  37030. */
  37031. camera: FlyCamera;
  37032. /**
  37033. * The list of keyboard keys used to control the forward move of the camera.
  37034. */
  37035. keysForward: number[];
  37036. /**
  37037. * The list of keyboard keys used to control the backward move of the camera.
  37038. */
  37039. keysBackward: number[];
  37040. /**
  37041. * The list of keyboard keys used to control the forward move of the camera.
  37042. */
  37043. keysUp: number[];
  37044. /**
  37045. * The list of keyboard keys used to control the backward move of the camera.
  37046. */
  37047. keysDown: number[];
  37048. /**
  37049. * The list of keyboard keys used to control the right strafe move of the camera.
  37050. */
  37051. keysRight: number[];
  37052. /**
  37053. * The list of keyboard keys used to control the left strafe move of the camera.
  37054. */
  37055. keysLeft: number[];
  37056. private _keys;
  37057. private _onCanvasBlurObserver;
  37058. private _onKeyboardObserver;
  37059. private _engine;
  37060. private _scene;
  37061. /**
  37062. * Attach the input controls to a specific dom element to get the input from.
  37063. * @param element Defines the element the controls should be listened from
  37064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37065. */
  37066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37067. /**
  37068. * Detach the current controls from the specified dom element.
  37069. * @param element Defines the element to stop listening the inputs from
  37070. */
  37071. detachControl(element: Nullable<HTMLElement>): void;
  37072. /**
  37073. * Gets the class name of the current intput.
  37074. * @returns the class name
  37075. */
  37076. getClassName(): string;
  37077. /** @hidden */
  37078. _onLostFocus(e: FocusEvent): void;
  37079. /**
  37080. * Get the friendly name associated with the input class.
  37081. * @returns the input friendly name
  37082. */
  37083. getSimpleName(): string;
  37084. /**
  37085. * Update the current camera state depending on the inputs that have been used this frame.
  37086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37087. */
  37088. checkInputs(): void;
  37089. }
  37090. }
  37091. declare module BABYLON {
  37092. /**
  37093. * Manage the mouse wheel inputs to control a follow camera.
  37094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37095. */
  37096. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37097. /**
  37098. * Defines the camera the input is attached to.
  37099. */
  37100. camera: FollowCamera;
  37101. /**
  37102. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37103. */
  37104. axisControlRadius: boolean;
  37105. /**
  37106. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37107. */
  37108. axisControlHeight: boolean;
  37109. /**
  37110. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37111. */
  37112. axisControlRotation: boolean;
  37113. /**
  37114. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37115. * relation to mouseWheel events.
  37116. */
  37117. wheelPrecision: number;
  37118. /**
  37119. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37120. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37121. */
  37122. wheelDeltaPercentage: number;
  37123. private _wheel;
  37124. private _observer;
  37125. /**
  37126. * Attach the input controls to a specific dom element to get the input from.
  37127. * @param element Defines the element the controls should be listened from
  37128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37129. */
  37130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37131. /**
  37132. * Detach the current controls from the specified dom element.
  37133. * @param element Defines the element to stop listening the inputs from
  37134. */
  37135. detachControl(element: Nullable<HTMLElement>): void;
  37136. /**
  37137. * Gets the class name of the current intput.
  37138. * @returns the class name
  37139. */
  37140. getClassName(): string;
  37141. /**
  37142. * Get the friendly name associated with the input class.
  37143. * @returns the input friendly name
  37144. */
  37145. getSimpleName(): string;
  37146. }
  37147. }
  37148. declare module BABYLON {
  37149. /**
  37150. * Manage the pointers inputs to control an follow camera.
  37151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37152. */
  37153. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37154. /**
  37155. * Defines the camera the input is attached to.
  37156. */
  37157. camera: FollowCamera;
  37158. /**
  37159. * Gets the class name of the current input.
  37160. * @returns the class name
  37161. */
  37162. getClassName(): string;
  37163. /**
  37164. * Defines the pointer angular sensibility along the X axis or how fast is
  37165. * the camera rotating.
  37166. * A negative number will reverse the axis direction.
  37167. */
  37168. angularSensibilityX: number;
  37169. /**
  37170. * Defines the pointer angular sensibility along the Y axis or how fast is
  37171. * the camera rotating.
  37172. * A negative number will reverse the axis direction.
  37173. */
  37174. angularSensibilityY: number;
  37175. /**
  37176. * Defines the pointer pinch precision or how fast is the camera zooming.
  37177. * A negative number will reverse the axis direction.
  37178. */
  37179. pinchPrecision: number;
  37180. /**
  37181. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37182. * from 0.
  37183. * It defines the percentage of current camera.radius to use as delta when
  37184. * pinch zoom is used.
  37185. */
  37186. pinchDeltaPercentage: number;
  37187. /**
  37188. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37189. */
  37190. axisXControlRadius: boolean;
  37191. /**
  37192. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37193. */
  37194. axisXControlHeight: boolean;
  37195. /**
  37196. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37197. */
  37198. axisXControlRotation: boolean;
  37199. /**
  37200. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37201. */
  37202. axisYControlRadius: boolean;
  37203. /**
  37204. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37205. */
  37206. axisYControlHeight: boolean;
  37207. /**
  37208. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37209. */
  37210. axisYControlRotation: boolean;
  37211. /**
  37212. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37213. */
  37214. axisPinchControlRadius: boolean;
  37215. /**
  37216. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37217. */
  37218. axisPinchControlHeight: boolean;
  37219. /**
  37220. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37221. */
  37222. axisPinchControlRotation: boolean;
  37223. /**
  37224. * Log error messages if basic misconfiguration has occurred.
  37225. */
  37226. warningEnable: boolean;
  37227. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37228. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37229. private _warningCounter;
  37230. private _warning;
  37231. }
  37232. }
  37233. declare module BABYLON {
  37234. /**
  37235. * Default Inputs manager for the FollowCamera.
  37236. * It groups all the default supported inputs for ease of use.
  37237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37238. */
  37239. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37240. /**
  37241. * Instantiates a new FollowCameraInputsManager.
  37242. * @param camera Defines the camera the inputs belong to
  37243. */
  37244. constructor(camera: FollowCamera);
  37245. /**
  37246. * Add keyboard input support to the input manager.
  37247. * @returns the current input manager
  37248. */
  37249. addKeyboard(): FollowCameraInputsManager;
  37250. /**
  37251. * Add mouse wheel input support to the input manager.
  37252. * @returns the current input manager
  37253. */
  37254. addMouseWheel(): FollowCameraInputsManager;
  37255. /**
  37256. * Add pointers input support to the input manager.
  37257. * @returns the current input manager
  37258. */
  37259. addPointers(): FollowCameraInputsManager;
  37260. /**
  37261. * Add orientation input support to the input manager.
  37262. * @returns the current input manager
  37263. */
  37264. addVRDeviceOrientation(): FollowCameraInputsManager;
  37265. }
  37266. }
  37267. declare module BABYLON {
  37268. /**
  37269. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37270. * an arc rotate version arcFollowCamera are available.
  37271. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37272. */
  37273. export class FollowCamera extends TargetCamera {
  37274. /**
  37275. * Distance the follow camera should follow an object at
  37276. */
  37277. radius: number;
  37278. /**
  37279. * Minimum allowed distance of the camera to the axis of rotation
  37280. * (The camera can not get closer).
  37281. * This can help limiting how the Camera is able to move in the scene.
  37282. */
  37283. lowerRadiusLimit: Nullable<number>;
  37284. /**
  37285. * Maximum allowed distance of the camera to the axis of rotation
  37286. * (The camera can not get further).
  37287. * This can help limiting how the Camera is able to move in the scene.
  37288. */
  37289. upperRadiusLimit: Nullable<number>;
  37290. /**
  37291. * Define a rotation offset between the camera and the object it follows
  37292. */
  37293. rotationOffset: number;
  37294. /**
  37295. * Minimum allowed angle to camera position relative to target object.
  37296. * This can help limiting how the Camera is able to move in the scene.
  37297. */
  37298. lowerRotationOffsetLimit: Nullable<number>;
  37299. /**
  37300. * Maximum allowed angle to camera position relative to target object.
  37301. * This can help limiting how the Camera is able to move in the scene.
  37302. */
  37303. upperRotationOffsetLimit: Nullable<number>;
  37304. /**
  37305. * Define a height offset between the camera and the object it follows.
  37306. * It can help following an object from the top (like a car chaing a plane)
  37307. */
  37308. heightOffset: number;
  37309. /**
  37310. * Minimum allowed height of camera position relative to target object.
  37311. * This can help limiting how the Camera is able to move in the scene.
  37312. */
  37313. lowerHeightOffsetLimit: Nullable<number>;
  37314. /**
  37315. * Maximum allowed height of camera position relative to target object.
  37316. * This can help limiting how the Camera is able to move in the scene.
  37317. */
  37318. upperHeightOffsetLimit: Nullable<number>;
  37319. /**
  37320. * Define how fast the camera can accelerate to follow it s target.
  37321. */
  37322. cameraAcceleration: number;
  37323. /**
  37324. * Define the speed limit of the camera following an object.
  37325. */
  37326. maxCameraSpeed: number;
  37327. /**
  37328. * Define the target of the camera.
  37329. */
  37330. lockedTarget: Nullable<AbstractMesh>;
  37331. /**
  37332. * Defines the input associated with the camera.
  37333. */
  37334. inputs: FollowCameraInputsManager;
  37335. /**
  37336. * Instantiates the follow camera.
  37337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37338. * @param name Define the name of the camera in the scene
  37339. * @param position Define the position of the camera
  37340. * @param scene Define the scene the camera belong to
  37341. * @param lockedTarget Define the target of the camera
  37342. */
  37343. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37344. private _follow;
  37345. /**
  37346. * Attached controls to the current camera.
  37347. * @param element Defines the element the controls should be listened from
  37348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37349. */
  37350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37351. /**
  37352. * Detach the current controls from the camera.
  37353. * The camera will stop reacting to inputs.
  37354. * @param element Defines the element to stop listening the inputs from
  37355. */
  37356. detachControl(element: HTMLElement): void;
  37357. /** @hidden */
  37358. _checkInputs(): void;
  37359. private _checkLimits;
  37360. /**
  37361. * Gets the camera class name.
  37362. * @returns the class name
  37363. */
  37364. getClassName(): string;
  37365. }
  37366. /**
  37367. * Arc Rotate version of the follow camera.
  37368. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37370. */
  37371. export class ArcFollowCamera extends TargetCamera {
  37372. /** The longitudinal angle of the camera */
  37373. alpha: number;
  37374. /** The latitudinal angle of the camera */
  37375. beta: number;
  37376. /** The radius of the camera from its target */
  37377. radius: number;
  37378. /** Define the camera target (the messh it should follow) */
  37379. target: Nullable<AbstractMesh>;
  37380. private _cartesianCoordinates;
  37381. /**
  37382. * Instantiates a new ArcFollowCamera
  37383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37384. * @param name Define the name of the camera
  37385. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37386. * @param beta Define the rotation angle of the camera around the elevation axis
  37387. * @param radius Define the radius of the camera from its target point
  37388. * @param target Define the target of the camera
  37389. * @param scene Define the scene the camera belongs to
  37390. */
  37391. constructor(name: string,
  37392. /** The longitudinal angle of the camera */
  37393. alpha: number,
  37394. /** The latitudinal angle of the camera */
  37395. beta: number,
  37396. /** The radius of the camera from its target */
  37397. radius: number,
  37398. /** Define the camera target (the messh it should follow) */
  37399. target: Nullable<AbstractMesh>, scene: Scene);
  37400. private _follow;
  37401. /** @hidden */
  37402. _checkInputs(): void;
  37403. /**
  37404. * Returns the class name of the object.
  37405. * It is mostly used internally for serialization purposes.
  37406. */
  37407. getClassName(): string;
  37408. }
  37409. }
  37410. declare module BABYLON {
  37411. /**
  37412. * Manage the keyboard inputs to control the movement of a follow camera.
  37413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37414. */
  37415. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37416. /**
  37417. * Defines the camera the input is attached to.
  37418. */
  37419. camera: FollowCamera;
  37420. /**
  37421. * Defines the list of key codes associated with the up action (increase heightOffset)
  37422. */
  37423. keysHeightOffsetIncr: number[];
  37424. /**
  37425. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37426. */
  37427. keysHeightOffsetDecr: number[];
  37428. /**
  37429. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37430. */
  37431. keysHeightOffsetModifierAlt: boolean;
  37432. /**
  37433. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37434. */
  37435. keysHeightOffsetModifierCtrl: boolean;
  37436. /**
  37437. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37438. */
  37439. keysHeightOffsetModifierShift: boolean;
  37440. /**
  37441. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37442. */
  37443. keysRotationOffsetIncr: number[];
  37444. /**
  37445. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37446. */
  37447. keysRotationOffsetDecr: number[];
  37448. /**
  37449. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37450. */
  37451. keysRotationOffsetModifierAlt: boolean;
  37452. /**
  37453. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37454. */
  37455. keysRotationOffsetModifierCtrl: boolean;
  37456. /**
  37457. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37458. */
  37459. keysRotationOffsetModifierShift: boolean;
  37460. /**
  37461. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37462. */
  37463. keysRadiusIncr: number[];
  37464. /**
  37465. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37466. */
  37467. keysRadiusDecr: number[];
  37468. /**
  37469. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37470. */
  37471. keysRadiusModifierAlt: boolean;
  37472. /**
  37473. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37474. */
  37475. keysRadiusModifierCtrl: boolean;
  37476. /**
  37477. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37478. */
  37479. keysRadiusModifierShift: boolean;
  37480. /**
  37481. * Defines the rate of change of heightOffset.
  37482. */
  37483. heightSensibility: number;
  37484. /**
  37485. * Defines the rate of change of rotationOffset.
  37486. */
  37487. rotationSensibility: number;
  37488. /**
  37489. * Defines the rate of change of radius.
  37490. */
  37491. radiusSensibility: number;
  37492. private _keys;
  37493. private _ctrlPressed;
  37494. private _altPressed;
  37495. private _shiftPressed;
  37496. private _onCanvasBlurObserver;
  37497. private _onKeyboardObserver;
  37498. private _engine;
  37499. private _scene;
  37500. /**
  37501. * Attach the input controls to a specific dom element to get the input from.
  37502. * @param element Defines the element the controls should be listened from
  37503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37504. */
  37505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37506. /**
  37507. * Detach the current controls from the specified dom element.
  37508. * @param element Defines the element to stop listening the inputs from
  37509. */
  37510. detachControl(element: Nullable<HTMLElement>): void;
  37511. /**
  37512. * Update the current camera state depending on the inputs that have been used this frame.
  37513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37514. */
  37515. checkInputs(): void;
  37516. /**
  37517. * Gets the class name of the current input.
  37518. * @returns the class name
  37519. */
  37520. getClassName(): string;
  37521. /**
  37522. * Get the friendly name associated with the input class.
  37523. * @returns the input friendly name
  37524. */
  37525. getSimpleName(): string;
  37526. /**
  37527. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37528. * allow modification of the heightOffset value.
  37529. */
  37530. private _modifierHeightOffset;
  37531. /**
  37532. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37533. * allow modification of the rotationOffset value.
  37534. */
  37535. private _modifierRotationOffset;
  37536. /**
  37537. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37538. * allow modification of the radius value.
  37539. */
  37540. private _modifierRadius;
  37541. }
  37542. }
  37543. declare module BABYLON {
  37544. interface FreeCameraInputsManager {
  37545. /**
  37546. * @hidden
  37547. */
  37548. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37549. /**
  37550. * Add orientation input support to the input manager.
  37551. * @returns the current input manager
  37552. */
  37553. addDeviceOrientation(): FreeCameraInputsManager;
  37554. }
  37555. /**
  37556. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37557. * Screen rotation is taken into account.
  37558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37559. */
  37560. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37561. private _camera;
  37562. private _screenOrientationAngle;
  37563. private _constantTranform;
  37564. private _screenQuaternion;
  37565. private _alpha;
  37566. private _beta;
  37567. private _gamma;
  37568. /**
  37569. * Can be used to detect if a device orientation sensor is availible on a device
  37570. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37571. * @returns a promise that will resolve on orientation change
  37572. */
  37573. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37574. /**
  37575. * @hidden
  37576. */
  37577. _onDeviceOrientationChangedObservable: Observable<void>;
  37578. /**
  37579. * Instantiates a new input
  37580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37581. */
  37582. constructor();
  37583. /**
  37584. * Define the camera controlled by the input.
  37585. */
  37586. camera: FreeCamera;
  37587. /**
  37588. * Attach the input controls to a specific dom element to get the input from.
  37589. * @param element Defines the element the controls should be listened from
  37590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37591. */
  37592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37593. private _orientationChanged;
  37594. private _deviceOrientation;
  37595. /**
  37596. * Detach the current controls from the specified dom element.
  37597. * @param element Defines the element to stop listening the inputs from
  37598. */
  37599. detachControl(element: Nullable<HTMLElement>): void;
  37600. /**
  37601. * Update the current camera state depending on the inputs that have been used this frame.
  37602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37603. */
  37604. checkInputs(): void;
  37605. /**
  37606. * Gets the class name of the current intput.
  37607. * @returns the class name
  37608. */
  37609. getClassName(): string;
  37610. /**
  37611. * Get the friendly name associated with the input class.
  37612. * @returns the input friendly name
  37613. */
  37614. getSimpleName(): string;
  37615. }
  37616. }
  37617. declare module BABYLON {
  37618. /**
  37619. * Manage the gamepad inputs to control a free camera.
  37620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37621. */
  37622. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37623. /**
  37624. * Define the camera the input is attached to.
  37625. */
  37626. camera: FreeCamera;
  37627. /**
  37628. * Define the Gamepad controlling the input
  37629. */
  37630. gamepad: Nullable<Gamepad>;
  37631. /**
  37632. * Defines the gamepad rotation sensiblity.
  37633. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37634. */
  37635. gamepadAngularSensibility: number;
  37636. /**
  37637. * Defines the gamepad move sensiblity.
  37638. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37639. */
  37640. gamepadMoveSensibility: number;
  37641. private _onGamepadConnectedObserver;
  37642. private _onGamepadDisconnectedObserver;
  37643. private _cameraTransform;
  37644. private _deltaTransform;
  37645. private _vector3;
  37646. private _vector2;
  37647. /**
  37648. * Attach the input controls to a specific dom element to get the input from.
  37649. * @param element Defines the element the controls should be listened from
  37650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37651. */
  37652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37653. /**
  37654. * Detach the current controls from the specified dom element.
  37655. * @param element Defines the element to stop listening the inputs from
  37656. */
  37657. detachControl(element: Nullable<HTMLElement>): void;
  37658. /**
  37659. * Update the current camera state depending on the inputs that have been used this frame.
  37660. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37661. */
  37662. checkInputs(): void;
  37663. /**
  37664. * Gets the class name of the current intput.
  37665. * @returns the class name
  37666. */
  37667. getClassName(): string;
  37668. /**
  37669. * Get the friendly name associated with the input class.
  37670. * @returns the input friendly name
  37671. */
  37672. getSimpleName(): string;
  37673. }
  37674. }
  37675. declare module BABYLON {
  37676. /**
  37677. * Defines the potential axis of a Joystick
  37678. */
  37679. export enum JoystickAxis {
  37680. /** X axis */
  37681. X = 0,
  37682. /** Y axis */
  37683. Y = 1,
  37684. /** Z axis */
  37685. Z = 2
  37686. }
  37687. /**
  37688. * Class used to define virtual joystick (used in touch mode)
  37689. */
  37690. export class VirtualJoystick {
  37691. /**
  37692. * Gets or sets a boolean indicating that left and right values must be inverted
  37693. */
  37694. reverseLeftRight: boolean;
  37695. /**
  37696. * Gets or sets a boolean indicating that up and down values must be inverted
  37697. */
  37698. reverseUpDown: boolean;
  37699. /**
  37700. * Gets the offset value for the position (ie. the change of the position value)
  37701. */
  37702. deltaPosition: Vector3;
  37703. /**
  37704. * Gets a boolean indicating if the virtual joystick was pressed
  37705. */
  37706. pressed: boolean;
  37707. /**
  37708. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37709. */
  37710. static Canvas: Nullable<HTMLCanvasElement>;
  37711. private static _globalJoystickIndex;
  37712. private static vjCanvasContext;
  37713. private static vjCanvasWidth;
  37714. private static vjCanvasHeight;
  37715. private static halfWidth;
  37716. private _action;
  37717. private _axisTargetedByLeftAndRight;
  37718. private _axisTargetedByUpAndDown;
  37719. private _joystickSensibility;
  37720. private _inversedSensibility;
  37721. private _joystickPointerID;
  37722. private _joystickColor;
  37723. private _joystickPointerPos;
  37724. private _joystickPreviousPointerPos;
  37725. private _joystickPointerStartPos;
  37726. private _deltaJoystickVector;
  37727. private _leftJoystick;
  37728. private _touches;
  37729. private _onPointerDownHandlerRef;
  37730. private _onPointerMoveHandlerRef;
  37731. private _onPointerUpHandlerRef;
  37732. private _onResize;
  37733. /**
  37734. * Creates a new virtual joystick
  37735. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37736. */
  37737. constructor(leftJoystick?: boolean);
  37738. /**
  37739. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37740. * @param newJoystickSensibility defines the new sensibility
  37741. */
  37742. setJoystickSensibility(newJoystickSensibility: number): void;
  37743. private _onPointerDown;
  37744. private _onPointerMove;
  37745. private _onPointerUp;
  37746. /**
  37747. * Change the color of the virtual joystick
  37748. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37749. */
  37750. setJoystickColor(newColor: string): void;
  37751. /**
  37752. * Defines a callback to call when the joystick is touched
  37753. * @param action defines the callback
  37754. */
  37755. setActionOnTouch(action: () => any): void;
  37756. /**
  37757. * Defines which axis you'd like to control for left & right
  37758. * @param axis defines the axis to use
  37759. */
  37760. setAxisForLeftRight(axis: JoystickAxis): void;
  37761. /**
  37762. * Defines which axis you'd like to control for up & down
  37763. * @param axis defines the axis to use
  37764. */
  37765. setAxisForUpDown(axis: JoystickAxis): void;
  37766. private _drawVirtualJoystick;
  37767. /**
  37768. * Release internal HTML canvas
  37769. */
  37770. releaseCanvas(): void;
  37771. }
  37772. }
  37773. declare module BABYLON {
  37774. interface FreeCameraInputsManager {
  37775. /**
  37776. * Add virtual joystick input support to the input manager.
  37777. * @returns the current input manager
  37778. */
  37779. addVirtualJoystick(): FreeCameraInputsManager;
  37780. }
  37781. /**
  37782. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37784. */
  37785. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37786. /**
  37787. * Defines the camera the input is attached to.
  37788. */
  37789. camera: FreeCamera;
  37790. private _leftjoystick;
  37791. private _rightjoystick;
  37792. /**
  37793. * Gets the left stick of the virtual joystick.
  37794. * @returns The virtual Joystick
  37795. */
  37796. getLeftJoystick(): VirtualJoystick;
  37797. /**
  37798. * Gets the right stick of the virtual joystick.
  37799. * @returns The virtual Joystick
  37800. */
  37801. getRightJoystick(): VirtualJoystick;
  37802. /**
  37803. * Update the current camera state depending on the inputs that have been used this frame.
  37804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37805. */
  37806. checkInputs(): void;
  37807. /**
  37808. * Attach the input controls to a specific dom element to get the input from.
  37809. * @param element Defines the element the controls should be listened from
  37810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37811. */
  37812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37813. /**
  37814. * Detach the current controls from the specified dom element.
  37815. * @param element Defines the element to stop listening the inputs from
  37816. */
  37817. detachControl(element: Nullable<HTMLElement>): void;
  37818. /**
  37819. * Gets the class name of the current intput.
  37820. * @returns the class name
  37821. */
  37822. getClassName(): string;
  37823. /**
  37824. * Get the friendly name associated with the input class.
  37825. * @returns the input friendly name
  37826. */
  37827. getSimpleName(): string;
  37828. }
  37829. }
  37830. declare module BABYLON {
  37831. /**
  37832. * This represents a FPS type of camera controlled by touch.
  37833. * This is like a universal camera minus the Gamepad controls.
  37834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37835. */
  37836. export class TouchCamera extends FreeCamera {
  37837. /**
  37838. * Defines the touch sensibility for rotation.
  37839. * The higher the faster.
  37840. */
  37841. touchAngularSensibility: number;
  37842. /**
  37843. * Defines the touch sensibility for move.
  37844. * The higher the faster.
  37845. */
  37846. touchMoveSensibility: number;
  37847. /**
  37848. * Instantiates a new touch camera.
  37849. * This represents a FPS type of camera controlled by touch.
  37850. * This is like a universal camera minus the Gamepad controls.
  37851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37852. * @param name Define the name of the camera in the scene
  37853. * @param position Define the start position of the camera in the scene
  37854. * @param scene Define the scene the camera belongs to
  37855. */
  37856. constructor(name: string, position: Vector3, scene: Scene);
  37857. /**
  37858. * Gets the current object class name.
  37859. * @return the class name
  37860. */
  37861. getClassName(): string;
  37862. /** @hidden */
  37863. _setupInputs(): void;
  37864. }
  37865. }
  37866. declare module BABYLON {
  37867. /**
  37868. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37869. * being tilted forward or back and left or right.
  37870. */
  37871. export class DeviceOrientationCamera extends FreeCamera {
  37872. private _initialQuaternion;
  37873. private _quaternionCache;
  37874. private _tmpDragQuaternion;
  37875. /**
  37876. * Creates a new device orientation camera
  37877. * @param name The name of the camera
  37878. * @param position The start position camera
  37879. * @param scene The scene the camera belongs to
  37880. */
  37881. constructor(name: string, position: Vector3, scene: Scene);
  37882. /**
  37883. * @hidden
  37884. * Disabled pointer input on first orientation sensor update (Default: true)
  37885. */
  37886. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37887. private _dragFactor;
  37888. /**
  37889. * Enabled turning on the y axis when the orientation sensor is active
  37890. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37891. */
  37892. enableHorizontalDragging(dragFactor?: number): void;
  37893. /**
  37894. * Gets the current instance class name ("DeviceOrientationCamera").
  37895. * This helps avoiding instanceof at run time.
  37896. * @returns the class name
  37897. */
  37898. getClassName(): string;
  37899. /**
  37900. * @hidden
  37901. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37902. */
  37903. _checkInputs(): void;
  37904. /**
  37905. * Reset the camera to its default orientation on the specified axis only.
  37906. * @param axis The axis to reset
  37907. */
  37908. resetToCurrentRotation(axis?: Axis): void;
  37909. }
  37910. }
  37911. declare module BABYLON {
  37912. /**
  37913. * Defines supported buttons for XBox360 compatible gamepads
  37914. */
  37915. export enum Xbox360Button {
  37916. /** A */
  37917. A = 0,
  37918. /** B */
  37919. B = 1,
  37920. /** X */
  37921. X = 2,
  37922. /** Y */
  37923. Y = 3,
  37924. /** Start */
  37925. Start = 4,
  37926. /** Back */
  37927. Back = 5,
  37928. /** Left button */
  37929. LB = 6,
  37930. /** Right button */
  37931. RB = 7,
  37932. /** Left stick */
  37933. LeftStick = 8,
  37934. /** Right stick */
  37935. RightStick = 9
  37936. }
  37937. /** Defines values for XBox360 DPad */
  37938. export enum Xbox360Dpad {
  37939. /** Up */
  37940. Up = 0,
  37941. /** Down */
  37942. Down = 1,
  37943. /** Left */
  37944. Left = 2,
  37945. /** Right */
  37946. Right = 3
  37947. }
  37948. /**
  37949. * Defines a XBox360 gamepad
  37950. */
  37951. export class Xbox360Pad extends Gamepad {
  37952. private _leftTrigger;
  37953. private _rightTrigger;
  37954. private _onlefttriggerchanged;
  37955. private _onrighttriggerchanged;
  37956. private _onbuttondown;
  37957. private _onbuttonup;
  37958. private _ondpaddown;
  37959. private _ondpadup;
  37960. /** Observable raised when a button is pressed */
  37961. onButtonDownObservable: Observable<Xbox360Button>;
  37962. /** Observable raised when a button is released */
  37963. onButtonUpObservable: Observable<Xbox360Button>;
  37964. /** Observable raised when a pad is pressed */
  37965. onPadDownObservable: Observable<Xbox360Dpad>;
  37966. /** Observable raised when a pad is released */
  37967. onPadUpObservable: Observable<Xbox360Dpad>;
  37968. private _buttonA;
  37969. private _buttonB;
  37970. private _buttonX;
  37971. private _buttonY;
  37972. private _buttonBack;
  37973. private _buttonStart;
  37974. private _buttonLB;
  37975. private _buttonRB;
  37976. private _buttonLeftStick;
  37977. private _buttonRightStick;
  37978. private _dPadUp;
  37979. private _dPadDown;
  37980. private _dPadLeft;
  37981. private _dPadRight;
  37982. private _isXboxOnePad;
  37983. /**
  37984. * Creates a new XBox360 gamepad object
  37985. * @param id defines the id of this gamepad
  37986. * @param index defines its index
  37987. * @param gamepad defines the internal HTML gamepad object
  37988. * @param xboxOne defines if it is a XBox One gamepad
  37989. */
  37990. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37991. /**
  37992. * Defines the callback to call when left trigger is pressed
  37993. * @param callback defines the callback to use
  37994. */
  37995. onlefttriggerchanged(callback: (value: number) => void): void;
  37996. /**
  37997. * Defines the callback to call when right trigger is pressed
  37998. * @param callback defines the callback to use
  37999. */
  38000. onrighttriggerchanged(callback: (value: number) => void): void;
  38001. /**
  38002. * Gets the left trigger value
  38003. */
  38004. /**
  38005. * Sets the left trigger value
  38006. */
  38007. leftTrigger: number;
  38008. /**
  38009. * Gets the right trigger value
  38010. */
  38011. /**
  38012. * Sets the right trigger value
  38013. */
  38014. rightTrigger: number;
  38015. /**
  38016. * Defines the callback to call when a button is pressed
  38017. * @param callback defines the callback to use
  38018. */
  38019. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38020. /**
  38021. * Defines the callback to call when a button is released
  38022. * @param callback defines the callback to use
  38023. */
  38024. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38025. /**
  38026. * Defines the callback to call when a pad is pressed
  38027. * @param callback defines the callback to use
  38028. */
  38029. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38030. /**
  38031. * Defines the callback to call when a pad is released
  38032. * @param callback defines the callback to use
  38033. */
  38034. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38035. private _setButtonValue;
  38036. private _setDPadValue;
  38037. /**
  38038. * Gets the value of the `A` button
  38039. */
  38040. /**
  38041. * Sets the value of the `A` button
  38042. */
  38043. buttonA: number;
  38044. /**
  38045. * Gets the value of the `B` button
  38046. */
  38047. /**
  38048. * Sets the value of the `B` button
  38049. */
  38050. buttonB: number;
  38051. /**
  38052. * Gets the value of the `X` button
  38053. */
  38054. /**
  38055. * Sets the value of the `X` button
  38056. */
  38057. buttonX: number;
  38058. /**
  38059. * Gets the value of the `Y` button
  38060. */
  38061. /**
  38062. * Sets the value of the `Y` button
  38063. */
  38064. buttonY: number;
  38065. /**
  38066. * Gets the value of the `Start` button
  38067. */
  38068. /**
  38069. * Sets the value of the `Start` button
  38070. */
  38071. buttonStart: number;
  38072. /**
  38073. * Gets the value of the `Back` button
  38074. */
  38075. /**
  38076. * Sets the value of the `Back` button
  38077. */
  38078. buttonBack: number;
  38079. /**
  38080. * Gets the value of the `Left` button
  38081. */
  38082. /**
  38083. * Sets the value of the `Left` button
  38084. */
  38085. buttonLB: number;
  38086. /**
  38087. * Gets the value of the `Right` button
  38088. */
  38089. /**
  38090. * Sets the value of the `Right` button
  38091. */
  38092. buttonRB: number;
  38093. /**
  38094. * Gets the value of the Left joystick
  38095. */
  38096. /**
  38097. * Sets the value of the Left joystick
  38098. */
  38099. buttonLeftStick: number;
  38100. /**
  38101. * Gets the value of the Right joystick
  38102. */
  38103. /**
  38104. * Sets the value of the Right joystick
  38105. */
  38106. buttonRightStick: number;
  38107. /**
  38108. * Gets the value of D-pad up
  38109. */
  38110. /**
  38111. * Sets the value of D-pad up
  38112. */
  38113. dPadUp: number;
  38114. /**
  38115. * Gets the value of D-pad down
  38116. */
  38117. /**
  38118. * Sets the value of D-pad down
  38119. */
  38120. dPadDown: number;
  38121. /**
  38122. * Gets the value of D-pad left
  38123. */
  38124. /**
  38125. * Sets the value of D-pad left
  38126. */
  38127. dPadLeft: number;
  38128. /**
  38129. * Gets the value of D-pad right
  38130. */
  38131. /**
  38132. * Sets the value of D-pad right
  38133. */
  38134. dPadRight: number;
  38135. /**
  38136. * Force the gamepad to synchronize with device values
  38137. */
  38138. update(): void;
  38139. /**
  38140. * Disposes the gamepad
  38141. */
  38142. dispose(): void;
  38143. }
  38144. }
  38145. declare module BABYLON {
  38146. /**
  38147. * Manager for handling gamepads
  38148. */
  38149. export class GamepadManager {
  38150. private _scene?;
  38151. private _babylonGamepads;
  38152. private _oneGamepadConnected;
  38153. /** @hidden */
  38154. _isMonitoring: boolean;
  38155. private _gamepadEventSupported;
  38156. private _gamepadSupport;
  38157. /**
  38158. * observable to be triggered when the gamepad controller has been connected
  38159. */
  38160. onGamepadConnectedObservable: Observable<Gamepad>;
  38161. /**
  38162. * observable to be triggered when the gamepad controller has been disconnected
  38163. */
  38164. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38165. private _onGamepadConnectedEvent;
  38166. private _onGamepadDisconnectedEvent;
  38167. /**
  38168. * Initializes the gamepad manager
  38169. * @param _scene BabylonJS scene
  38170. */
  38171. constructor(_scene?: Scene | undefined);
  38172. /**
  38173. * The gamepads in the game pad manager
  38174. */
  38175. readonly gamepads: Gamepad[];
  38176. /**
  38177. * Get the gamepad controllers based on type
  38178. * @param type The type of gamepad controller
  38179. * @returns Nullable gamepad
  38180. */
  38181. getGamepadByType(type?: number): Nullable<Gamepad>;
  38182. /**
  38183. * Disposes the gamepad manager
  38184. */
  38185. dispose(): void;
  38186. private _addNewGamepad;
  38187. private _startMonitoringGamepads;
  38188. private _stopMonitoringGamepads;
  38189. /** @hidden */
  38190. _checkGamepadsStatus(): void;
  38191. private _updateGamepadObjects;
  38192. }
  38193. }
  38194. declare module BABYLON {
  38195. interface Scene {
  38196. /** @hidden */
  38197. _gamepadManager: Nullable<GamepadManager>;
  38198. /**
  38199. * Gets the gamepad manager associated with the scene
  38200. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38201. */
  38202. gamepadManager: GamepadManager;
  38203. }
  38204. /**
  38205. * Interface representing a free camera inputs manager
  38206. */
  38207. interface FreeCameraInputsManager {
  38208. /**
  38209. * Adds gamepad input support to the FreeCameraInputsManager.
  38210. * @returns the FreeCameraInputsManager
  38211. */
  38212. addGamepad(): FreeCameraInputsManager;
  38213. }
  38214. /**
  38215. * Interface representing an arc rotate camera inputs manager
  38216. */
  38217. interface ArcRotateCameraInputsManager {
  38218. /**
  38219. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38220. * @returns the camera inputs manager
  38221. */
  38222. addGamepad(): ArcRotateCameraInputsManager;
  38223. }
  38224. /**
  38225. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38226. */
  38227. export class GamepadSystemSceneComponent implements ISceneComponent {
  38228. /**
  38229. * The component name helpfull to identify the component in the list of scene components.
  38230. */
  38231. readonly name: string;
  38232. /**
  38233. * The scene the component belongs to.
  38234. */
  38235. scene: Scene;
  38236. /**
  38237. * Creates a new instance of the component for the given scene
  38238. * @param scene Defines the scene to register the component in
  38239. */
  38240. constructor(scene: Scene);
  38241. /**
  38242. * Registers the component in a given scene
  38243. */
  38244. register(): void;
  38245. /**
  38246. * Rebuilds the elements related to this component in case of
  38247. * context lost for instance.
  38248. */
  38249. rebuild(): void;
  38250. /**
  38251. * Disposes the component and the associated ressources
  38252. */
  38253. dispose(): void;
  38254. private _beforeCameraUpdate;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * 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,
  38260. * which still works and will still be found in many Playgrounds.
  38261. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38262. */
  38263. export class UniversalCamera extends TouchCamera {
  38264. /**
  38265. * Defines the gamepad rotation sensiblity.
  38266. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38267. */
  38268. gamepadAngularSensibility: number;
  38269. /**
  38270. * Defines the gamepad move sensiblity.
  38271. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38272. */
  38273. gamepadMoveSensibility: number;
  38274. /**
  38275. * 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,
  38276. * which still works and will still be found in many Playgrounds.
  38277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38278. * @param name Define the name of the camera in the scene
  38279. * @param position Define the start position of the camera in the scene
  38280. * @param scene Define the scene the camera belongs to
  38281. */
  38282. constructor(name: string, position: Vector3, scene: Scene);
  38283. /**
  38284. * Gets the current object class name.
  38285. * @return the class name
  38286. */
  38287. getClassName(): string;
  38288. }
  38289. }
  38290. declare module BABYLON {
  38291. /**
  38292. * This represents a FPS type of camera. This is only here for back compat purpose.
  38293. * Please use the UniversalCamera instead as both are identical.
  38294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38295. */
  38296. export class GamepadCamera extends UniversalCamera {
  38297. /**
  38298. * Instantiates a new Gamepad Camera
  38299. * This represents a FPS type of camera. This is only here for back compat purpose.
  38300. * Please use the UniversalCamera instead as both are identical.
  38301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38302. * @param name Define the name of the camera in the scene
  38303. * @param position Define the start position of the camera in the scene
  38304. * @param scene Define the scene the camera belongs to
  38305. */
  38306. constructor(name: string, position: Vector3, scene: Scene);
  38307. /**
  38308. * Gets the current object class name.
  38309. * @return the class name
  38310. */
  38311. getClassName(): string;
  38312. }
  38313. }
  38314. declare module BABYLON {
  38315. /** @hidden */
  38316. export var passPixelShader: {
  38317. name: string;
  38318. shader: string;
  38319. };
  38320. }
  38321. declare module BABYLON {
  38322. /** @hidden */
  38323. export var passCubePixelShader: {
  38324. name: string;
  38325. shader: string;
  38326. };
  38327. }
  38328. declare module BABYLON {
  38329. /**
  38330. * PassPostProcess which produces an output the same as it's input
  38331. */
  38332. export class PassPostProcess extends PostProcess {
  38333. /**
  38334. * Creates the PassPostProcess
  38335. * @param name The name of the effect.
  38336. * @param options The required width/height ratio to downsize to before computing the render pass.
  38337. * @param camera The camera to apply the render pass to.
  38338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38339. * @param engine The engine which the post process will be applied. (default: current engine)
  38340. * @param reusable If the post process can be reused on the same frame. (default: false)
  38341. * @param textureType The type of texture to be used when performing the post processing.
  38342. * @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)
  38343. */
  38344. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38345. }
  38346. /**
  38347. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38348. */
  38349. export class PassCubePostProcess extends PostProcess {
  38350. private _face;
  38351. /**
  38352. * Gets or sets the cube face to display.
  38353. * * 0 is +X
  38354. * * 1 is -X
  38355. * * 2 is +Y
  38356. * * 3 is -Y
  38357. * * 4 is +Z
  38358. * * 5 is -Z
  38359. */
  38360. face: number;
  38361. /**
  38362. * Creates the PassCubePostProcess
  38363. * @param name The name of the effect.
  38364. * @param options The required width/height ratio to downsize to before computing the render pass.
  38365. * @param camera The camera to apply the render pass to.
  38366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38367. * @param engine The engine which the post process will be applied. (default: current engine)
  38368. * @param reusable If the post process can be reused on the same frame. (default: false)
  38369. * @param textureType The type of texture to be used when performing the post processing.
  38370. * @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)
  38371. */
  38372. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38373. }
  38374. }
  38375. declare module BABYLON {
  38376. /** @hidden */
  38377. export var anaglyphPixelShader: {
  38378. name: string;
  38379. shader: string;
  38380. };
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * Postprocess used to generate anaglyphic rendering
  38385. */
  38386. export class AnaglyphPostProcess extends PostProcess {
  38387. private _passedProcess;
  38388. /**
  38389. * Creates a new AnaglyphPostProcess
  38390. * @param name defines postprocess name
  38391. * @param options defines creation options or target ratio scale
  38392. * @param rigCameras defines cameras using this postprocess
  38393. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38394. * @param engine defines hosting engine
  38395. * @param reusable defines if the postprocess will be reused multiple times per frame
  38396. */
  38397. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38398. }
  38399. }
  38400. declare module BABYLON {
  38401. /**
  38402. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38403. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38404. */
  38405. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38406. /**
  38407. * Creates a new AnaglyphArcRotateCamera
  38408. * @param name defines camera name
  38409. * @param alpha defines alpha angle (in radians)
  38410. * @param beta defines beta angle (in radians)
  38411. * @param radius defines radius
  38412. * @param target defines camera target
  38413. * @param interaxialDistance defines distance between each color axis
  38414. * @param scene defines the hosting scene
  38415. */
  38416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38417. /**
  38418. * Gets camera class name
  38419. * @returns AnaglyphArcRotateCamera
  38420. */
  38421. getClassName(): string;
  38422. }
  38423. }
  38424. declare module BABYLON {
  38425. /**
  38426. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38427. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38428. */
  38429. export class AnaglyphFreeCamera extends FreeCamera {
  38430. /**
  38431. * Creates a new AnaglyphFreeCamera
  38432. * @param name defines camera name
  38433. * @param position defines initial position
  38434. * @param interaxialDistance defines distance between each color axis
  38435. * @param scene defines the hosting scene
  38436. */
  38437. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38438. /**
  38439. * Gets camera class name
  38440. * @returns AnaglyphFreeCamera
  38441. */
  38442. getClassName(): string;
  38443. }
  38444. }
  38445. declare module BABYLON {
  38446. /**
  38447. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38449. */
  38450. export class AnaglyphGamepadCamera extends GamepadCamera {
  38451. /**
  38452. * Creates a new AnaglyphGamepadCamera
  38453. * @param name defines camera name
  38454. * @param position defines initial position
  38455. * @param interaxialDistance defines distance between each color axis
  38456. * @param scene defines the hosting scene
  38457. */
  38458. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38459. /**
  38460. * Gets camera class name
  38461. * @returns AnaglyphGamepadCamera
  38462. */
  38463. getClassName(): string;
  38464. }
  38465. }
  38466. declare module BABYLON {
  38467. /**
  38468. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38469. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38470. */
  38471. export class AnaglyphUniversalCamera extends UniversalCamera {
  38472. /**
  38473. * Creates a new AnaglyphUniversalCamera
  38474. * @param name defines camera name
  38475. * @param position defines initial position
  38476. * @param interaxialDistance defines distance between each color axis
  38477. * @param scene defines the hosting scene
  38478. */
  38479. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38480. /**
  38481. * Gets camera class name
  38482. * @returns AnaglyphUniversalCamera
  38483. */
  38484. getClassName(): string;
  38485. }
  38486. }
  38487. declare module BABYLON {
  38488. /** @hidden */
  38489. export var stereoscopicInterlacePixelShader: {
  38490. name: string;
  38491. shader: string;
  38492. };
  38493. }
  38494. declare module BABYLON {
  38495. /**
  38496. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38497. */
  38498. export class StereoscopicInterlacePostProcess extends PostProcess {
  38499. private _stepSize;
  38500. private _passedProcess;
  38501. /**
  38502. * Initializes a StereoscopicInterlacePostProcess
  38503. * @param name The name of the effect.
  38504. * @param rigCameras The rig cameras to be appled to the post process
  38505. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38507. * @param engine The engine which the post process will be applied. (default: current engine)
  38508. * @param reusable If the post process can be reused on the same frame. (default: false)
  38509. */
  38510. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38511. }
  38512. }
  38513. declare module BABYLON {
  38514. /**
  38515. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38516. * @see http://doc.babylonjs.com/features/cameras
  38517. */
  38518. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38519. /**
  38520. * Creates a new StereoscopicArcRotateCamera
  38521. * @param name defines camera name
  38522. * @param alpha defines alpha angle (in radians)
  38523. * @param beta defines beta angle (in radians)
  38524. * @param radius defines radius
  38525. * @param target defines camera target
  38526. * @param interaxialDistance defines distance between each color axis
  38527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38528. * @param scene defines the hosting scene
  38529. */
  38530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38531. /**
  38532. * Gets camera class name
  38533. * @returns StereoscopicArcRotateCamera
  38534. */
  38535. getClassName(): string;
  38536. }
  38537. }
  38538. declare module BABYLON {
  38539. /**
  38540. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38541. * @see http://doc.babylonjs.com/features/cameras
  38542. */
  38543. export class StereoscopicFreeCamera extends FreeCamera {
  38544. /**
  38545. * Creates a new StereoscopicFreeCamera
  38546. * @param name defines camera name
  38547. * @param position defines initial position
  38548. * @param interaxialDistance defines distance between each color axis
  38549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38550. * @param scene defines the hosting scene
  38551. */
  38552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38553. /**
  38554. * Gets camera class name
  38555. * @returns StereoscopicFreeCamera
  38556. */
  38557. getClassName(): string;
  38558. }
  38559. }
  38560. declare module BABYLON {
  38561. /**
  38562. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38563. * @see http://doc.babylonjs.com/features/cameras
  38564. */
  38565. export class StereoscopicGamepadCamera extends GamepadCamera {
  38566. /**
  38567. * Creates a new StereoscopicGamepadCamera
  38568. * @param name defines camera name
  38569. * @param position defines initial position
  38570. * @param interaxialDistance defines distance between each color axis
  38571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38572. * @param scene defines the hosting scene
  38573. */
  38574. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38575. /**
  38576. * Gets camera class name
  38577. * @returns StereoscopicGamepadCamera
  38578. */
  38579. getClassName(): string;
  38580. }
  38581. }
  38582. declare module BABYLON {
  38583. /**
  38584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38585. * @see http://doc.babylonjs.com/features/cameras
  38586. */
  38587. export class StereoscopicUniversalCamera extends UniversalCamera {
  38588. /**
  38589. * Creates a new StereoscopicUniversalCamera
  38590. * @param name defines camera name
  38591. * @param position defines initial position
  38592. * @param interaxialDistance defines distance between each color axis
  38593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38594. * @param scene defines the hosting scene
  38595. */
  38596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38597. /**
  38598. * Gets camera class name
  38599. * @returns StereoscopicUniversalCamera
  38600. */
  38601. getClassName(): string;
  38602. }
  38603. }
  38604. declare module BABYLON {
  38605. /**
  38606. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38607. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38608. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38609. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38610. */
  38611. export class VirtualJoysticksCamera extends FreeCamera {
  38612. /**
  38613. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38614. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38615. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38616. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38617. * @param name Define the name of the camera in the scene
  38618. * @param position Define the start position of the camera in the scene
  38619. * @param scene Define the scene the camera belongs to
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene);
  38622. /**
  38623. * Gets the current object class name.
  38624. * @return the class name
  38625. */
  38626. getClassName(): string;
  38627. }
  38628. }
  38629. declare module BABYLON {
  38630. /**
  38631. * This represents all the required metrics to create a VR camera.
  38632. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38633. */
  38634. export class VRCameraMetrics {
  38635. /**
  38636. * Define the horizontal resolution off the screen.
  38637. */
  38638. hResolution: number;
  38639. /**
  38640. * Define the vertical resolution off the screen.
  38641. */
  38642. vResolution: number;
  38643. /**
  38644. * Define the horizontal screen size.
  38645. */
  38646. hScreenSize: number;
  38647. /**
  38648. * Define the vertical screen size.
  38649. */
  38650. vScreenSize: number;
  38651. /**
  38652. * Define the vertical screen center position.
  38653. */
  38654. vScreenCenter: number;
  38655. /**
  38656. * Define the distance of the eyes to the screen.
  38657. */
  38658. eyeToScreenDistance: number;
  38659. /**
  38660. * Define the distance between both lenses
  38661. */
  38662. lensSeparationDistance: number;
  38663. /**
  38664. * Define the distance between both viewer's eyes.
  38665. */
  38666. interpupillaryDistance: number;
  38667. /**
  38668. * Define the distortion factor of the VR postprocess.
  38669. * Please, touch with care.
  38670. */
  38671. distortionK: number[];
  38672. /**
  38673. * Define the chromatic aberration correction factors for the VR post process.
  38674. */
  38675. chromaAbCorrection: number[];
  38676. /**
  38677. * Define the scale factor of the post process.
  38678. * The smaller the better but the slower.
  38679. */
  38680. postProcessScaleFactor: number;
  38681. /**
  38682. * Define an offset for the lens center.
  38683. */
  38684. lensCenterOffset: number;
  38685. /**
  38686. * Define if the current vr camera should compensate the distortion of the lense or not.
  38687. */
  38688. compensateDistortion: boolean;
  38689. /**
  38690. * Defines if multiview should be enabled when rendering (Default: false)
  38691. */
  38692. multiviewEnabled: boolean;
  38693. /**
  38694. * Gets the rendering aspect ratio based on the provided resolutions.
  38695. */
  38696. readonly aspectRatio: number;
  38697. /**
  38698. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38699. */
  38700. readonly aspectRatioFov: number;
  38701. /**
  38702. * @hidden
  38703. */
  38704. readonly leftHMatrix: Matrix;
  38705. /**
  38706. * @hidden
  38707. */
  38708. readonly rightHMatrix: Matrix;
  38709. /**
  38710. * @hidden
  38711. */
  38712. readonly leftPreViewMatrix: Matrix;
  38713. /**
  38714. * @hidden
  38715. */
  38716. readonly rightPreViewMatrix: Matrix;
  38717. /**
  38718. * Get the default VRMetrics based on the most generic setup.
  38719. * @returns the default vr metrics
  38720. */
  38721. static GetDefault(): VRCameraMetrics;
  38722. }
  38723. }
  38724. declare module BABYLON {
  38725. /** @hidden */
  38726. export var vrDistortionCorrectionPixelShader: {
  38727. name: string;
  38728. shader: string;
  38729. };
  38730. }
  38731. declare module BABYLON {
  38732. /**
  38733. * VRDistortionCorrectionPostProcess used for mobile VR
  38734. */
  38735. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38736. private _isRightEye;
  38737. private _distortionFactors;
  38738. private _postProcessScaleFactor;
  38739. private _lensCenterOffset;
  38740. private _scaleIn;
  38741. private _scaleFactor;
  38742. private _lensCenter;
  38743. /**
  38744. * Initializes the VRDistortionCorrectionPostProcess
  38745. * @param name The name of the effect.
  38746. * @param camera The camera to apply the render pass to.
  38747. * @param isRightEye If this is for the right eye distortion
  38748. * @param vrMetrics All the required metrics for the VR camera
  38749. */
  38750. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38751. }
  38752. }
  38753. declare module BABYLON {
  38754. /**
  38755. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38757. */
  38758. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38759. /**
  38760. * Creates a new VRDeviceOrientationArcRotateCamera
  38761. * @param name defines camera name
  38762. * @param alpha defines the camera rotation along the logitudinal axis
  38763. * @param beta defines the camera rotation along the latitudinal axis
  38764. * @param radius defines the camera distance from its target
  38765. * @param target defines the camera target
  38766. * @param scene defines the scene the camera belongs to
  38767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38769. */
  38770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38771. /**
  38772. * Gets camera class name
  38773. * @returns VRDeviceOrientationArcRotateCamera
  38774. */
  38775. getClassName(): string;
  38776. }
  38777. }
  38778. declare module BABYLON {
  38779. /**
  38780. * Camera used to simulate VR rendering (based on FreeCamera)
  38781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38782. */
  38783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38784. /**
  38785. * Creates a new VRDeviceOrientationFreeCamera
  38786. * @param name defines camera name
  38787. * @param position defines the start position of the camera
  38788. * @param scene defines the scene the camera belongs to
  38789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38791. */
  38792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38793. /**
  38794. * Gets camera class name
  38795. * @returns VRDeviceOrientationFreeCamera
  38796. */
  38797. getClassName(): string;
  38798. }
  38799. }
  38800. declare module BABYLON {
  38801. /**
  38802. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38803. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38804. */
  38805. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38806. /**
  38807. * Creates a new VRDeviceOrientationGamepadCamera
  38808. * @param name defines camera name
  38809. * @param position defines the start position of the camera
  38810. * @param scene defines the scene the camera belongs to
  38811. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38812. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38813. */
  38814. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38815. /**
  38816. * Gets camera class name
  38817. * @returns VRDeviceOrientationGamepadCamera
  38818. */
  38819. getClassName(): string;
  38820. }
  38821. }
  38822. declare module BABYLON {
  38823. /**
  38824. * Base class of materials working in push mode in babylon JS
  38825. * @hidden
  38826. */
  38827. export class PushMaterial extends Material {
  38828. protected _activeEffect: Effect;
  38829. protected _normalMatrix: Matrix;
  38830. /**
  38831. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38832. * This means that the material can keep using a previous shader while a new one is being compiled.
  38833. * This is mostly used when shader parallel compilation is supported (true by default)
  38834. */
  38835. allowShaderHotSwapping: boolean;
  38836. constructor(name: string, scene: Scene);
  38837. getEffect(): Effect;
  38838. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38839. /**
  38840. * Binds the given world matrix to the active effect
  38841. *
  38842. * @param world the matrix to bind
  38843. */
  38844. bindOnlyWorldMatrix(world: Matrix): void;
  38845. /**
  38846. * Binds the given normal matrix to the active effect
  38847. *
  38848. * @param normalMatrix the matrix to bind
  38849. */
  38850. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38851. bind(world: Matrix, mesh?: Mesh): void;
  38852. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38853. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38854. }
  38855. }
  38856. declare module BABYLON {
  38857. /**
  38858. * This groups all the flags used to control the materials channel.
  38859. */
  38860. export class MaterialFlags {
  38861. private static _DiffuseTextureEnabled;
  38862. /**
  38863. * Are diffuse textures enabled in the application.
  38864. */
  38865. static DiffuseTextureEnabled: boolean;
  38866. private static _AmbientTextureEnabled;
  38867. /**
  38868. * Are ambient textures enabled in the application.
  38869. */
  38870. static AmbientTextureEnabled: boolean;
  38871. private static _OpacityTextureEnabled;
  38872. /**
  38873. * Are opacity textures enabled in the application.
  38874. */
  38875. static OpacityTextureEnabled: boolean;
  38876. private static _ReflectionTextureEnabled;
  38877. /**
  38878. * Are reflection textures enabled in the application.
  38879. */
  38880. static ReflectionTextureEnabled: boolean;
  38881. private static _EmissiveTextureEnabled;
  38882. /**
  38883. * Are emissive textures enabled in the application.
  38884. */
  38885. static EmissiveTextureEnabled: boolean;
  38886. private static _SpecularTextureEnabled;
  38887. /**
  38888. * Are specular textures enabled in the application.
  38889. */
  38890. static SpecularTextureEnabled: boolean;
  38891. private static _BumpTextureEnabled;
  38892. /**
  38893. * Are bump textures enabled in the application.
  38894. */
  38895. static BumpTextureEnabled: boolean;
  38896. private static _LightmapTextureEnabled;
  38897. /**
  38898. * Are lightmap textures enabled in the application.
  38899. */
  38900. static LightmapTextureEnabled: boolean;
  38901. private static _RefractionTextureEnabled;
  38902. /**
  38903. * Are refraction textures enabled in the application.
  38904. */
  38905. static RefractionTextureEnabled: boolean;
  38906. private static _ColorGradingTextureEnabled;
  38907. /**
  38908. * Are color grading textures enabled in the application.
  38909. */
  38910. static ColorGradingTextureEnabled: boolean;
  38911. private static _FresnelEnabled;
  38912. /**
  38913. * Are fresnels enabled in the application.
  38914. */
  38915. static FresnelEnabled: boolean;
  38916. private static _ClearCoatTextureEnabled;
  38917. /**
  38918. * Are clear coat textures enabled in the application.
  38919. */
  38920. static ClearCoatTextureEnabled: boolean;
  38921. private static _ClearCoatBumpTextureEnabled;
  38922. /**
  38923. * Are clear coat bump textures enabled in the application.
  38924. */
  38925. static ClearCoatBumpTextureEnabled: boolean;
  38926. private static _ClearCoatTintTextureEnabled;
  38927. /**
  38928. * Are clear coat tint textures enabled in the application.
  38929. */
  38930. static ClearCoatTintTextureEnabled: boolean;
  38931. private static _SheenTextureEnabled;
  38932. /**
  38933. * Are sheen textures enabled in the application.
  38934. */
  38935. static SheenTextureEnabled: boolean;
  38936. private static _AnisotropicTextureEnabled;
  38937. /**
  38938. * Are anisotropic textures enabled in the application.
  38939. */
  38940. static AnisotropicTextureEnabled: boolean;
  38941. private static _ThicknessTextureEnabled;
  38942. /**
  38943. * Are thickness textures enabled in the application.
  38944. */
  38945. static ThicknessTextureEnabled: boolean;
  38946. }
  38947. }
  38948. declare module BABYLON {
  38949. /** @hidden */
  38950. export var defaultFragmentDeclaration: {
  38951. name: string;
  38952. shader: string;
  38953. };
  38954. }
  38955. declare module BABYLON {
  38956. /** @hidden */
  38957. export var defaultUboDeclaration: {
  38958. name: string;
  38959. shader: string;
  38960. };
  38961. }
  38962. declare module BABYLON {
  38963. /** @hidden */
  38964. export var lightFragmentDeclaration: {
  38965. name: string;
  38966. shader: string;
  38967. };
  38968. }
  38969. declare module BABYLON {
  38970. /** @hidden */
  38971. export var lightUboDeclaration: {
  38972. name: string;
  38973. shader: string;
  38974. };
  38975. }
  38976. declare module BABYLON {
  38977. /** @hidden */
  38978. export var lightsFragmentFunctions: {
  38979. name: string;
  38980. shader: string;
  38981. };
  38982. }
  38983. declare module BABYLON {
  38984. /** @hidden */
  38985. export var shadowsFragmentFunctions: {
  38986. name: string;
  38987. shader: string;
  38988. };
  38989. }
  38990. declare module BABYLON {
  38991. /** @hidden */
  38992. export var fresnelFunction: {
  38993. name: string;
  38994. shader: string;
  38995. };
  38996. }
  38997. declare module BABYLON {
  38998. /** @hidden */
  38999. export var reflectionFunction: {
  39000. name: string;
  39001. shader: string;
  39002. };
  39003. }
  39004. declare module BABYLON {
  39005. /** @hidden */
  39006. export var bumpFragmentFunctions: {
  39007. name: string;
  39008. shader: string;
  39009. };
  39010. }
  39011. declare module BABYLON {
  39012. /** @hidden */
  39013. export var logDepthDeclaration: {
  39014. name: string;
  39015. shader: string;
  39016. };
  39017. }
  39018. declare module BABYLON {
  39019. /** @hidden */
  39020. export var bumpFragment: {
  39021. name: string;
  39022. shader: string;
  39023. };
  39024. }
  39025. declare module BABYLON {
  39026. /** @hidden */
  39027. export var depthPrePass: {
  39028. name: string;
  39029. shader: string;
  39030. };
  39031. }
  39032. declare module BABYLON {
  39033. /** @hidden */
  39034. export var lightFragment: {
  39035. name: string;
  39036. shader: string;
  39037. };
  39038. }
  39039. declare module BABYLON {
  39040. /** @hidden */
  39041. export var logDepthFragment: {
  39042. name: string;
  39043. shader: string;
  39044. };
  39045. }
  39046. declare module BABYLON {
  39047. /** @hidden */
  39048. export var defaultPixelShader: {
  39049. name: string;
  39050. shader: string;
  39051. };
  39052. }
  39053. declare module BABYLON {
  39054. /** @hidden */
  39055. export var defaultVertexDeclaration: {
  39056. name: string;
  39057. shader: string;
  39058. };
  39059. }
  39060. declare module BABYLON {
  39061. /** @hidden */
  39062. export var bumpVertexDeclaration: {
  39063. name: string;
  39064. shader: string;
  39065. };
  39066. }
  39067. declare module BABYLON {
  39068. /** @hidden */
  39069. export var bumpVertex: {
  39070. name: string;
  39071. shader: string;
  39072. };
  39073. }
  39074. declare module BABYLON {
  39075. /** @hidden */
  39076. export var fogVertex: {
  39077. name: string;
  39078. shader: string;
  39079. };
  39080. }
  39081. declare module BABYLON {
  39082. /** @hidden */
  39083. export var shadowsVertex: {
  39084. name: string;
  39085. shader: string;
  39086. };
  39087. }
  39088. declare module BABYLON {
  39089. /** @hidden */
  39090. export var pointCloudVertex: {
  39091. name: string;
  39092. shader: string;
  39093. };
  39094. }
  39095. declare module BABYLON {
  39096. /** @hidden */
  39097. export var logDepthVertex: {
  39098. name: string;
  39099. shader: string;
  39100. };
  39101. }
  39102. declare module BABYLON {
  39103. /** @hidden */
  39104. export var defaultVertexShader: {
  39105. name: string;
  39106. shader: string;
  39107. };
  39108. }
  39109. declare module BABYLON {
  39110. /** @hidden */
  39111. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39112. MAINUV1: boolean;
  39113. MAINUV2: boolean;
  39114. DIFFUSE: boolean;
  39115. DIFFUSEDIRECTUV: number;
  39116. AMBIENT: boolean;
  39117. AMBIENTDIRECTUV: number;
  39118. OPACITY: boolean;
  39119. OPACITYDIRECTUV: number;
  39120. OPACITYRGB: boolean;
  39121. REFLECTION: boolean;
  39122. EMISSIVE: boolean;
  39123. EMISSIVEDIRECTUV: number;
  39124. SPECULAR: boolean;
  39125. SPECULARDIRECTUV: number;
  39126. BUMP: boolean;
  39127. BUMPDIRECTUV: number;
  39128. PARALLAX: boolean;
  39129. PARALLAXOCCLUSION: boolean;
  39130. SPECULAROVERALPHA: boolean;
  39131. CLIPPLANE: boolean;
  39132. CLIPPLANE2: boolean;
  39133. CLIPPLANE3: boolean;
  39134. CLIPPLANE4: boolean;
  39135. ALPHATEST: boolean;
  39136. DEPTHPREPASS: boolean;
  39137. ALPHAFROMDIFFUSE: boolean;
  39138. POINTSIZE: boolean;
  39139. FOG: boolean;
  39140. SPECULARTERM: boolean;
  39141. DIFFUSEFRESNEL: boolean;
  39142. OPACITYFRESNEL: boolean;
  39143. REFLECTIONFRESNEL: boolean;
  39144. REFRACTIONFRESNEL: boolean;
  39145. EMISSIVEFRESNEL: boolean;
  39146. FRESNEL: boolean;
  39147. NORMAL: boolean;
  39148. UV1: boolean;
  39149. UV2: boolean;
  39150. VERTEXCOLOR: boolean;
  39151. VERTEXALPHA: boolean;
  39152. NUM_BONE_INFLUENCERS: number;
  39153. BonesPerMesh: number;
  39154. BONETEXTURE: boolean;
  39155. INSTANCES: boolean;
  39156. GLOSSINESS: boolean;
  39157. ROUGHNESS: boolean;
  39158. EMISSIVEASILLUMINATION: boolean;
  39159. LINKEMISSIVEWITHDIFFUSE: boolean;
  39160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39161. LIGHTMAP: boolean;
  39162. LIGHTMAPDIRECTUV: number;
  39163. OBJECTSPACE_NORMALMAP: boolean;
  39164. USELIGHTMAPASSHADOWMAP: boolean;
  39165. REFLECTIONMAP_3D: boolean;
  39166. REFLECTIONMAP_SPHERICAL: boolean;
  39167. REFLECTIONMAP_PLANAR: boolean;
  39168. REFLECTIONMAP_CUBIC: boolean;
  39169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39170. REFLECTIONMAP_PROJECTION: boolean;
  39171. REFLECTIONMAP_SKYBOX: boolean;
  39172. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39173. REFLECTIONMAP_EXPLICIT: boolean;
  39174. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39175. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39176. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39177. INVERTCUBICMAP: boolean;
  39178. LOGARITHMICDEPTH: boolean;
  39179. REFRACTION: boolean;
  39180. REFRACTIONMAP_3D: boolean;
  39181. REFLECTIONOVERALPHA: boolean;
  39182. TWOSIDEDLIGHTING: boolean;
  39183. SHADOWFLOAT: boolean;
  39184. MORPHTARGETS: boolean;
  39185. MORPHTARGETS_NORMAL: boolean;
  39186. MORPHTARGETS_TANGENT: boolean;
  39187. MORPHTARGETS_UV: boolean;
  39188. NUM_MORPH_INFLUENCERS: number;
  39189. NONUNIFORMSCALING: boolean;
  39190. PREMULTIPLYALPHA: boolean;
  39191. IMAGEPROCESSING: boolean;
  39192. VIGNETTE: boolean;
  39193. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39194. VIGNETTEBLENDMODEOPAQUE: boolean;
  39195. TONEMAPPING: boolean;
  39196. TONEMAPPING_ACES: boolean;
  39197. CONTRAST: boolean;
  39198. COLORCURVES: boolean;
  39199. COLORGRADING: boolean;
  39200. COLORGRADING3D: boolean;
  39201. SAMPLER3DGREENDEPTH: boolean;
  39202. SAMPLER3DBGRMAP: boolean;
  39203. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39204. MULTIVIEW: boolean;
  39205. /**
  39206. * If the reflection texture on this material is in linear color space
  39207. * @hidden
  39208. */
  39209. IS_REFLECTION_LINEAR: boolean;
  39210. /**
  39211. * If the refraction texture on this material is in linear color space
  39212. * @hidden
  39213. */
  39214. IS_REFRACTION_LINEAR: boolean;
  39215. EXPOSURE: boolean;
  39216. constructor();
  39217. setReflectionMode(modeToEnable: string): void;
  39218. }
  39219. /**
  39220. * This is the default material used in Babylon. It is the best trade off between quality
  39221. * and performances.
  39222. * @see http://doc.babylonjs.com/babylon101/materials
  39223. */
  39224. export class StandardMaterial extends PushMaterial {
  39225. private _diffuseTexture;
  39226. /**
  39227. * The basic texture of the material as viewed under a light.
  39228. */
  39229. diffuseTexture: Nullable<BaseTexture>;
  39230. private _ambientTexture;
  39231. /**
  39232. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39233. */
  39234. ambientTexture: Nullable<BaseTexture>;
  39235. private _opacityTexture;
  39236. /**
  39237. * Define the transparency of the material from a texture.
  39238. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39239. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39240. */
  39241. opacityTexture: Nullable<BaseTexture>;
  39242. private _reflectionTexture;
  39243. /**
  39244. * Define the texture used to display the reflection.
  39245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39246. */
  39247. reflectionTexture: Nullable<BaseTexture>;
  39248. private _emissiveTexture;
  39249. /**
  39250. * Define texture of the material as if self lit.
  39251. * This will be mixed in the final result even in the absence of light.
  39252. */
  39253. emissiveTexture: Nullable<BaseTexture>;
  39254. private _specularTexture;
  39255. /**
  39256. * Define how the color and intensity of the highlight given by the light in the material.
  39257. */
  39258. specularTexture: Nullable<BaseTexture>;
  39259. private _bumpTexture;
  39260. /**
  39261. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39262. * 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.
  39263. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39264. */
  39265. bumpTexture: Nullable<BaseTexture>;
  39266. private _lightmapTexture;
  39267. /**
  39268. * Complex lighting can be computationally expensive to compute at runtime.
  39269. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39270. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39271. */
  39272. lightmapTexture: Nullable<BaseTexture>;
  39273. private _refractionTexture;
  39274. /**
  39275. * Define the texture used to display the refraction.
  39276. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39277. */
  39278. refractionTexture: Nullable<BaseTexture>;
  39279. /**
  39280. * The color of the material lit by the environmental background lighting.
  39281. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39282. */
  39283. ambientColor: Color3;
  39284. /**
  39285. * The basic color of the material as viewed under a light.
  39286. */
  39287. diffuseColor: Color3;
  39288. /**
  39289. * Define how the color and intensity of the highlight given by the light in the material.
  39290. */
  39291. specularColor: Color3;
  39292. /**
  39293. * Define the color of the material as if self lit.
  39294. * This will be mixed in the final result even in the absence of light.
  39295. */
  39296. emissiveColor: Color3;
  39297. /**
  39298. * Defines how sharp are the highlights in the material.
  39299. * The bigger the value the sharper giving a more glossy feeling to the result.
  39300. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39301. */
  39302. specularPower: number;
  39303. private _useAlphaFromDiffuseTexture;
  39304. /**
  39305. * Does the transparency come from the diffuse texture alpha channel.
  39306. */
  39307. useAlphaFromDiffuseTexture: boolean;
  39308. private _useEmissiveAsIllumination;
  39309. /**
  39310. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39311. */
  39312. useEmissiveAsIllumination: boolean;
  39313. private _linkEmissiveWithDiffuse;
  39314. /**
  39315. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39316. * the emissive level when the final color is close to one.
  39317. */
  39318. linkEmissiveWithDiffuse: boolean;
  39319. private _useSpecularOverAlpha;
  39320. /**
  39321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39323. */
  39324. useSpecularOverAlpha: boolean;
  39325. private _useReflectionOverAlpha;
  39326. /**
  39327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39329. */
  39330. useReflectionOverAlpha: boolean;
  39331. private _disableLighting;
  39332. /**
  39333. * Does lights from the scene impacts this material.
  39334. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39335. */
  39336. disableLighting: boolean;
  39337. private _useObjectSpaceNormalMap;
  39338. /**
  39339. * Allows using an object space normal map (instead of tangent space).
  39340. */
  39341. useObjectSpaceNormalMap: boolean;
  39342. private _useParallax;
  39343. /**
  39344. * Is parallax enabled or not.
  39345. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39346. */
  39347. useParallax: boolean;
  39348. private _useParallaxOcclusion;
  39349. /**
  39350. * Is parallax occlusion enabled or not.
  39351. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39352. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39353. */
  39354. useParallaxOcclusion: boolean;
  39355. /**
  39356. * 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.
  39357. */
  39358. parallaxScaleBias: number;
  39359. private _roughness;
  39360. /**
  39361. * Helps to define how blurry the reflections should appears in the material.
  39362. */
  39363. roughness: number;
  39364. /**
  39365. * In case of refraction, define the value of the index of refraction.
  39366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39367. */
  39368. indexOfRefraction: number;
  39369. /**
  39370. * Invert the refraction texture alongside the y axis.
  39371. * It can be useful with procedural textures or probe for instance.
  39372. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39373. */
  39374. invertRefractionY: boolean;
  39375. /**
  39376. * Defines the alpha limits in alpha test mode.
  39377. */
  39378. alphaCutOff: number;
  39379. private _useLightmapAsShadowmap;
  39380. /**
  39381. * In case of light mapping, define whether the map contains light or shadow informations.
  39382. */
  39383. useLightmapAsShadowmap: boolean;
  39384. private _diffuseFresnelParameters;
  39385. /**
  39386. * Define the diffuse fresnel parameters of the material.
  39387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39388. */
  39389. diffuseFresnelParameters: FresnelParameters;
  39390. private _opacityFresnelParameters;
  39391. /**
  39392. * Define the opacity fresnel parameters of the material.
  39393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39394. */
  39395. opacityFresnelParameters: FresnelParameters;
  39396. private _reflectionFresnelParameters;
  39397. /**
  39398. * Define the reflection fresnel parameters of the material.
  39399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39400. */
  39401. reflectionFresnelParameters: FresnelParameters;
  39402. private _refractionFresnelParameters;
  39403. /**
  39404. * Define the refraction fresnel parameters of the material.
  39405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39406. */
  39407. refractionFresnelParameters: FresnelParameters;
  39408. private _emissiveFresnelParameters;
  39409. /**
  39410. * Define the emissive fresnel parameters of the material.
  39411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39412. */
  39413. emissiveFresnelParameters: FresnelParameters;
  39414. private _useReflectionFresnelFromSpecular;
  39415. /**
  39416. * If true automatically deducts the fresnels values from the material specularity.
  39417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39418. */
  39419. useReflectionFresnelFromSpecular: boolean;
  39420. private _useGlossinessFromSpecularMapAlpha;
  39421. /**
  39422. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39423. */
  39424. useGlossinessFromSpecularMapAlpha: boolean;
  39425. private _maxSimultaneousLights;
  39426. /**
  39427. * Defines the maximum number of lights that can be used in the material
  39428. */
  39429. maxSimultaneousLights: number;
  39430. private _invertNormalMapX;
  39431. /**
  39432. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39433. */
  39434. invertNormalMapX: boolean;
  39435. private _invertNormalMapY;
  39436. /**
  39437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39438. */
  39439. invertNormalMapY: boolean;
  39440. private _twoSidedLighting;
  39441. /**
  39442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39443. */
  39444. twoSidedLighting: boolean;
  39445. /**
  39446. * Default configuration related to image processing available in the standard Material.
  39447. */
  39448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39449. /**
  39450. * Gets the image processing configuration used either in this material.
  39451. */
  39452. /**
  39453. * Sets the Default image processing configuration used either in the this material.
  39454. *
  39455. * If sets to null, the scene one is in use.
  39456. */
  39457. imageProcessingConfiguration: ImageProcessingConfiguration;
  39458. /**
  39459. * Keep track of the image processing observer to allow dispose and replace.
  39460. */
  39461. private _imageProcessingObserver;
  39462. /**
  39463. * Attaches a new image processing configuration to the Standard Material.
  39464. * @param configuration
  39465. */
  39466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39467. /**
  39468. * Gets wether the color curves effect is enabled.
  39469. */
  39470. /**
  39471. * Sets wether the color curves effect is enabled.
  39472. */
  39473. cameraColorCurvesEnabled: boolean;
  39474. /**
  39475. * Gets wether the color grading effect is enabled.
  39476. */
  39477. /**
  39478. * Gets wether the color grading effect is enabled.
  39479. */
  39480. cameraColorGradingEnabled: boolean;
  39481. /**
  39482. * Gets wether tonemapping is enabled or not.
  39483. */
  39484. /**
  39485. * Sets wether tonemapping is enabled or not
  39486. */
  39487. cameraToneMappingEnabled: boolean;
  39488. /**
  39489. * The camera exposure used on this material.
  39490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39491. * This corresponds to a photographic exposure.
  39492. */
  39493. /**
  39494. * The camera exposure used on this material.
  39495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39496. * This corresponds to a photographic exposure.
  39497. */
  39498. cameraExposure: number;
  39499. /**
  39500. * Gets The camera contrast used on this material.
  39501. */
  39502. /**
  39503. * Sets The camera contrast used on this material.
  39504. */
  39505. cameraContrast: number;
  39506. /**
  39507. * Gets the Color Grading 2D Lookup Texture.
  39508. */
  39509. /**
  39510. * Sets the Color Grading 2D Lookup Texture.
  39511. */
  39512. cameraColorGradingTexture: Nullable<BaseTexture>;
  39513. /**
  39514. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39515. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39516. * 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;
  39517. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39518. */
  39519. /**
  39520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39522. * 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;
  39523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39524. */
  39525. cameraColorCurves: Nullable<ColorCurves>;
  39526. /**
  39527. * Custom callback helping to override the default shader used in the material.
  39528. */
  39529. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39530. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39531. protected _worldViewProjectionMatrix: Matrix;
  39532. protected _globalAmbientColor: Color3;
  39533. protected _useLogarithmicDepth: boolean;
  39534. /**
  39535. * Instantiates a new standard material.
  39536. * This is the default material used in Babylon. It is the best trade off between quality
  39537. * and performances.
  39538. * @see http://doc.babylonjs.com/babylon101/materials
  39539. * @param name Define the name of the material in the scene
  39540. * @param scene Define the scene the material belong to
  39541. */
  39542. constructor(name: string, scene: Scene);
  39543. /**
  39544. * Gets a boolean indicating that current material needs to register RTT
  39545. */
  39546. readonly hasRenderTargetTextures: boolean;
  39547. /**
  39548. * Gets the current class name of the material e.g. "StandardMaterial"
  39549. * Mainly use in serialization.
  39550. * @returns the class name
  39551. */
  39552. getClassName(): string;
  39553. /**
  39554. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39555. * You can try switching to logarithmic depth.
  39556. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39557. */
  39558. useLogarithmicDepth: boolean;
  39559. /**
  39560. * Specifies if the material will require alpha blending
  39561. * @returns a boolean specifying if alpha blending is needed
  39562. */
  39563. needAlphaBlending(): boolean;
  39564. /**
  39565. * Specifies if this material should be rendered in alpha test mode
  39566. * @returns a boolean specifying if an alpha test is needed.
  39567. */
  39568. needAlphaTesting(): boolean;
  39569. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39570. /**
  39571. * Get the texture used for alpha test purpose.
  39572. * @returns the diffuse texture in case of the standard material.
  39573. */
  39574. getAlphaTestTexture(): Nullable<BaseTexture>;
  39575. /**
  39576. * Get if the submesh is ready to be used and all its information available.
  39577. * Child classes can use it to update shaders
  39578. * @param mesh defines the mesh to check
  39579. * @param subMesh defines which submesh to check
  39580. * @param useInstances specifies that instances should be used
  39581. * @returns a boolean indicating that the submesh is ready or not
  39582. */
  39583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39584. /**
  39585. * Builds the material UBO layouts.
  39586. * Used internally during the effect preparation.
  39587. */
  39588. buildUniformLayout(): void;
  39589. /**
  39590. * Unbinds the material from the mesh
  39591. */
  39592. unbind(): void;
  39593. /**
  39594. * Binds the submesh to this material by preparing the effect and shader to draw
  39595. * @param world defines the world transformation matrix
  39596. * @param mesh defines the mesh containing the submesh
  39597. * @param subMesh defines the submesh to bind the material to
  39598. */
  39599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39600. /**
  39601. * Get the list of animatables in the material.
  39602. * @returns the list of animatables object used in the material
  39603. */
  39604. getAnimatables(): IAnimatable[];
  39605. /**
  39606. * Gets the active textures from the material
  39607. * @returns an array of textures
  39608. */
  39609. getActiveTextures(): BaseTexture[];
  39610. /**
  39611. * Specifies if the material uses a texture
  39612. * @param texture defines the texture to check against the material
  39613. * @returns a boolean specifying if the material uses the texture
  39614. */
  39615. hasTexture(texture: BaseTexture): boolean;
  39616. /**
  39617. * Disposes the material
  39618. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39619. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39620. */
  39621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39622. /**
  39623. * Makes a duplicate of the material, and gives it a new name
  39624. * @param name defines the new name for the duplicated material
  39625. * @returns the cloned material
  39626. */
  39627. clone(name: string): StandardMaterial;
  39628. /**
  39629. * Serializes this material in a JSON representation
  39630. * @returns the serialized material object
  39631. */
  39632. serialize(): any;
  39633. /**
  39634. * Creates a standard material from parsed material data
  39635. * @param source defines the JSON representation of the material
  39636. * @param scene defines the hosting scene
  39637. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39638. * @returns a new standard material
  39639. */
  39640. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39641. /**
  39642. * Are diffuse textures enabled in the application.
  39643. */
  39644. static DiffuseTextureEnabled: boolean;
  39645. /**
  39646. * Are ambient textures enabled in the application.
  39647. */
  39648. static AmbientTextureEnabled: boolean;
  39649. /**
  39650. * Are opacity textures enabled in the application.
  39651. */
  39652. static OpacityTextureEnabled: boolean;
  39653. /**
  39654. * Are reflection textures enabled in the application.
  39655. */
  39656. static ReflectionTextureEnabled: boolean;
  39657. /**
  39658. * Are emissive textures enabled in the application.
  39659. */
  39660. static EmissiveTextureEnabled: boolean;
  39661. /**
  39662. * Are specular textures enabled in the application.
  39663. */
  39664. static SpecularTextureEnabled: boolean;
  39665. /**
  39666. * Are bump textures enabled in the application.
  39667. */
  39668. static BumpTextureEnabled: boolean;
  39669. /**
  39670. * Are lightmap textures enabled in the application.
  39671. */
  39672. static LightmapTextureEnabled: boolean;
  39673. /**
  39674. * Are refraction textures enabled in the application.
  39675. */
  39676. static RefractionTextureEnabled: boolean;
  39677. /**
  39678. * Are color grading textures enabled in the application.
  39679. */
  39680. static ColorGradingTextureEnabled: boolean;
  39681. /**
  39682. * Are fresnels enabled in the application.
  39683. */
  39684. static FresnelEnabled: boolean;
  39685. }
  39686. }
  39687. declare module BABYLON {
  39688. /**
  39689. * A class extending Texture allowing drawing on a texture
  39690. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39691. */
  39692. export class DynamicTexture extends Texture {
  39693. private _generateMipMaps;
  39694. private _canvas;
  39695. private _context;
  39696. private _engine;
  39697. /**
  39698. * Creates a DynamicTexture
  39699. * @param name defines the name of the texture
  39700. * @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
  39701. * @param scene defines the scene where you want the texture
  39702. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39703. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39704. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39705. */
  39706. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39707. /**
  39708. * Get the current class name of the texture useful for serialization or dynamic coding.
  39709. * @returns "DynamicTexture"
  39710. */
  39711. getClassName(): string;
  39712. /**
  39713. * Gets the current state of canRescale
  39714. */
  39715. readonly canRescale: boolean;
  39716. private _recreate;
  39717. /**
  39718. * Scales the texture
  39719. * @param ratio the scale factor to apply to both width and height
  39720. */
  39721. scale(ratio: number): void;
  39722. /**
  39723. * Resizes the texture
  39724. * @param width the new width
  39725. * @param height the new height
  39726. */
  39727. scaleTo(width: number, height: number): void;
  39728. /**
  39729. * Gets the context of the canvas used by the texture
  39730. * @returns the canvas context of the dynamic texture
  39731. */
  39732. getContext(): CanvasRenderingContext2D;
  39733. /**
  39734. * Clears the texture
  39735. */
  39736. clear(): void;
  39737. /**
  39738. * Updates the texture
  39739. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39740. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39741. */
  39742. update(invertY?: boolean, premulAlpha?: boolean): void;
  39743. /**
  39744. * Draws text onto the texture
  39745. * @param text defines the text to be drawn
  39746. * @param x defines the placement of the text from the left
  39747. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39748. * @param font defines the font to be used with font-style, font-size, font-name
  39749. * @param color defines the color used for the text
  39750. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39751. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39752. * @param update defines whether texture is immediately update (default is true)
  39753. */
  39754. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39755. /**
  39756. * Clones the texture
  39757. * @returns the clone of the texture.
  39758. */
  39759. clone(): DynamicTexture;
  39760. /**
  39761. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39762. * @returns a serialized dynamic texture object
  39763. */
  39764. serialize(): any;
  39765. /** @hidden */
  39766. _rebuild(): void;
  39767. }
  39768. }
  39769. declare module BABYLON {
  39770. /** @hidden */
  39771. export var imageProcessingPixelShader: {
  39772. name: string;
  39773. shader: string;
  39774. };
  39775. }
  39776. declare module BABYLON {
  39777. /**
  39778. * ImageProcessingPostProcess
  39779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39780. */
  39781. export class ImageProcessingPostProcess extends PostProcess {
  39782. /**
  39783. * Default configuration related to image processing available in the PBR Material.
  39784. */
  39785. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39786. /**
  39787. * Gets the image processing configuration used either in this material.
  39788. */
  39789. /**
  39790. * Sets the Default image processing configuration used either in the this material.
  39791. *
  39792. * If sets to null, the scene one is in use.
  39793. */
  39794. imageProcessingConfiguration: ImageProcessingConfiguration;
  39795. /**
  39796. * Keep track of the image processing observer to allow dispose and replace.
  39797. */
  39798. private _imageProcessingObserver;
  39799. /**
  39800. * Attaches a new image processing configuration to the PBR Material.
  39801. * @param configuration
  39802. */
  39803. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39804. /**
  39805. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39806. */
  39807. /**
  39808. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39809. */
  39810. colorCurves: Nullable<ColorCurves>;
  39811. /**
  39812. * Gets wether the color curves effect is enabled.
  39813. */
  39814. /**
  39815. * Sets wether the color curves effect is enabled.
  39816. */
  39817. colorCurvesEnabled: boolean;
  39818. /**
  39819. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39820. */
  39821. /**
  39822. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39823. */
  39824. colorGradingTexture: Nullable<BaseTexture>;
  39825. /**
  39826. * Gets wether the color grading effect is enabled.
  39827. */
  39828. /**
  39829. * Gets wether the color grading effect is enabled.
  39830. */
  39831. colorGradingEnabled: boolean;
  39832. /**
  39833. * Gets exposure used in the effect.
  39834. */
  39835. /**
  39836. * Sets exposure used in the effect.
  39837. */
  39838. exposure: number;
  39839. /**
  39840. * Gets wether tonemapping is enabled or not.
  39841. */
  39842. /**
  39843. * Sets wether tonemapping is enabled or not
  39844. */
  39845. toneMappingEnabled: boolean;
  39846. /**
  39847. * Gets the type of tone mapping effect.
  39848. */
  39849. /**
  39850. * Sets the type of tone mapping effect.
  39851. */
  39852. toneMappingType: number;
  39853. /**
  39854. * Gets contrast used in the effect.
  39855. */
  39856. /**
  39857. * Sets contrast used in the effect.
  39858. */
  39859. contrast: number;
  39860. /**
  39861. * Gets Vignette stretch size.
  39862. */
  39863. /**
  39864. * Sets Vignette stretch size.
  39865. */
  39866. vignetteStretch: number;
  39867. /**
  39868. * Gets Vignette centre X Offset.
  39869. */
  39870. /**
  39871. * Sets Vignette centre X Offset.
  39872. */
  39873. vignetteCentreX: number;
  39874. /**
  39875. * Gets Vignette centre Y Offset.
  39876. */
  39877. /**
  39878. * Sets Vignette centre Y Offset.
  39879. */
  39880. vignetteCentreY: number;
  39881. /**
  39882. * Gets Vignette weight or intensity of the vignette effect.
  39883. */
  39884. /**
  39885. * Sets Vignette weight or intensity of the vignette effect.
  39886. */
  39887. vignetteWeight: number;
  39888. /**
  39889. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39890. * if vignetteEnabled is set to true.
  39891. */
  39892. /**
  39893. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39894. * if vignetteEnabled is set to true.
  39895. */
  39896. vignetteColor: Color4;
  39897. /**
  39898. * Gets Camera field of view used by the Vignette effect.
  39899. */
  39900. /**
  39901. * Sets Camera field of view used by the Vignette effect.
  39902. */
  39903. vignetteCameraFov: number;
  39904. /**
  39905. * Gets the vignette blend mode allowing different kind of effect.
  39906. */
  39907. /**
  39908. * Sets the vignette blend mode allowing different kind of effect.
  39909. */
  39910. vignetteBlendMode: number;
  39911. /**
  39912. * Gets wether the vignette effect is enabled.
  39913. */
  39914. /**
  39915. * Sets wether the vignette effect is enabled.
  39916. */
  39917. vignetteEnabled: boolean;
  39918. private _fromLinearSpace;
  39919. /**
  39920. * Gets wether the input of the processing is in Gamma or Linear Space.
  39921. */
  39922. /**
  39923. * Sets wether the input of the processing is in Gamma or Linear Space.
  39924. */
  39925. fromLinearSpace: boolean;
  39926. /**
  39927. * Defines cache preventing GC.
  39928. */
  39929. private _defines;
  39930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39931. /**
  39932. * "ImageProcessingPostProcess"
  39933. * @returns "ImageProcessingPostProcess"
  39934. */
  39935. getClassName(): string;
  39936. protected _updateParameters(): void;
  39937. dispose(camera?: Camera): void;
  39938. }
  39939. }
  39940. declare module BABYLON {
  39941. /**
  39942. * Class containing static functions to help procedurally build meshes
  39943. */
  39944. export class GroundBuilder {
  39945. /**
  39946. * Creates a ground mesh
  39947. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39948. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39950. * @param name defines the name of the mesh
  39951. * @param options defines the options used to create the mesh
  39952. * @param scene defines the hosting scene
  39953. * @returns the ground mesh
  39954. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39955. */
  39956. static CreateGround(name: string, options: {
  39957. width?: number;
  39958. height?: number;
  39959. subdivisions?: number;
  39960. subdivisionsX?: number;
  39961. subdivisionsY?: number;
  39962. updatable?: boolean;
  39963. }, scene: any): Mesh;
  39964. /**
  39965. * Creates a tiled ground mesh
  39966. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39967. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39968. * * 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
  39969. * * 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
  39970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39971. * @param name defines the name of the mesh
  39972. * @param options defines the options used to create the mesh
  39973. * @param scene defines the hosting scene
  39974. * @returns the tiled ground mesh
  39975. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39976. */
  39977. static CreateTiledGround(name: string, options: {
  39978. xmin: number;
  39979. zmin: number;
  39980. xmax: number;
  39981. zmax: number;
  39982. subdivisions?: {
  39983. w: number;
  39984. h: number;
  39985. };
  39986. precision?: {
  39987. w: number;
  39988. h: number;
  39989. };
  39990. updatable?: boolean;
  39991. }, scene?: Nullable<Scene>): Mesh;
  39992. /**
  39993. * Creates a ground mesh from a height map
  39994. * * The parameter `url` sets the URL of the height map image resource.
  39995. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39996. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39997. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39998. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39999. * * 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.
  40000. * * 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).
  40001. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40003. * @param name defines the name of the mesh
  40004. * @param url defines the url to the height map
  40005. * @param options defines the options used to create the mesh
  40006. * @param scene defines the hosting scene
  40007. * @returns the ground mesh
  40008. * @see https://doc.babylonjs.com/babylon101/height_map
  40009. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40010. */
  40011. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40012. width?: number;
  40013. height?: number;
  40014. subdivisions?: number;
  40015. minHeight?: number;
  40016. maxHeight?: number;
  40017. colorFilter?: Color3;
  40018. alphaFilter?: number;
  40019. updatable?: boolean;
  40020. onReady?: (mesh: GroundMesh) => void;
  40021. }, scene?: Nullable<Scene>): GroundMesh;
  40022. }
  40023. }
  40024. declare module BABYLON {
  40025. /**
  40026. * Class containing static functions to help procedurally build meshes
  40027. */
  40028. export class TorusBuilder {
  40029. /**
  40030. * Creates a torus mesh
  40031. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40032. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40033. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40035. * * 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
  40036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40037. * @param name defines the name of the mesh
  40038. * @param options defines the options used to create the mesh
  40039. * @param scene defines the hosting scene
  40040. * @returns the torus mesh
  40041. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40042. */
  40043. static CreateTorus(name: string, options: {
  40044. diameter?: number;
  40045. thickness?: number;
  40046. tessellation?: number;
  40047. updatable?: boolean;
  40048. sideOrientation?: number;
  40049. frontUVs?: Vector4;
  40050. backUVs?: Vector4;
  40051. }, scene: any): Mesh;
  40052. }
  40053. }
  40054. declare module BABYLON {
  40055. /**
  40056. * Class containing static functions to help procedurally build meshes
  40057. */
  40058. export class CylinderBuilder {
  40059. /**
  40060. * Creates a cylinder or a cone mesh
  40061. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40062. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40063. * * 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.
  40064. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40065. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40066. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40067. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40068. * * 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).
  40069. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40070. * * 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).
  40071. * * 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
  40072. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40073. * * 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
  40074. * * 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.
  40075. * * If `enclose` is false, a ring surface is one element.
  40076. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40077. * * 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
  40078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40079. * * 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
  40080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40081. * @param name defines the name of the mesh
  40082. * @param options defines the options used to create the mesh
  40083. * @param scene defines the hosting scene
  40084. * @returns the cylinder mesh
  40085. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40086. */
  40087. static CreateCylinder(name: string, options: {
  40088. height?: number;
  40089. diameterTop?: number;
  40090. diameterBottom?: number;
  40091. diameter?: number;
  40092. tessellation?: number;
  40093. subdivisions?: number;
  40094. arc?: number;
  40095. faceColors?: Color4[];
  40096. faceUV?: Vector4[];
  40097. updatable?: boolean;
  40098. hasRings?: boolean;
  40099. enclose?: boolean;
  40100. cap?: number;
  40101. sideOrientation?: number;
  40102. frontUVs?: Vector4;
  40103. backUVs?: Vector4;
  40104. }, scene: any): Mesh;
  40105. }
  40106. }
  40107. declare module BABYLON {
  40108. /**
  40109. * Options to modify the vr teleportation behavior.
  40110. */
  40111. export interface VRTeleportationOptions {
  40112. /**
  40113. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40114. */
  40115. floorMeshName?: string;
  40116. /**
  40117. * A list of meshes to be used as the teleportation floor. (default: empty)
  40118. */
  40119. floorMeshes?: Mesh[];
  40120. }
  40121. /**
  40122. * Options to modify the vr experience helper's behavior.
  40123. */
  40124. export interface VRExperienceHelperOptions extends WebVROptions {
  40125. /**
  40126. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40127. */
  40128. createDeviceOrientationCamera?: boolean;
  40129. /**
  40130. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40131. */
  40132. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40133. /**
  40134. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40135. */
  40136. laserToggle?: boolean;
  40137. /**
  40138. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40139. */
  40140. floorMeshes?: Mesh[];
  40141. /**
  40142. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40143. */
  40144. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40145. }
  40146. /**
  40147. * Event containing information after VR has been entered
  40148. */
  40149. export class OnAfterEnteringVRObservableEvent {
  40150. /**
  40151. * If entering vr was successful
  40152. */
  40153. success: boolean;
  40154. }
  40155. /**
  40156. * Helps to quickly add VR support to an existing scene.
  40157. * See http://doc.babylonjs.com/how_to/webvr_helper
  40158. */
  40159. export class VRExperienceHelper {
  40160. /** Options to modify the vr experience helper's behavior. */
  40161. webVROptions: VRExperienceHelperOptions;
  40162. private _scene;
  40163. private _position;
  40164. private _btnVR;
  40165. private _btnVRDisplayed;
  40166. private _webVRsupported;
  40167. private _webVRready;
  40168. private _webVRrequesting;
  40169. private _webVRpresenting;
  40170. private _hasEnteredVR;
  40171. private _fullscreenVRpresenting;
  40172. private _canvas;
  40173. private _webVRCamera;
  40174. private _vrDeviceOrientationCamera;
  40175. private _deviceOrientationCamera;
  40176. private _existingCamera;
  40177. private _onKeyDown;
  40178. private _onVrDisplayPresentChange;
  40179. private _onVRDisplayChanged;
  40180. private _onVRRequestPresentStart;
  40181. private _onVRRequestPresentComplete;
  40182. /**
  40183. * Observable raised right before entering VR.
  40184. */
  40185. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40186. /**
  40187. * Observable raised when entering VR has completed.
  40188. */
  40189. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40190. /**
  40191. * Observable raised when exiting VR.
  40192. */
  40193. onExitingVRObservable: Observable<VRExperienceHelper>;
  40194. /**
  40195. * Observable raised when controller mesh is loaded.
  40196. */
  40197. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40198. /** Return this.onEnteringVRObservable
  40199. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40200. */
  40201. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40202. /** Return this.onExitingVRObservable
  40203. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40204. */
  40205. readonly onExitingVR: Observable<VRExperienceHelper>;
  40206. /** Return this.onControllerMeshLoadedObservable
  40207. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40208. */
  40209. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40210. private _rayLength;
  40211. private _useCustomVRButton;
  40212. private _teleportationRequested;
  40213. private _teleportActive;
  40214. private _floorMeshName;
  40215. private _floorMeshesCollection;
  40216. private _rotationAllowed;
  40217. private _teleportBackwardsVector;
  40218. private _teleportationTarget;
  40219. private _isDefaultTeleportationTarget;
  40220. private _postProcessMove;
  40221. private _teleportationFillColor;
  40222. private _teleportationBorderColor;
  40223. private _rotationAngle;
  40224. private _haloCenter;
  40225. private _cameraGazer;
  40226. private _padSensibilityUp;
  40227. private _padSensibilityDown;
  40228. private _leftController;
  40229. private _rightController;
  40230. /**
  40231. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40232. */
  40233. onNewMeshSelected: Observable<AbstractMesh>;
  40234. /**
  40235. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40236. */
  40237. onNewMeshPicked: Observable<PickingInfo>;
  40238. private _circleEase;
  40239. /**
  40240. * Observable raised before camera teleportation
  40241. */
  40242. onBeforeCameraTeleport: Observable<Vector3>;
  40243. /**
  40244. * Observable raised after camera teleportation
  40245. */
  40246. onAfterCameraTeleport: Observable<Vector3>;
  40247. /**
  40248. * Observable raised when current selected mesh gets unselected
  40249. */
  40250. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40251. private _raySelectionPredicate;
  40252. /**
  40253. * To be optionaly changed by user to define custom ray selection
  40254. */
  40255. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40256. /**
  40257. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40258. */
  40259. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40260. /**
  40261. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40262. */
  40263. teleportationEnabled: boolean;
  40264. private _defaultHeight;
  40265. private _teleportationInitialized;
  40266. private _interactionsEnabled;
  40267. private _interactionsRequested;
  40268. private _displayGaze;
  40269. private _displayLaserPointer;
  40270. /**
  40271. * The mesh used to display where the user is going to teleport.
  40272. */
  40273. /**
  40274. * Sets the mesh to be used to display where the user is going to teleport.
  40275. */
  40276. teleportationTarget: Mesh;
  40277. /**
  40278. * 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
  40279. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40280. * See http://doc.babylonjs.com/resources/baking_transformations
  40281. */
  40282. gazeTrackerMesh: Mesh;
  40283. /**
  40284. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40285. */
  40286. updateGazeTrackerScale: boolean;
  40287. /**
  40288. * If the gaze trackers color should be updated when selecting meshes
  40289. */
  40290. updateGazeTrackerColor: boolean;
  40291. /**
  40292. * The gaze tracking mesh corresponding to the left controller
  40293. */
  40294. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40295. /**
  40296. * The gaze tracking mesh corresponding to the right controller
  40297. */
  40298. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40299. /**
  40300. * If the ray of the gaze should be displayed.
  40301. */
  40302. /**
  40303. * Sets if the ray of the gaze should be displayed.
  40304. */
  40305. displayGaze: boolean;
  40306. /**
  40307. * If the ray of the LaserPointer should be displayed.
  40308. */
  40309. /**
  40310. * Sets if the ray of the LaserPointer should be displayed.
  40311. */
  40312. displayLaserPointer: boolean;
  40313. /**
  40314. * The deviceOrientationCamera used as the camera when not in VR.
  40315. */
  40316. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40317. /**
  40318. * Based on the current WebVR support, returns the current VR camera used.
  40319. */
  40320. readonly currentVRCamera: Nullable<Camera>;
  40321. /**
  40322. * The webVRCamera which is used when in VR.
  40323. */
  40324. readonly webVRCamera: WebVRFreeCamera;
  40325. /**
  40326. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40327. */
  40328. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40329. private readonly _teleportationRequestInitiated;
  40330. /**
  40331. * Defines wether or not Pointer lock should be requested when switching to
  40332. * full screen.
  40333. */
  40334. requestPointerLockOnFullScreen: boolean;
  40335. /**
  40336. * Instantiates a VRExperienceHelper.
  40337. * Helps to quickly add VR support to an existing scene.
  40338. * @param scene The scene the VRExperienceHelper belongs to.
  40339. * @param webVROptions Options to modify the vr experience helper's behavior.
  40340. */
  40341. constructor(scene: Scene,
  40342. /** Options to modify the vr experience helper's behavior. */
  40343. webVROptions?: VRExperienceHelperOptions);
  40344. private _onDefaultMeshLoaded;
  40345. private _onResize;
  40346. private _onFullscreenChange;
  40347. /**
  40348. * Gets a value indicating if we are currently in VR mode.
  40349. */
  40350. readonly isInVRMode: boolean;
  40351. private onVrDisplayPresentChange;
  40352. private onVRDisplayChanged;
  40353. private moveButtonToBottomRight;
  40354. private displayVRButton;
  40355. private updateButtonVisibility;
  40356. private _cachedAngularSensibility;
  40357. /**
  40358. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40359. * Otherwise, will use the fullscreen API.
  40360. */
  40361. enterVR(): void;
  40362. /**
  40363. * Attempt to exit VR, or fullscreen.
  40364. */
  40365. exitVR(): void;
  40366. /**
  40367. * The position of the vr experience helper.
  40368. */
  40369. /**
  40370. * Sets the position of the vr experience helper.
  40371. */
  40372. position: Vector3;
  40373. /**
  40374. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40375. */
  40376. enableInteractions(): void;
  40377. private readonly _noControllerIsActive;
  40378. private beforeRender;
  40379. private _isTeleportationFloor;
  40380. /**
  40381. * Adds a floor mesh to be used for teleportation.
  40382. * @param floorMesh the mesh to be used for teleportation.
  40383. */
  40384. addFloorMesh(floorMesh: Mesh): void;
  40385. /**
  40386. * Removes a floor mesh from being used for teleportation.
  40387. * @param floorMesh the mesh to be removed.
  40388. */
  40389. removeFloorMesh(floorMesh: Mesh): void;
  40390. /**
  40391. * Enables interactions and teleportation using the VR controllers and gaze.
  40392. * @param vrTeleportationOptions options to modify teleportation behavior.
  40393. */
  40394. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40395. private _onNewGamepadConnected;
  40396. private _tryEnableInteractionOnController;
  40397. private _onNewGamepadDisconnected;
  40398. private _enableInteractionOnController;
  40399. private _checkTeleportWithRay;
  40400. private _checkRotate;
  40401. private _checkTeleportBackwards;
  40402. private _enableTeleportationOnController;
  40403. private _createTeleportationCircles;
  40404. private _displayTeleportationTarget;
  40405. private _hideTeleportationTarget;
  40406. private _rotateCamera;
  40407. private _moveTeleportationSelectorTo;
  40408. private _workingVector;
  40409. private _workingQuaternion;
  40410. private _workingMatrix;
  40411. /**
  40412. * Teleports the users feet to the desired location
  40413. * @param location The location where the user's feet should be placed
  40414. */
  40415. teleportCamera(location: Vector3): void;
  40416. private _convertNormalToDirectionOfRay;
  40417. private _castRayAndSelectObject;
  40418. private _notifySelectedMeshUnselected;
  40419. /**
  40420. * Sets the color of the laser ray from the vr controllers.
  40421. * @param color new color for the ray.
  40422. */
  40423. changeLaserColor(color: Color3): void;
  40424. /**
  40425. * Sets the color of the ray from the vr headsets gaze.
  40426. * @param color new color for the ray.
  40427. */
  40428. changeGazeColor(color: Color3): void;
  40429. /**
  40430. * Exits VR and disposes of the vr experience helper
  40431. */
  40432. dispose(): void;
  40433. /**
  40434. * Gets the name of the VRExperienceHelper class
  40435. * @returns "VRExperienceHelper"
  40436. */
  40437. getClassName(): string;
  40438. }
  40439. }
  40440. declare module BABYLON {
  40441. /**
  40442. * Manages an XRSession
  40443. * @see https://doc.babylonjs.com/how_to/webxr
  40444. */
  40445. export class WebXRSessionManager implements IDisposable {
  40446. private scene;
  40447. /**
  40448. * Fires every time a new xrFrame arrives which can be used to update the camera
  40449. */
  40450. onXRFrameObservable: Observable<any>;
  40451. /**
  40452. * Fires when the xr session is ended either by the device or manually done
  40453. */
  40454. onXRSessionEnded: Observable<any>;
  40455. /** @hidden */
  40456. _xrSession: XRSession;
  40457. /** @hidden */
  40458. _frameOfReference: XRFrameOfReference;
  40459. /** @hidden */
  40460. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40461. /** @hidden */
  40462. _currentXRFrame: Nullable<XRFrame>;
  40463. private _xrNavigator;
  40464. private _xrDevice;
  40465. private _tmpMatrix;
  40466. /**
  40467. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40468. * @param scene The scene which the session should be created for
  40469. */
  40470. constructor(scene: Scene);
  40471. /**
  40472. * Initializes the manager
  40473. * After initialization enterXR can be called to start an XR session
  40474. * @returns Promise which resolves after it is initialized
  40475. */
  40476. initializeAsync(): Promise<void>;
  40477. /**
  40478. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40479. * @param sessionCreationOptions xr options to create the session with
  40480. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40481. * @returns Promise which resolves after it enters XR
  40482. */
  40483. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40484. /**
  40485. * Stops the xrSession and restores the renderloop
  40486. * @returns Promise which resolves after it exits XR
  40487. */
  40488. exitXRAsync(): Promise<void>;
  40489. /**
  40490. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40491. * @param ray ray to cast into the environment
  40492. * @returns Promise which resolves with a collision point in the environment if it exists
  40493. */
  40494. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40495. /**
  40496. * Checks if a session would be supported for the creation options specified
  40497. * @param options creation options to check if they are supported
  40498. * @returns true if supported
  40499. */
  40500. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40501. /**
  40502. * @hidden
  40503. * Converts the render layer of xrSession to a render target
  40504. * @param session session to create render target for
  40505. * @param scene scene the new render target should be created for
  40506. */
  40507. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40508. /**
  40509. * Disposes of the session manager
  40510. */
  40511. dispose(): void;
  40512. }
  40513. }
  40514. declare module BABYLON {
  40515. /**
  40516. * WebXR Camera which holds the views for the xrSession
  40517. * @see https://doc.babylonjs.com/how_to/webxr
  40518. */
  40519. export class WebXRCamera extends FreeCamera {
  40520. private static _TmpMatrix;
  40521. /**
  40522. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40523. * @param name the name of the camera
  40524. * @param scene the scene to add the camera to
  40525. */
  40526. constructor(name: string, scene: Scene);
  40527. private _updateNumberOfRigCameras;
  40528. /** @hidden */
  40529. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40530. /**
  40531. * Updates the cameras position from the current pose information of the XR session
  40532. * @param xrSessionManager the session containing pose information
  40533. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40534. */
  40535. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40536. }
  40537. }
  40538. declare module BABYLON {
  40539. /**
  40540. * States of the webXR experience
  40541. */
  40542. export enum WebXRState {
  40543. /**
  40544. * Transitioning to being in XR mode
  40545. */
  40546. ENTERING_XR = 0,
  40547. /**
  40548. * Transitioning to non XR mode
  40549. */
  40550. EXITING_XR = 1,
  40551. /**
  40552. * In XR mode and presenting
  40553. */
  40554. IN_XR = 2,
  40555. /**
  40556. * Not entered XR mode
  40557. */
  40558. NOT_IN_XR = 3
  40559. }
  40560. /**
  40561. * Helper class used to enable XR
  40562. * @see https://doc.babylonjs.com/how_to/webxr
  40563. */
  40564. export class WebXRExperienceHelper implements IDisposable {
  40565. private scene;
  40566. /**
  40567. * 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
  40568. */
  40569. container: AbstractMesh;
  40570. /**
  40571. * Camera used to render xr content
  40572. */
  40573. camera: WebXRCamera;
  40574. /**
  40575. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40576. */
  40577. state: WebXRState;
  40578. private _setState;
  40579. private static _TmpVector;
  40580. /**
  40581. * Fires when the state of the experience helper has changed
  40582. */
  40583. onStateChangedObservable: Observable<WebXRState>;
  40584. /** @hidden */
  40585. _sessionManager: WebXRSessionManager;
  40586. private _nonVRCamera;
  40587. private _originalSceneAutoClear;
  40588. private _supported;
  40589. /**
  40590. * Creates the experience helper
  40591. * @param scene the scene to attach the experience helper to
  40592. * @returns a promise for the experience helper
  40593. */
  40594. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40595. /**
  40596. * Creates a WebXRExperienceHelper
  40597. * @param scene The scene the helper should be created in
  40598. */
  40599. private constructor();
  40600. /**
  40601. * Exits XR mode and returns the scene to its original state
  40602. * @returns promise that resolves after xr mode has exited
  40603. */
  40604. exitXRAsync(): Promise<void>;
  40605. /**
  40606. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40607. * @param sessionCreationOptions options for the XR session
  40608. * @param frameOfReference frame of reference of the XR session
  40609. * @returns promise that resolves after xr mode has entered
  40610. */
  40611. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40612. /**
  40613. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40614. * @param ray ray to cast into the environment
  40615. * @returns Promise which resolves with a collision point in the environment if it exists
  40616. */
  40617. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40618. /**
  40619. * Updates the global position of the camera by moving the camera's container
  40620. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40621. * @param position The desired global position of the camera
  40622. */
  40623. setPositionOfCameraUsingContainer(position: Vector3): void;
  40624. /**
  40625. * Rotates the xr camera by rotating the camera's container around the camera's position
  40626. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40627. * @param rotation the desired quaternion rotation to apply to the camera
  40628. */
  40629. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40630. /**
  40631. * Checks if the creation options are supported by the xr session
  40632. * @param options creation options
  40633. * @returns true if supported
  40634. */
  40635. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40636. /**
  40637. * Disposes of the experience helper
  40638. */
  40639. dispose(): void;
  40640. }
  40641. }
  40642. declare module BABYLON {
  40643. /**
  40644. * Button which can be used to enter a different mode of XR
  40645. */
  40646. export class WebXREnterExitUIButton {
  40647. /** button element */
  40648. element: HTMLElement;
  40649. /** XR initialization options for the button */
  40650. initializationOptions: XRSessionCreationOptions;
  40651. /**
  40652. * Creates a WebXREnterExitUIButton
  40653. * @param element button element
  40654. * @param initializationOptions XR initialization options for the button
  40655. */
  40656. constructor(
  40657. /** button element */
  40658. element: HTMLElement,
  40659. /** XR initialization options for the button */
  40660. initializationOptions: XRSessionCreationOptions);
  40661. /**
  40662. * Overwritable function which can be used to update the button's visuals when the state changes
  40663. * @param activeButton the current active button in the UI
  40664. */
  40665. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40666. }
  40667. /**
  40668. * Options to create the webXR UI
  40669. */
  40670. export class WebXREnterExitUIOptions {
  40671. /**
  40672. * Context to enter xr with
  40673. */
  40674. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40675. /**
  40676. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40677. */
  40678. customButtons?: Array<WebXREnterExitUIButton>;
  40679. }
  40680. /**
  40681. * UI to allow the user to enter/exit XR mode
  40682. */
  40683. export class WebXREnterExitUI implements IDisposable {
  40684. private scene;
  40685. private _overlay;
  40686. private _buttons;
  40687. private _activeButton;
  40688. /**
  40689. * Fired every time the active button is changed.
  40690. *
  40691. * When xr is entered via a button that launches xr that button will be the callback parameter
  40692. *
  40693. * When exiting xr the callback parameter will be null)
  40694. */
  40695. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40696. /**
  40697. * Creates UI to allow the user to enter/exit XR mode
  40698. * @param scene the scene to add the ui to
  40699. * @param helper the xr experience helper to enter/exit xr with
  40700. * @param options options to configure the UI
  40701. * @returns the created ui
  40702. */
  40703. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40704. private constructor();
  40705. private _updateButtons;
  40706. /**
  40707. * Disposes of the object
  40708. */
  40709. dispose(): void;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. /**
  40714. * Represents an XR input
  40715. */
  40716. export class WebXRController {
  40717. /**
  40718. * 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
  40719. */
  40720. grip?: AbstractMesh;
  40721. /**
  40722. * Pointer which can be used to select objects or attach a visible laser to
  40723. */
  40724. pointer: AbstractMesh;
  40725. /**
  40726. * Creates the controller
  40727. * @see https://doc.babylonjs.com/how_to/webxr
  40728. * @param scene the scene which the controller should be associated to
  40729. */
  40730. constructor(scene: Scene);
  40731. /**
  40732. * Disposes of the object
  40733. */
  40734. dispose(): void;
  40735. }
  40736. /**
  40737. * XR input used to track XR inputs such as controllers/rays
  40738. */
  40739. export class WebXRInput implements IDisposable {
  40740. private helper;
  40741. /**
  40742. * XR controllers being tracked
  40743. */
  40744. controllers: Array<WebXRController>;
  40745. private _tmpMatrix;
  40746. private _frameObserver;
  40747. /**
  40748. * Initializes the WebXRInput
  40749. * @param helper experience helper which the input should be created for
  40750. */
  40751. constructor(helper: WebXRExperienceHelper);
  40752. /**
  40753. * Disposes of the object
  40754. */
  40755. dispose(): void;
  40756. }
  40757. }
  40758. declare module BABYLON {
  40759. /**
  40760. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40761. */
  40762. export class WebXRManagedOutputCanvas implements IDisposable {
  40763. private _canvas;
  40764. /**
  40765. * xrpresent context of the canvas which can be used to display/mirror xr content
  40766. */
  40767. canvasContext: Nullable<WebGLRenderingContext>;
  40768. /**
  40769. * Initializes the canvas to be added/removed upon entering/exiting xr
  40770. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40771. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40772. */
  40773. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40774. /**
  40775. * Disposes of the object
  40776. */
  40777. dispose(): void;
  40778. private _setManagedOutputCanvas;
  40779. private _addCanvas;
  40780. private _removeCanvas;
  40781. }
  40782. }
  40783. declare module BABYLON {
  40784. /**
  40785. * Contains an array of blocks representing the octree
  40786. */
  40787. export interface IOctreeContainer<T> {
  40788. /**
  40789. * Blocks within the octree
  40790. */
  40791. blocks: Array<OctreeBlock<T>>;
  40792. }
  40793. /**
  40794. * Class used to store a cell in an octree
  40795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40796. */
  40797. export class OctreeBlock<T> {
  40798. /**
  40799. * Gets the content of the current block
  40800. */
  40801. entries: T[];
  40802. /**
  40803. * Gets the list of block children
  40804. */
  40805. blocks: Array<OctreeBlock<T>>;
  40806. private _depth;
  40807. private _maxDepth;
  40808. private _capacity;
  40809. private _minPoint;
  40810. private _maxPoint;
  40811. private _boundingVectors;
  40812. private _creationFunc;
  40813. /**
  40814. * Creates a new block
  40815. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40816. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40817. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40818. * @param depth defines the current depth of this block in the octree
  40819. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40820. * @param creationFunc defines a callback to call when an element is added to the block
  40821. */
  40822. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40823. /**
  40824. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40825. */
  40826. readonly capacity: number;
  40827. /**
  40828. * Gets the minimum vector (in world space) of the block's bounding box
  40829. */
  40830. readonly minPoint: Vector3;
  40831. /**
  40832. * Gets the maximum vector (in world space) of the block's bounding box
  40833. */
  40834. readonly maxPoint: Vector3;
  40835. /**
  40836. * Add a new element to this block
  40837. * @param entry defines the element to add
  40838. */
  40839. addEntry(entry: T): void;
  40840. /**
  40841. * Remove an element from this block
  40842. * @param entry defines the element to remove
  40843. */
  40844. removeEntry(entry: T): void;
  40845. /**
  40846. * Add an array of elements to this block
  40847. * @param entries defines the array of elements to add
  40848. */
  40849. addEntries(entries: T[]): void;
  40850. /**
  40851. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40852. * @param frustumPlanes defines the frustum planes to test
  40853. * @param selection defines the array to store current content if selection is positive
  40854. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40855. */
  40856. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40857. /**
  40858. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40859. * @param sphereCenter defines the bounding sphere center
  40860. * @param sphereRadius defines the bounding sphere radius
  40861. * @param selection defines the array to store current content if selection is positive
  40862. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40863. */
  40864. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40865. /**
  40866. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40867. * @param ray defines the ray to test with
  40868. * @param selection defines the array to store current content if selection is positive
  40869. */
  40870. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40871. /**
  40872. * Subdivide the content into child blocks (this block will then be empty)
  40873. */
  40874. createInnerBlocks(): void;
  40875. /**
  40876. * @hidden
  40877. */
  40878. 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;
  40879. }
  40880. }
  40881. declare module BABYLON {
  40882. /**
  40883. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40884. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40885. */
  40886. export class Octree<T> {
  40887. /** 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.) */
  40888. maxDepth: number;
  40889. /**
  40890. * Blocks within the octree containing objects
  40891. */
  40892. blocks: Array<OctreeBlock<T>>;
  40893. /**
  40894. * Content stored in the octree
  40895. */
  40896. dynamicContent: T[];
  40897. private _maxBlockCapacity;
  40898. private _selectionContent;
  40899. private _creationFunc;
  40900. /**
  40901. * Creates a octree
  40902. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40903. * @param creationFunc function to be used to instatiate the octree
  40904. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40905. * @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.)
  40906. */
  40907. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40908. /** 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.) */
  40909. maxDepth?: number);
  40910. /**
  40911. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40912. * @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);
  40913. * @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);
  40914. * @param entries meshes to be added to the octree blocks
  40915. */
  40916. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40917. /**
  40918. * Adds a mesh to the octree
  40919. * @param entry Mesh to add to the octree
  40920. */
  40921. addMesh(entry: T): void;
  40922. /**
  40923. * Remove an element from the octree
  40924. * @param entry defines the element to remove
  40925. */
  40926. removeMesh(entry: T): void;
  40927. /**
  40928. * Selects an array of meshes within the frustum
  40929. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40930. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40931. * @returns array of meshes within the frustum
  40932. */
  40933. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40934. /**
  40935. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40936. * @param sphereCenter defines the bounding sphere center
  40937. * @param sphereRadius defines the bounding sphere radius
  40938. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40939. * @returns an array of objects that intersect the sphere
  40940. */
  40941. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40942. /**
  40943. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40944. * @param ray defines the ray to test with
  40945. * @returns array of intersected objects
  40946. */
  40947. intersectsRay(ray: Ray): SmartArray<T>;
  40948. /**
  40949. * Adds a mesh into the octree block if it intersects the block
  40950. */
  40951. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40952. /**
  40953. * Adds a submesh into the octree block if it intersects the block
  40954. */
  40955. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40956. }
  40957. }
  40958. declare module BABYLON {
  40959. interface Scene {
  40960. /**
  40961. * @hidden
  40962. * Backing Filed
  40963. */
  40964. _selectionOctree: Octree<AbstractMesh>;
  40965. /**
  40966. * Gets the octree used to boost mesh selection (picking)
  40967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40968. */
  40969. selectionOctree: Octree<AbstractMesh>;
  40970. /**
  40971. * Creates or updates the octree used to boost selection (picking)
  40972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40973. * @param maxCapacity defines the maximum capacity per leaf
  40974. * @param maxDepth defines the maximum depth of the octree
  40975. * @returns an octree of AbstractMesh
  40976. */
  40977. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40978. }
  40979. interface AbstractMesh {
  40980. /**
  40981. * @hidden
  40982. * Backing Field
  40983. */
  40984. _submeshesOctree: Octree<SubMesh>;
  40985. /**
  40986. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40987. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40988. * @param maxCapacity defines the maximum size of each block (64 by default)
  40989. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40990. * @returns the new octree
  40991. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40993. */
  40994. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40995. }
  40996. /**
  40997. * Defines the octree scene component responsible to manage any octrees
  40998. * in a given scene.
  40999. */
  41000. export class OctreeSceneComponent {
  41001. /**
  41002. * The component name help to identify the component in the list of scene components.
  41003. */
  41004. readonly name: string;
  41005. /**
  41006. * The scene the component belongs to.
  41007. */
  41008. scene: Scene;
  41009. /**
  41010. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41011. */
  41012. readonly checksIsEnabled: boolean;
  41013. /**
  41014. * Creates a new instance of the component for the given scene
  41015. * @param scene Defines the scene to register the component in
  41016. */
  41017. constructor(scene: Scene);
  41018. /**
  41019. * Registers the component in a given scene
  41020. */
  41021. register(): void;
  41022. /**
  41023. * Return the list of active meshes
  41024. * @returns the list of active meshes
  41025. */
  41026. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41027. /**
  41028. * Return the list of active sub meshes
  41029. * @param mesh The mesh to get the candidates sub meshes from
  41030. * @returns the list of active sub meshes
  41031. */
  41032. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41033. private _tempRay;
  41034. /**
  41035. * Return the list of sub meshes intersecting with a given local ray
  41036. * @param mesh defines the mesh to find the submesh for
  41037. * @param localRay defines the ray in local space
  41038. * @returns the list of intersecting sub meshes
  41039. */
  41040. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41041. /**
  41042. * Return the list of sub meshes colliding with a collider
  41043. * @param mesh defines the mesh to find the submesh for
  41044. * @param collider defines the collider to evaluate the collision against
  41045. * @returns the list of colliding sub meshes
  41046. */
  41047. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41048. /**
  41049. * Rebuilds the elements related to this component in case of
  41050. * context lost for instance.
  41051. */
  41052. rebuild(): void;
  41053. /**
  41054. * Disposes the component and the associated ressources.
  41055. */
  41056. dispose(): void;
  41057. }
  41058. }
  41059. declare module BABYLON {
  41060. /**
  41061. * Renders a layer on top of an existing scene
  41062. */
  41063. export class UtilityLayerRenderer implements IDisposable {
  41064. /** the original scene that will be rendered on top of */
  41065. originalScene: Scene;
  41066. private _pointerCaptures;
  41067. private _lastPointerEvents;
  41068. private static _DefaultUtilityLayer;
  41069. private static _DefaultKeepDepthUtilityLayer;
  41070. private _sharedGizmoLight;
  41071. private _renderCamera;
  41072. /**
  41073. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41074. * @returns the camera that is used when rendering the utility layer
  41075. */
  41076. getRenderCamera(): Nullable<Camera>;
  41077. /**
  41078. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41079. * @param cam the camera that should be used when rendering the utility layer
  41080. */
  41081. setRenderCamera(cam: Nullable<Camera>): void;
  41082. /**
  41083. * @hidden
  41084. * Light which used by gizmos to get light shading
  41085. */
  41086. _getSharedGizmoLight(): HemisphericLight;
  41087. /**
  41088. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41089. */
  41090. pickUtilitySceneFirst: boolean;
  41091. /**
  41092. * 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)
  41093. */
  41094. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41095. /**
  41096. * 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)
  41097. */
  41098. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41099. /**
  41100. * The scene that is rendered on top of the original scene
  41101. */
  41102. utilityLayerScene: Scene;
  41103. /**
  41104. * If the utility layer should automatically be rendered on top of existing scene
  41105. */
  41106. shouldRender: boolean;
  41107. /**
  41108. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41109. */
  41110. onlyCheckPointerDownEvents: boolean;
  41111. /**
  41112. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41113. */
  41114. processAllEvents: boolean;
  41115. /**
  41116. * Observable raised when the pointer move from the utility layer scene to the main scene
  41117. */
  41118. onPointerOutObservable: Observable<number>;
  41119. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41120. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41121. private _afterRenderObserver;
  41122. private _sceneDisposeObserver;
  41123. private _originalPointerObserver;
  41124. /**
  41125. * Instantiates a UtilityLayerRenderer
  41126. * @param originalScene the original scene that will be rendered on top of
  41127. * @param handleEvents boolean indicating if the utility layer should handle events
  41128. */
  41129. constructor(
  41130. /** the original scene that will be rendered on top of */
  41131. originalScene: Scene, handleEvents?: boolean);
  41132. private _notifyObservers;
  41133. /**
  41134. * Renders the utility layers scene on top of the original scene
  41135. */
  41136. render(): void;
  41137. /**
  41138. * Disposes of the renderer
  41139. */
  41140. dispose(): void;
  41141. private _updateCamera;
  41142. }
  41143. }
  41144. declare module BABYLON {
  41145. /**
  41146. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41147. */
  41148. export class Gizmo implements IDisposable {
  41149. /** The utility layer the gizmo will be added to */
  41150. gizmoLayer: UtilityLayerRenderer;
  41151. /**
  41152. * The root mesh of the gizmo
  41153. */
  41154. _rootMesh: Mesh;
  41155. private _attachedMesh;
  41156. /**
  41157. * Ratio for the scale of the gizmo (Default: 1)
  41158. */
  41159. scaleRatio: number;
  41160. /**
  41161. * If a custom mesh has been set (Default: false)
  41162. */
  41163. protected _customMeshSet: boolean;
  41164. /**
  41165. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41166. * * When set, interactions will be enabled
  41167. */
  41168. attachedMesh: Nullable<AbstractMesh>;
  41169. /**
  41170. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41171. * @param mesh The mesh to replace the default mesh of the gizmo
  41172. */
  41173. setCustomMesh(mesh: Mesh): void;
  41174. /**
  41175. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41176. */
  41177. updateGizmoRotationToMatchAttachedMesh: boolean;
  41178. /**
  41179. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41180. */
  41181. updateGizmoPositionToMatchAttachedMesh: boolean;
  41182. /**
  41183. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41184. */
  41185. protected _updateScale: boolean;
  41186. protected _interactionsEnabled: boolean;
  41187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41188. private _beforeRenderObserver;
  41189. private _tempVector;
  41190. /**
  41191. * Creates a gizmo
  41192. * @param gizmoLayer The utility layer the gizmo will be added to
  41193. */
  41194. constructor(
  41195. /** The utility layer the gizmo will be added to */
  41196. gizmoLayer?: UtilityLayerRenderer);
  41197. /**
  41198. * Updates the gizmo to match the attached mesh's position/rotation
  41199. */
  41200. protected _update(): void;
  41201. /**
  41202. * Disposes of the gizmo
  41203. */
  41204. dispose(): void;
  41205. }
  41206. }
  41207. declare module BABYLON {
  41208. /**
  41209. * Single plane drag gizmo
  41210. */
  41211. export class PlaneDragGizmo extends Gizmo {
  41212. /**
  41213. * Drag behavior responsible for the gizmos dragging interactions
  41214. */
  41215. dragBehavior: PointerDragBehavior;
  41216. private _pointerObserver;
  41217. /**
  41218. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41219. */
  41220. snapDistance: number;
  41221. /**
  41222. * Event that fires each time the gizmo snaps to a new location.
  41223. * * snapDistance is the the change in distance
  41224. */
  41225. onSnapObservable: Observable<{
  41226. snapDistance: number;
  41227. }>;
  41228. private _plane;
  41229. private _coloredMaterial;
  41230. private _hoverMaterial;
  41231. private _isEnabled;
  41232. private _parent;
  41233. /** @hidden */
  41234. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41235. /** @hidden */
  41236. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41237. /**
  41238. * Creates a PlaneDragGizmo
  41239. * @param gizmoLayer The utility layer the gizmo will be added to
  41240. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41241. * @param color The color of the gizmo
  41242. */
  41243. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41244. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41245. /**
  41246. * If the gizmo is enabled
  41247. */
  41248. isEnabled: boolean;
  41249. /**
  41250. * Disposes of the gizmo
  41251. */
  41252. dispose(): void;
  41253. }
  41254. }
  41255. declare module BABYLON {
  41256. /**
  41257. * Gizmo that enables dragging a mesh along 3 axis
  41258. */
  41259. export class PositionGizmo extends Gizmo {
  41260. /**
  41261. * Internal gizmo used for interactions on the x axis
  41262. */
  41263. xGizmo: AxisDragGizmo;
  41264. /**
  41265. * Internal gizmo used for interactions on the y axis
  41266. */
  41267. yGizmo: AxisDragGizmo;
  41268. /**
  41269. * Internal gizmo used for interactions on the z axis
  41270. */
  41271. zGizmo: AxisDragGizmo;
  41272. /**
  41273. * Internal gizmo used for interactions on the yz plane
  41274. */
  41275. xPlaneGizmo: PlaneDragGizmo;
  41276. /**
  41277. * Internal gizmo used for interactions on the xz plane
  41278. */
  41279. yPlaneGizmo: PlaneDragGizmo;
  41280. /**
  41281. * Internal gizmo used for interactions on the xy plane
  41282. */
  41283. zPlaneGizmo: PlaneDragGizmo;
  41284. /**
  41285. * private variables
  41286. */
  41287. private _meshAttached;
  41288. private _updateGizmoRotationToMatchAttachedMesh;
  41289. private _snapDistance;
  41290. private _scaleRatio;
  41291. /** Fires an event when any of it's sub gizmos are dragged */
  41292. onDragStartObservable: Observable<unknown>;
  41293. /** Fires an event when any of it's sub gizmos are released from dragging */
  41294. onDragEndObservable: Observable<unknown>;
  41295. /**
  41296. * If set to true, planar drag is enabled
  41297. */
  41298. private _planarGizmoEnabled;
  41299. attachedMesh: Nullable<AbstractMesh>;
  41300. /**
  41301. * Creates a PositionGizmo
  41302. * @param gizmoLayer The utility layer the gizmo will be added to
  41303. */
  41304. constructor(gizmoLayer?: UtilityLayerRenderer);
  41305. /**
  41306. * If the planar drag gizmo is enabled
  41307. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41308. */
  41309. planarGizmoEnabled: boolean;
  41310. updateGizmoRotationToMatchAttachedMesh: boolean;
  41311. /**
  41312. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41313. */
  41314. snapDistance: number;
  41315. /**
  41316. * Ratio for the scale of the gizmo (Default: 1)
  41317. */
  41318. scaleRatio: number;
  41319. /**
  41320. * Disposes of the gizmo
  41321. */
  41322. dispose(): void;
  41323. /**
  41324. * CustomMeshes are not supported by this gizmo
  41325. * @param mesh The mesh to replace the default mesh of the gizmo
  41326. */
  41327. setCustomMesh(mesh: Mesh): void;
  41328. }
  41329. }
  41330. declare module BABYLON {
  41331. /**
  41332. * Single axis drag gizmo
  41333. */
  41334. export class AxisDragGizmo extends Gizmo {
  41335. /**
  41336. * Drag behavior responsible for the gizmos dragging interactions
  41337. */
  41338. dragBehavior: PointerDragBehavior;
  41339. private _pointerObserver;
  41340. /**
  41341. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41342. */
  41343. snapDistance: number;
  41344. /**
  41345. * Event that fires each time the gizmo snaps to a new location.
  41346. * * snapDistance is the the change in distance
  41347. */
  41348. onSnapObservable: Observable<{
  41349. snapDistance: number;
  41350. }>;
  41351. private _isEnabled;
  41352. private _parent;
  41353. private _arrow;
  41354. private _coloredMaterial;
  41355. private _hoverMaterial;
  41356. /** @hidden */
  41357. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41358. /** @hidden */
  41359. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41360. /**
  41361. * Creates an AxisDragGizmo
  41362. * @param gizmoLayer The utility layer the gizmo will be added to
  41363. * @param dragAxis The axis which the gizmo will be able to drag on
  41364. * @param color The color of the gizmo
  41365. */
  41366. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41367. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41368. /**
  41369. * If the gizmo is enabled
  41370. */
  41371. isEnabled: boolean;
  41372. /**
  41373. * Disposes of the gizmo
  41374. */
  41375. dispose(): void;
  41376. }
  41377. }
  41378. declare module BABYLON.Debug {
  41379. /**
  41380. * The Axes viewer will show 3 axes in a specific point in space
  41381. */
  41382. export class AxesViewer {
  41383. private _xAxis;
  41384. private _yAxis;
  41385. private _zAxis;
  41386. private _scaleLinesFactor;
  41387. private _instanced;
  41388. /**
  41389. * Gets the hosting scene
  41390. */
  41391. scene: Scene;
  41392. /**
  41393. * Gets or sets a number used to scale line length
  41394. */
  41395. scaleLines: number;
  41396. /** Gets the node hierarchy used to render x-axis */
  41397. readonly xAxis: TransformNode;
  41398. /** Gets the node hierarchy used to render y-axis */
  41399. readonly yAxis: TransformNode;
  41400. /** Gets the node hierarchy used to render z-axis */
  41401. readonly zAxis: TransformNode;
  41402. /**
  41403. * Creates a new AxesViewer
  41404. * @param scene defines the hosting scene
  41405. * @param scaleLines defines a number used to scale line length (1 by default)
  41406. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41407. * @param xAxis defines the node hierarchy used to render the x-axis
  41408. * @param yAxis defines the node hierarchy used to render the y-axis
  41409. * @param zAxis defines the node hierarchy used to render the z-axis
  41410. */
  41411. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41412. /**
  41413. * Force the viewer to update
  41414. * @param position defines the position of the viewer
  41415. * @param xaxis defines the x axis of the viewer
  41416. * @param yaxis defines the y axis of the viewer
  41417. * @param zaxis defines the z axis of the viewer
  41418. */
  41419. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41420. /**
  41421. * Creates an instance of this axes viewer.
  41422. * @returns a new axes viewer with instanced meshes
  41423. */
  41424. createInstance(): AxesViewer;
  41425. /** Releases resources */
  41426. dispose(): void;
  41427. private static _SetRenderingGroupId;
  41428. }
  41429. }
  41430. declare module BABYLON.Debug {
  41431. /**
  41432. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41433. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41434. */
  41435. export class BoneAxesViewer extends AxesViewer {
  41436. /**
  41437. * Gets or sets the target mesh where to display the axes viewer
  41438. */
  41439. mesh: Nullable<Mesh>;
  41440. /**
  41441. * Gets or sets the target bone where to display the axes viewer
  41442. */
  41443. bone: Nullable<Bone>;
  41444. /** Gets current position */
  41445. pos: Vector3;
  41446. /** Gets direction of X axis */
  41447. xaxis: Vector3;
  41448. /** Gets direction of Y axis */
  41449. yaxis: Vector3;
  41450. /** Gets direction of Z axis */
  41451. zaxis: Vector3;
  41452. /**
  41453. * Creates a new BoneAxesViewer
  41454. * @param scene defines the hosting scene
  41455. * @param bone defines the target bone
  41456. * @param mesh defines the target mesh
  41457. * @param scaleLines defines a scaling factor for line length (1 by default)
  41458. */
  41459. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41460. /**
  41461. * Force the viewer to update
  41462. */
  41463. update(): void;
  41464. /** Releases resources */
  41465. dispose(): void;
  41466. }
  41467. }
  41468. declare module BABYLON {
  41469. /**
  41470. * Interface used to define scene explorer extensibility option
  41471. */
  41472. export interface IExplorerExtensibilityOption {
  41473. /**
  41474. * Define the option label
  41475. */
  41476. label: string;
  41477. /**
  41478. * Defines the action to execute on click
  41479. */
  41480. action: (entity: any) => void;
  41481. }
  41482. /**
  41483. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41484. */
  41485. export interface IExplorerExtensibilityGroup {
  41486. /**
  41487. * Defines a predicate to test if a given type mut be extended
  41488. */
  41489. predicate: (entity: any) => boolean;
  41490. /**
  41491. * Gets the list of options added to a type
  41492. */
  41493. entries: IExplorerExtensibilityOption[];
  41494. }
  41495. /**
  41496. * Interface used to define the options to use to create the Inspector
  41497. */
  41498. export interface IInspectorOptions {
  41499. /**
  41500. * Display in overlay mode (default: false)
  41501. */
  41502. overlay?: boolean;
  41503. /**
  41504. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41505. */
  41506. globalRoot?: HTMLElement;
  41507. /**
  41508. * Display the Scene explorer
  41509. */
  41510. showExplorer?: boolean;
  41511. /**
  41512. * Display the property inspector
  41513. */
  41514. showInspector?: boolean;
  41515. /**
  41516. * Display in embed mode (both panes on the right)
  41517. */
  41518. embedMode?: boolean;
  41519. /**
  41520. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41521. */
  41522. handleResize?: boolean;
  41523. /**
  41524. * Allow the panes to popup (default: true)
  41525. */
  41526. enablePopup?: boolean;
  41527. /**
  41528. * Allow the panes to be closed by users (default: true)
  41529. */
  41530. enableClose?: boolean;
  41531. /**
  41532. * Optional list of extensibility entries
  41533. */
  41534. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41535. /**
  41536. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41537. */
  41538. inspectorURL?: string;
  41539. }
  41540. interface Scene {
  41541. /**
  41542. * @hidden
  41543. * Backing field
  41544. */
  41545. _debugLayer: DebugLayer;
  41546. /**
  41547. * Gets the debug layer (aka Inspector) associated with the scene
  41548. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41549. */
  41550. debugLayer: DebugLayer;
  41551. }
  41552. /**
  41553. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41554. * what is happening in your scene
  41555. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41556. */
  41557. export class DebugLayer {
  41558. /**
  41559. * Define the url to get the inspector script from.
  41560. * By default it uses the babylonjs CDN.
  41561. * @ignoreNaming
  41562. */
  41563. static InspectorURL: string;
  41564. private _scene;
  41565. private BJSINSPECTOR;
  41566. /**
  41567. * Observable triggered when a property is changed through the inspector.
  41568. */
  41569. onPropertyChangedObservable: Observable<{
  41570. object: any;
  41571. property: string;
  41572. value: any;
  41573. initialValue: any;
  41574. }>;
  41575. /**
  41576. * Instantiates a new debug layer.
  41577. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41578. * what is happening in your scene
  41579. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41580. * @param scene Defines the scene to inspect
  41581. */
  41582. constructor(scene: Scene);
  41583. /** Creates the inspector window. */
  41584. private _createInspector;
  41585. /**
  41586. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41587. * @param entity defines the entity to select
  41588. * @param lineContainerTitle defines the specific block to highlight
  41589. */
  41590. select(entity: any, lineContainerTitle?: string): void;
  41591. /** Get the inspector from bundle or global */
  41592. private _getGlobalInspector;
  41593. /**
  41594. * Get if the inspector is visible or not.
  41595. * @returns true if visible otherwise, false
  41596. */
  41597. isVisible(): boolean;
  41598. /**
  41599. * Hide the inspector and close its window.
  41600. */
  41601. hide(): void;
  41602. /**
  41603. * Launch the debugLayer.
  41604. * @param config Define the configuration of the inspector
  41605. * @return a promise fulfilled when the debug layer is visible
  41606. */
  41607. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41608. }
  41609. }
  41610. declare module BABYLON {
  41611. /**
  41612. * Class containing static functions to help procedurally build meshes
  41613. */
  41614. export class BoxBuilder {
  41615. /**
  41616. * Creates a box mesh
  41617. * * The parameter `size` sets the size (float) of each box side (default 1)
  41618. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41619. * * 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)
  41620. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41622. * * 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
  41623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41624. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41625. * @param name defines the name of the mesh
  41626. * @param options defines the options used to create the mesh
  41627. * @param scene defines the hosting scene
  41628. * @returns the box mesh
  41629. */
  41630. static CreateBox(name: string, options: {
  41631. size?: number;
  41632. width?: number;
  41633. height?: number;
  41634. depth?: number;
  41635. faceUV?: Vector4[];
  41636. faceColors?: Color4[];
  41637. sideOrientation?: number;
  41638. frontUVs?: Vector4;
  41639. backUVs?: Vector4;
  41640. wrap?: boolean;
  41641. topBaseAt?: number;
  41642. bottomBaseAt?: number;
  41643. updatable?: boolean;
  41644. }, scene?: Nullable<Scene>): Mesh;
  41645. }
  41646. }
  41647. declare module BABYLON {
  41648. /**
  41649. * Class containing static functions to help procedurally build meshes
  41650. */
  41651. export class SphereBuilder {
  41652. /**
  41653. * Creates a sphere mesh
  41654. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41655. * * 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`)
  41656. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41657. * * 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
  41658. * * 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)
  41659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41660. * * 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
  41661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41662. * @param name defines the name of the mesh
  41663. * @param options defines the options used to create the mesh
  41664. * @param scene defines the hosting scene
  41665. * @returns the sphere mesh
  41666. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41667. */
  41668. static CreateSphere(name: string, options: {
  41669. segments?: number;
  41670. diameter?: number;
  41671. diameterX?: number;
  41672. diameterY?: number;
  41673. diameterZ?: number;
  41674. arc?: number;
  41675. slice?: number;
  41676. sideOrientation?: number;
  41677. frontUVs?: Vector4;
  41678. backUVs?: Vector4;
  41679. updatable?: boolean;
  41680. }, scene: any): Mesh;
  41681. }
  41682. }
  41683. declare module BABYLON.Debug {
  41684. /**
  41685. * Used to show the physics impostor around the specific mesh
  41686. */
  41687. export class PhysicsViewer {
  41688. /** @hidden */
  41689. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41690. /** @hidden */
  41691. protected _meshes: Array<Nullable<AbstractMesh>>;
  41692. /** @hidden */
  41693. protected _scene: Nullable<Scene>;
  41694. /** @hidden */
  41695. protected _numMeshes: number;
  41696. /** @hidden */
  41697. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41698. private _renderFunction;
  41699. private _utilityLayer;
  41700. private _debugBoxMesh;
  41701. private _debugSphereMesh;
  41702. private _debugCylinderMesh;
  41703. private _debugMaterial;
  41704. private _debugMeshMeshes;
  41705. /**
  41706. * Creates a new PhysicsViewer
  41707. * @param scene defines the hosting scene
  41708. */
  41709. constructor(scene: Scene);
  41710. /** @hidden */
  41711. protected _updateDebugMeshes(): void;
  41712. /**
  41713. * Renders a specified physic impostor
  41714. * @param impostor defines the impostor to render
  41715. * @param targetMesh defines the mesh represented by the impostor
  41716. * @returns the new debug mesh used to render the impostor
  41717. */
  41718. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41719. /**
  41720. * Hides a specified physic impostor
  41721. * @param impostor defines the impostor to hide
  41722. */
  41723. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41724. private _getDebugMaterial;
  41725. private _getDebugBoxMesh;
  41726. private _getDebugSphereMesh;
  41727. private _getDebugCylinderMesh;
  41728. private _getDebugMeshMesh;
  41729. private _getDebugMesh;
  41730. /** Releases all resources */
  41731. dispose(): void;
  41732. }
  41733. }
  41734. declare module BABYLON {
  41735. /**
  41736. * Class containing static functions to help procedurally build meshes
  41737. */
  41738. export class LinesBuilder {
  41739. /**
  41740. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41741. * * 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
  41742. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41743. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41744. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41745. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41746. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41747. * * 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
  41748. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41751. * @param name defines the name of the new line system
  41752. * @param options defines the options used to create the line system
  41753. * @param scene defines the hosting scene
  41754. * @returns a new line system mesh
  41755. */
  41756. static CreateLineSystem(name: string, options: {
  41757. lines: Vector3[][];
  41758. updatable?: boolean;
  41759. instance?: Nullable<LinesMesh>;
  41760. colors?: Nullable<Color4[][]>;
  41761. useVertexAlpha?: boolean;
  41762. }, scene: Nullable<Scene>): LinesMesh;
  41763. /**
  41764. * Creates a line mesh
  41765. * 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
  41766. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41767. * * The parameter `points` is an array successive Vector3
  41768. * * 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
  41769. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41770. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41771. * * When updating an instance, remember that only point positions can change, not the number of points
  41772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41774. * @param name defines the name of the new line system
  41775. * @param options defines the options used to create the line system
  41776. * @param scene defines the hosting scene
  41777. * @returns a new line mesh
  41778. */
  41779. static CreateLines(name: string, options: {
  41780. points: Vector3[];
  41781. updatable?: boolean;
  41782. instance?: Nullable<LinesMesh>;
  41783. colors?: Color4[];
  41784. useVertexAlpha?: boolean;
  41785. }, scene?: Nullable<Scene>): LinesMesh;
  41786. /**
  41787. * Creates a dashed line mesh
  41788. * * 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
  41789. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41790. * * The parameter `points` is an array successive Vector3
  41791. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41792. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41793. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41794. * * 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
  41795. * * When updating an instance, remember that only point positions can change, not the number of points
  41796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41797. * @param name defines the name of the mesh
  41798. * @param options defines the options used to create the mesh
  41799. * @param scene defines the hosting scene
  41800. * @returns the dashed line mesh
  41801. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41802. */
  41803. static CreateDashedLines(name: string, options: {
  41804. points: Vector3[];
  41805. dashSize?: number;
  41806. gapSize?: number;
  41807. dashNb?: number;
  41808. updatable?: boolean;
  41809. instance?: LinesMesh;
  41810. }, scene?: Nullable<Scene>): LinesMesh;
  41811. }
  41812. }
  41813. declare module BABYLON {
  41814. /**
  41815. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41816. * in order to better appreciate the issue one might have.
  41817. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41818. */
  41819. export class RayHelper {
  41820. /**
  41821. * Defines the ray we are currently tryin to visualize.
  41822. */
  41823. ray: Nullable<Ray>;
  41824. private _renderPoints;
  41825. private _renderLine;
  41826. private _renderFunction;
  41827. private _scene;
  41828. private _updateToMeshFunction;
  41829. private _attachedToMesh;
  41830. private _meshSpaceDirection;
  41831. private _meshSpaceOrigin;
  41832. /**
  41833. * Helper function to create a colored helper in a scene in one line.
  41834. * @param ray Defines the ray we are currently tryin to visualize
  41835. * @param scene Defines the scene the ray is used in
  41836. * @param color Defines the color we want to see the ray in
  41837. * @returns The newly created ray helper.
  41838. */
  41839. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41840. /**
  41841. * Instantiate a new ray helper.
  41842. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41843. * in order to better appreciate the issue one might have.
  41844. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41845. * @param ray Defines the ray we are currently tryin to visualize
  41846. */
  41847. constructor(ray: Ray);
  41848. /**
  41849. * Shows the ray we are willing to debug.
  41850. * @param scene Defines the scene the ray needs to be rendered in
  41851. * @param color Defines the color the ray needs to be rendered in
  41852. */
  41853. show(scene: Scene, color?: Color3): void;
  41854. /**
  41855. * Hides the ray we are debugging.
  41856. */
  41857. hide(): void;
  41858. private _render;
  41859. /**
  41860. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41861. * @param mesh Defines the mesh we want the helper attached to
  41862. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41863. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41864. * @param length Defines the length of the ray
  41865. */
  41866. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41867. /**
  41868. * Detach the ray helper from the mesh it has previously been attached to.
  41869. */
  41870. detachFromMesh(): void;
  41871. private _updateToMesh;
  41872. /**
  41873. * Dispose the helper and release its associated resources.
  41874. */
  41875. dispose(): void;
  41876. }
  41877. }
  41878. declare module BABYLON.Debug {
  41879. /**
  41880. * Class used to render a debug view of a given skeleton
  41881. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41882. */
  41883. export class SkeletonViewer {
  41884. /** defines the skeleton to render */
  41885. skeleton: Skeleton;
  41886. /** defines the mesh attached to the skeleton */
  41887. mesh: AbstractMesh;
  41888. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41889. autoUpdateBonesMatrices: boolean;
  41890. /** defines the rendering group id to use with the viewer */
  41891. renderingGroupId: number;
  41892. /** Gets or sets the color used to render the skeleton */
  41893. color: Color3;
  41894. private _scene;
  41895. private _debugLines;
  41896. private _debugMesh;
  41897. private _isEnabled;
  41898. private _renderFunction;
  41899. private _utilityLayer;
  41900. /**
  41901. * Returns the mesh used to render the bones
  41902. */
  41903. readonly debugMesh: Nullable<LinesMesh>;
  41904. /**
  41905. * Creates a new SkeletonViewer
  41906. * @param skeleton defines the skeleton to render
  41907. * @param mesh defines the mesh attached to the skeleton
  41908. * @param scene defines the hosting scene
  41909. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41910. * @param renderingGroupId defines the rendering group id to use with the viewer
  41911. */
  41912. constructor(
  41913. /** defines the skeleton to render */
  41914. skeleton: Skeleton,
  41915. /** defines the mesh attached to the skeleton */
  41916. mesh: AbstractMesh, scene: Scene,
  41917. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41918. autoUpdateBonesMatrices?: boolean,
  41919. /** defines the rendering group id to use with the viewer */
  41920. renderingGroupId?: number);
  41921. /** Gets or sets a boolean indicating if the viewer is enabled */
  41922. isEnabled: boolean;
  41923. private _getBonePosition;
  41924. private _getLinesForBonesWithLength;
  41925. private _getLinesForBonesNoLength;
  41926. /** Update the viewer to sync with current skeleton state */
  41927. update(): void;
  41928. /** Release associated resources */
  41929. dispose(): void;
  41930. }
  41931. }
  41932. declare module BABYLON {
  41933. /**
  41934. * Options to create the null engine
  41935. */
  41936. export class NullEngineOptions {
  41937. /**
  41938. * Render width (Default: 512)
  41939. */
  41940. renderWidth: number;
  41941. /**
  41942. * Render height (Default: 256)
  41943. */
  41944. renderHeight: number;
  41945. /**
  41946. * Texture size (Default: 512)
  41947. */
  41948. textureSize: number;
  41949. /**
  41950. * If delta time between frames should be constant
  41951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41952. */
  41953. deterministicLockstep: boolean;
  41954. /**
  41955. * Maximum about of steps between frames (Default: 4)
  41956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41957. */
  41958. lockstepMaxSteps: number;
  41959. }
  41960. /**
  41961. * The null engine class provides support for headless version of babylon.js.
  41962. * This can be used in server side scenario or for testing purposes
  41963. */
  41964. export class NullEngine extends Engine {
  41965. private _options;
  41966. /**
  41967. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41968. */
  41969. isDeterministicLockStep(): boolean;
  41970. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41971. getLockstepMaxSteps(): number;
  41972. /**
  41973. * Sets hardware scaling, used to save performance if needed
  41974. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41975. */
  41976. getHardwareScalingLevel(): number;
  41977. constructor(options?: NullEngineOptions);
  41978. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41979. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41980. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41981. getRenderWidth(useScreen?: boolean): number;
  41982. getRenderHeight(useScreen?: boolean): number;
  41983. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41984. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41985. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41986. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41987. bindSamplers(effect: Effect): void;
  41988. enableEffect(effect: Effect): void;
  41989. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41990. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41991. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41992. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41993. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41994. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41995. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41996. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41997. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41998. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41999. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42000. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42001. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42002. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42003. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42004. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42005. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42006. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42007. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42008. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42009. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42010. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42011. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42012. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42013. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42014. bindBuffers(vertexBuffers: {
  42015. [key: string]: VertexBuffer;
  42016. }, indexBuffer: DataBuffer, effect: Effect): void;
  42017. wipeCaches(bruteForce?: boolean): void;
  42018. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42019. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42020. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42021. /** @hidden */
  42022. _createTexture(): WebGLTexture;
  42023. /** @hidden */
  42024. _releaseTexture(texture: InternalTexture): void;
  42025. 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;
  42026. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42027. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42029. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42030. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42031. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42032. areAllEffectsReady(): boolean;
  42033. /**
  42034. * @hidden
  42035. * Get the current error code of the webGL context
  42036. * @returns the error code
  42037. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42038. */
  42039. getError(): number;
  42040. /** @hidden */
  42041. _getUnpackAlignement(): number;
  42042. /** @hidden */
  42043. _unpackFlipY(value: boolean): void;
  42044. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42045. /**
  42046. * Updates a dynamic vertex buffer.
  42047. * @param vertexBuffer the vertex buffer to update
  42048. * @param data the data used to update the vertex buffer
  42049. * @param byteOffset the byte offset of the data (optional)
  42050. * @param byteLength the byte length of the data (optional)
  42051. */
  42052. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42053. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42054. /** @hidden */
  42055. _bindTexture(channel: number, texture: InternalTexture): void;
  42056. /** @hidden */
  42057. _releaseBuffer(buffer: DataBuffer): boolean;
  42058. releaseEffects(): void;
  42059. displayLoadingUI(): void;
  42060. hideLoadingUI(): void;
  42061. /** @hidden */
  42062. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42063. /** @hidden */
  42064. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42065. /** @hidden */
  42066. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42067. /** @hidden */
  42068. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42069. }
  42070. }
  42071. declare module BABYLON {
  42072. /** @hidden */
  42073. export class _OcclusionDataStorage {
  42074. /** @hidden */
  42075. occlusionInternalRetryCounter: number;
  42076. /** @hidden */
  42077. isOcclusionQueryInProgress: boolean;
  42078. /** @hidden */
  42079. isOccluded: boolean;
  42080. /** @hidden */
  42081. occlusionRetryCount: number;
  42082. /** @hidden */
  42083. occlusionType: number;
  42084. /** @hidden */
  42085. occlusionQueryAlgorithmType: number;
  42086. }
  42087. interface Engine {
  42088. /**
  42089. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42090. * @return the new query
  42091. */
  42092. createQuery(): WebGLQuery;
  42093. /**
  42094. * Delete and release a webGL query
  42095. * @param query defines the query to delete
  42096. * @return the current engine
  42097. */
  42098. deleteQuery(query: WebGLQuery): Engine;
  42099. /**
  42100. * Check if a given query has resolved and got its value
  42101. * @param query defines the query to check
  42102. * @returns true if the query got its value
  42103. */
  42104. isQueryResultAvailable(query: WebGLQuery): boolean;
  42105. /**
  42106. * Gets the value of a given query
  42107. * @param query defines the query to check
  42108. * @returns the value of the query
  42109. */
  42110. getQueryResult(query: WebGLQuery): number;
  42111. /**
  42112. * Initiates an occlusion query
  42113. * @param algorithmType defines the algorithm to use
  42114. * @param query defines the query to use
  42115. * @returns the current engine
  42116. * @see http://doc.babylonjs.com/features/occlusionquery
  42117. */
  42118. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42119. /**
  42120. * Ends an occlusion query
  42121. * @see http://doc.babylonjs.com/features/occlusionquery
  42122. * @param algorithmType defines the algorithm to use
  42123. * @returns the current engine
  42124. */
  42125. endOcclusionQuery(algorithmType: number): Engine;
  42126. /**
  42127. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42128. * Please note that only one query can be issued at a time
  42129. * @returns a time token used to track the time span
  42130. */
  42131. startTimeQuery(): Nullable<_TimeToken>;
  42132. /**
  42133. * Ends a time query
  42134. * @param token defines the token used to measure the time span
  42135. * @returns the time spent (in ns)
  42136. */
  42137. endTimeQuery(token: _TimeToken): int;
  42138. /** @hidden */
  42139. _currentNonTimestampToken: Nullable<_TimeToken>;
  42140. /** @hidden */
  42141. _createTimeQuery(): WebGLQuery;
  42142. /** @hidden */
  42143. _deleteTimeQuery(query: WebGLQuery): void;
  42144. /** @hidden */
  42145. _getGlAlgorithmType(algorithmType: number): number;
  42146. /** @hidden */
  42147. _getTimeQueryResult(query: WebGLQuery): any;
  42148. /** @hidden */
  42149. _getTimeQueryAvailability(query: WebGLQuery): any;
  42150. }
  42151. interface AbstractMesh {
  42152. /**
  42153. * Backing filed
  42154. * @hidden
  42155. */
  42156. __occlusionDataStorage: _OcclusionDataStorage;
  42157. /**
  42158. * Access property
  42159. * @hidden
  42160. */
  42161. _occlusionDataStorage: _OcclusionDataStorage;
  42162. /**
  42163. * 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.
  42164. * The default value is -1 which means don't break the query and wait till the result
  42165. * @see http://doc.babylonjs.com/features/occlusionquery
  42166. */
  42167. occlusionRetryCount: number;
  42168. /**
  42169. * 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:
  42170. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42171. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42172. * * 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.
  42173. * @see http://doc.babylonjs.com/features/occlusionquery
  42174. */
  42175. occlusionType: number;
  42176. /**
  42177. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42178. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42179. * * 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.
  42180. * @see http://doc.babylonjs.com/features/occlusionquery
  42181. */
  42182. occlusionQueryAlgorithmType: number;
  42183. /**
  42184. * 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
  42185. * @see http://doc.babylonjs.com/features/occlusionquery
  42186. */
  42187. isOccluded: boolean;
  42188. /**
  42189. * Flag to check the progress status of the query
  42190. * @see http://doc.babylonjs.com/features/occlusionquery
  42191. */
  42192. isOcclusionQueryInProgress: boolean;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /** @hidden */
  42197. export var _forceTransformFeedbackToBundle: boolean;
  42198. interface Engine {
  42199. /**
  42200. * Creates a webGL transform feedback object
  42201. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42202. * @returns the webGL transform feedback object
  42203. */
  42204. createTransformFeedback(): WebGLTransformFeedback;
  42205. /**
  42206. * Delete a webGL transform feedback object
  42207. * @param value defines the webGL transform feedback object to delete
  42208. */
  42209. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42210. /**
  42211. * Bind a webGL transform feedback object to the webgl context
  42212. * @param value defines the webGL transform feedback object to bind
  42213. */
  42214. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42215. /**
  42216. * Begins a transform feedback operation
  42217. * @param usePoints defines if points or triangles must be used
  42218. */
  42219. beginTransformFeedback(usePoints: boolean): void;
  42220. /**
  42221. * Ends a transform feedback operation
  42222. */
  42223. endTransformFeedback(): void;
  42224. /**
  42225. * Specify the varyings to use with transform feedback
  42226. * @param program defines the associated webGL program
  42227. * @param value defines the list of strings representing the varying names
  42228. */
  42229. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42230. /**
  42231. * Bind a webGL buffer for a transform feedback operation
  42232. * @param value defines the webGL buffer to bind
  42233. */
  42234. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42235. }
  42236. }
  42237. declare module BABYLON {
  42238. /**
  42239. * Creation options of the multi render target texture.
  42240. */
  42241. export interface IMultiRenderTargetOptions {
  42242. /**
  42243. * Define if the texture needs to create mip maps after render.
  42244. */
  42245. generateMipMaps?: boolean;
  42246. /**
  42247. * Define the types of all the draw buffers we want to create
  42248. */
  42249. types?: number[];
  42250. /**
  42251. * Define the sampling modes of all the draw buffers we want to create
  42252. */
  42253. samplingModes?: number[];
  42254. /**
  42255. * Define if a depth buffer is required
  42256. */
  42257. generateDepthBuffer?: boolean;
  42258. /**
  42259. * Define if a stencil buffer is required
  42260. */
  42261. generateStencilBuffer?: boolean;
  42262. /**
  42263. * Define if a depth texture is required instead of a depth buffer
  42264. */
  42265. generateDepthTexture?: boolean;
  42266. /**
  42267. * Define the number of desired draw buffers
  42268. */
  42269. textureCount?: number;
  42270. /**
  42271. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42272. */
  42273. doNotChangeAspectRatio?: boolean;
  42274. /**
  42275. * Define the default type of the buffers we are creating
  42276. */
  42277. defaultType?: number;
  42278. }
  42279. /**
  42280. * A multi render target, like a render target provides the ability to render to a texture.
  42281. * Unlike the render target, it can render to several draw buffers in one draw.
  42282. * This is specially interesting in deferred rendering or for any effects requiring more than
  42283. * just one color from a single pass.
  42284. */
  42285. export class MultiRenderTarget extends RenderTargetTexture {
  42286. private _internalTextures;
  42287. private _textures;
  42288. private _multiRenderTargetOptions;
  42289. /**
  42290. * Get if draw buffers are currently supported by the used hardware and browser.
  42291. */
  42292. readonly isSupported: boolean;
  42293. /**
  42294. * Get the list of textures generated by the multi render target.
  42295. */
  42296. readonly textures: Texture[];
  42297. /**
  42298. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42299. */
  42300. readonly depthTexture: Texture;
  42301. /**
  42302. * Set the wrapping mode on U of all the textures we are rendering to.
  42303. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42304. */
  42305. wrapU: number;
  42306. /**
  42307. * Set the wrapping mode on V of all the textures we are rendering to.
  42308. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42309. */
  42310. wrapV: number;
  42311. /**
  42312. * Instantiate a new multi render target texture.
  42313. * A multi render target, like a render target provides the ability to render to a texture.
  42314. * Unlike the render target, it can render to several draw buffers in one draw.
  42315. * This is specially interesting in deferred rendering or for any effects requiring more than
  42316. * just one color from a single pass.
  42317. * @param name Define the name of the texture
  42318. * @param size Define the size of the buffers to render to
  42319. * @param count Define the number of target we are rendering into
  42320. * @param scene Define the scene the texture belongs to
  42321. * @param options Define the options used to create the multi render target
  42322. */
  42323. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42324. /** @hidden */
  42325. _rebuild(): void;
  42326. private _createInternalTextures;
  42327. private _createTextures;
  42328. /**
  42329. * Define the number of samples used if MSAA is enabled.
  42330. */
  42331. samples: number;
  42332. /**
  42333. * Resize all the textures in the multi render target.
  42334. * Be carrefull as it will recreate all the data in the new texture.
  42335. * @param size Define the new size
  42336. */
  42337. resize(size: any): void;
  42338. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42339. /**
  42340. * Dispose the render targets and their associated resources
  42341. */
  42342. dispose(): void;
  42343. /**
  42344. * Release all the underlying texture used as draw buffers.
  42345. */
  42346. releaseInternalTextures(): void;
  42347. }
  42348. }
  42349. declare module BABYLON {
  42350. interface Engine {
  42351. /**
  42352. * Unbind a list of render target textures from the webGL context
  42353. * This is used only when drawBuffer extension or webGL2 are active
  42354. * @param textures defines the render target textures to unbind
  42355. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42356. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42357. */
  42358. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42359. /**
  42360. * Create a multi render target texture
  42361. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42362. * @param size defines the size of the texture
  42363. * @param options defines the creation options
  42364. * @returns the cube texture as an InternalTexture
  42365. */
  42366. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42367. /**
  42368. * Update the sample count for a given multiple render target texture
  42369. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42370. * @param textures defines the textures to update
  42371. * @param samples defines the sample count to set
  42372. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42373. */
  42374. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42375. }
  42376. }
  42377. declare module BABYLON {
  42378. /**
  42379. * Gather the list of clipboard event types as constants.
  42380. */
  42381. export class ClipboardEventTypes {
  42382. /**
  42383. * The clipboard event is fired when a copy command is active (pressed).
  42384. */
  42385. static readonly COPY: number;
  42386. /**
  42387. * The clipboard event is fired when a cut command is active (pressed).
  42388. */
  42389. static readonly CUT: number;
  42390. /**
  42391. * The clipboard event is fired when a paste command is active (pressed).
  42392. */
  42393. static readonly PASTE: number;
  42394. }
  42395. /**
  42396. * This class is used to store clipboard related info for the onClipboardObservable event.
  42397. */
  42398. export class ClipboardInfo {
  42399. /**
  42400. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42401. */
  42402. type: number;
  42403. /**
  42404. * Defines the related dom event
  42405. */
  42406. event: ClipboardEvent;
  42407. /**
  42408. *Creates an instance of ClipboardInfo.
  42409. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42410. * @param event Defines the related dom event
  42411. */
  42412. constructor(
  42413. /**
  42414. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42415. */
  42416. type: number,
  42417. /**
  42418. * Defines the related dom event
  42419. */
  42420. event: ClipboardEvent);
  42421. /**
  42422. * Get the clipboard event's type from the keycode.
  42423. * @param keyCode Defines the keyCode for the current keyboard event.
  42424. * @return {number}
  42425. */
  42426. static GetTypeFromCharacter(keyCode: number): number;
  42427. }
  42428. }
  42429. declare module BABYLON {
  42430. /**
  42431. * Class used to represent data loading progression
  42432. */
  42433. export class SceneLoaderProgressEvent {
  42434. /** defines if data length to load can be evaluated */
  42435. readonly lengthComputable: boolean;
  42436. /** defines the loaded data length */
  42437. readonly loaded: number;
  42438. /** defines the data length to load */
  42439. readonly total: number;
  42440. /**
  42441. * Create a new progress event
  42442. * @param lengthComputable defines if data length to load can be evaluated
  42443. * @param loaded defines the loaded data length
  42444. * @param total defines the data length to load
  42445. */
  42446. constructor(
  42447. /** defines if data length to load can be evaluated */
  42448. lengthComputable: boolean,
  42449. /** defines the loaded data length */
  42450. loaded: number,
  42451. /** defines the data length to load */
  42452. total: number);
  42453. /**
  42454. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42455. * @param event defines the source event
  42456. * @returns a new SceneLoaderProgressEvent
  42457. */
  42458. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42459. }
  42460. /**
  42461. * Interface used by SceneLoader plugins to define supported file extensions
  42462. */
  42463. export interface ISceneLoaderPluginExtensions {
  42464. /**
  42465. * Defines the list of supported extensions
  42466. */
  42467. [extension: string]: {
  42468. isBinary: boolean;
  42469. };
  42470. }
  42471. /**
  42472. * Interface used by SceneLoader plugin factory
  42473. */
  42474. export interface ISceneLoaderPluginFactory {
  42475. /**
  42476. * Defines the name of the factory
  42477. */
  42478. name: string;
  42479. /**
  42480. * Function called to create a new plugin
  42481. * @return the new plugin
  42482. */
  42483. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42484. /**
  42485. * Boolean indicating if the plugin can direct load specific data
  42486. */
  42487. canDirectLoad?: (data: string) => boolean;
  42488. }
  42489. /**
  42490. * Interface used to define a SceneLoader plugin
  42491. */
  42492. export interface ISceneLoaderPlugin {
  42493. /**
  42494. * The friendly name of this plugin.
  42495. */
  42496. name: string;
  42497. /**
  42498. * The file extensions supported by this plugin.
  42499. */
  42500. extensions: string | ISceneLoaderPluginExtensions;
  42501. /**
  42502. * Import meshes into a scene.
  42503. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42504. * @param scene The scene to import into
  42505. * @param data The data to import
  42506. * @param rootUrl The root url for scene and resources
  42507. * @param meshes The meshes array to import into
  42508. * @param particleSystems The particle systems array to import into
  42509. * @param skeletons The skeletons array to import into
  42510. * @param onError The callback when import fails
  42511. * @returns True if successful or false otherwise
  42512. */
  42513. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42514. /**
  42515. * Load into a scene.
  42516. * @param scene The scene to load into
  42517. * @param data The data to import
  42518. * @param rootUrl The root url for scene and resources
  42519. * @param onError The callback when import fails
  42520. * @returns true if successful or false otherwise
  42521. */
  42522. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42523. /**
  42524. * The callback that returns true if the data can be directly loaded.
  42525. */
  42526. canDirectLoad?: (data: string) => boolean;
  42527. /**
  42528. * The callback that allows custom handling of the root url based on the response url.
  42529. */
  42530. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42531. /**
  42532. * Load into an asset container.
  42533. * @param scene The scene to load into
  42534. * @param data The data to import
  42535. * @param rootUrl The root url for scene and resources
  42536. * @param onError The callback when import fails
  42537. * @returns The loaded asset container
  42538. */
  42539. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42540. }
  42541. /**
  42542. * Interface used to define an async SceneLoader plugin
  42543. */
  42544. export interface ISceneLoaderPluginAsync {
  42545. /**
  42546. * The friendly name of this plugin.
  42547. */
  42548. name: string;
  42549. /**
  42550. * The file extensions supported by this plugin.
  42551. */
  42552. extensions: string | ISceneLoaderPluginExtensions;
  42553. /**
  42554. * Import meshes into a scene.
  42555. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42556. * @param scene The scene to import into
  42557. * @param data The data to import
  42558. * @param rootUrl The root url for scene and resources
  42559. * @param onProgress The callback when the load progresses
  42560. * @param fileName Defines the name of the file to load
  42561. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42562. */
  42563. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42564. meshes: AbstractMesh[];
  42565. particleSystems: IParticleSystem[];
  42566. skeletons: Skeleton[];
  42567. animationGroups: AnimationGroup[];
  42568. }>;
  42569. /**
  42570. * Load into a scene.
  42571. * @param scene The scene to load into
  42572. * @param data The data to import
  42573. * @param rootUrl The root url for scene and resources
  42574. * @param onProgress The callback when the load progresses
  42575. * @param fileName Defines the name of the file to load
  42576. * @returns Nothing
  42577. */
  42578. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42579. /**
  42580. * The callback that returns true if the data can be directly loaded.
  42581. */
  42582. canDirectLoad?: (data: string) => boolean;
  42583. /**
  42584. * The callback that allows custom handling of the root url based on the response url.
  42585. */
  42586. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42587. /**
  42588. * Load into an asset container.
  42589. * @param scene The scene to load into
  42590. * @param data The data to import
  42591. * @param rootUrl The root url for scene and resources
  42592. * @param onProgress The callback when the load progresses
  42593. * @param fileName Defines the name of the file to load
  42594. * @returns The loaded asset container
  42595. */
  42596. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42597. }
  42598. /**
  42599. * Class used to load scene from various file formats using registered plugins
  42600. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42601. */
  42602. export class SceneLoader {
  42603. /**
  42604. * No logging while loading
  42605. */
  42606. static readonly NO_LOGGING: number;
  42607. /**
  42608. * Minimal logging while loading
  42609. */
  42610. static readonly MINIMAL_LOGGING: number;
  42611. /**
  42612. * Summary logging while loading
  42613. */
  42614. static readonly SUMMARY_LOGGING: number;
  42615. /**
  42616. * Detailled logging while loading
  42617. */
  42618. static readonly DETAILED_LOGGING: number;
  42619. /**
  42620. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42621. */
  42622. static ForceFullSceneLoadingForIncremental: boolean;
  42623. /**
  42624. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42625. */
  42626. static ShowLoadingScreen: boolean;
  42627. /**
  42628. * Defines the current logging level (while loading the scene)
  42629. * @ignorenaming
  42630. */
  42631. static loggingLevel: number;
  42632. /**
  42633. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42634. */
  42635. static CleanBoneMatrixWeights: boolean;
  42636. /**
  42637. * Event raised when a plugin is used to load a scene
  42638. */
  42639. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42640. private static _registeredPlugins;
  42641. private static _getDefaultPlugin;
  42642. private static _getPluginForExtension;
  42643. private static _getPluginForDirectLoad;
  42644. private static _getPluginForFilename;
  42645. private static _getDirectLoad;
  42646. private static _loadData;
  42647. private static _getFileInfo;
  42648. /**
  42649. * Gets a plugin that can load the given extension
  42650. * @param extension defines the extension to load
  42651. * @returns a plugin or null if none works
  42652. */
  42653. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42654. /**
  42655. * Gets a boolean indicating that the given extension can be loaded
  42656. * @param extension defines the extension to load
  42657. * @returns true if the extension is supported
  42658. */
  42659. static IsPluginForExtensionAvailable(extension: string): boolean;
  42660. /**
  42661. * Adds a new plugin to the list of registered plugins
  42662. * @param plugin defines the plugin to add
  42663. */
  42664. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42665. /**
  42666. * Import meshes into a scene
  42667. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42668. * @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)
  42669. * @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)
  42670. * @param scene the instance of BABYLON.Scene to append to
  42671. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42672. * @param onProgress a callback with a progress event for each file being loaded
  42673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42674. * @param pluginExtension the extension used to determine the plugin
  42675. * @returns The loaded plugin
  42676. */
  42677. 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>;
  42678. /**
  42679. * Import meshes into a scene
  42680. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42681. * @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)
  42682. * @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)
  42683. * @param scene the instance of BABYLON.Scene to append to
  42684. * @param onProgress a callback with a progress event for each file being loaded
  42685. * @param pluginExtension the extension used to determine the plugin
  42686. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42687. */
  42688. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42689. meshes: AbstractMesh[];
  42690. particleSystems: IParticleSystem[];
  42691. skeletons: Skeleton[];
  42692. animationGroups: AnimationGroup[];
  42693. }>;
  42694. /**
  42695. * Load a scene
  42696. * @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)
  42697. * @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)
  42698. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42699. * @param onSuccess a callback with the scene when import succeeds
  42700. * @param onProgress a callback with a progress event for each file being loaded
  42701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42702. * @param pluginExtension the extension used to determine the plugin
  42703. * @returns The loaded plugin
  42704. */
  42705. 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>;
  42706. /**
  42707. * Load a scene
  42708. * @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)
  42709. * @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)
  42710. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42711. * @param onProgress a callback with a progress event for each file being loaded
  42712. * @param pluginExtension the extension used to determine the plugin
  42713. * @returns The loaded scene
  42714. */
  42715. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42716. /**
  42717. * Append a scene
  42718. * @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)
  42719. * @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)
  42720. * @param scene is the instance of BABYLON.Scene to append to
  42721. * @param onSuccess a callback with the scene when import succeeds
  42722. * @param onProgress a callback with a progress event for each file being loaded
  42723. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42724. * @param pluginExtension the extension used to determine the plugin
  42725. * @returns The loaded plugin
  42726. */
  42727. 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>;
  42728. /**
  42729. * Append a scene
  42730. * @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)
  42731. * @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)
  42732. * @param scene is the instance of BABYLON.Scene to append to
  42733. * @param onProgress a callback with a progress event for each file being loaded
  42734. * @param pluginExtension the extension used to determine the plugin
  42735. * @returns The given scene
  42736. */
  42737. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42738. /**
  42739. * Load a scene into an asset container
  42740. * @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)
  42741. * @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)
  42742. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42743. * @param onSuccess a callback with the scene when import succeeds
  42744. * @param onProgress a callback with a progress event for each file being loaded
  42745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42746. * @param pluginExtension the extension used to determine the plugin
  42747. * @returns The loaded plugin
  42748. */
  42749. 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>;
  42750. /**
  42751. * Load a scene into an asset container
  42752. * @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)
  42753. * @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)
  42754. * @param scene is the instance of Scene to append to
  42755. * @param onProgress a callback with a progress event for each file being loaded
  42756. * @param pluginExtension the extension used to determine the plugin
  42757. * @returns The loaded asset container
  42758. */
  42759. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42760. }
  42761. }
  42762. declare module BABYLON {
  42763. /**
  42764. * Google Daydream controller
  42765. */
  42766. export class DaydreamController extends WebVRController {
  42767. /**
  42768. * Base Url for the controller model.
  42769. */
  42770. static MODEL_BASE_URL: string;
  42771. /**
  42772. * File name for the controller model.
  42773. */
  42774. static MODEL_FILENAME: string;
  42775. /**
  42776. * Gamepad Id prefix used to identify Daydream Controller.
  42777. */
  42778. static readonly GAMEPAD_ID_PREFIX: string;
  42779. /**
  42780. * Creates a new DaydreamController from a gamepad
  42781. * @param vrGamepad the gamepad that the controller should be created from
  42782. */
  42783. constructor(vrGamepad: any);
  42784. /**
  42785. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42786. * @param scene scene in which to add meshes
  42787. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42788. */
  42789. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42790. /**
  42791. * Called once for each button that changed state since the last frame
  42792. * @param buttonIdx Which button index changed
  42793. * @param state New state of the button
  42794. * @param changes Which properties on the state changed since last frame
  42795. */
  42796. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42797. }
  42798. }
  42799. declare module BABYLON {
  42800. /**
  42801. * Gear VR Controller
  42802. */
  42803. export class GearVRController extends WebVRController {
  42804. /**
  42805. * Base Url for the controller model.
  42806. */
  42807. static MODEL_BASE_URL: string;
  42808. /**
  42809. * File name for the controller model.
  42810. */
  42811. static MODEL_FILENAME: string;
  42812. /**
  42813. * Gamepad Id prefix used to identify this controller.
  42814. */
  42815. static readonly GAMEPAD_ID_PREFIX: string;
  42816. private readonly _buttonIndexToObservableNameMap;
  42817. /**
  42818. * Creates a new GearVRController from a gamepad
  42819. * @param vrGamepad the gamepad that the controller should be created from
  42820. */
  42821. constructor(vrGamepad: any);
  42822. /**
  42823. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42824. * @param scene scene in which to add meshes
  42825. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42826. */
  42827. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42828. /**
  42829. * Called once for each button that changed state since the last frame
  42830. * @param buttonIdx Which button index changed
  42831. * @param state New state of the button
  42832. * @param changes Which properties on the state changed since last frame
  42833. */
  42834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42835. }
  42836. }
  42837. declare module BABYLON {
  42838. /**
  42839. * Generic Controller
  42840. */
  42841. export class GenericController extends WebVRController {
  42842. /**
  42843. * Base Url for the controller model.
  42844. */
  42845. static readonly MODEL_BASE_URL: string;
  42846. /**
  42847. * File name for the controller model.
  42848. */
  42849. static readonly MODEL_FILENAME: string;
  42850. /**
  42851. * Creates a new GenericController from a gamepad
  42852. * @param vrGamepad the gamepad that the controller should be created from
  42853. */
  42854. constructor(vrGamepad: any);
  42855. /**
  42856. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42857. * @param scene scene in which to add meshes
  42858. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42859. */
  42860. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42861. /**
  42862. * Called once for each button that changed state since the last frame
  42863. * @param buttonIdx Which button index changed
  42864. * @param state New state of the button
  42865. * @param changes Which properties on the state changed since last frame
  42866. */
  42867. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42868. }
  42869. }
  42870. declare module BABYLON {
  42871. /**
  42872. * Oculus Touch Controller
  42873. */
  42874. export class OculusTouchController extends WebVRController {
  42875. /**
  42876. * Base Url for the controller model.
  42877. */
  42878. static MODEL_BASE_URL: string;
  42879. /**
  42880. * File name for the left controller model.
  42881. */
  42882. static MODEL_LEFT_FILENAME: string;
  42883. /**
  42884. * File name for the right controller model.
  42885. */
  42886. static MODEL_RIGHT_FILENAME: string;
  42887. /**
  42888. * Base Url for the Quest controller model.
  42889. */
  42890. static QUEST_MODEL_BASE_URL: string;
  42891. /**
  42892. * @hidden
  42893. * If the controllers are running on a device that needs the updated Quest controller models
  42894. */
  42895. static _IsQuest: boolean;
  42896. /**
  42897. * Fired when the secondary trigger on this controller is modified
  42898. */
  42899. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42900. /**
  42901. * Fired when the thumb rest on this controller is modified
  42902. */
  42903. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42904. /**
  42905. * Creates a new OculusTouchController from a gamepad
  42906. * @param vrGamepad the gamepad that the controller should be created from
  42907. */
  42908. constructor(vrGamepad: any);
  42909. /**
  42910. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42911. * @param scene scene in which to add meshes
  42912. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42913. */
  42914. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42915. /**
  42916. * Fired when the A button on this controller is modified
  42917. */
  42918. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42919. /**
  42920. * Fired when the B button on this controller is modified
  42921. */
  42922. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42923. /**
  42924. * Fired when the X button on this controller is modified
  42925. */
  42926. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Fired when the Y button on this controller is modified
  42929. */
  42930. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42931. /**
  42932. * Called once for each button that changed state since the last frame
  42933. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42934. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42935. * 2) secondary trigger (same)
  42936. * 3) A (right) X (left), touch, pressed = value
  42937. * 4) B / Y
  42938. * 5) thumb rest
  42939. * @param buttonIdx Which button index changed
  42940. * @param state New state of the button
  42941. * @param changes Which properties on the state changed since last frame
  42942. */
  42943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42944. }
  42945. }
  42946. declare module BABYLON {
  42947. /**
  42948. * Vive Controller
  42949. */
  42950. export class ViveController extends WebVRController {
  42951. /**
  42952. * Base Url for the controller model.
  42953. */
  42954. static MODEL_BASE_URL: string;
  42955. /**
  42956. * File name for the controller model.
  42957. */
  42958. static MODEL_FILENAME: string;
  42959. /**
  42960. * Creates a new ViveController from a gamepad
  42961. * @param vrGamepad the gamepad that the controller should be created from
  42962. */
  42963. constructor(vrGamepad: any);
  42964. /**
  42965. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42966. * @param scene scene in which to add meshes
  42967. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42968. */
  42969. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42970. /**
  42971. * Fired when the left button on this controller is modified
  42972. */
  42973. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42974. /**
  42975. * Fired when the right button on this controller is modified
  42976. */
  42977. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42978. /**
  42979. * Fired when the menu button on this controller is modified
  42980. */
  42981. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42982. /**
  42983. * Called once for each button that changed state since the last frame
  42984. * Vive mapping:
  42985. * 0: touchpad
  42986. * 1: trigger
  42987. * 2: left AND right buttons
  42988. * 3: menu button
  42989. * @param buttonIdx Which button index changed
  42990. * @param state New state of the button
  42991. * @param changes Which properties on the state changed since last frame
  42992. */
  42993. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42994. }
  42995. }
  42996. declare module BABYLON {
  42997. /**
  42998. * Defines the WindowsMotionController object that the state of the windows motion controller
  42999. */
  43000. export class WindowsMotionController extends WebVRController {
  43001. /**
  43002. * The base url used to load the left and right controller models
  43003. */
  43004. static MODEL_BASE_URL: string;
  43005. /**
  43006. * The name of the left controller model file
  43007. */
  43008. static MODEL_LEFT_FILENAME: string;
  43009. /**
  43010. * The name of the right controller model file
  43011. */
  43012. static MODEL_RIGHT_FILENAME: string;
  43013. /**
  43014. * The controller name prefix for this controller type
  43015. */
  43016. static readonly GAMEPAD_ID_PREFIX: string;
  43017. /**
  43018. * The controller id pattern for this controller type
  43019. */
  43020. private static readonly GAMEPAD_ID_PATTERN;
  43021. private _loadedMeshInfo;
  43022. private readonly _mapping;
  43023. /**
  43024. * Fired when the trackpad on this controller is clicked
  43025. */
  43026. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43027. /**
  43028. * Fired when the trackpad on this controller is modified
  43029. */
  43030. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43031. /**
  43032. * The current x and y values of this controller's trackpad
  43033. */
  43034. trackpad: StickValues;
  43035. /**
  43036. * Creates a new WindowsMotionController from a gamepad
  43037. * @param vrGamepad the gamepad that the controller should be created from
  43038. */
  43039. constructor(vrGamepad: any);
  43040. /**
  43041. * Fired when the trigger on this controller is modified
  43042. */
  43043. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43044. /**
  43045. * Fired when the menu button on this controller is modified
  43046. */
  43047. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43048. /**
  43049. * Fired when the grip button on this controller is modified
  43050. */
  43051. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43052. /**
  43053. * Fired when the thumbstick button on this controller is modified
  43054. */
  43055. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43056. /**
  43057. * Fired when the touchpad button on this controller is modified
  43058. */
  43059. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43060. /**
  43061. * Fired when the touchpad values on this controller are modified
  43062. */
  43063. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43064. private _updateTrackpad;
  43065. /**
  43066. * Called once per frame by the engine.
  43067. */
  43068. update(): void;
  43069. /**
  43070. * Called once for each button that changed state since the last frame
  43071. * @param buttonIdx Which button index changed
  43072. * @param state New state of the button
  43073. * @param changes Which properties on the state changed since last frame
  43074. */
  43075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43076. /**
  43077. * Moves the buttons on the controller mesh based on their current state
  43078. * @param buttonName the name of the button to move
  43079. * @param buttonValue the value of the button which determines the buttons new position
  43080. */
  43081. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43082. /**
  43083. * Moves the axis on the controller mesh based on its current state
  43084. * @param axis the index of the axis
  43085. * @param axisValue the value of the axis which determines the meshes new position
  43086. * @hidden
  43087. */
  43088. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43089. /**
  43090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43091. * @param scene scene in which to add meshes
  43092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43093. */
  43094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43095. /**
  43096. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43097. * can be transformed by button presses and axes values, based on this._mapping.
  43098. *
  43099. * @param scene scene in which the meshes exist
  43100. * @param meshes list of meshes that make up the controller model to process
  43101. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43102. */
  43103. private processModel;
  43104. private createMeshInfo;
  43105. /**
  43106. * Gets the ray of the controller in the direction the controller is pointing
  43107. * @param length the length the resulting ray should be
  43108. * @returns a ray in the direction the controller is pointing
  43109. */
  43110. getForwardRay(length?: number): Ray;
  43111. /**
  43112. * Disposes of the controller
  43113. */
  43114. dispose(): void;
  43115. }
  43116. }
  43117. declare module BABYLON {
  43118. /**
  43119. * Class containing static functions to help procedurally build meshes
  43120. */
  43121. export class PolyhedronBuilder {
  43122. /**
  43123. * Creates a polyhedron mesh
  43124. * * 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
  43125. * * The parameter `size` (positive float, default 1) sets the polygon size
  43126. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43127. * * 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`
  43128. * * 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
  43129. * * 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)`)
  43130. * * 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
  43131. * * 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
  43132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43133. * * 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
  43134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43135. * @param name defines the name of the mesh
  43136. * @param options defines the options used to create the mesh
  43137. * @param scene defines the hosting scene
  43138. * @returns the polyhedron mesh
  43139. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43140. */
  43141. static CreatePolyhedron(name: string, options: {
  43142. type?: number;
  43143. size?: number;
  43144. sizeX?: number;
  43145. sizeY?: number;
  43146. sizeZ?: number;
  43147. custom?: any;
  43148. faceUV?: Vector4[];
  43149. faceColors?: Color4[];
  43150. flat?: boolean;
  43151. updatable?: boolean;
  43152. sideOrientation?: number;
  43153. frontUVs?: Vector4;
  43154. backUVs?: Vector4;
  43155. }, scene?: Nullable<Scene>): Mesh;
  43156. }
  43157. }
  43158. declare module BABYLON {
  43159. /**
  43160. * Gizmo that enables scaling a mesh along 3 axis
  43161. */
  43162. export class ScaleGizmo extends Gizmo {
  43163. /**
  43164. * Internal gizmo used for interactions on the x axis
  43165. */
  43166. xGizmo: AxisScaleGizmo;
  43167. /**
  43168. * Internal gizmo used for interactions on the y axis
  43169. */
  43170. yGizmo: AxisScaleGizmo;
  43171. /**
  43172. * Internal gizmo used for interactions on the z axis
  43173. */
  43174. zGizmo: AxisScaleGizmo;
  43175. /**
  43176. * Internal gizmo used to scale all axis equally
  43177. */
  43178. uniformScaleGizmo: AxisScaleGizmo;
  43179. private _meshAttached;
  43180. private _updateGizmoRotationToMatchAttachedMesh;
  43181. private _snapDistance;
  43182. private _scaleRatio;
  43183. private _uniformScalingMesh;
  43184. private _octahedron;
  43185. /** Fires an event when any of it's sub gizmos are dragged */
  43186. onDragStartObservable: Observable<unknown>;
  43187. /** Fires an event when any of it's sub gizmos are released from dragging */
  43188. onDragEndObservable: Observable<unknown>;
  43189. attachedMesh: Nullable<AbstractMesh>;
  43190. /**
  43191. * Creates a ScaleGizmo
  43192. * @param gizmoLayer The utility layer the gizmo will be added to
  43193. */
  43194. constructor(gizmoLayer?: UtilityLayerRenderer);
  43195. updateGizmoRotationToMatchAttachedMesh: boolean;
  43196. /**
  43197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43198. */
  43199. snapDistance: number;
  43200. /**
  43201. * Ratio for the scale of the gizmo (Default: 1)
  43202. */
  43203. scaleRatio: number;
  43204. /**
  43205. * Disposes of the gizmo
  43206. */
  43207. dispose(): void;
  43208. }
  43209. }
  43210. declare module BABYLON {
  43211. /**
  43212. * Single axis scale gizmo
  43213. */
  43214. export class AxisScaleGizmo extends Gizmo {
  43215. /**
  43216. * Drag behavior responsible for the gizmos dragging interactions
  43217. */
  43218. dragBehavior: PointerDragBehavior;
  43219. private _pointerObserver;
  43220. /**
  43221. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43222. */
  43223. snapDistance: number;
  43224. /**
  43225. * Event that fires each time the gizmo snaps to a new location.
  43226. * * snapDistance is the the change in distance
  43227. */
  43228. onSnapObservable: Observable<{
  43229. snapDistance: number;
  43230. }>;
  43231. /**
  43232. * If the scaling operation should be done on all axis (default: false)
  43233. */
  43234. uniformScaling: boolean;
  43235. private _isEnabled;
  43236. private _parent;
  43237. private _arrow;
  43238. private _coloredMaterial;
  43239. private _hoverMaterial;
  43240. /**
  43241. * Creates an AxisScaleGizmo
  43242. * @param gizmoLayer The utility layer the gizmo will be added to
  43243. * @param dragAxis The axis which the gizmo will be able to scale on
  43244. * @param color The color of the gizmo
  43245. */
  43246. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43247. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43248. /**
  43249. * If the gizmo is enabled
  43250. */
  43251. isEnabled: boolean;
  43252. /**
  43253. * Disposes of the gizmo
  43254. */
  43255. dispose(): void;
  43256. /**
  43257. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43258. * @param mesh The mesh to replace the default mesh of the gizmo
  43259. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43260. */
  43261. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43262. }
  43263. }
  43264. declare module BABYLON {
  43265. /**
  43266. * Bounding box gizmo
  43267. */
  43268. export class BoundingBoxGizmo extends Gizmo {
  43269. private _lineBoundingBox;
  43270. private _rotateSpheresParent;
  43271. private _scaleBoxesParent;
  43272. private _boundingDimensions;
  43273. private _renderObserver;
  43274. private _pointerObserver;
  43275. private _scaleDragSpeed;
  43276. private _tmpQuaternion;
  43277. private _tmpVector;
  43278. private _tmpRotationMatrix;
  43279. /**
  43280. * 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)
  43281. */
  43282. ignoreChildren: boolean;
  43283. /**
  43284. * 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)
  43285. */
  43286. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43287. /**
  43288. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43289. */
  43290. rotationSphereSize: number;
  43291. /**
  43292. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43293. */
  43294. scaleBoxSize: number;
  43295. /**
  43296. * 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)
  43297. */
  43298. fixedDragMeshScreenSize: boolean;
  43299. /**
  43300. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43301. */
  43302. fixedDragMeshScreenSizeDistanceFactor: number;
  43303. /**
  43304. * Fired when a rotation sphere or scale box is dragged
  43305. */
  43306. onDragStartObservable: Observable<{}>;
  43307. /**
  43308. * Fired when a scale box is dragged
  43309. */
  43310. onScaleBoxDragObservable: Observable<{}>;
  43311. /**
  43312. * Fired when a scale box drag is ended
  43313. */
  43314. onScaleBoxDragEndObservable: Observable<{}>;
  43315. /**
  43316. * Fired when a rotation sphere is dragged
  43317. */
  43318. onRotationSphereDragObservable: Observable<{}>;
  43319. /**
  43320. * Fired when a rotation sphere drag is ended
  43321. */
  43322. onRotationSphereDragEndObservable: Observable<{}>;
  43323. /**
  43324. * 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)
  43325. */
  43326. scalePivot: Nullable<Vector3>;
  43327. /**
  43328. * Mesh used as a pivot to rotate the attached mesh
  43329. */
  43330. private _anchorMesh;
  43331. private _existingMeshScale;
  43332. private _dragMesh;
  43333. private pointerDragBehavior;
  43334. private coloredMaterial;
  43335. private hoverColoredMaterial;
  43336. /**
  43337. * Sets the color of the bounding box gizmo
  43338. * @param color the color to set
  43339. */
  43340. setColor(color: Color3): void;
  43341. /**
  43342. * Creates an BoundingBoxGizmo
  43343. * @param gizmoLayer The utility layer the gizmo will be added to
  43344. * @param color The color of the gizmo
  43345. */
  43346. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43347. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43348. private _selectNode;
  43349. /**
  43350. * Updates the bounding box information for the Gizmo
  43351. */
  43352. updateBoundingBox(): void;
  43353. private _updateRotationSpheres;
  43354. private _updateScaleBoxes;
  43355. /**
  43356. * Enables rotation on the specified axis and disables rotation on the others
  43357. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43358. */
  43359. setEnabledRotationAxis(axis: string): void;
  43360. /**
  43361. * Enables/disables scaling
  43362. * @param enable if scaling should be enabled
  43363. */
  43364. setEnabledScaling(enable: boolean): void;
  43365. private _updateDummy;
  43366. /**
  43367. * Enables a pointer drag behavior on the bounding box of the gizmo
  43368. */
  43369. enableDragBehavior(): void;
  43370. /**
  43371. * Disposes of the gizmo
  43372. */
  43373. dispose(): void;
  43374. /**
  43375. * 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)
  43376. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43377. * @returns the bounding box mesh with the passed in mesh as a child
  43378. */
  43379. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43380. /**
  43381. * CustomMeshes are not supported by this gizmo
  43382. * @param mesh The mesh to replace the default mesh of the gizmo
  43383. */
  43384. setCustomMesh(mesh: Mesh): void;
  43385. }
  43386. }
  43387. declare module BABYLON {
  43388. /**
  43389. * Single plane rotation gizmo
  43390. */
  43391. export class PlaneRotationGizmo extends Gizmo {
  43392. /**
  43393. * Drag behavior responsible for the gizmos dragging interactions
  43394. */
  43395. dragBehavior: PointerDragBehavior;
  43396. private _pointerObserver;
  43397. /**
  43398. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43399. */
  43400. snapDistance: number;
  43401. /**
  43402. * Event that fires each time the gizmo snaps to a new location.
  43403. * * snapDistance is the the change in distance
  43404. */
  43405. onSnapObservable: Observable<{
  43406. snapDistance: number;
  43407. }>;
  43408. private _isEnabled;
  43409. private _parent;
  43410. /**
  43411. * Creates a PlaneRotationGizmo
  43412. * @param gizmoLayer The utility layer the gizmo will be added to
  43413. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43414. * @param color The color of the gizmo
  43415. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43416. */
  43417. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43418. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43419. /**
  43420. * If the gizmo is enabled
  43421. */
  43422. isEnabled: boolean;
  43423. /**
  43424. * Disposes of the gizmo
  43425. */
  43426. dispose(): void;
  43427. }
  43428. }
  43429. declare module BABYLON {
  43430. /**
  43431. * Gizmo that enables rotating a mesh along 3 axis
  43432. */
  43433. export class RotationGizmo extends Gizmo {
  43434. /**
  43435. * Internal gizmo used for interactions on the x axis
  43436. */
  43437. xGizmo: PlaneRotationGizmo;
  43438. /**
  43439. * Internal gizmo used for interactions on the y axis
  43440. */
  43441. yGizmo: PlaneRotationGizmo;
  43442. /**
  43443. * Internal gizmo used for interactions on the z axis
  43444. */
  43445. zGizmo: PlaneRotationGizmo;
  43446. /** Fires an event when any of it's sub gizmos are dragged */
  43447. onDragStartObservable: Observable<unknown>;
  43448. /** Fires an event when any of it's sub gizmos are released from dragging */
  43449. onDragEndObservable: Observable<unknown>;
  43450. private _meshAttached;
  43451. attachedMesh: Nullable<AbstractMesh>;
  43452. /**
  43453. * Creates a RotationGizmo
  43454. * @param gizmoLayer The utility layer the gizmo will be added to
  43455. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43456. */
  43457. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43458. updateGizmoRotationToMatchAttachedMesh: boolean;
  43459. /**
  43460. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43461. */
  43462. snapDistance: number;
  43463. /**
  43464. * Ratio for the scale of the gizmo (Default: 1)
  43465. */
  43466. scaleRatio: number;
  43467. /**
  43468. * Disposes of the gizmo
  43469. */
  43470. dispose(): void;
  43471. /**
  43472. * CustomMeshes are not supported by this gizmo
  43473. * @param mesh The mesh to replace the default mesh of the gizmo
  43474. */
  43475. setCustomMesh(mesh: Mesh): void;
  43476. }
  43477. }
  43478. declare module BABYLON {
  43479. /**
  43480. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43481. */
  43482. export class GizmoManager implements IDisposable {
  43483. private scene;
  43484. /**
  43485. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43486. */
  43487. gizmos: {
  43488. positionGizmo: Nullable<PositionGizmo>;
  43489. rotationGizmo: Nullable<RotationGizmo>;
  43490. scaleGizmo: Nullable<ScaleGizmo>;
  43491. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43492. };
  43493. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43494. clearGizmoOnEmptyPointerEvent: boolean;
  43495. /** Fires an event when the manager is attached to a mesh */
  43496. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43497. private _gizmosEnabled;
  43498. private _pointerObserver;
  43499. private _attachedMesh;
  43500. private _boundingBoxColor;
  43501. private _defaultUtilityLayer;
  43502. private _defaultKeepDepthUtilityLayer;
  43503. /**
  43504. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43505. */
  43506. boundingBoxDragBehavior: SixDofDragBehavior;
  43507. /**
  43508. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43509. */
  43510. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43511. /**
  43512. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43513. */
  43514. usePointerToAttachGizmos: boolean;
  43515. /**
  43516. * Utility layer that the bounding box gizmo belongs to
  43517. */
  43518. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43519. /**
  43520. * Utility layer that all gizmos besides bounding box belong to
  43521. */
  43522. readonly utilityLayer: UtilityLayerRenderer;
  43523. /**
  43524. * Instatiates a gizmo manager
  43525. * @param scene the scene to overlay the gizmos on top of
  43526. */
  43527. constructor(scene: Scene);
  43528. /**
  43529. * Attaches a set of gizmos to the specified mesh
  43530. * @param mesh The mesh the gizmo's should be attached to
  43531. */
  43532. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43533. /**
  43534. * If the position gizmo is enabled
  43535. */
  43536. positionGizmoEnabled: boolean;
  43537. /**
  43538. * If the rotation gizmo is enabled
  43539. */
  43540. rotationGizmoEnabled: boolean;
  43541. /**
  43542. * If the scale gizmo is enabled
  43543. */
  43544. scaleGizmoEnabled: boolean;
  43545. /**
  43546. * If the boundingBox gizmo is enabled
  43547. */
  43548. boundingBoxGizmoEnabled: boolean;
  43549. /**
  43550. * Disposes of the gizmo manager
  43551. */
  43552. dispose(): void;
  43553. }
  43554. }
  43555. declare module BABYLON {
  43556. /**
  43557. * A directional light is defined by a direction (what a surprise!).
  43558. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43559. * 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.
  43560. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43561. */
  43562. export class DirectionalLight extends ShadowLight {
  43563. private _shadowFrustumSize;
  43564. /**
  43565. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43566. */
  43567. /**
  43568. * Specifies a fix frustum size for the shadow generation.
  43569. */
  43570. shadowFrustumSize: number;
  43571. private _shadowOrthoScale;
  43572. /**
  43573. * Gets the shadow projection scale against the optimal computed one.
  43574. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43575. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43576. */
  43577. /**
  43578. * Sets the shadow projection scale against the optimal computed one.
  43579. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43580. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43581. */
  43582. shadowOrthoScale: number;
  43583. /**
  43584. * Automatically compute the projection matrix to best fit (including all the casters)
  43585. * on each frame.
  43586. */
  43587. autoUpdateExtends: boolean;
  43588. private _orthoLeft;
  43589. private _orthoRight;
  43590. private _orthoTop;
  43591. private _orthoBottom;
  43592. /**
  43593. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43594. * The directional light is emitted from everywhere in the given direction.
  43595. * It can cast shadows.
  43596. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43597. * @param name The friendly name of the light
  43598. * @param direction The direction of the light
  43599. * @param scene The scene the light belongs to
  43600. */
  43601. constructor(name: string, direction: Vector3, scene: Scene);
  43602. /**
  43603. * Returns the string "DirectionalLight".
  43604. * @return The class name
  43605. */
  43606. getClassName(): string;
  43607. /**
  43608. * Returns the integer 1.
  43609. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43610. */
  43611. getTypeID(): number;
  43612. /**
  43613. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43614. * Returns the DirectionalLight Shadow projection matrix.
  43615. */
  43616. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43617. /**
  43618. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43619. * Returns the DirectionalLight Shadow projection matrix.
  43620. */
  43621. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43622. /**
  43623. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43624. * Returns the DirectionalLight Shadow projection matrix.
  43625. */
  43626. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43627. protected _buildUniformLayout(): void;
  43628. /**
  43629. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43630. * @param effect The effect to update
  43631. * @param lightIndex The index of the light in the effect to update
  43632. * @returns The directional light
  43633. */
  43634. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43635. /**
  43636. * Gets the minZ used for shadow according to both the scene and the light.
  43637. *
  43638. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43639. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43640. * @param activeCamera The camera we are returning the min for
  43641. * @returns the depth min z
  43642. */
  43643. getDepthMinZ(activeCamera: Camera): number;
  43644. /**
  43645. * Gets the maxZ used for shadow according to both the scene and the light.
  43646. *
  43647. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43648. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43649. * @param activeCamera The camera we are returning the max for
  43650. * @returns the depth max z
  43651. */
  43652. getDepthMaxZ(activeCamera: Camera): number;
  43653. /**
  43654. * Prepares the list of defines specific to the light type.
  43655. * @param defines the list of defines
  43656. * @param lightIndex defines the index of the light for the effect
  43657. */
  43658. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43659. }
  43660. }
  43661. declare module BABYLON {
  43662. /**
  43663. * Class containing static functions to help procedurally build meshes
  43664. */
  43665. export class HemisphereBuilder {
  43666. /**
  43667. * Creates a hemisphere mesh
  43668. * @param name defines the name of the mesh
  43669. * @param options defines the options used to create the mesh
  43670. * @param scene defines the hosting scene
  43671. * @returns the hemisphere mesh
  43672. */
  43673. static CreateHemisphere(name: string, options: {
  43674. segments?: number;
  43675. diameter?: number;
  43676. sideOrientation?: number;
  43677. }, scene: any): Mesh;
  43678. }
  43679. }
  43680. declare module BABYLON {
  43681. /**
  43682. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43683. * These values define a cone of light starting from the position, emitting toward the direction.
  43684. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43685. * and the exponent defines the speed of the decay of the light with distance (reach).
  43686. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43687. */
  43688. export class SpotLight extends ShadowLight {
  43689. private _angle;
  43690. private _innerAngle;
  43691. private _cosHalfAngle;
  43692. private _lightAngleScale;
  43693. private _lightAngleOffset;
  43694. /**
  43695. * Gets the cone angle of the spot light in Radians.
  43696. */
  43697. /**
  43698. * Sets the cone angle of the spot light in Radians.
  43699. */
  43700. angle: number;
  43701. /**
  43702. * Only used in gltf falloff mode, this defines the angle where
  43703. * the directional falloff will start before cutting at angle which could be seen
  43704. * as outer angle.
  43705. */
  43706. /**
  43707. * Only used in gltf falloff mode, this defines the angle where
  43708. * the directional falloff will start before cutting at angle which could be seen
  43709. * as outer angle.
  43710. */
  43711. innerAngle: number;
  43712. private _shadowAngleScale;
  43713. /**
  43714. * Allows scaling the angle of the light for shadow generation only.
  43715. */
  43716. /**
  43717. * Allows scaling the angle of the light for shadow generation only.
  43718. */
  43719. shadowAngleScale: number;
  43720. /**
  43721. * The light decay speed with the distance from the emission spot.
  43722. */
  43723. exponent: number;
  43724. private _projectionTextureMatrix;
  43725. /**
  43726. * Allows reading the projecton texture
  43727. */
  43728. readonly projectionTextureMatrix: Matrix;
  43729. protected _projectionTextureLightNear: number;
  43730. /**
  43731. * Gets the near clip of the Spotlight for texture projection.
  43732. */
  43733. /**
  43734. * Sets the near clip of the Spotlight for texture projection.
  43735. */
  43736. projectionTextureLightNear: number;
  43737. protected _projectionTextureLightFar: number;
  43738. /**
  43739. * Gets the far clip of the Spotlight for texture projection.
  43740. */
  43741. /**
  43742. * Sets the far clip of the Spotlight for texture projection.
  43743. */
  43744. projectionTextureLightFar: number;
  43745. protected _projectionTextureUpDirection: Vector3;
  43746. /**
  43747. * Gets the Up vector of the Spotlight for texture projection.
  43748. */
  43749. /**
  43750. * Sets the Up vector of the Spotlight for texture projection.
  43751. */
  43752. projectionTextureUpDirection: Vector3;
  43753. private _projectionTexture;
  43754. /**
  43755. * Gets the projection texture of the light.
  43756. */
  43757. /**
  43758. * Sets the projection texture of the light.
  43759. */
  43760. projectionTexture: Nullable<BaseTexture>;
  43761. private _projectionTextureViewLightDirty;
  43762. private _projectionTextureProjectionLightDirty;
  43763. private _projectionTextureDirty;
  43764. private _projectionTextureViewTargetVector;
  43765. private _projectionTextureViewLightMatrix;
  43766. private _projectionTextureProjectionLightMatrix;
  43767. private _projectionTextureScalingMatrix;
  43768. /**
  43769. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43770. * It can cast shadows.
  43771. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43772. * @param name The light friendly name
  43773. * @param position The position of the spot light in the scene
  43774. * @param direction The direction of the light in the scene
  43775. * @param angle The cone angle of the light in Radians
  43776. * @param exponent The light decay speed with the distance from the emission spot
  43777. * @param scene The scene the lights belongs to
  43778. */
  43779. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43780. /**
  43781. * Returns the string "SpotLight".
  43782. * @returns the class name
  43783. */
  43784. getClassName(): string;
  43785. /**
  43786. * Returns the integer 2.
  43787. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43788. */
  43789. getTypeID(): number;
  43790. /**
  43791. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43792. */
  43793. protected _setDirection(value: Vector3): void;
  43794. /**
  43795. * Overrides the position setter to recompute the projection texture view light Matrix.
  43796. */
  43797. protected _setPosition(value: Vector3): void;
  43798. /**
  43799. * 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.
  43800. * Returns the SpotLight.
  43801. */
  43802. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43803. protected _computeProjectionTextureViewLightMatrix(): void;
  43804. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43805. /**
  43806. * Main function for light texture projection matrix computing.
  43807. */
  43808. protected _computeProjectionTextureMatrix(): void;
  43809. protected _buildUniformLayout(): void;
  43810. private _computeAngleValues;
  43811. /**
  43812. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43813. * @param effect The effect to update
  43814. * @param lightIndex The index of the light in the effect to update
  43815. * @returns The spot light
  43816. */
  43817. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43818. /**
  43819. * Disposes the light and the associated resources.
  43820. */
  43821. dispose(): void;
  43822. /**
  43823. * Prepares the list of defines specific to the light type.
  43824. * @param defines the list of defines
  43825. * @param lightIndex defines the index of the light for the effect
  43826. */
  43827. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43828. }
  43829. }
  43830. declare module BABYLON {
  43831. /**
  43832. * Gizmo that enables viewing a light
  43833. */
  43834. export class LightGizmo extends Gizmo {
  43835. private _lightMesh;
  43836. private _material;
  43837. private cachedPosition;
  43838. private cachedForward;
  43839. /**
  43840. * Creates a LightGizmo
  43841. * @param gizmoLayer The utility layer the gizmo will be added to
  43842. */
  43843. constructor(gizmoLayer?: UtilityLayerRenderer);
  43844. private _light;
  43845. /**
  43846. * The light that the gizmo is attached to
  43847. */
  43848. light: Nullable<Light>;
  43849. /**
  43850. * @hidden
  43851. * Updates the gizmo to match the attached mesh's position/rotation
  43852. */
  43853. protected _update(): void;
  43854. private static _Scale;
  43855. /**
  43856. * Creates the lines for a light mesh
  43857. */
  43858. private static _createLightLines;
  43859. /**
  43860. * Disposes of the light gizmo
  43861. */
  43862. dispose(): void;
  43863. private static _CreateHemisphericLightMesh;
  43864. private static _CreatePointLightMesh;
  43865. private static _CreateSpotLightMesh;
  43866. private static _CreateDirectionalLightMesh;
  43867. }
  43868. }
  43869. declare module BABYLON {
  43870. /** @hidden */
  43871. export var backgroundFragmentDeclaration: {
  43872. name: string;
  43873. shader: string;
  43874. };
  43875. }
  43876. declare module BABYLON {
  43877. /** @hidden */
  43878. export var backgroundUboDeclaration: {
  43879. name: string;
  43880. shader: string;
  43881. };
  43882. }
  43883. declare module BABYLON {
  43884. /** @hidden */
  43885. export var backgroundPixelShader: {
  43886. name: string;
  43887. shader: string;
  43888. };
  43889. }
  43890. declare module BABYLON {
  43891. /** @hidden */
  43892. export var backgroundVertexDeclaration: {
  43893. name: string;
  43894. shader: string;
  43895. };
  43896. }
  43897. declare module BABYLON {
  43898. /** @hidden */
  43899. export var backgroundVertexShader: {
  43900. name: string;
  43901. shader: string;
  43902. };
  43903. }
  43904. declare module BABYLON {
  43905. /**
  43906. * Background material used to create an efficient environement around your scene.
  43907. */
  43908. export class BackgroundMaterial extends PushMaterial {
  43909. /**
  43910. * Standard reflectance value at parallel view angle.
  43911. */
  43912. static StandardReflectance0: number;
  43913. /**
  43914. * Standard reflectance value at grazing angle.
  43915. */
  43916. static StandardReflectance90: number;
  43917. protected _primaryColor: Color3;
  43918. /**
  43919. * Key light Color (multiply against the environement texture)
  43920. */
  43921. primaryColor: Color3;
  43922. protected __perceptualColor: Nullable<Color3>;
  43923. /**
  43924. * Experimental Internal Use Only.
  43925. *
  43926. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43927. * This acts as a helper to set the primary color to a more "human friendly" value.
  43928. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43929. * output color as close as possible from the chosen value.
  43930. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43931. * part of lighting setup.)
  43932. */
  43933. _perceptualColor: Nullable<Color3>;
  43934. protected _primaryColorShadowLevel: float;
  43935. /**
  43936. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43937. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43938. */
  43939. primaryColorShadowLevel: float;
  43940. protected _primaryColorHighlightLevel: float;
  43941. /**
  43942. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43943. * The primary color is used at the level chosen to define what the white area would look.
  43944. */
  43945. primaryColorHighlightLevel: float;
  43946. protected _reflectionTexture: Nullable<BaseTexture>;
  43947. /**
  43948. * Reflection Texture used in the material.
  43949. * Should be author in a specific way for the best result (refer to the documentation).
  43950. */
  43951. reflectionTexture: Nullable<BaseTexture>;
  43952. protected _reflectionBlur: float;
  43953. /**
  43954. * Reflection Texture level of blur.
  43955. *
  43956. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43957. * texture twice.
  43958. */
  43959. reflectionBlur: float;
  43960. protected _diffuseTexture: Nullable<BaseTexture>;
  43961. /**
  43962. * Diffuse Texture used in the material.
  43963. * Should be author in a specific way for the best result (refer to the documentation).
  43964. */
  43965. diffuseTexture: Nullable<BaseTexture>;
  43966. protected _shadowLights: Nullable<IShadowLight[]>;
  43967. /**
  43968. * Specify the list of lights casting shadow on the material.
  43969. * All scene shadow lights will be included if null.
  43970. */
  43971. shadowLights: Nullable<IShadowLight[]>;
  43972. protected _shadowLevel: float;
  43973. /**
  43974. * Helps adjusting the shadow to a softer level if required.
  43975. * 0 means black shadows and 1 means no shadows.
  43976. */
  43977. shadowLevel: float;
  43978. protected _sceneCenter: Vector3;
  43979. /**
  43980. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43981. * It is usually zero but might be interesting to modify according to your setup.
  43982. */
  43983. sceneCenter: Vector3;
  43984. protected _opacityFresnel: boolean;
  43985. /**
  43986. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43987. * This helps ensuring a nice transition when the camera goes under the ground.
  43988. */
  43989. opacityFresnel: boolean;
  43990. protected _reflectionFresnel: boolean;
  43991. /**
  43992. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43993. * This helps adding a mirror texture on the ground.
  43994. */
  43995. reflectionFresnel: boolean;
  43996. protected _reflectionFalloffDistance: number;
  43997. /**
  43998. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43999. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44000. */
  44001. reflectionFalloffDistance: number;
  44002. protected _reflectionAmount: number;
  44003. /**
  44004. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44005. */
  44006. reflectionAmount: number;
  44007. protected _reflectionReflectance0: number;
  44008. /**
  44009. * This specifies the weight of the reflection at grazing angle.
  44010. */
  44011. reflectionReflectance0: number;
  44012. protected _reflectionReflectance90: number;
  44013. /**
  44014. * This specifies the weight of the reflection at a perpendicular point of view.
  44015. */
  44016. reflectionReflectance90: number;
  44017. /**
  44018. * Sets the reflection reflectance fresnel values according to the default standard
  44019. * empirically know to work well :-)
  44020. */
  44021. reflectionStandardFresnelWeight: number;
  44022. protected _useRGBColor: boolean;
  44023. /**
  44024. * Helps to directly use the maps channels instead of their level.
  44025. */
  44026. useRGBColor: boolean;
  44027. protected _enableNoise: boolean;
  44028. /**
  44029. * This helps reducing the banding effect that could occur on the background.
  44030. */
  44031. enableNoise: boolean;
  44032. /**
  44033. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44034. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44035. * Recommended to be keep at 1.0 except for special cases.
  44036. */
  44037. fovMultiplier: number;
  44038. private _fovMultiplier;
  44039. /**
  44040. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44041. */
  44042. useEquirectangularFOV: boolean;
  44043. private _maxSimultaneousLights;
  44044. /**
  44045. * Number of Simultaneous lights allowed on the material.
  44046. */
  44047. maxSimultaneousLights: int;
  44048. /**
  44049. * Default configuration related to image processing available in the Background Material.
  44050. */
  44051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44052. /**
  44053. * Keep track of the image processing observer to allow dispose and replace.
  44054. */
  44055. private _imageProcessingObserver;
  44056. /**
  44057. * Attaches a new image processing configuration to the PBR Material.
  44058. * @param configuration (if null the scene configuration will be use)
  44059. */
  44060. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44061. /**
  44062. * Gets the image processing configuration used either in this material.
  44063. */
  44064. /**
  44065. * Sets the Default image processing configuration used either in the this material.
  44066. *
  44067. * If sets to null, the scene one is in use.
  44068. */
  44069. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44070. /**
  44071. * Gets wether the color curves effect is enabled.
  44072. */
  44073. /**
  44074. * Sets wether the color curves effect is enabled.
  44075. */
  44076. cameraColorCurvesEnabled: boolean;
  44077. /**
  44078. * Gets wether the color grading effect is enabled.
  44079. */
  44080. /**
  44081. * Gets wether the color grading effect is enabled.
  44082. */
  44083. cameraColorGradingEnabled: boolean;
  44084. /**
  44085. * Gets wether tonemapping is enabled or not.
  44086. */
  44087. /**
  44088. * Sets wether tonemapping is enabled or not
  44089. */
  44090. cameraToneMappingEnabled: boolean;
  44091. /**
  44092. * The camera exposure used on this material.
  44093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44094. * This corresponds to a photographic exposure.
  44095. */
  44096. /**
  44097. * The camera exposure used on this material.
  44098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44099. * This corresponds to a photographic exposure.
  44100. */
  44101. cameraExposure: float;
  44102. /**
  44103. * Gets The camera contrast used on this material.
  44104. */
  44105. /**
  44106. * Sets The camera contrast used on this material.
  44107. */
  44108. cameraContrast: float;
  44109. /**
  44110. * Gets the Color Grading 2D Lookup Texture.
  44111. */
  44112. /**
  44113. * Sets the Color Grading 2D Lookup Texture.
  44114. */
  44115. cameraColorGradingTexture: Nullable<BaseTexture>;
  44116. /**
  44117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44119. * 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;
  44120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44121. */
  44122. /**
  44123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44125. * 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;
  44126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44127. */
  44128. cameraColorCurves: Nullable<ColorCurves>;
  44129. /**
  44130. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44131. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44132. */
  44133. switchToBGR: boolean;
  44134. private _renderTargets;
  44135. private _reflectionControls;
  44136. private _white;
  44137. private _primaryShadowColor;
  44138. private _primaryHighlightColor;
  44139. /**
  44140. * Instantiates a Background Material in the given scene
  44141. * @param name The friendly name of the material
  44142. * @param scene The scene to add the material to
  44143. */
  44144. constructor(name: string, scene: Scene);
  44145. /**
  44146. * Gets a boolean indicating that current material needs to register RTT
  44147. */
  44148. readonly hasRenderTargetTextures: boolean;
  44149. /**
  44150. * The entire material has been created in order to prevent overdraw.
  44151. * @returns false
  44152. */
  44153. needAlphaTesting(): boolean;
  44154. /**
  44155. * The entire material has been created in order to prevent overdraw.
  44156. * @returns true if blending is enable
  44157. */
  44158. needAlphaBlending(): boolean;
  44159. /**
  44160. * Checks wether the material is ready to be rendered for a given mesh.
  44161. * @param mesh The mesh to render
  44162. * @param subMesh The submesh to check against
  44163. * @param useInstances Specify wether or not the material is used with instances
  44164. * @returns true if all the dependencies are ready (Textures, Effects...)
  44165. */
  44166. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44167. /**
  44168. * Compute the primary color according to the chosen perceptual color.
  44169. */
  44170. private _computePrimaryColorFromPerceptualColor;
  44171. /**
  44172. * Compute the highlights and shadow colors according to their chosen levels.
  44173. */
  44174. private _computePrimaryColors;
  44175. /**
  44176. * Build the uniform buffer used in the material.
  44177. */
  44178. buildUniformLayout(): void;
  44179. /**
  44180. * Unbind the material.
  44181. */
  44182. unbind(): void;
  44183. /**
  44184. * Bind only the world matrix to the material.
  44185. * @param world The world matrix to bind.
  44186. */
  44187. bindOnlyWorldMatrix(world: Matrix): void;
  44188. /**
  44189. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44190. * @param world The world matrix to bind.
  44191. * @param subMesh The submesh to bind for.
  44192. */
  44193. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44194. /**
  44195. * Dispose the material.
  44196. * @param forceDisposeEffect Force disposal of the associated effect.
  44197. * @param forceDisposeTextures Force disposal of the associated textures.
  44198. */
  44199. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44200. /**
  44201. * Clones the material.
  44202. * @param name The cloned name.
  44203. * @returns The cloned material.
  44204. */
  44205. clone(name: string): BackgroundMaterial;
  44206. /**
  44207. * Serializes the current material to its JSON representation.
  44208. * @returns The JSON representation.
  44209. */
  44210. serialize(): any;
  44211. /**
  44212. * Gets the class name of the material
  44213. * @returns "BackgroundMaterial"
  44214. */
  44215. getClassName(): string;
  44216. /**
  44217. * Parse a JSON input to create back a background material.
  44218. * @param source The JSON data to parse
  44219. * @param scene The scene to create the parsed material in
  44220. * @param rootUrl The root url of the assets the material depends upon
  44221. * @returns the instantiated BackgroundMaterial.
  44222. */
  44223. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44224. }
  44225. }
  44226. declare module BABYLON {
  44227. /**
  44228. * Represents the different options available during the creation of
  44229. * a Environment helper.
  44230. *
  44231. * This can control the default ground, skybox and image processing setup of your scene.
  44232. */
  44233. export interface IEnvironmentHelperOptions {
  44234. /**
  44235. * Specifies wether or not to create a ground.
  44236. * True by default.
  44237. */
  44238. createGround: boolean;
  44239. /**
  44240. * Specifies the ground size.
  44241. * 15 by default.
  44242. */
  44243. groundSize: number;
  44244. /**
  44245. * The texture used on the ground for the main color.
  44246. * Comes from the BabylonJS CDN by default.
  44247. *
  44248. * Remarks: Can be either a texture or a url.
  44249. */
  44250. groundTexture: string | BaseTexture;
  44251. /**
  44252. * The color mixed in the ground texture by default.
  44253. * BabylonJS clearColor by default.
  44254. */
  44255. groundColor: Color3;
  44256. /**
  44257. * Specifies the ground opacity.
  44258. * 1 by default.
  44259. */
  44260. groundOpacity: number;
  44261. /**
  44262. * Enables the ground to receive shadows.
  44263. * True by default.
  44264. */
  44265. enableGroundShadow: boolean;
  44266. /**
  44267. * Helps preventing the shadow to be fully black on the ground.
  44268. * 0.5 by default.
  44269. */
  44270. groundShadowLevel: number;
  44271. /**
  44272. * Creates a mirror texture attach to the ground.
  44273. * false by default.
  44274. */
  44275. enableGroundMirror: boolean;
  44276. /**
  44277. * Specifies the ground mirror size ratio.
  44278. * 0.3 by default as the default kernel is 64.
  44279. */
  44280. groundMirrorSizeRatio: number;
  44281. /**
  44282. * Specifies the ground mirror blur kernel size.
  44283. * 64 by default.
  44284. */
  44285. groundMirrorBlurKernel: number;
  44286. /**
  44287. * Specifies the ground mirror visibility amount.
  44288. * 1 by default
  44289. */
  44290. groundMirrorAmount: number;
  44291. /**
  44292. * Specifies the ground mirror reflectance weight.
  44293. * This uses the standard weight of the background material to setup the fresnel effect
  44294. * of the mirror.
  44295. * 1 by default.
  44296. */
  44297. groundMirrorFresnelWeight: number;
  44298. /**
  44299. * Specifies the ground mirror Falloff distance.
  44300. * This can helps reducing the size of the reflection.
  44301. * 0 by Default.
  44302. */
  44303. groundMirrorFallOffDistance: number;
  44304. /**
  44305. * Specifies the ground mirror texture type.
  44306. * Unsigned Int by Default.
  44307. */
  44308. groundMirrorTextureType: number;
  44309. /**
  44310. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44311. * the shown objects.
  44312. */
  44313. groundYBias: number;
  44314. /**
  44315. * Specifies wether or not to create a skybox.
  44316. * True by default.
  44317. */
  44318. createSkybox: boolean;
  44319. /**
  44320. * Specifies the skybox size.
  44321. * 20 by default.
  44322. */
  44323. skyboxSize: number;
  44324. /**
  44325. * The texture used on the skybox for the main color.
  44326. * Comes from the BabylonJS CDN by default.
  44327. *
  44328. * Remarks: Can be either a texture or a url.
  44329. */
  44330. skyboxTexture: string | BaseTexture;
  44331. /**
  44332. * The color mixed in the skybox texture by default.
  44333. * BabylonJS clearColor by default.
  44334. */
  44335. skyboxColor: Color3;
  44336. /**
  44337. * The background rotation around the Y axis of the scene.
  44338. * This helps aligning the key lights of your scene with the background.
  44339. * 0 by default.
  44340. */
  44341. backgroundYRotation: number;
  44342. /**
  44343. * Compute automatically the size of the elements to best fit with the scene.
  44344. */
  44345. sizeAuto: boolean;
  44346. /**
  44347. * Default position of the rootMesh if autoSize is not true.
  44348. */
  44349. rootPosition: Vector3;
  44350. /**
  44351. * Sets up the image processing in the scene.
  44352. * true by default.
  44353. */
  44354. setupImageProcessing: boolean;
  44355. /**
  44356. * The texture used as your environment texture in the scene.
  44357. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44358. *
  44359. * Remarks: Can be either a texture or a url.
  44360. */
  44361. environmentTexture: string | BaseTexture;
  44362. /**
  44363. * The value of the exposure to apply to the scene.
  44364. * 0.6 by default if setupImageProcessing is true.
  44365. */
  44366. cameraExposure: number;
  44367. /**
  44368. * The value of the contrast to apply to the scene.
  44369. * 1.6 by default if setupImageProcessing is true.
  44370. */
  44371. cameraContrast: number;
  44372. /**
  44373. * Specifies wether or not tonemapping should be enabled in the scene.
  44374. * true by default if setupImageProcessing is true.
  44375. */
  44376. toneMappingEnabled: boolean;
  44377. }
  44378. /**
  44379. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44380. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44381. * It also helps with the default setup of your imageProcessing configuration.
  44382. */
  44383. export class EnvironmentHelper {
  44384. /**
  44385. * Default ground texture URL.
  44386. */
  44387. private static _groundTextureCDNUrl;
  44388. /**
  44389. * Default skybox texture URL.
  44390. */
  44391. private static _skyboxTextureCDNUrl;
  44392. /**
  44393. * Default environment texture URL.
  44394. */
  44395. private static _environmentTextureCDNUrl;
  44396. /**
  44397. * Creates the default options for the helper.
  44398. */
  44399. private static _getDefaultOptions;
  44400. private _rootMesh;
  44401. /**
  44402. * Gets the root mesh created by the helper.
  44403. */
  44404. readonly rootMesh: Mesh;
  44405. private _skybox;
  44406. /**
  44407. * Gets the skybox created by the helper.
  44408. */
  44409. readonly skybox: Nullable<Mesh>;
  44410. private _skyboxTexture;
  44411. /**
  44412. * Gets the skybox texture created by the helper.
  44413. */
  44414. readonly skyboxTexture: Nullable<BaseTexture>;
  44415. private _skyboxMaterial;
  44416. /**
  44417. * Gets the skybox material created by the helper.
  44418. */
  44419. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44420. private _ground;
  44421. /**
  44422. * Gets the ground mesh created by the helper.
  44423. */
  44424. readonly ground: Nullable<Mesh>;
  44425. private _groundTexture;
  44426. /**
  44427. * Gets the ground texture created by the helper.
  44428. */
  44429. readonly groundTexture: Nullable<BaseTexture>;
  44430. private _groundMirror;
  44431. /**
  44432. * Gets the ground mirror created by the helper.
  44433. */
  44434. readonly groundMirror: Nullable<MirrorTexture>;
  44435. /**
  44436. * Gets the ground mirror render list to helps pushing the meshes
  44437. * you wish in the ground reflection.
  44438. */
  44439. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44440. private _groundMaterial;
  44441. /**
  44442. * Gets the ground material created by the helper.
  44443. */
  44444. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44445. /**
  44446. * Stores the creation options.
  44447. */
  44448. private readonly _scene;
  44449. private _options;
  44450. /**
  44451. * This observable will be notified with any error during the creation of the environment,
  44452. * mainly texture creation errors.
  44453. */
  44454. onErrorObservable: Observable<{
  44455. message?: string;
  44456. exception?: any;
  44457. }>;
  44458. /**
  44459. * constructor
  44460. * @param options Defines the options we want to customize the helper
  44461. * @param scene The scene to add the material to
  44462. */
  44463. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44464. /**
  44465. * Updates the background according to the new options
  44466. * @param options
  44467. */
  44468. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44469. /**
  44470. * Sets the primary color of all the available elements.
  44471. * @param color the main color to affect to the ground and the background
  44472. */
  44473. setMainColor(color: Color3): void;
  44474. /**
  44475. * Setup the image processing according to the specified options.
  44476. */
  44477. private _setupImageProcessing;
  44478. /**
  44479. * Setup the environment texture according to the specified options.
  44480. */
  44481. private _setupEnvironmentTexture;
  44482. /**
  44483. * Setup the background according to the specified options.
  44484. */
  44485. private _setupBackground;
  44486. /**
  44487. * Get the scene sizes according to the setup.
  44488. */
  44489. private _getSceneSize;
  44490. /**
  44491. * Setup the ground according to the specified options.
  44492. */
  44493. private _setupGround;
  44494. /**
  44495. * Setup the ground material according to the specified options.
  44496. */
  44497. private _setupGroundMaterial;
  44498. /**
  44499. * Setup the ground diffuse texture according to the specified options.
  44500. */
  44501. private _setupGroundDiffuseTexture;
  44502. /**
  44503. * Setup the ground mirror texture according to the specified options.
  44504. */
  44505. private _setupGroundMirrorTexture;
  44506. /**
  44507. * Setup the ground to receive the mirror texture.
  44508. */
  44509. private _setupMirrorInGroundMaterial;
  44510. /**
  44511. * Setup the skybox according to the specified options.
  44512. */
  44513. private _setupSkybox;
  44514. /**
  44515. * Setup the skybox material according to the specified options.
  44516. */
  44517. private _setupSkyboxMaterial;
  44518. /**
  44519. * Setup the skybox reflection texture according to the specified options.
  44520. */
  44521. private _setupSkyboxReflectionTexture;
  44522. private _errorHandler;
  44523. /**
  44524. * Dispose all the elements created by the Helper.
  44525. */
  44526. dispose(): void;
  44527. }
  44528. }
  44529. declare module BABYLON {
  44530. /**
  44531. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44532. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44533. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44535. */
  44536. export class PhotoDome extends TransformNode {
  44537. /**
  44538. * Define the image as a Monoscopic panoramic 360 image.
  44539. */
  44540. static readonly MODE_MONOSCOPIC: number;
  44541. /**
  44542. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44543. */
  44544. static readonly MODE_TOPBOTTOM: number;
  44545. /**
  44546. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44547. */
  44548. static readonly MODE_SIDEBYSIDE: number;
  44549. private _useDirectMapping;
  44550. /**
  44551. * The texture being displayed on the sphere
  44552. */
  44553. protected _photoTexture: Texture;
  44554. /**
  44555. * Gets or sets the texture being displayed on the sphere
  44556. */
  44557. photoTexture: Texture;
  44558. /**
  44559. * Observable raised when an error occured while loading the 360 image
  44560. */
  44561. onLoadErrorObservable: Observable<string>;
  44562. /**
  44563. * The skybox material
  44564. */
  44565. protected _material: BackgroundMaterial;
  44566. /**
  44567. * The surface used for the skybox
  44568. */
  44569. protected _mesh: Mesh;
  44570. /**
  44571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44572. * Also see the options.resolution property.
  44573. */
  44574. fovMultiplier: number;
  44575. private _imageMode;
  44576. /**
  44577. * Gets or set the current video mode for the video. It can be:
  44578. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44579. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44580. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44581. */
  44582. imageMode: number;
  44583. /**
  44584. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44585. * @param name Element's name, child elements will append suffixes for their own names.
  44586. * @param urlsOfPhoto defines the url of the photo to display
  44587. * @param options defines an object containing optional or exposed sub element properties
  44588. * @param onError defines a callback called when an error occured while loading the texture
  44589. */
  44590. constructor(name: string, urlOfPhoto: string, options: {
  44591. resolution?: number;
  44592. size?: number;
  44593. useDirectMapping?: boolean;
  44594. faceForward?: boolean;
  44595. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44596. private _onBeforeCameraRenderObserver;
  44597. private _changeImageMode;
  44598. /**
  44599. * Releases resources associated with this node.
  44600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44602. */
  44603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44604. }
  44605. }
  44606. declare module BABYLON {
  44607. /** @hidden */
  44608. export var rgbdDecodePixelShader: {
  44609. name: string;
  44610. shader: string;
  44611. };
  44612. }
  44613. declare module BABYLON {
  44614. /**
  44615. * Class used to host texture specific utilities
  44616. */
  44617. export class BRDFTextureTools {
  44618. /**
  44619. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44620. * @param texture the texture to expand.
  44621. */
  44622. private static _ExpandDefaultBRDFTexture;
  44623. /**
  44624. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44625. * @param scene defines the hosting scene
  44626. * @returns the environment BRDF texture
  44627. */
  44628. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44629. private static _environmentBRDFBase64Texture;
  44630. }
  44631. }
  44632. declare module BABYLON {
  44633. /**
  44634. * @hidden
  44635. */
  44636. export interface IMaterialClearCoatDefines {
  44637. CLEARCOAT: boolean;
  44638. CLEARCOAT_DEFAULTIOR: boolean;
  44639. CLEARCOAT_TEXTURE: boolean;
  44640. CLEARCOAT_TEXTUREDIRECTUV: number;
  44641. CLEARCOAT_BUMP: boolean;
  44642. CLEARCOAT_BUMPDIRECTUV: number;
  44643. CLEARCOAT_TINT: boolean;
  44644. CLEARCOAT_TINT_TEXTURE: boolean;
  44645. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44646. /** @hidden */
  44647. _areTexturesDirty: boolean;
  44648. }
  44649. /**
  44650. * Define the code related to the clear coat parameters of the pbr material.
  44651. */
  44652. export class PBRClearCoatConfiguration {
  44653. /**
  44654. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44655. * The default fits with a polyurethane material.
  44656. */
  44657. private static readonly _DefaultIndexOfRefraction;
  44658. private _isEnabled;
  44659. /**
  44660. * Defines if the clear coat is enabled in the material.
  44661. */
  44662. isEnabled: boolean;
  44663. /**
  44664. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44665. */
  44666. intensity: number;
  44667. /**
  44668. * Defines the clear coat layer roughness.
  44669. */
  44670. roughness: number;
  44671. private _indexOfRefraction;
  44672. /**
  44673. * Defines the index of refraction of the clear coat.
  44674. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44675. * The default fits with a polyurethane material.
  44676. * Changing the default value is more performance intensive.
  44677. */
  44678. indexOfRefraction: number;
  44679. private _texture;
  44680. /**
  44681. * Stores the clear coat values in a texture.
  44682. */
  44683. texture: Nullable<BaseTexture>;
  44684. private _bumpTexture;
  44685. /**
  44686. * Define the clear coat specific bump texture.
  44687. */
  44688. bumpTexture: Nullable<BaseTexture>;
  44689. private _isTintEnabled;
  44690. /**
  44691. * Defines if the clear coat tint is enabled in the material.
  44692. */
  44693. isTintEnabled: boolean;
  44694. /**
  44695. * Defines the clear coat tint of the material.
  44696. * This is only use if tint is enabled
  44697. */
  44698. tintColor: Color3;
  44699. /**
  44700. * Defines the distance at which the tint color should be found in the
  44701. * clear coat media.
  44702. * This is only use if tint is enabled
  44703. */
  44704. tintColorAtDistance: number;
  44705. /**
  44706. * Defines the clear coat layer thickness.
  44707. * This is only use if tint is enabled
  44708. */
  44709. tintThickness: number;
  44710. private _tintTexture;
  44711. /**
  44712. * Stores the clear tint values in a texture.
  44713. * rgb is tint
  44714. * a is a thickness factor
  44715. */
  44716. tintTexture: Nullable<BaseTexture>;
  44717. /** @hidden */
  44718. private _internalMarkAllSubMeshesAsTexturesDirty;
  44719. /** @hidden */
  44720. _markAllSubMeshesAsTexturesDirty(): void;
  44721. /**
  44722. * Instantiate a new istance of clear coat configuration.
  44723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44724. */
  44725. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44726. /**
  44727. * Gets wehter the submesh is ready to be used or not.
  44728. * @param defines the list of "defines" to update.
  44729. * @param scene defines the scene the material belongs to.
  44730. * @param engine defines the engine the material belongs to.
  44731. * @param disableBumpMap defines wether the material disables bump or not.
  44732. * @returns - boolean indicating that the submesh is ready or not.
  44733. */
  44734. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44735. /**
  44736. * Checks to see if a texture is used in the material.
  44737. * @param defines the list of "defines" to update.
  44738. * @param scene defines the scene to the material belongs to.
  44739. */
  44740. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44741. /**
  44742. * Binds the material data.
  44743. * @param uniformBuffer defines the Uniform buffer to fill in.
  44744. * @param scene defines the scene the material belongs to.
  44745. * @param engine defines the engine the material belongs to.
  44746. * @param disableBumpMap defines wether the material disables bump or not.
  44747. * @param isFrozen defines wether the material is frozen or not.
  44748. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44749. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44750. */
  44751. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44752. /**
  44753. * Checks to see if a texture is used in the material.
  44754. * @param texture - Base texture to use.
  44755. * @returns - Boolean specifying if a texture is used in the material.
  44756. */
  44757. hasTexture(texture: BaseTexture): boolean;
  44758. /**
  44759. * Returns an array of the actively used textures.
  44760. * @param activeTextures Array of BaseTextures
  44761. */
  44762. getActiveTextures(activeTextures: BaseTexture[]): void;
  44763. /**
  44764. * Returns the animatable textures.
  44765. * @param animatables Array of animatable textures.
  44766. */
  44767. getAnimatables(animatables: IAnimatable[]): void;
  44768. /**
  44769. * Disposes the resources of the material.
  44770. * @param forceDisposeTextures - Forces the disposal of all textures.
  44771. */
  44772. dispose(forceDisposeTextures?: boolean): void;
  44773. /**
  44774. * Get the current class name of the texture useful for serialization or dynamic coding.
  44775. * @returns "PBRClearCoatConfiguration"
  44776. */
  44777. getClassName(): string;
  44778. /**
  44779. * Add fallbacks to the effect fallbacks list.
  44780. * @param defines defines the Base texture to use.
  44781. * @param fallbacks defines the current fallback list.
  44782. * @param currentRank defines the current fallback rank.
  44783. * @returns the new fallback rank.
  44784. */
  44785. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44786. /**
  44787. * Add the required uniforms to the current list.
  44788. * @param uniforms defines the current uniform list.
  44789. */
  44790. static AddUniforms(uniforms: string[]): void;
  44791. /**
  44792. * Add the required samplers to the current list.
  44793. * @param samplers defines the current sampler list.
  44794. */
  44795. static AddSamplers(samplers: string[]): void;
  44796. /**
  44797. * Add the required uniforms to the current buffer.
  44798. * @param uniformBuffer defines the current uniform buffer.
  44799. */
  44800. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44801. /**
  44802. * Makes a duplicate of the current configuration into another one.
  44803. * @param clearCoatConfiguration define the config where to copy the info
  44804. */
  44805. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44806. /**
  44807. * Serializes this clear coat configuration.
  44808. * @returns - An object with the serialized config.
  44809. */
  44810. serialize(): any;
  44811. /**
  44812. * Parses a anisotropy Configuration from a serialized object.
  44813. * @param source - Serialized object.
  44814. * @param scene Defines the scene we are parsing for
  44815. * @param rootUrl Defines the rootUrl to load from
  44816. */
  44817. parse(source: any, scene: Scene, rootUrl: string): void;
  44818. }
  44819. }
  44820. declare module BABYLON {
  44821. /**
  44822. * @hidden
  44823. */
  44824. export interface IMaterialAnisotropicDefines {
  44825. ANISOTROPIC: boolean;
  44826. ANISOTROPIC_TEXTURE: boolean;
  44827. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44828. MAINUV1: boolean;
  44829. _areTexturesDirty: boolean;
  44830. _needUVs: boolean;
  44831. }
  44832. /**
  44833. * Define the code related to the anisotropic parameters of the pbr material.
  44834. */
  44835. export class PBRAnisotropicConfiguration {
  44836. private _isEnabled;
  44837. /**
  44838. * Defines if the anisotropy is enabled in the material.
  44839. */
  44840. isEnabled: boolean;
  44841. /**
  44842. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44843. */
  44844. intensity: number;
  44845. /**
  44846. * Defines if the effect is along the tangents, bitangents or in between.
  44847. * By default, the effect is "strectching" the highlights along the tangents.
  44848. */
  44849. direction: Vector2;
  44850. private _texture;
  44851. /**
  44852. * Stores the anisotropy values in a texture.
  44853. * rg is direction (like normal from -1 to 1)
  44854. * b is a intensity
  44855. */
  44856. texture: Nullable<BaseTexture>;
  44857. /** @hidden */
  44858. private _internalMarkAllSubMeshesAsTexturesDirty;
  44859. /** @hidden */
  44860. _markAllSubMeshesAsTexturesDirty(): void;
  44861. /**
  44862. * Instantiate a new istance of anisotropy configuration.
  44863. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44864. */
  44865. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44866. /**
  44867. * Specifies that the submesh is ready to be used.
  44868. * @param defines the list of "defines" to update.
  44869. * @param scene defines the scene the material belongs to.
  44870. * @returns - boolean indicating that the submesh is ready or not.
  44871. */
  44872. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44873. /**
  44874. * Checks to see if a texture is used in the material.
  44875. * @param defines the list of "defines" to update.
  44876. * @param mesh the mesh we are preparing the defines for.
  44877. * @param scene defines the scene the material belongs to.
  44878. */
  44879. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44880. /**
  44881. * Binds the material data.
  44882. * @param uniformBuffer defines the Uniform buffer to fill in.
  44883. * @param scene defines the scene the material belongs to.
  44884. * @param isFrozen defines wether the material is frozen or not.
  44885. */
  44886. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44887. /**
  44888. * Checks to see if a texture is used in the material.
  44889. * @param texture - Base texture to use.
  44890. * @returns - Boolean specifying if a texture is used in the material.
  44891. */
  44892. hasTexture(texture: BaseTexture): boolean;
  44893. /**
  44894. * Returns an array of the actively used textures.
  44895. * @param activeTextures Array of BaseTextures
  44896. */
  44897. getActiveTextures(activeTextures: BaseTexture[]): void;
  44898. /**
  44899. * Returns the animatable textures.
  44900. * @param animatables Array of animatable textures.
  44901. */
  44902. getAnimatables(animatables: IAnimatable[]): void;
  44903. /**
  44904. * Disposes the resources of the material.
  44905. * @param forceDisposeTextures - Forces the disposal of all textures.
  44906. */
  44907. dispose(forceDisposeTextures?: boolean): void;
  44908. /**
  44909. * Get the current class name of the texture useful for serialization or dynamic coding.
  44910. * @returns "PBRAnisotropicConfiguration"
  44911. */
  44912. getClassName(): string;
  44913. /**
  44914. * Add fallbacks to the effect fallbacks list.
  44915. * @param defines defines the Base texture to use.
  44916. * @param fallbacks defines the current fallback list.
  44917. * @param currentRank defines the current fallback rank.
  44918. * @returns the new fallback rank.
  44919. */
  44920. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44921. /**
  44922. * Add the required uniforms to the current list.
  44923. * @param uniforms defines the current uniform list.
  44924. */
  44925. static AddUniforms(uniforms: string[]): void;
  44926. /**
  44927. * Add the required uniforms to the current buffer.
  44928. * @param uniformBuffer defines the current uniform buffer.
  44929. */
  44930. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44931. /**
  44932. * Add the required samplers to the current list.
  44933. * @param samplers defines the current sampler list.
  44934. */
  44935. static AddSamplers(samplers: string[]): void;
  44936. /**
  44937. * Makes a duplicate of the current configuration into another one.
  44938. * @param anisotropicConfiguration define the config where to copy the info
  44939. */
  44940. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44941. /**
  44942. * Serializes this anisotropy configuration.
  44943. * @returns - An object with the serialized config.
  44944. */
  44945. serialize(): any;
  44946. /**
  44947. * Parses a anisotropy Configuration from a serialized object.
  44948. * @param source - Serialized object.
  44949. * @param scene Defines the scene we are parsing for
  44950. * @param rootUrl Defines the rootUrl to load from
  44951. */
  44952. parse(source: any, scene: Scene, rootUrl: string): void;
  44953. }
  44954. }
  44955. declare module BABYLON {
  44956. /**
  44957. * @hidden
  44958. */
  44959. export interface IMaterialBRDFDefines {
  44960. BRDF_V_HEIGHT_CORRELATED: boolean;
  44961. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44962. SPHERICAL_HARMONICS: boolean;
  44963. /** @hidden */
  44964. _areMiscDirty: boolean;
  44965. }
  44966. /**
  44967. * Define the code related to the BRDF parameters of the pbr material.
  44968. */
  44969. export class PBRBRDFConfiguration {
  44970. /**
  44971. * Default value used for the energy conservation.
  44972. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44973. */
  44974. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44975. /**
  44976. * Default value used for the Smith Visibility Height Correlated mode.
  44977. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44978. */
  44979. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44980. /**
  44981. * Default value used for the IBL diffuse part.
  44982. * This can help switching back to the polynomials mode globally which is a tiny bit
  44983. * less GPU intensive at the drawback of a lower quality.
  44984. */
  44985. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44986. private _useEnergyConservation;
  44987. /**
  44988. * Defines if the material uses energy conservation.
  44989. */
  44990. useEnergyConservation: boolean;
  44991. private _useSmithVisibilityHeightCorrelated;
  44992. /**
  44993. * LEGACY Mode set to false
  44994. * Defines if the material uses height smith correlated visibility term.
  44995. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44996. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44997. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44998. * Not relying on height correlated will also disable energy conservation.
  44999. */
  45000. useSmithVisibilityHeightCorrelated: boolean;
  45001. private _useSphericalHarmonics;
  45002. /**
  45003. * LEGACY Mode set to false
  45004. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45005. * diffuse part of the IBL.
  45006. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45007. * to the ground truth.
  45008. */
  45009. useSphericalHarmonics: boolean;
  45010. /** @hidden */
  45011. private _internalMarkAllSubMeshesAsMiscDirty;
  45012. /** @hidden */
  45013. _markAllSubMeshesAsMiscDirty(): void;
  45014. /**
  45015. * Instantiate a new istance of clear coat configuration.
  45016. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45017. */
  45018. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45019. /**
  45020. * Checks to see if a texture is used in the material.
  45021. * @param defines the list of "defines" to update.
  45022. */
  45023. prepareDefines(defines: IMaterialBRDFDefines): void;
  45024. /**
  45025. * Get the current class name of the texture useful for serialization or dynamic coding.
  45026. * @returns "PBRClearCoatConfiguration"
  45027. */
  45028. getClassName(): string;
  45029. /**
  45030. * Makes a duplicate of the current configuration into another one.
  45031. * @param brdfConfiguration define the config where to copy the info
  45032. */
  45033. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45034. /**
  45035. * Serializes this BRDF configuration.
  45036. * @returns - An object with the serialized config.
  45037. */
  45038. serialize(): any;
  45039. /**
  45040. * Parses a anisotropy Configuration from a serialized object.
  45041. * @param source - Serialized object.
  45042. * @param scene Defines the scene we are parsing for
  45043. * @param rootUrl Defines the rootUrl to load from
  45044. */
  45045. parse(source: any, scene: Scene, rootUrl: string): void;
  45046. }
  45047. }
  45048. declare module BABYLON {
  45049. /**
  45050. * @hidden
  45051. */
  45052. export interface IMaterialSheenDefines {
  45053. SHEEN: boolean;
  45054. SHEEN_TEXTURE: boolean;
  45055. SHEEN_TEXTUREDIRECTUV: number;
  45056. SHEEN_LINKWITHALBEDO: boolean;
  45057. /** @hidden */
  45058. _areTexturesDirty: boolean;
  45059. }
  45060. /**
  45061. * Define the code related to the Sheen parameters of the pbr material.
  45062. */
  45063. export class PBRSheenConfiguration {
  45064. private _isEnabled;
  45065. /**
  45066. * Defines if the material uses sheen.
  45067. */
  45068. isEnabled: boolean;
  45069. private _linkSheenWithAlbedo;
  45070. /**
  45071. * Defines if the sheen is linked to the sheen color.
  45072. */
  45073. linkSheenWithAlbedo: boolean;
  45074. /**
  45075. * Defines the sheen intensity.
  45076. */
  45077. intensity: number;
  45078. /**
  45079. * Defines the sheen color.
  45080. */
  45081. color: Color3;
  45082. private _texture;
  45083. /**
  45084. * Stores the sheen tint values in a texture.
  45085. * rgb is tint
  45086. * a is a intensity
  45087. */
  45088. texture: Nullable<BaseTexture>;
  45089. /** @hidden */
  45090. private _internalMarkAllSubMeshesAsTexturesDirty;
  45091. /** @hidden */
  45092. _markAllSubMeshesAsTexturesDirty(): void;
  45093. /**
  45094. * Instantiate a new istance of clear coat configuration.
  45095. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45096. */
  45097. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45098. /**
  45099. * Specifies that the submesh is ready to be used.
  45100. * @param defines the list of "defines" to update.
  45101. * @param scene defines the scene the material belongs to.
  45102. * @returns - boolean indicating that the submesh is ready or not.
  45103. */
  45104. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45105. /**
  45106. * Checks to see if a texture is used in the material.
  45107. * @param defines the list of "defines" to update.
  45108. * @param scene defines the scene the material belongs to.
  45109. */
  45110. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45111. /**
  45112. * Binds the material data.
  45113. * @param uniformBuffer defines the Uniform buffer to fill in.
  45114. * @param scene defines the scene the material belongs to.
  45115. * @param isFrozen defines wether the material is frozen or not.
  45116. */
  45117. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45118. /**
  45119. * Checks to see if a texture is used in the material.
  45120. * @param texture - Base texture to use.
  45121. * @returns - Boolean specifying if a texture is used in the material.
  45122. */
  45123. hasTexture(texture: BaseTexture): boolean;
  45124. /**
  45125. * Returns an array of the actively used textures.
  45126. * @param activeTextures Array of BaseTextures
  45127. */
  45128. getActiveTextures(activeTextures: BaseTexture[]): void;
  45129. /**
  45130. * Returns the animatable textures.
  45131. * @param animatables Array of animatable textures.
  45132. */
  45133. getAnimatables(animatables: IAnimatable[]): void;
  45134. /**
  45135. * Disposes the resources of the material.
  45136. * @param forceDisposeTextures - Forces the disposal of all textures.
  45137. */
  45138. dispose(forceDisposeTextures?: boolean): void;
  45139. /**
  45140. * Get the current class name of the texture useful for serialization or dynamic coding.
  45141. * @returns "PBRSheenConfiguration"
  45142. */
  45143. getClassName(): string;
  45144. /**
  45145. * Add fallbacks to the effect fallbacks list.
  45146. * @param defines defines the Base texture to use.
  45147. * @param fallbacks defines the current fallback list.
  45148. * @param currentRank defines the current fallback rank.
  45149. * @returns the new fallback rank.
  45150. */
  45151. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45152. /**
  45153. * Add the required uniforms to the current list.
  45154. * @param uniforms defines the current uniform list.
  45155. */
  45156. static AddUniforms(uniforms: string[]): void;
  45157. /**
  45158. * Add the required uniforms to the current buffer.
  45159. * @param uniformBuffer defines the current uniform buffer.
  45160. */
  45161. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45162. /**
  45163. * Add the required samplers to the current list.
  45164. * @param samplers defines the current sampler list.
  45165. */
  45166. static AddSamplers(samplers: string[]): void;
  45167. /**
  45168. * Makes a duplicate of the current configuration into another one.
  45169. * @param sheenConfiguration define the config where to copy the info
  45170. */
  45171. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45172. /**
  45173. * Serializes this BRDF configuration.
  45174. * @returns - An object with the serialized config.
  45175. */
  45176. serialize(): any;
  45177. /**
  45178. * Parses a anisotropy Configuration from a serialized object.
  45179. * @param source - Serialized object.
  45180. * @param scene Defines the scene we are parsing for
  45181. * @param rootUrl Defines the rootUrl to load from
  45182. */
  45183. parse(source: any, scene: Scene, rootUrl: string): void;
  45184. }
  45185. }
  45186. declare module BABYLON {
  45187. /**
  45188. * @hidden
  45189. */
  45190. export interface IMaterialSubSurfaceDefines {
  45191. SUBSURFACE: boolean;
  45192. SS_REFRACTION: boolean;
  45193. SS_TRANSLUCENCY: boolean;
  45194. SS_SCATERRING: boolean;
  45195. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45196. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45197. SS_REFRACTIONMAP_3D: boolean;
  45198. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45199. SS_LODINREFRACTIONALPHA: boolean;
  45200. SS_GAMMAREFRACTION: boolean;
  45201. SS_RGBDREFRACTION: boolean;
  45202. SS_LINEARSPECULARREFRACTION: boolean;
  45203. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45204. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45205. /** @hidden */
  45206. _areTexturesDirty: boolean;
  45207. }
  45208. /**
  45209. * Define the code related to the sub surface parameters of the pbr material.
  45210. */
  45211. export class PBRSubSurfaceConfiguration {
  45212. private _isRefractionEnabled;
  45213. /**
  45214. * Defines if the refraction is enabled in the material.
  45215. */
  45216. isRefractionEnabled: boolean;
  45217. private _isTranslucencyEnabled;
  45218. /**
  45219. * Defines if the translucency is enabled in the material.
  45220. */
  45221. isTranslucencyEnabled: boolean;
  45222. private _isScatteringEnabled;
  45223. /**
  45224. * Defines the refraction intensity of the material.
  45225. * The refraction when enabled replaces the Diffuse part of the material.
  45226. * The intensity helps transitionning between diffuse and refraction.
  45227. */
  45228. refractionIntensity: number;
  45229. /**
  45230. * Defines the translucency intensity of the material.
  45231. * When translucency has been enabled, this defines how much of the "translucency"
  45232. * is addded to the diffuse part of the material.
  45233. */
  45234. translucencyIntensity: number;
  45235. /**
  45236. * Defines the scattering intensity of the material.
  45237. * When scattering has been enabled, this defines how much of the "scattered light"
  45238. * is addded to the diffuse part of the material.
  45239. */
  45240. scatteringIntensity: number;
  45241. private _thicknessTexture;
  45242. /**
  45243. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45244. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45245. * 0 would mean minimumThickness
  45246. * 1 would mean maximumThickness
  45247. * The other channels might be use as a mask to vary the different effects intensity.
  45248. */
  45249. thicknessTexture: Nullable<BaseTexture>;
  45250. private _refractionTexture;
  45251. /**
  45252. * Defines the texture to use for refraction.
  45253. */
  45254. refractionTexture: Nullable<BaseTexture>;
  45255. private _indexOfRefraction;
  45256. /**
  45257. * Defines the index of refraction used in the material.
  45258. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45259. */
  45260. indexOfRefraction: number;
  45261. private _invertRefractionY;
  45262. /**
  45263. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45264. */
  45265. invertRefractionY: boolean;
  45266. private _linkRefractionWithTransparency;
  45267. /**
  45268. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45269. * Materials half opaque for instance using refraction could benefit from this control.
  45270. */
  45271. linkRefractionWithTransparency: boolean;
  45272. /**
  45273. * Defines the minimum thickness stored in the thickness map.
  45274. * If no thickness map is defined, this value will be used to simulate thickness.
  45275. */
  45276. minimumThickness: number;
  45277. /**
  45278. * Defines the maximum thickness stored in the thickness map.
  45279. */
  45280. maximumThickness: number;
  45281. /**
  45282. * Defines the volume tint of the material.
  45283. * This is used for both translucency and scattering.
  45284. */
  45285. tintColor: Color3;
  45286. /**
  45287. * Defines the distance at which the tint color should be found in the media.
  45288. * This is used for refraction only.
  45289. */
  45290. tintColorAtDistance: number;
  45291. /**
  45292. * Defines how far each channel transmit through the media.
  45293. * It is defined as a color to simplify it selection.
  45294. */
  45295. diffusionDistance: Color3;
  45296. private _useMaskFromThicknessTexture;
  45297. /**
  45298. * Stores the intensity of the different subsurface effects in the thickness texture.
  45299. * * the green channel is the translucency intensity.
  45300. * * the blue channel is the scattering intensity.
  45301. * * the alpha channel is the refraction intensity.
  45302. */
  45303. useMaskFromThicknessTexture: boolean;
  45304. /** @hidden */
  45305. private _internalMarkAllSubMeshesAsTexturesDirty;
  45306. /** @hidden */
  45307. _markAllSubMeshesAsTexturesDirty(): void;
  45308. /**
  45309. * Instantiate a new istance of sub surface configuration.
  45310. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45311. */
  45312. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45313. /**
  45314. * Gets wehter the submesh is ready to be used or not.
  45315. * @param defines the list of "defines" to update.
  45316. * @param scene defines the scene the material belongs to.
  45317. * @returns - boolean indicating that the submesh is ready or not.
  45318. */
  45319. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45320. /**
  45321. * Checks to see if a texture is used in the material.
  45322. * @param defines the list of "defines" to update.
  45323. * @param scene defines the scene to the material belongs to.
  45324. */
  45325. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45326. /**
  45327. * Binds the material data.
  45328. * @param uniformBuffer defines the Uniform buffer to fill in.
  45329. * @param scene defines the scene the material belongs to.
  45330. * @param engine defines the engine the material belongs to.
  45331. * @param isFrozen defines wether the material is frozen or not.
  45332. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45333. */
  45334. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45335. /**
  45336. * Unbinds the material from the mesh.
  45337. * @param activeEffect defines the effect that should be unbound from.
  45338. * @returns true if unbound, otherwise false
  45339. */
  45340. unbind(activeEffect: Effect): boolean;
  45341. /**
  45342. * Returns the texture used for refraction or null if none is used.
  45343. * @param scene defines the scene the material belongs to.
  45344. * @returns - Refraction texture if present. If no refraction texture and refraction
  45345. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45346. */
  45347. private _getRefractionTexture;
  45348. /**
  45349. * Returns true if alpha blending should be disabled.
  45350. */
  45351. readonly disableAlphaBlending: boolean;
  45352. /**
  45353. * Fills the list of render target textures.
  45354. * @param renderTargets the list of render targets to update
  45355. */
  45356. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45357. /**
  45358. * Checks to see if a texture is used in the material.
  45359. * @param texture - Base texture to use.
  45360. * @returns - Boolean specifying if a texture is used in the material.
  45361. */
  45362. hasTexture(texture: BaseTexture): boolean;
  45363. /**
  45364. * Gets a boolean indicating that current material needs to register RTT
  45365. * @returns true if this uses a render target otherwise false.
  45366. */
  45367. hasRenderTargetTextures(): boolean;
  45368. /**
  45369. * Returns an array of the actively used textures.
  45370. * @param activeTextures Array of BaseTextures
  45371. */
  45372. getActiveTextures(activeTextures: BaseTexture[]): void;
  45373. /**
  45374. * Returns the animatable textures.
  45375. * @param animatables Array of animatable textures.
  45376. */
  45377. getAnimatables(animatables: IAnimatable[]): void;
  45378. /**
  45379. * Disposes the resources of the material.
  45380. * @param forceDisposeTextures - Forces the disposal of all textures.
  45381. */
  45382. dispose(forceDisposeTextures?: boolean): void;
  45383. /**
  45384. * Get the current class name of the texture useful for serialization or dynamic coding.
  45385. * @returns "PBRSubSurfaceConfiguration"
  45386. */
  45387. getClassName(): string;
  45388. /**
  45389. * Add fallbacks to the effect fallbacks list.
  45390. * @param defines defines the Base texture to use.
  45391. * @param fallbacks defines the current fallback list.
  45392. * @param currentRank defines the current fallback rank.
  45393. * @returns the new fallback rank.
  45394. */
  45395. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45396. /**
  45397. * Add the required uniforms to the current list.
  45398. * @param uniforms defines the current uniform list.
  45399. */
  45400. static AddUniforms(uniforms: string[]): void;
  45401. /**
  45402. * Add the required samplers to the current list.
  45403. * @param samplers defines the current sampler list.
  45404. */
  45405. static AddSamplers(samplers: string[]): void;
  45406. /**
  45407. * Add the required uniforms to the current buffer.
  45408. * @param uniformBuffer defines the current uniform buffer.
  45409. */
  45410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45411. /**
  45412. * Makes a duplicate of the current configuration into another one.
  45413. * @param configuration define the config where to copy the info
  45414. */
  45415. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45416. /**
  45417. * Serializes this Sub Surface configuration.
  45418. * @returns - An object with the serialized config.
  45419. */
  45420. serialize(): any;
  45421. /**
  45422. * Parses a anisotropy Configuration from a serialized object.
  45423. * @param source - Serialized object.
  45424. * @param scene Defines the scene we are parsing for
  45425. * @param rootUrl Defines the rootUrl to load from
  45426. */
  45427. parse(source: any, scene: Scene, rootUrl: string): void;
  45428. }
  45429. }
  45430. declare module BABYLON {
  45431. /** @hidden */
  45432. export var pbrFragmentDeclaration: {
  45433. name: string;
  45434. shader: string;
  45435. };
  45436. }
  45437. declare module BABYLON {
  45438. /** @hidden */
  45439. export var pbrUboDeclaration: {
  45440. name: string;
  45441. shader: string;
  45442. };
  45443. }
  45444. declare module BABYLON {
  45445. /** @hidden */
  45446. export var pbrFragmentExtraDeclaration: {
  45447. name: string;
  45448. shader: string;
  45449. };
  45450. }
  45451. declare module BABYLON {
  45452. /** @hidden */
  45453. export var pbrFragmentSamplersDeclaration: {
  45454. name: string;
  45455. shader: string;
  45456. };
  45457. }
  45458. declare module BABYLON {
  45459. /** @hidden */
  45460. export var pbrHelperFunctions: {
  45461. name: string;
  45462. shader: string;
  45463. };
  45464. }
  45465. declare module BABYLON {
  45466. /** @hidden */
  45467. export var harmonicsFunctions: {
  45468. name: string;
  45469. shader: string;
  45470. };
  45471. }
  45472. declare module BABYLON {
  45473. /** @hidden */
  45474. export var pbrDirectLightingSetupFunctions: {
  45475. name: string;
  45476. shader: string;
  45477. };
  45478. }
  45479. declare module BABYLON {
  45480. /** @hidden */
  45481. export var pbrDirectLightingFalloffFunctions: {
  45482. name: string;
  45483. shader: string;
  45484. };
  45485. }
  45486. declare module BABYLON {
  45487. /** @hidden */
  45488. export var pbrBRDFFunctions: {
  45489. name: string;
  45490. shader: string;
  45491. };
  45492. }
  45493. declare module BABYLON {
  45494. /** @hidden */
  45495. export var pbrDirectLightingFunctions: {
  45496. name: string;
  45497. shader: string;
  45498. };
  45499. }
  45500. declare module BABYLON {
  45501. /** @hidden */
  45502. export var pbrIBLFunctions: {
  45503. name: string;
  45504. shader: string;
  45505. };
  45506. }
  45507. declare module BABYLON {
  45508. /** @hidden */
  45509. export var pbrDebug: {
  45510. name: string;
  45511. shader: string;
  45512. };
  45513. }
  45514. declare module BABYLON {
  45515. /** @hidden */
  45516. export var pbrPixelShader: {
  45517. name: string;
  45518. shader: string;
  45519. };
  45520. }
  45521. declare module BABYLON {
  45522. /** @hidden */
  45523. export var pbrVertexDeclaration: {
  45524. name: string;
  45525. shader: string;
  45526. };
  45527. }
  45528. declare module BABYLON {
  45529. /** @hidden */
  45530. export var pbrVertexShader: {
  45531. name: string;
  45532. shader: string;
  45533. };
  45534. }
  45535. declare module BABYLON {
  45536. /**
  45537. * Manages the defines for the PBR Material.
  45538. * @hidden
  45539. */
  45540. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45541. PBR: boolean;
  45542. MAINUV1: boolean;
  45543. MAINUV2: boolean;
  45544. UV1: boolean;
  45545. UV2: boolean;
  45546. ALBEDO: boolean;
  45547. ALBEDODIRECTUV: number;
  45548. VERTEXCOLOR: boolean;
  45549. AMBIENT: boolean;
  45550. AMBIENTDIRECTUV: number;
  45551. AMBIENTINGRAYSCALE: boolean;
  45552. OPACITY: boolean;
  45553. VERTEXALPHA: boolean;
  45554. OPACITYDIRECTUV: number;
  45555. OPACITYRGB: boolean;
  45556. ALPHATEST: boolean;
  45557. DEPTHPREPASS: boolean;
  45558. ALPHABLEND: boolean;
  45559. ALPHAFROMALBEDO: boolean;
  45560. ALPHATESTVALUE: string;
  45561. SPECULAROVERALPHA: boolean;
  45562. RADIANCEOVERALPHA: boolean;
  45563. ALPHAFRESNEL: boolean;
  45564. LINEARALPHAFRESNEL: boolean;
  45565. PREMULTIPLYALPHA: boolean;
  45566. EMISSIVE: boolean;
  45567. EMISSIVEDIRECTUV: number;
  45568. REFLECTIVITY: boolean;
  45569. REFLECTIVITYDIRECTUV: number;
  45570. SPECULARTERM: boolean;
  45571. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45572. MICROSURFACEAUTOMATIC: boolean;
  45573. LODBASEDMICROSFURACE: boolean;
  45574. MICROSURFACEMAP: boolean;
  45575. MICROSURFACEMAPDIRECTUV: number;
  45576. METALLICWORKFLOW: boolean;
  45577. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45578. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45579. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45580. AOSTOREINMETALMAPRED: boolean;
  45581. ENVIRONMENTBRDF: boolean;
  45582. ENVIRONMENTBRDF_RGBD: boolean;
  45583. NORMAL: boolean;
  45584. TANGENT: boolean;
  45585. BUMP: boolean;
  45586. BUMPDIRECTUV: number;
  45587. OBJECTSPACE_NORMALMAP: boolean;
  45588. PARALLAX: boolean;
  45589. PARALLAXOCCLUSION: boolean;
  45590. NORMALXYSCALE: boolean;
  45591. LIGHTMAP: boolean;
  45592. LIGHTMAPDIRECTUV: number;
  45593. USELIGHTMAPASSHADOWMAP: boolean;
  45594. GAMMALIGHTMAP: boolean;
  45595. REFLECTION: boolean;
  45596. REFLECTIONMAP_3D: boolean;
  45597. REFLECTIONMAP_SPHERICAL: boolean;
  45598. REFLECTIONMAP_PLANAR: boolean;
  45599. REFLECTIONMAP_CUBIC: boolean;
  45600. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45601. REFLECTIONMAP_PROJECTION: boolean;
  45602. REFLECTIONMAP_SKYBOX: boolean;
  45603. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45604. REFLECTIONMAP_EXPLICIT: boolean;
  45605. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45606. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45607. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45608. INVERTCUBICMAP: boolean;
  45609. USESPHERICALFROMREFLECTIONMAP: boolean;
  45610. USEIRRADIANCEMAP: boolean;
  45611. SPHERICAL_HARMONICS: boolean;
  45612. USESPHERICALINVERTEX: boolean;
  45613. REFLECTIONMAP_OPPOSITEZ: boolean;
  45614. LODINREFLECTIONALPHA: boolean;
  45615. GAMMAREFLECTION: boolean;
  45616. RGBDREFLECTION: boolean;
  45617. LINEARSPECULARREFLECTION: boolean;
  45618. RADIANCEOCCLUSION: boolean;
  45619. HORIZONOCCLUSION: boolean;
  45620. INSTANCES: boolean;
  45621. NUM_BONE_INFLUENCERS: number;
  45622. BonesPerMesh: number;
  45623. BONETEXTURE: boolean;
  45624. NONUNIFORMSCALING: boolean;
  45625. MORPHTARGETS: boolean;
  45626. MORPHTARGETS_NORMAL: boolean;
  45627. MORPHTARGETS_TANGENT: boolean;
  45628. MORPHTARGETS_UV: boolean;
  45629. NUM_MORPH_INFLUENCERS: number;
  45630. IMAGEPROCESSING: boolean;
  45631. VIGNETTE: boolean;
  45632. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45633. VIGNETTEBLENDMODEOPAQUE: boolean;
  45634. TONEMAPPING: boolean;
  45635. TONEMAPPING_ACES: boolean;
  45636. CONTRAST: boolean;
  45637. COLORCURVES: boolean;
  45638. COLORGRADING: boolean;
  45639. COLORGRADING3D: boolean;
  45640. SAMPLER3DGREENDEPTH: boolean;
  45641. SAMPLER3DBGRMAP: boolean;
  45642. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45643. EXPOSURE: boolean;
  45644. MULTIVIEW: boolean;
  45645. USEPHYSICALLIGHTFALLOFF: boolean;
  45646. USEGLTFLIGHTFALLOFF: boolean;
  45647. TWOSIDEDLIGHTING: boolean;
  45648. SHADOWFLOAT: boolean;
  45649. CLIPPLANE: boolean;
  45650. CLIPPLANE2: boolean;
  45651. CLIPPLANE3: boolean;
  45652. CLIPPLANE4: boolean;
  45653. POINTSIZE: boolean;
  45654. FOG: boolean;
  45655. LOGARITHMICDEPTH: boolean;
  45656. FORCENORMALFORWARD: boolean;
  45657. SPECULARAA: boolean;
  45658. CLEARCOAT: boolean;
  45659. CLEARCOAT_DEFAULTIOR: boolean;
  45660. CLEARCOAT_TEXTURE: boolean;
  45661. CLEARCOAT_TEXTUREDIRECTUV: number;
  45662. CLEARCOAT_BUMP: boolean;
  45663. CLEARCOAT_BUMPDIRECTUV: number;
  45664. CLEARCOAT_TINT: boolean;
  45665. CLEARCOAT_TINT_TEXTURE: boolean;
  45666. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45667. ANISOTROPIC: boolean;
  45668. ANISOTROPIC_TEXTURE: boolean;
  45669. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45670. BRDF_V_HEIGHT_CORRELATED: boolean;
  45671. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45672. SHEEN: boolean;
  45673. SHEEN_TEXTURE: boolean;
  45674. SHEEN_TEXTUREDIRECTUV: number;
  45675. SHEEN_LINKWITHALBEDO: boolean;
  45676. SUBSURFACE: boolean;
  45677. SS_REFRACTION: boolean;
  45678. SS_TRANSLUCENCY: boolean;
  45679. SS_SCATERRING: boolean;
  45680. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45681. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45682. SS_REFRACTIONMAP_3D: boolean;
  45683. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45684. SS_LODINREFRACTIONALPHA: boolean;
  45685. SS_GAMMAREFRACTION: boolean;
  45686. SS_RGBDREFRACTION: boolean;
  45687. SS_LINEARSPECULARREFRACTION: boolean;
  45688. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45689. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45690. UNLIT: boolean;
  45691. DEBUGMODE: number;
  45692. /**
  45693. * Initializes the PBR Material defines.
  45694. */
  45695. constructor();
  45696. /**
  45697. * Resets the PBR Material defines.
  45698. */
  45699. reset(): void;
  45700. }
  45701. /**
  45702. * The Physically based material base class of BJS.
  45703. *
  45704. * This offers the main features of a standard PBR material.
  45705. * For more information, please refer to the documentation :
  45706. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45707. */
  45708. export abstract class PBRBaseMaterial extends PushMaterial {
  45709. /**
  45710. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45711. */
  45712. static readonly PBRMATERIAL_OPAQUE: number;
  45713. /**
  45714. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45715. */
  45716. static readonly PBRMATERIAL_ALPHATEST: number;
  45717. /**
  45718. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45719. */
  45720. static readonly PBRMATERIAL_ALPHABLEND: number;
  45721. /**
  45722. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45723. * They are also discarded below the alpha cutoff threshold to improve performances.
  45724. */
  45725. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45726. /**
  45727. * Defines the default value of how much AO map is occluding the analytical lights
  45728. * (point spot...).
  45729. */
  45730. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45731. /**
  45732. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45733. */
  45734. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45735. /**
  45736. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45737. * to enhance interoperability with other engines.
  45738. */
  45739. static readonly LIGHTFALLOFF_GLTF: number;
  45740. /**
  45741. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45742. * to enhance interoperability with other materials.
  45743. */
  45744. static readonly LIGHTFALLOFF_STANDARD: number;
  45745. /**
  45746. * Intensity of the direct lights e.g. the four lights available in your scene.
  45747. * This impacts both the direct diffuse and specular highlights.
  45748. */
  45749. protected _directIntensity: number;
  45750. /**
  45751. * Intensity of the emissive part of the material.
  45752. * This helps controlling the emissive effect without modifying the emissive color.
  45753. */
  45754. protected _emissiveIntensity: number;
  45755. /**
  45756. * Intensity of the environment e.g. how much the environment will light the object
  45757. * either through harmonics for rough material or through the refelction for shiny ones.
  45758. */
  45759. protected _environmentIntensity: number;
  45760. /**
  45761. * This is a special control allowing the reduction of the specular highlights coming from the
  45762. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45763. */
  45764. protected _specularIntensity: number;
  45765. /**
  45766. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45767. */
  45768. private _lightingInfos;
  45769. /**
  45770. * Debug Control allowing disabling the bump map on this material.
  45771. */
  45772. protected _disableBumpMap: boolean;
  45773. /**
  45774. * AKA Diffuse Texture in standard nomenclature.
  45775. */
  45776. protected _albedoTexture: Nullable<BaseTexture>;
  45777. /**
  45778. * AKA Occlusion Texture in other nomenclature.
  45779. */
  45780. protected _ambientTexture: Nullable<BaseTexture>;
  45781. /**
  45782. * AKA Occlusion Texture Intensity in other nomenclature.
  45783. */
  45784. protected _ambientTextureStrength: number;
  45785. /**
  45786. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45787. * 1 means it completely occludes it
  45788. * 0 mean it has no impact
  45789. */
  45790. protected _ambientTextureImpactOnAnalyticalLights: number;
  45791. /**
  45792. * Stores the alpha values in a texture.
  45793. */
  45794. protected _opacityTexture: Nullable<BaseTexture>;
  45795. /**
  45796. * Stores the reflection values in a texture.
  45797. */
  45798. protected _reflectionTexture: Nullable<BaseTexture>;
  45799. /**
  45800. * Stores the emissive values in a texture.
  45801. */
  45802. protected _emissiveTexture: Nullable<BaseTexture>;
  45803. /**
  45804. * AKA Specular texture in other nomenclature.
  45805. */
  45806. protected _reflectivityTexture: Nullable<BaseTexture>;
  45807. /**
  45808. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45809. */
  45810. protected _metallicTexture: Nullable<BaseTexture>;
  45811. /**
  45812. * Specifies the metallic scalar of the metallic/roughness workflow.
  45813. * Can also be used to scale the metalness values of the metallic texture.
  45814. */
  45815. protected _metallic: Nullable<number>;
  45816. /**
  45817. * Specifies the roughness scalar of the metallic/roughness workflow.
  45818. * Can also be used to scale the roughness values of the metallic texture.
  45819. */
  45820. protected _roughness: Nullable<number>;
  45821. /**
  45822. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45823. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45824. */
  45825. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45826. /**
  45827. * Stores surface normal data used to displace a mesh in a texture.
  45828. */
  45829. protected _bumpTexture: Nullable<BaseTexture>;
  45830. /**
  45831. * Stores the pre-calculated light information of a mesh in a texture.
  45832. */
  45833. protected _lightmapTexture: Nullable<BaseTexture>;
  45834. /**
  45835. * The color of a material in ambient lighting.
  45836. */
  45837. protected _ambientColor: Color3;
  45838. /**
  45839. * AKA Diffuse Color in other nomenclature.
  45840. */
  45841. protected _albedoColor: Color3;
  45842. /**
  45843. * AKA Specular Color in other nomenclature.
  45844. */
  45845. protected _reflectivityColor: Color3;
  45846. /**
  45847. * The color applied when light is reflected from a material.
  45848. */
  45849. protected _reflectionColor: Color3;
  45850. /**
  45851. * The color applied when light is emitted from a material.
  45852. */
  45853. protected _emissiveColor: Color3;
  45854. /**
  45855. * AKA Glossiness in other nomenclature.
  45856. */
  45857. protected _microSurface: number;
  45858. /**
  45859. * Specifies that the material will use the light map as a show map.
  45860. */
  45861. protected _useLightmapAsShadowmap: boolean;
  45862. /**
  45863. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45864. * makes the reflect vector face the model (under horizon).
  45865. */
  45866. protected _useHorizonOcclusion: boolean;
  45867. /**
  45868. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45869. * too much the area relying on ambient texture to define their ambient occlusion.
  45870. */
  45871. protected _useRadianceOcclusion: boolean;
  45872. /**
  45873. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45874. */
  45875. protected _useAlphaFromAlbedoTexture: boolean;
  45876. /**
  45877. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45878. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45879. */
  45880. protected _useSpecularOverAlpha: boolean;
  45881. /**
  45882. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45883. */
  45884. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45885. /**
  45886. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45887. */
  45888. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45889. /**
  45890. * Specifies if the metallic texture contains the roughness information in its green channel.
  45891. */
  45892. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45893. /**
  45894. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45895. */
  45896. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45897. /**
  45898. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45899. */
  45900. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45901. /**
  45902. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45903. */
  45904. protected _useAmbientInGrayScale: boolean;
  45905. /**
  45906. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45907. * The material will try to infer what glossiness each pixel should be.
  45908. */
  45909. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45910. /**
  45911. * Defines the falloff type used in this material.
  45912. * It by default is Physical.
  45913. */
  45914. protected _lightFalloff: number;
  45915. /**
  45916. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45917. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45918. */
  45919. protected _useRadianceOverAlpha: boolean;
  45920. /**
  45921. * Allows using an object space normal map (instead of tangent space).
  45922. */
  45923. protected _useObjectSpaceNormalMap: boolean;
  45924. /**
  45925. * Allows using the bump map in parallax mode.
  45926. */
  45927. protected _useParallax: boolean;
  45928. /**
  45929. * Allows using the bump map in parallax occlusion mode.
  45930. */
  45931. protected _useParallaxOcclusion: boolean;
  45932. /**
  45933. * Controls the scale bias of the parallax mode.
  45934. */
  45935. protected _parallaxScaleBias: number;
  45936. /**
  45937. * If sets to true, disables all the lights affecting the material.
  45938. */
  45939. protected _disableLighting: boolean;
  45940. /**
  45941. * Number of Simultaneous lights allowed on the material.
  45942. */
  45943. protected _maxSimultaneousLights: number;
  45944. /**
  45945. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45946. */
  45947. protected _invertNormalMapX: boolean;
  45948. /**
  45949. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45950. */
  45951. protected _invertNormalMapY: boolean;
  45952. /**
  45953. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45954. */
  45955. protected _twoSidedLighting: boolean;
  45956. /**
  45957. * Defines the alpha limits in alpha test mode.
  45958. */
  45959. protected _alphaCutOff: number;
  45960. /**
  45961. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45962. */
  45963. protected _forceAlphaTest: boolean;
  45964. /**
  45965. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45966. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45967. */
  45968. protected _useAlphaFresnel: boolean;
  45969. /**
  45970. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45971. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45972. */
  45973. protected _useLinearAlphaFresnel: boolean;
  45974. /**
  45975. * The transparency mode of the material.
  45976. */
  45977. protected _transparencyMode: Nullable<number>;
  45978. /**
  45979. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45980. * from cos thetav and roughness:
  45981. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45982. */
  45983. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45984. /**
  45985. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45986. */
  45987. protected _forceIrradianceInFragment: boolean;
  45988. /**
  45989. * Force normal to face away from face.
  45990. */
  45991. protected _forceNormalForward: boolean;
  45992. /**
  45993. * Enables specular anti aliasing in the PBR shader.
  45994. * It will both interacts on the Geometry for analytical and IBL lighting.
  45995. * It also prefilter the roughness map based on the bump values.
  45996. */
  45997. protected _enableSpecularAntiAliasing: boolean;
  45998. /**
  45999. * Default configuration related to image processing available in the PBR Material.
  46000. */
  46001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46002. /**
  46003. * Keep track of the image processing observer to allow dispose and replace.
  46004. */
  46005. private _imageProcessingObserver;
  46006. /**
  46007. * Attaches a new image processing configuration to the PBR Material.
  46008. * @param configuration
  46009. */
  46010. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46011. /**
  46012. * Stores the available render targets.
  46013. */
  46014. private _renderTargets;
  46015. /**
  46016. * Sets the global ambient color for the material used in lighting calculations.
  46017. */
  46018. private _globalAmbientColor;
  46019. /**
  46020. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46021. */
  46022. private _useLogarithmicDepth;
  46023. /**
  46024. * If set to true, no lighting calculations will be applied.
  46025. */
  46026. private _unlit;
  46027. private _debugMode;
  46028. /**
  46029. * @hidden
  46030. * This is reserved for the inspector.
  46031. * Defines the material debug mode.
  46032. * It helps seeing only some components of the material while troubleshooting.
  46033. */
  46034. debugMode: number;
  46035. /**
  46036. * @hidden
  46037. * This is reserved for the inspector.
  46038. * Specify from where on screen the debug mode should start.
  46039. * The value goes from -1 (full screen) to 1 (not visible)
  46040. * It helps with side by side comparison against the final render
  46041. * This defaults to -1
  46042. */
  46043. private debugLimit;
  46044. /**
  46045. * @hidden
  46046. * This is reserved for the inspector.
  46047. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46048. * You can use the factor to better multiply the final value.
  46049. */
  46050. private debugFactor;
  46051. /**
  46052. * Defines the clear coat layer parameters for the material.
  46053. */
  46054. readonly clearCoat: PBRClearCoatConfiguration;
  46055. /**
  46056. * Defines the anisotropic parameters for the material.
  46057. */
  46058. readonly anisotropy: PBRAnisotropicConfiguration;
  46059. /**
  46060. * Defines the BRDF parameters for the material.
  46061. */
  46062. readonly brdf: PBRBRDFConfiguration;
  46063. /**
  46064. * Defines the Sheen parameters for the material.
  46065. */
  46066. readonly sheen: PBRSheenConfiguration;
  46067. /**
  46068. * Defines the SubSurface parameters for the material.
  46069. */
  46070. readonly subSurface: PBRSubSurfaceConfiguration;
  46071. /**
  46072. * Custom callback helping to override the default shader used in the material.
  46073. */
  46074. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46075. /**
  46076. * Instantiates a new PBRMaterial instance.
  46077. *
  46078. * @param name The material name
  46079. * @param scene The scene the material will be use in.
  46080. */
  46081. constructor(name: string, scene: Scene);
  46082. /**
  46083. * Gets a boolean indicating that current material needs to register RTT
  46084. */
  46085. readonly hasRenderTargetTextures: boolean;
  46086. /**
  46087. * Gets the name of the material class.
  46088. */
  46089. getClassName(): string;
  46090. /**
  46091. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46092. */
  46093. /**
  46094. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46095. */
  46096. useLogarithmicDepth: boolean;
  46097. /**
  46098. * Gets the current transparency mode.
  46099. */
  46100. /**
  46101. * Sets the transparency mode of the material.
  46102. *
  46103. * | Value | Type | Description |
  46104. * | ----- | ----------------------------------- | ----------- |
  46105. * | 0 | OPAQUE | |
  46106. * | 1 | ALPHATEST | |
  46107. * | 2 | ALPHABLEND | |
  46108. * | 3 | ALPHATESTANDBLEND | |
  46109. *
  46110. */
  46111. transparencyMode: Nullable<number>;
  46112. /**
  46113. * Returns true if alpha blending should be disabled.
  46114. */
  46115. private readonly _disableAlphaBlending;
  46116. /**
  46117. * Specifies whether or not this material should be rendered in alpha blend mode.
  46118. */
  46119. needAlphaBlending(): boolean;
  46120. /**
  46121. * Specifies if the mesh will require alpha blending.
  46122. * @param mesh - BJS mesh.
  46123. */
  46124. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46125. /**
  46126. * Specifies whether or not this material should be rendered in alpha test mode.
  46127. */
  46128. needAlphaTesting(): boolean;
  46129. /**
  46130. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46131. */
  46132. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46133. /**
  46134. * Gets the texture used for the alpha test.
  46135. */
  46136. getAlphaTestTexture(): Nullable<BaseTexture>;
  46137. /**
  46138. * Specifies that the submesh is ready to be used.
  46139. * @param mesh - BJS mesh.
  46140. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46141. * @param useInstances - Specifies that instances should be used.
  46142. * @returns - boolean indicating that the submesh is ready or not.
  46143. */
  46144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46145. /**
  46146. * Specifies if the material uses metallic roughness workflow.
  46147. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46148. */
  46149. isMetallicWorkflow(): boolean;
  46150. private _prepareEffect;
  46151. private _prepareDefines;
  46152. /**
  46153. * Force shader compilation
  46154. */
  46155. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46156. clipPlane: boolean;
  46157. }>): void;
  46158. /**
  46159. * Initializes the uniform buffer layout for the shader.
  46160. */
  46161. buildUniformLayout(): void;
  46162. /**
  46163. * Unbinds the material from the mesh
  46164. */
  46165. unbind(): void;
  46166. /**
  46167. * Binds the submesh data.
  46168. * @param world - The world matrix.
  46169. * @param mesh - The BJS mesh.
  46170. * @param subMesh - A submesh of the BJS mesh.
  46171. */
  46172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46173. /**
  46174. * Returns the animatable textures.
  46175. * @returns - Array of animatable textures.
  46176. */
  46177. getAnimatables(): IAnimatable[];
  46178. /**
  46179. * Returns the texture used for reflections.
  46180. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46181. */
  46182. private _getReflectionTexture;
  46183. /**
  46184. * Returns an array of the actively used textures.
  46185. * @returns - Array of BaseTextures
  46186. */
  46187. getActiveTextures(): BaseTexture[];
  46188. /**
  46189. * Checks to see if a texture is used in the material.
  46190. * @param texture - Base texture to use.
  46191. * @returns - Boolean specifying if a texture is used in the material.
  46192. */
  46193. hasTexture(texture: BaseTexture): boolean;
  46194. /**
  46195. * Disposes the resources of the material.
  46196. * @param forceDisposeEffect - Forces the disposal of effects.
  46197. * @param forceDisposeTextures - Forces the disposal of all textures.
  46198. */
  46199. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46200. }
  46201. }
  46202. declare module BABYLON {
  46203. /**
  46204. * The Physically based material of BJS.
  46205. *
  46206. * This offers the main features of a standard PBR material.
  46207. * For more information, please refer to the documentation :
  46208. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46209. */
  46210. export class PBRMaterial extends PBRBaseMaterial {
  46211. /**
  46212. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46213. */
  46214. static readonly PBRMATERIAL_OPAQUE: number;
  46215. /**
  46216. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46217. */
  46218. static readonly PBRMATERIAL_ALPHATEST: number;
  46219. /**
  46220. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46221. */
  46222. static readonly PBRMATERIAL_ALPHABLEND: number;
  46223. /**
  46224. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46225. * They are also discarded below the alpha cutoff threshold to improve performances.
  46226. */
  46227. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46228. /**
  46229. * Defines the default value of how much AO map is occluding the analytical lights
  46230. * (point spot...).
  46231. */
  46232. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46233. /**
  46234. * Intensity of the direct lights e.g. the four lights available in your scene.
  46235. * This impacts both the direct diffuse and specular highlights.
  46236. */
  46237. directIntensity: number;
  46238. /**
  46239. * Intensity of the emissive part of the material.
  46240. * This helps controlling the emissive effect without modifying the emissive color.
  46241. */
  46242. emissiveIntensity: number;
  46243. /**
  46244. * Intensity of the environment e.g. how much the environment will light the object
  46245. * either through harmonics for rough material or through the refelction for shiny ones.
  46246. */
  46247. environmentIntensity: number;
  46248. /**
  46249. * This is a special control allowing the reduction of the specular highlights coming from the
  46250. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46251. */
  46252. specularIntensity: number;
  46253. /**
  46254. * Debug Control allowing disabling the bump map on this material.
  46255. */
  46256. disableBumpMap: boolean;
  46257. /**
  46258. * AKA Diffuse Texture in standard nomenclature.
  46259. */
  46260. albedoTexture: BaseTexture;
  46261. /**
  46262. * AKA Occlusion Texture in other nomenclature.
  46263. */
  46264. ambientTexture: BaseTexture;
  46265. /**
  46266. * AKA Occlusion Texture Intensity in other nomenclature.
  46267. */
  46268. ambientTextureStrength: number;
  46269. /**
  46270. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46271. * 1 means it completely occludes it
  46272. * 0 mean it has no impact
  46273. */
  46274. ambientTextureImpactOnAnalyticalLights: number;
  46275. /**
  46276. * Stores the alpha values in a texture.
  46277. */
  46278. opacityTexture: BaseTexture;
  46279. /**
  46280. * Stores the reflection values in a texture.
  46281. */
  46282. reflectionTexture: Nullable<BaseTexture>;
  46283. /**
  46284. * Stores the emissive values in a texture.
  46285. */
  46286. emissiveTexture: BaseTexture;
  46287. /**
  46288. * AKA Specular texture in other nomenclature.
  46289. */
  46290. reflectivityTexture: BaseTexture;
  46291. /**
  46292. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46293. */
  46294. metallicTexture: BaseTexture;
  46295. /**
  46296. * Specifies the metallic scalar of the metallic/roughness workflow.
  46297. * Can also be used to scale the metalness values of the metallic texture.
  46298. */
  46299. metallic: Nullable<number>;
  46300. /**
  46301. * Specifies the roughness scalar of the metallic/roughness workflow.
  46302. * Can also be used to scale the roughness values of the metallic texture.
  46303. */
  46304. roughness: Nullable<number>;
  46305. /**
  46306. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46307. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46308. */
  46309. microSurfaceTexture: BaseTexture;
  46310. /**
  46311. * Stores surface normal data used to displace a mesh in a texture.
  46312. */
  46313. bumpTexture: BaseTexture;
  46314. /**
  46315. * Stores the pre-calculated light information of a mesh in a texture.
  46316. */
  46317. lightmapTexture: BaseTexture;
  46318. /**
  46319. * Stores the refracted light information in a texture.
  46320. */
  46321. refractionTexture: Nullable<BaseTexture>;
  46322. /**
  46323. * The color of a material in ambient lighting.
  46324. */
  46325. ambientColor: Color3;
  46326. /**
  46327. * AKA Diffuse Color in other nomenclature.
  46328. */
  46329. albedoColor: Color3;
  46330. /**
  46331. * AKA Specular Color in other nomenclature.
  46332. */
  46333. reflectivityColor: Color3;
  46334. /**
  46335. * The color reflected from the material.
  46336. */
  46337. reflectionColor: Color3;
  46338. /**
  46339. * The color emitted from the material.
  46340. */
  46341. emissiveColor: Color3;
  46342. /**
  46343. * AKA Glossiness in other nomenclature.
  46344. */
  46345. microSurface: number;
  46346. /**
  46347. * source material index of refraction (IOR)' / 'destination material IOR.
  46348. */
  46349. indexOfRefraction: number;
  46350. /**
  46351. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46352. */
  46353. invertRefractionY: boolean;
  46354. /**
  46355. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46356. * Materials half opaque for instance using refraction could benefit from this control.
  46357. */
  46358. linkRefractionWithTransparency: boolean;
  46359. /**
  46360. * If true, the light map contains occlusion information instead of lighting info.
  46361. */
  46362. useLightmapAsShadowmap: boolean;
  46363. /**
  46364. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46365. */
  46366. useAlphaFromAlbedoTexture: boolean;
  46367. /**
  46368. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46369. */
  46370. forceAlphaTest: boolean;
  46371. /**
  46372. * Defines the alpha limits in alpha test mode.
  46373. */
  46374. alphaCutOff: number;
  46375. /**
  46376. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46377. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46378. */
  46379. useSpecularOverAlpha: boolean;
  46380. /**
  46381. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46382. */
  46383. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46384. /**
  46385. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46386. */
  46387. useRoughnessFromMetallicTextureAlpha: boolean;
  46388. /**
  46389. * Specifies if the metallic texture contains the roughness information in its green channel.
  46390. */
  46391. useRoughnessFromMetallicTextureGreen: boolean;
  46392. /**
  46393. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46394. */
  46395. useMetallnessFromMetallicTextureBlue: boolean;
  46396. /**
  46397. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46398. */
  46399. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46400. /**
  46401. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46402. */
  46403. useAmbientInGrayScale: boolean;
  46404. /**
  46405. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46406. * The material will try to infer what glossiness each pixel should be.
  46407. */
  46408. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46409. /**
  46410. * BJS is using an harcoded light falloff based on a manually sets up range.
  46411. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46412. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46413. */
  46414. /**
  46415. * BJS is using an harcoded light falloff based on a manually sets up range.
  46416. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46417. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46418. */
  46419. usePhysicalLightFalloff: boolean;
  46420. /**
  46421. * In order to support the falloff compatibility with gltf, a special mode has been added
  46422. * to reproduce the gltf light falloff.
  46423. */
  46424. /**
  46425. * In order to support the falloff compatibility with gltf, a special mode has been added
  46426. * to reproduce the gltf light falloff.
  46427. */
  46428. useGLTFLightFalloff: boolean;
  46429. /**
  46430. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46431. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46432. */
  46433. useRadianceOverAlpha: boolean;
  46434. /**
  46435. * Allows using an object space normal map (instead of tangent space).
  46436. */
  46437. useObjectSpaceNormalMap: boolean;
  46438. /**
  46439. * Allows using the bump map in parallax mode.
  46440. */
  46441. useParallax: boolean;
  46442. /**
  46443. * Allows using the bump map in parallax occlusion mode.
  46444. */
  46445. useParallaxOcclusion: boolean;
  46446. /**
  46447. * Controls the scale bias of the parallax mode.
  46448. */
  46449. parallaxScaleBias: number;
  46450. /**
  46451. * If sets to true, disables all the lights affecting the material.
  46452. */
  46453. disableLighting: boolean;
  46454. /**
  46455. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46456. */
  46457. forceIrradianceInFragment: boolean;
  46458. /**
  46459. * Number of Simultaneous lights allowed on the material.
  46460. */
  46461. maxSimultaneousLights: number;
  46462. /**
  46463. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46464. */
  46465. invertNormalMapX: boolean;
  46466. /**
  46467. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46468. */
  46469. invertNormalMapY: boolean;
  46470. /**
  46471. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46472. */
  46473. twoSidedLighting: boolean;
  46474. /**
  46475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46476. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46477. */
  46478. useAlphaFresnel: boolean;
  46479. /**
  46480. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46481. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46482. */
  46483. useLinearAlphaFresnel: boolean;
  46484. /**
  46485. * Let user defines the brdf lookup texture used for IBL.
  46486. * A default 8bit version is embedded but you could point at :
  46487. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46488. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46489. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46490. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46491. */
  46492. environmentBRDFTexture: Nullable<BaseTexture>;
  46493. /**
  46494. * Force normal to face away from face.
  46495. */
  46496. forceNormalForward: boolean;
  46497. /**
  46498. * Enables specular anti aliasing in the PBR shader.
  46499. * It will both interacts on the Geometry for analytical and IBL lighting.
  46500. * It also prefilter the roughness map based on the bump values.
  46501. */
  46502. enableSpecularAntiAliasing: boolean;
  46503. /**
  46504. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46505. * makes the reflect vector face the model (under horizon).
  46506. */
  46507. useHorizonOcclusion: boolean;
  46508. /**
  46509. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46510. * too much the area relying on ambient texture to define their ambient occlusion.
  46511. */
  46512. useRadianceOcclusion: boolean;
  46513. /**
  46514. * If set to true, no lighting calculations will be applied.
  46515. */
  46516. unlit: boolean;
  46517. /**
  46518. * Gets the image processing configuration used either in this material.
  46519. */
  46520. /**
  46521. * Sets the Default image processing configuration used either in the this material.
  46522. *
  46523. * If sets to null, the scene one is in use.
  46524. */
  46525. imageProcessingConfiguration: ImageProcessingConfiguration;
  46526. /**
  46527. * Gets wether the color curves effect is enabled.
  46528. */
  46529. /**
  46530. * Sets wether the color curves effect is enabled.
  46531. */
  46532. cameraColorCurvesEnabled: boolean;
  46533. /**
  46534. * Gets wether the color grading effect is enabled.
  46535. */
  46536. /**
  46537. * Gets wether the color grading effect is enabled.
  46538. */
  46539. cameraColorGradingEnabled: boolean;
  46540. /**
  46541. * Gets wether tonemapping is enabled or not.
  46542. */
  46543. /**
  46544. * Sets wether tonemapping is enabled or not
  46545. */
  46546. cameraToneMappingEnabled: boolean;
  46547. /**
  46548. * The camera exposure used on this material.
  46549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46550. * This corresponds to a photographic exposure.
  46551. */
  46552. /**
  46553. * The camera exposure used on this material.
  46554. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46555. * This corresponds to a photographic exposure.
  46556. */
  46557. cameraExposure: number;
  46558. /**
  46559. * Gets The camera contrast used on this material.
  46560. */
  46561. /**
  46562. * Sets The camera contrast used on this material.
  46563. */
  46564. cameraContrast: number;
  46565. /**
  46566. * Gets the Color Grading 2D Lookup Texture.
  46567. */
  46568. /**
  46569. * Sets the Color Grading 2D Lookup Texture.
  46570. */
  46571. cameraColorGradingTexture: Nullable<BaseTexture>;
  46572. /**
  46573. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46574. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46575. * 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;
  46576. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46577. */
  46578. /**
  46579. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46580. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46581. * 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;
  46582. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46583. */
  46584. cameraColorCurves: Nullable<ColorCurves>;
  46585. /**
  46586. * Instantiates a new PBRMaterial instance.
  46587. *
  46588. * @param name The material name
  46589. * @param scene The scene the material will be use in.
  46590. */
  46591. constructor(name: string, scene: Scene);
  46592. /**
  46593. * Returns the name of this material class.
  46594. */
  46595. getClassName(): string;
  46596. /**
  46597. * Makes a duplicate of the current material.
  46598. * @param name - name to use for the new material.
  46599. */
  46600. clone(name: string): PBRMaterial;
  46601. /**
  46602. * Serializes this PBR Material.
  46603. * @returns - An object with the serialized material.
  46604. */
  46605. serialize(): any;
  46606. /**
  46607. * Parses a PBR Material from a serialized object.
  46608. * @param source - Serialized object.
  46609. * @param scene - BJS scene instance.
  46610. * @param rootUrl - url for the scene object
  46611. * @returns - PBRMaterial
  46612. */
  46613. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46614. }
  46615. }
  46616. declare module BABYLON {
  46617. /**
  46618. * Direct draw surface info
  46619. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46620. */
  46621. export interface DDSInfo {
  46622. /**
  46623. * Width of the texture
  46624. */
  46625. width: number;
  46626. /**
  46627. * Width of the texture
  46628. */
  46629. height: number;
  46630. /**
  46631. * Number of Mipmaps for the texture
  46632. * @see https://en.wikipedia.org/wiki/Mipmap
  46633. */
  46634. mipmapCount: number;
  46635. /**
  46636. * If the textures format is a known fourCC format
  46637. * @see https://www.fourcc.org/
  46638. */
  46639. isFourCC: boolean;
  46640. /**
  46641. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46642. */
  46643. isRGB: boolean;
  46644. /**
  46645. * If the texture is a lumincance format
  46646. */
  46647. isLuminance: boolean;
  46648. /**
  46649. * If this is a cube texture
  46650. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46651. */
  46652. isCube: boolean;
  46653. /**
  46654. * If the texture is a compressed format eg. FOURCC_DXT1
  46655. */
  46656. isCompressed: boolean;
  46657. /**
  46658. * The dxgiFormat of the texture
  46659. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46660. */
  46661. dxgiFormat: number;
  46662. /**
  46663. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46664. */
  46665. textureType: number;
  46666. /**
  46667. * Sphericle polynomial created for the dds texture
  46668. */
  46669. sphericalPolynomial?: SphericalPolynomial;
  46670. }
  46671. /**
  46672. * Class used to provide DDS decompression tools
  46673. */
  46674. export class DDSTools {
  46675. /**
  46676. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46677. */
  46678. static StoreLODInAlphaChannel: boolean;
  46679. /**
  46680. * Gets DDS information from an array buffer
  46681. * @param arrayBuffer defines the array buffer to read data from
  46682. * @returns the DDS information
  46683. */
  46684. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46685. private static _FloatView;
  46686. private static _Int32View;
  46687. private static _ToHalfFloat;
  46688. private static _FromHalfFloat;
  46689. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46690. private static _GetHalfFloatRGBAArrayBuffer;
  46691. private static _GetFloatRGBAArrayBuffer;
  46692. private static _GetFloatAsUIntRGBAArrayBuffer;
  46693. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46694. private static _GetRGBAArrayBuffer;
  46695. private static _ExtractLongWordOrder;
  46696. private static _GetRGBArrayBuffer;
  46697. private static _GetLuminanceArrayBuffer;
  46698. /**
  46699. * Uploads DDS Levels to a Babylon Texture
  46700. * @hidden
  46701. */
  46702. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46703. }
  46704. interface Engine {
  46705. /**
  46706. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46707. * @param rootUrl defines the url where the file to load is located
  46708. * @param scene defines the current scene
  46709. * @param lodScale defines scale to apply to the mip map selection
  46710. * @param lodOffset defines offset to apply to the mip map selection
  46711. * @param onLoad defines an optional callback raised when the texture is loaded
  46712. * @param onError defines an optional callback raised if there is an issue to load the texture
  46713. * @param format defines the format of the data
  46714. * @param forcedExtension defines the extension to use to pick the right loader
  46715. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46716. * @returns the cube texture as an InternalTexture
  46717. */
  46718. 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;
  46719. }
  46720. }
  46721. declare module BABYLON {
  46722. /**
  46723. * Implementation of the DDS Texture Loader.
  46724. * @hidden
  46725. */
  46726. export class _DDSTextureLoader implements IInternalTextureLoader {
  46727. /**
  46728. * Defines wether the loader supports cascade loading the different faces.
  46729. */
  46730. readonly supportCascades: boolean;
  46731. /**
  46732. * This returns if the loader support the current file information.
  46733. * @param extension defines the file extension of the file being loaded
  46734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46735. * @param fallback defines the fallback internal texture if any
  46736. * @param isBase64 defines whether the texture is encoded as a base64
  46737. * @param isBuffer defines whether the texture data are stored as a buffer
  46738. * @returns true if the loader can load the specified file
  46739. */
  46740. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46741. /**
  46742. * Transform the url before loading if required.
  46743. * @param rootUrl the url of the texture
  46744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46745. * @returns the transformed texture
  46746. */
  46747. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46748. /**
  46749. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46750. * @param rootUrl the url of the texture
  46751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46752. * @returns the fallback texture
  46753. */
  46754. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46755. /**
  46756. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46757. * @param data contains the texture data
  46758. * @param texture defines the BabylonJS internal texture
  46759. * @param createPolynomials will be true if polynomials have been requested
  46760. * @param onLoad defines the callback to trigger once the texture is ready
  46761. * @param onError defines the callback to trigger in case of error
  46762. */
  46763. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46764. /**
  46765. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46766. * @param data contains the texture data
  46767. * @param texture defines the BabylonJS internal texture
  46768. * @param callback defines the method to call once ready to upload
  46769. */
  46770. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46771. }
  46772. }
  46773. declare module BABYLON {
  46774. /** @hidden */
  46775. export var rgbdEncodePixelShader: {
  46776. name: string;
  46777. shader: string;
  46778. };
  46779. }
  46780. declare module BABYLON {
  46781. /**
  46782. * Raw texture data and descriptor sufficient for WebGL texture upload
  46783. */
  46784. export interface EnvironmentTextureInfo {
  46785. /**
  46786. * Version of the environment map
  46787. */
  46788. version: number;
  46789. /**
  46790. * Width of image
  46791. */
  46792. width: number;
  46793. /**
  46794. * Irradiance information stored in the file.
  46795. */
  46796. irradiance: any;
  46797. /**
  46798. * Specular information stored in the file.
  46799. */
  46800. specular: any;
  46801. }
  46802. /**
  46803. * Sets of helpers addressing the serialization and deserialization of environment texture
  46804. * stored in a BabylonJS env file.
  46805. * Those files are usually stored as .env files.
  46806. */
  46807. export class EnvironmentTextureTools {
  46808. /**
  46809. * Magic number identifying the env file.
  46810. */
  46811. private static _MagicBytes;
  46812. /**
  46813. * Gets the environment info from an env file.
  46814. * @param data The array buffer containing the .env bytes.
  46815. * @returns the environment file info (the json header) if successfully parsed.
  46816. */
  46817. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46818. /**
  46819. * Creates an environment texture from a loaded cube texture.
  46820. * @param texture defines the cube texture to convert in env file
  46821. * @return a promise containing the environment data if succesfull.
  46822. */
  46823. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46824. /**
  46825. * Creates a JSON representation of the spherical data.
  46826. * @param texture defines the texture containing the polynomials
  46827. * @return the JSON representation of the spherical info
  46828. */
  46829. private static _CreateEnvTextureIrradiance;
  46830. /**
  46831. * Uploads the texture info contained in the env file to the GPU.
  46832. * @param texture defines the internal texture to upload to
  46833. * @param arrayBuffer defines the buffer cotaining the data to load
  46834. * @param info defines the texture info retrieved through the GetEnvInfo method
  46835. * @returns a promise
  46836. */
  46837. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46838. /**
  46839. * Uploads the levels of image data to the GPU.
  46840. * @param texture defines the internal texture to upload to
  46841. * @param imageData defines the array buffer views of image data [mipmap][face]
  46842. * @returns a promise
  46843. */
  46844. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46845. /**
  46846. * Uploads spherical polynomials information to the texture.
  46847. * @param texture defines the texture we are trying to upload the information to
  46848. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46849. */
  46850. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46851. /** @hidden */
  46852. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46853. }
  46854. }
  46855. declare module BABYLON {
  46856. /**
  46857. * Implementation of the ENV Texture Loader.
  46858. * @hidden
  46859. */
  46860. export class _ENVTextureLoader implements IInternalTextureLoader {
  46861. /**
  46862. * Defines wether the loader supports cascade loading the different faces.
  46863. */
  46864. readonly supportCascades: boolean;
  46865. /**
  46866. * This returns if the loader support the current file information.
  46867. * @param extension defines the file extension of the file being loaded
  46868. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46869. * @param fallback defines the fallback internal texture if any
  46870. * @param isBase64 defines whether the texture is encoded as a base64
  46871. * @param isBuffer defines whether the texture data are stored as a buffer
  46872. * @returns true if the loader can load the specified file
  46873. */
  46874. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46875. /**
  46876. * Transform the url before loading if required.
  46877. * @param rootUrl the url of the texture
  46878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46879. * @returns the transformed texture
  46880. */
  46881. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46882. /**
  46883. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46884. * @param rootUrl the url of the texture
  46885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46886. * @returns the fallback texture
  46887. */
  46888. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46889. /**
  46890. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46891. * @param data contains the texture data
  46892. * @param texture defines the BabylonJS internal texture
  46893. * @param createPolynomials will be true if polynomials have been requested
  46894. * @param onLoad defines the callback to trigger once the texture is ready
  46895. * @param onError defines the callback to trigger in case of error
  46896. */
  46897. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46898. /**
  46899. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46900. * @param data contains the texture data
  46901. * @param texture defines the BabylonJS internal texture
  46902. * @param callback defines the method to call once ready to upload
  46903. */
  46904. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46905. }
  46906. }
  46907. declare module BABYLON {
  46908. /**
  46909. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46910. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46911. */
  46912. export class KhronosTextureContainer {
  46913. /** contents of the KTX container file */
  46914. arrayBuffer: any;
  46915. private static HEADER_LEN;
  46916. private static COMPRESSED_2D;
  46917. private static COMPRESSED_3D;
  46918. private static TEX_2D;
  46919. private static TEX_3D;
  46920. /**
  46921. * Gets the openGL type
  46922. */
  46923. glType: number;
  46924. /**
  46925. * Gets the openGL type size
  46926. */
  46927. glTypeSize: number;
  46928. /**
  46929. * Gets the openGL format
  46930. */
  46931. glFormat: number;
  46932. /**
  46933. * Gets the openGL internal format
  46934. */
  46935. glInternalFormat: number;
  46936. /**
  46937. * Gets the base internal format
  46938. */
  46939. glBaseInternalFormat: number;
  46940. /**
  46941. * Gets image width in pixel
  46942. */
  46943. pixelWidth: number;
  46944. /**
  46945. * Gets image height in pixel
  46946. */
  46947. pixelHeight: number;
  46948. /**
  46949. * Gets image depth in pixels
  46950. */
  46951. pixelDepth: number;
  46952. /**
  46953. * Gets the number of array elements
  46954. */
  46955. numberOfArrayElements: number;
  46956. /**
  46957. * Gets the number of faces
  46958. */
  46959. numberOfFaces: number;
  46960. /**
  46961. * Gets the number of mipmap levels
  46962. */
  46963. numberOfMipmapLevels: number;
  46964. /**
  46965. * Gets the bytes of key value data
  46966. */
  46967. bytesOfKeyValueData: number;
  46968. /**
  46969. * Gets the load type
  46970. */
  46971. loadType: number;
  46972. /**
  46973. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46974. */
  46975. isInvalid: boolean;
  46976. /**
  46977. * Creates a new KhronosTextureContainer
  46978. * @param arrayBuffer contents of the KTX container file
  46979. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46980. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46981. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46982. */
  46983. constructor(
  46984. /** contents of the KTX container file */
  46985. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46986. /**
  46987. * Uploads KTX content to a Babylon Texture.
  46988. * It is assumed that the texture has already been created & is currently bound
  46989. * @hidden
  46990. */
  46991. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46992. private _upload2DCompressedLevels;
  46993. }
  46994. }
  46995. declare module BABYLON {
  46996. /**
  46997. * Implementation of the KTX Texture Loader.
  46998. * @hidden
  46999. */
  47000. export class _KTXTextureLoader implements IInternalTextureLoader {
  47001. /**
  47002. * Defines wether the loader supports cascade loading the different faces.
  47003. */
  47004. readonly supportCascades: boolean;
  47005. /**
  47006. * This returns if the loader support the current file information.
  47007. * @param extension defines the file extension of the file being loaded
  47008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47009. * @param fallback defines the fallback internal texture if any
  47010. * @param isBase64 defines whether the texture is encoded as a base64
  47011. * @param isBuffer defines whether the texture data are stored as a buffer
  47012. * @returns true if the loader can load the specified file
  47013. */
  47014. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47015. /**
  47016. * Transform the url before loading if required.
  47017. * @param rootUrl the url of the texture
  47018. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47019. * @returns the transformed texture
  47020. */
  47021. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47022. /**
  47023. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47024. * @param rootUrl the url of the texture
  47025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47026. * @returns the fallback texture
  47027. */
  47028. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47029. /**
  47030. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47031. * @param data contains the texture data
  47032. * @param texture defines the BabylonJS internal texture
  47033. * @param createPolynomials will be true if polynomials have been requested
  47034. * @param onLoad defines the callback to trigger once the texture is ready
  47035. * @param onError defines the callback to trigger in case of error
  47036. */
  47037. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47038. /**
  47039. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47040. * @param data contains the texture data
  47041. * @param texture defines the BabylonJS internal texture
  47042. * @param callback defines the method to call once ready to upload
  47043. */
  47044. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47045. }
  47046. }
  47047. declare module BABYLON {
  47048. /** @hidden */
  47049. export var _forceSceneHelpersToBundle: boolean;
  47050. interface Scene {
  47051. /**
  47052. * Creates a default light for the scene.
  47053. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47054. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47055. */
  47056. createDefaultLight(replace?: boolean): void;
  47057. /**
  47058. * Creates a default camera for the scene.
  47059. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47060. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47061. * @param replace has default false, when true replaces the active camera in the scene
  47062. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47063. */
  47064. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47065. /**
  47066. * Creates a default camera and a default light.
  47067. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47068. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47069. * @param replace has the default false, when true replaces the active camera/light in the scene
  47070. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47071. */
  47072. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47073. /**
  47074. * Creates a new sky box
  47075. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47076. * @param environmentTexture defines the texture to use as environment texture
  47077. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47078. * @param scale defines the overall scale of the skybox
  47079. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47080. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47081. * @returns a new mesh holding the sky box
  47082. */
  47083. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47084. /**
  47085. * Creates a new environment
  47086. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47087. * @param options defines the options you can use to configure the environment
  47088. * @returns the new EnvironmentHelper
  47089. */
  47090. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47091. /**
  47092. * Creates a new VREXperienceHelper
  47093. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47094. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47095. * @returns a new VREXperienceHelper
  47096. */
  47097. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47098. /**
  47099. * Creates a new XREXperienceHelper
  47100. * @see http://doc.babylonjs.com/how_to/webxr
  47101. * @returns a promise for a new XREXperienceHelper
  47102. */
  47103. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47104. }
  47105. }
  47106. declare module BABYLON {
  47107. /**
  47108. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47109. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47110. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47111. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47112. */
  47113. export class VideoDome extends TransformNode {
  47114. /**
  47115. * Define the video source as a Monoscopic panoramic 360 video.
  47116. */
  47117. static readonly MODE_MONOSCOPIC: number;
  47118. /**
  47119. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47120. */
  47121. static readonly MODE_TOPBOTTOM: number;
  47122. /**
  47123. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47124. */
  47125. static readonly MODE_SIDEBYSIDE: number;
  47126. private _useDirectMapping;
  47127. /**
  47128. * The video texture being displayed on the sphere
  47129. */
  47130. protected _videoTexture: VideoTexture;
  47131. /**
  47132. * Gets the video texture being displayed on the sphere
  47133. */
  47134. readonly videoTexture: VideoTexture;
  47135. /**
  47136. * The skybox material
  47137. */
  47138. protected _material: BackgroundMaterial;
  47139. /**
  47140. * The surface used for the skybox
  47141. */
  47142. protected _mesh: Mesh;
  47143. /**
  47144. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47145. * Also see the options.resolution property.
  47146. */
  47147. fovMultiplier: number;
  47148. private _videoMode;
  47149. /**
  47150. * Gets or set the current video mode for the video. It can be:
  47151. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47152. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47153. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47154. */
  47155. videoMode: number;
  47156. /**
  47157. * Oberserver used in Stereoscopic VR Mode.
  47158. */
  47159. private _onBeforeCameraRenderObserver;
  47160. /**
  47161. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47162. * @param name Element's name, child elements will append suffixes for their own names.
  47163. * @param urlsOrVideo defines the url(s) or the video element to use
  47164. * @param options An object containing optional or exposed sub element properties
  47165. */
  47166. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47167. resolution?: number;
  47168. clickToPlay?: boolean;
  47169. autoPlay?: boolean;
  47170. loop?: boolean;
  47171. size?: number;
  47172. poster?: string;
  47173. faceForward?: boolean;
  47174. useDirectMapping?: boolean;
  47175. }, scene: Scene);
  47176. private _changeVideoMode;
  47177. /**
  47178. * Releases resources associated with this node.
  47179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47181. */
  47182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47183. }
  47184. }
  47185. declare module BABYLON {
  47186. /**
  47187. * This class can be used to get instrumentation data from a Babylon engine
  47188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47189. */
  47190. export class EngineInstrumentation implements IDisposable {
  47191. /**
  47192. * Define the instrumented engine.
  47193. */
  47194. engine: Engine;
  47195. private _captureGPUFrameTime;
  47196. private _gpuFrameTimeToken;
  47197. private _gpuFrameTime;
  47198. private _captureShaderCompilationTime;
  47199. private _shaderCompilationTime;
  47200. private _onBeginFrameObserver;
  47201. private _onEndFrameObserver;
  47202. private _onBeforeShaderCompilationObserver;
  47203. private _onAfterShaderCompilationObserver;
  47204. /**
  47205. * Gets the perf counter used for GPU frame time
  47206. */
  47207. readonly gpuFrameTimeCounter: PerfCounter;
  47208. /**
  47209. * Gets the GPU frame time capture status
  47210. */
  47211. /**
  47212. * Enable or disable the GPU frame time capture
  47213. */
  47214. captureGPUFrameTime: boolean;
  47215. /**
  47216. * Gets the perf counter used for shader compilation time
  47217. */
  47218. readonly shaderCompilationTimeCounter: PerfCounter;
  47219. /**
  47220. * Gets the shader compilation time capture status
  47221. */
  47222. /**
  47223. * Enable or disable the shader compilation time capture
  47224. */
  47225. captureShaderCompilationTime: boolean;
  47226. /**
  47227. * Instantiates a new engine instrumentation.
  47228. * This class can be used to get instrumentation data from a Babylon engine
  47229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47230. * @param engine Defines the engine to instrument
  47231. */
  47232. constructor(
  47233. /**
  47234. * Define the instrumented engine.
  47235. */
  47236. engine: Engine);
  47237. /**
  47238. * Dispose and release associated resources.
  47239. */
  47240. dispose(): void;
  47241. }
  47242. }
  47243. declare module BABYLON {
  47244. /**
  47245. * This class can be used to get instrumentation data from a Babylon engine
  47246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47247. */
  47248. export class SceneInstrumentation implements IDisposable {
  47249. /**
  47250. * Defines the scene to instrument
  47251. */
  47252. scene: Scene;
  47253. private _captureActiveMeshesEvaluationTime;
  47254. private _activeMeshesEvaluationTime;
  47255. private _captureRenderTargetsRenderTime;
  47256. private _renderTargetsRenderTime;
  47257. private _captureFrameTime;
  47258. private _frameTime;
  47259. private _captureRenderTime;
  47260. private _renderTime;
  47261. private _captureInterFrameTime;
  47262. private _interFrameTime;
  47263. private _captureParticlesRenderTime;
  47264. private _particlesRenderTime;
  47265. private _captureSpritesRenderTime;
  47266. private _spritesRenderTime;
  47267. private _capturePhysicsTime;
  47268. private _physicsTime;
  47269. private _captureAnimationsTime;
  47270. private _animationsTime;
  47271. private _captureCameraRenderTime;
  47272. private _cameraRenderTime;
  47273. private _onBeforeActiveMeshesEvaluationObserver;
  47274. private _onAfterActiveMeshesEvaluationObserver;
  47275. private _onBeforeRenderTargetsRenderObserver;
  47276. private _onAfterRenderTargetsRenderObserver;
  47277. private _onAfterRenderObserver;
  47278. private _onBeforeDrawPhaseObserver;
  47279. private _onAfterDrawPhaseObserver;
  47280. private _onBeforeAnimationsObserver;
  47281. private _onBeforeParticlesRenderingObserver;
  47282. private _onAfterParticlesRenderingObserver;
  47283. private _onBeforeSpritesRenderingObserver;
  47284. private _onAfterSpritesRenderingObserver;
  47285. private _onBeforePhysicsObserver;
  47286. private _onAfterPhysicsObserver;
  47287. private _onAfterAnimationsObserver;
  47288. private _onBeforeCameraRenderObserver;
  47289. private _onAfterCameraRenderObserver;
  47290. /**
  47291. * Gets the perf counter used for active meshes evaluation time
  47292. */
  47293. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47294. /**
  47295. * Gets the active meshes evaluation time capture status
  47296. */
  47297. /**
  47298. * Enable or disable the active meshes evaluation time capture
  47299. */
  47300. captureActiveMeshesEvaluationTime: boolean;
  47301. /**
  47302. * Gets the perf counter used for render targets render time
  47303. */
  47304. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47305. /**
  47306. * Gets the render targets render time capture status
  47307. */
  47308. /**
  47309. * Enable or disable the render targets render time capture
  47310. */
  47311. captureRenderTargetsRenderTime: boolean;
  47312. /**
  47313. * Gets the perf counter used for particles render time
  47314. */
  47315. readonly particlesRenderTimeCounter: PerfCounter;
  47316. /**
  47317. * Gets the particles render time capture status
  47318. */
  47319. /**
  47320. * Enable or disable the particles render time capture
  47321. */
  47322. captureParticlesRenderTime: boolean;
  47323. /**
  47324. * Gets the perf counter used for sprites render time
  47325. */
  47326. readonly spritesRenderTimeCounter: PerfCounter;
  47327. /**
  47328. * Gets the sprites render time capture status
  47329. */
  47330. /**
  47331. * Enable or disable the sprites render time capture
  47332. */
  47333. captureSpritesRenderTime: boolean;
  47334. /**
  47335. * Gets the perf counter used for physics time
  47336. */
  47337. readonly physicsTimeCounter: PerfCounter;
  47338. /**
  47339. * Gets the physics time capture status
  47340. */
  47341. /**
  47342. * Enable or disable the physics time capture
  47343. */
  47344. capturePhysicsTime: boolean;
  47345. /**
  47346. * Gets the perf counter used for animations time
  47347. */
  47348. readonly animationsTimeCounter: PerfCounter;
  47349. /**
  47350. * Gets the animations time capture status
  47351. */
  47352. /**
  47353. * Enable or disable the animations time capture
  47354. */
  47355. captureAnimationsTime: boolean;
  47356. /**
  47357. * Gets the perf counter used for frame time capture
  47358. */
  47359. readonly frameTimeCounter: PerfCounter;
  47360. /**
  47361. * Gets the frame time capture status
  47362. */
  47363. /**
  47364. * Enable or disable the frame time capture
  47365. */
  47366. captureFrameTime: boolean;
  47367. /**
  47368. * Gets the perf counter used for inter-frames time capture
  47369. */
  47370. readonly interFrameTimeCounter: PerfCounter;
  47371. /**
  47372. * Gets the inter-frames time capture status
  47373. */
  47374. /**
  47375. * Enable or disable the inter-frames time capture
  47376. */
  47377. captureInterFrameTime: boolean;
  47378. /**
  47379. * Gets the perf counter used for render time capture
  47380. */
  47381. readonly renderTimeCounter: PerfCounter;
  47382. /**
  47383. * Gets the render time capture status
  47384. */
  47385. /**
  47386. * Enable or disable the render time capture
  47387. */
  47388. captureRenderTime: boolean;
  47389. /**
  47390. * Gets the perf counter used for camera render time capture
  47391. */
  47392. readonly cameraRenderTimeCounter: PerfCounter;
  47393. /**
  47394. * Gets the camera render time capture status
  47395. */
  47396. /**
  47397. * Enable or disable the camera render time capture
  47398. */
  47399. captureCameraRenderTime: boolean;
  47400. /**
  47401. * Gets the perf counter used for draw calls
  47402. */
  47403. readonly drawCallsCounter: PerfCounter;
  47404. /**
  47405. * Instantiates a new scene instrumentation.
  47406. * This class can be used to get instrumentation data from a Babylon engine
  47407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47408. * @param scene Defines the scene to instrument
  47409. */
  47410. constructor(
  47411. /**
  47412. * Defines the scene to instrument
  47413. */
  47414. scene: Scene);
  47415. /**
  47416. * Dispose and release associated resources.
  47417. */
  47418. dispose(): void;
  47419. }
  47420. }
  47421. declare module BABYLON {
  47422. /** @hidden */
  47423. export var glowMapGenerationPixelShader: {
  47424. name: string;
  47425. shader: string;
  47426. };
  47427. }
  47428. declare module BABYLON {
  47429. /** @hidden */
  47430. export var glowMapGenerationVertexShader: {
  47431. name: string;
  47432. shader: string;
  47433. };
  47434. }
  47435. declare module BABYLON {
  47436. /**
  47437. * Effect layer options. This helps customizing the behaviour
  47438. * of the effect layer.
  47439. */
  47440. export interface IEffectLayerOptions {
  47441. /**
  47442. * Multiplication factor apply to the canvas size to compute the render target size
  47443. * used to generated the objects (the smaller the faster).
  47444. */
  47445. mainTextureRatio: number;
  47446. /**
  47447. * Enforces a fixed size texture to ensure effect stability across devices.
  47448. */
  47449. mainTextureFixedSize?: number;
  47450. /**
  47451. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47452. */
  47453. alphaBlendingMode: number;
  47454. /**
  47455. * The camera attached to the layer.
  47456. */
  47457. camera: Nullable<Camera>;
  47458. /**
  47459. * The rendering group to draw the layer in.
  47460. */
  47461. renderingGroupId: number;
  47462. }
  47463. /**
  47464. * The effect layer Helps adding post process effect blended with the main pass.
  47465. *
  47466. * This can be for instance use to generate glow or higlight effects on the scene.
  47467. *
  47468. * The effect layer class can not be used directly and is intented to inherited from to be
  47469. * customized per effects.
  47470. */
  47471. export abstract class EffectLayer {
  47472. private _vertexBuffers;
  47473. private _indexBuffer;
  47474. private _cachedDefines;
  47475. private _effectLayerMapGenerationEffect;
  47476. private _effectLayerOptions;
  47477. private _mergeEffect;
  47478. protected _scene: Scene;
  47479. protected _engine: Engine;
  47480. protected _maxSize: number;
  47481. protected _mainTextureDesiredSize: ISize;
  47482. protected _mainTexture: RenderTargetTexture;
  47483. protected _shouldRender: boolean;
  47484. protected _postProcesses: PostProcess[];
  47485. protected _textures: BaseTexture[];
  47486. protected _emissiveTextureAndColor: {
  47487. texture: Nullable<BaseTexture>;
  47488. color: Color4;
  47489. };
  47490. /**
  47491. * The name of the layer
  47492. */
  47493. name: string;
  47494. /**
  47495. * The clear color of the texture used to generate the glow map.
  47496. */
  47497. neutralColor: Color4;
  47498. /**
  47499. * Specifies wether the highlight layer is enabled or not.
  47500. */
  47501. isEnabled: boolean;
  47502. /**
  47503. * Gets the camera attached to the layer.
  47504. */
  47505. readonly camera: Nullable<Camera>;
  47506. /**
  47507. * Gets the rendering group id the layer should render in.
  47508. */
  47509. readonly renderingGroupId: number;
  47510. /**
  47511. * An event triggered when the effect layer has been disposed.
  47512. */
  47513. onDisposeObservable: Observable<EffectLayer>;
  47514. /**
  47515. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47516. */
  47517. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47518. /**
  47519. * An event triggered when the generated texture is being merged in the scene.
  47520. */
  47521. onBeforeComposeObservable: Observable<EffectLayer>;
  47522. /**
  47523. * An event triggered when the generated texture has been merged in the scene.
  47524. */
  47525. onAfterComposeObservable: Observable<EffectLayer>;
  47526. /**
  47527. * An event triggered when the efffect layer changes its size.
  47528. */
  47529. onSizeChangedObservable: Observable<EffectLayer>;
  47530. /** @hidden */
  47531. static _SceneComponentInitialization: (scene: Scene) => void;
  47532. /**
  47533. * Instantiates a new effect Layer and references it in the scene.
  47534. * @param name The name of the layer
  47535. * @param scene The scene to use the layer in
  47536. */
  47537. constructor(
  47538. /** The Friendly of the effect in the scene */
  47539. name: string, scene: Scene);
  47540. /**
  47541. * Get the effect name of the layer.
  47542. * @return The effect name
  47543. */
  47544. abstract getEffectName(): string;
  47545. /**
  47546. * Checks for the readiness of the element composing the layer.
  47547. * @param subMesh the mesh to check for
  47548. * @param useInstances specify wether or not to use instances to render the mesh
  47549. * @return true if ready otherwise, false
  47550. */
  47551. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47552. /**
  47553. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47554. * @returns true if the effect requires stencil during the main canvas render pass.
  47555. */
  47556. abstract needStencil(): boolean;
  47557. /**
  47558. * Create the merge effect. This is the shader use to blit the information back
  47559. * to the main canvas at the end of the scene rendering.
  47560. * @returns The effect containing the shader used to merge the effect on the main canvas
  47561. */
  47562. protected abstract _createMergeEffect(): Effect;
  47563. /**
  47564. * Creates the render target textures and post processes used in the effect layer.
  47565. */
  47566. protected abstract _createTextureAndPostProcesses(): void;
  47567. /**
  47568. * Implementation specific of rendering the generating effect on the main canvas.
  47569. * @param effect The effect used to render through
  47570. */
  47571. protected abstract _internalRender(effect: Effect): void;
  47572. /**
  47573. * Sets the required values for both the emissive texture and and the main color.
  47574. */
  47575. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47576. /**
  47577. * Free any resources and references associated to a mesh.
  47578. * Internal use
  47579. * @param mesh The mesh to free.
  47580. */
  47581. abstract _disposeMesh(mesh: Mesh): void;
  47582. /**
  47583. * Serializes this layer (Glow or Highlight for example)
  47584. * @returns a serialized layer object
  47585. */
  47586. abstract serialize?(): any;
  47587. /**
  47588. * Initializes the effect layer with the required options.
  47589. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47590. */
  47591. protected _init(options: Partial<IEffectLayerOptions>): void;
  47592. /**
  47593. * Generates the index buffer of the full screen quad blending to the main canvas.
  47594. */
  47595. private _generateIndexBuffer;
  47596. /**
  47597. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47598. */
  47599. private _generateVertexBuffer;
  47600. /**
  47601. * Sets the main texture desired size which is the closest power of two
  47602. * of the engine canvas size.
  47603. */
  47604. private _setMainTextureSize;
  47605. /**
  47606. * Creates the main texture for the effect layer.
  47607. */
  47608. protected _createMainTexture(): void;
  47609. /**
  47610. * Adds specific effects defines.
  47611. * @param defines The defines to add specifics to.
  47612. */
  47613. protected _addCustomEffectDefines(defines: string[]): void;
  47614. /**
  47615. * Checks for the readiness of the element composing the layer.
  47616. * @param subMesh the mesh to check for
  47617. * @param useInstances specify wether or not to use instances to render the mesh
  47618. * @param emissiveTexture the associated emissive texture used to generate the glow
  47619. * @return true if ready otherwise, false
  47620. */
  47621. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47622. /**
  47623. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47624. */
  47625. render(): void;
  47626. /**
  47627. * Determine if a given mesh will be used in the current effect.
  47628. * @param mesh mesh to test
  47629. * @returns true if the mesh will be used
  47630. */
  47631. hasMesh(mesh: AbstractMesh): boolean;
  47632. /**
  47633. * Returns true if the layer contains information to display, otherwise false.
  47634. * @returns true if the glow layer should be rendered
  47635. */
  47636. shouldRender(): boolean;
  47637. /**
  47638. * Returns true if the mesh should render, otherwise false.
  47639. * @param mesh The mesh to render
  47640. * @returns true if it should render otherwise false
  47641. */
  47642. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47643. /**
  47644. * Returns true if the mesh can be rendered, otherwise false.
  47645. * @param mesh The mesh to render
  47646. * @param material The material used on the mesh
  47647. * @returns true if it can be rendered otherwise false
  47648. */
  47649. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47650. /**
  47651. * Returns true if the mesh should render, otherwise false.
  47652. * @param mesh The mesh to render
  47653. * @returns true if it should render otherwise false
  47654. */
  47655. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47656. /**
  47657. * Renders the submesh passed in parameter to the generation map.
  47658. */
  47659. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47660. /**
  47661. * Rebuild the required buffers.
  47662. * @hidden Internal use only.
  47663. */
  47664. _rebuild(): void;
  47665. /**
  47666. * Dispose only the render target textures and post process.
  47667. */
  47668. private _disposeTextureAndPostProcesses;
  47669. /**
  47670. * Dispose the highlight layer and free resources.
  47671. */
  47672. dispose(): void;
  47673. /**
  47674. * Gets the class name of the effect layer
  47675. * @returns the string with the class name of the effect layer
  47676. */
  47677. getClassName(): string;
  47678. /**
  47679. * Creates an effect layer from parsed effect layer data
  47680. * @param parsedEffectLayer defines effect layer data
  47681. * @param scene defines the current scene
  47682. * @param rootUrl defines the root URL containing the effect layer information
  47683. * @returns a parsed effect Layer
  47684. */
  47685. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47686. }
  47687. }
  47688. declare module BABYLON {
  47689. interface AbstractScene {
  47690. /**
  47691. * The list of effect layers (highlights/glow) added to the scene
  47692. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47693. * @see http://doc.babylonjs.com/how_to/glow_layer
  47694. */
  47695. effectLayers: Array<EffectLayer>;
  47696. /**
  47697. * Removes the given effect layer from this scene.
  47698. * @param toRemove defines the effect layer to remove
  47699. * @returns the index of the removed effect layer
  47700. */
  47701. removeEffectLayer(toRemove: EffectLayer): number;
  47702. /**
  47703. * Adds the given effect layer to this scene
  47704. * @param newEffectLayer defines the effect layer to add
  47705. */
  47706. addEffectLayer(newEffectLayer: EffectLayer): void;
  47707. }
  47708. /**
  47709. * Defines the layer scene component responsible to manage any effect layers
  47710. * in a given scene.
  47711. */
  47712. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47713. /**
  47714. * The component name helpfull to identify the component in the list of scene components.
  47715. */
  47716. readonly name: string;
  47717. /**
  47718. * The scene the component belongs to.
  47719. */
  47720. scene: Scene;
  47721. private _engine;
  47722. private _renderEffects;
  47723. private _needStencil;
  47724. private _previousStencilState;
  47725. /**
  47726. * Creates a new instance of the component for the given scene
  47727. * @param scene Defines the scene to register the component in
  47728. */
  47729. constructor(scene: Scene);
  47730. /**
  47731. * Registers the component in a given scene
  47732. */
  47733. register(): void;
  47734. /**
  47735. * Rebuilds the elements related to this component in case of
  47736. * context lost for instance.
  47737. */
  47738. rebuild(): void;
  47739. /**
  47740. * Serializes the component data to the specified json object
  47741. * @param serializationObject The object to serialize to
  47742. */
  47743. serialize(serializationObject: any): void;
  47744. /**
  47745. * Adds all the elements from the container to the scene
  47746. * @param container the container holding the elements
  47747. */
  47748. addFromContainer(container: AbstractScene): void;
  47749. /**
  47750. * Removes all the elements in the container from the scene
  47751. * @param container contains the elements to remove
  47752. * @param dispose if the removed element should be disposed (default: false)
  47753. */
  47754. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47755. /**
  47756. * Disposes the component and the associated ressources.
  47757. */
  47758. dispose(): void;
  47759. private _isReadyForMesh;
  47760. private _renderMainTexture;
  47761. private _setStencil;
  47762. private _setStencilBack;
  47763. private _draw;
  47764. private _drawCamera;
  47765. private _drawRenderingGroup;
  47766. }
  47767. }
  47768. declare module BABYLON {
  47769. /** @hidden */
  47770. export var glowMapMergePixelShader: {
  47771. name: string;
  47772. shader: string;
  47773. };
  47774. }
  47775. declare module BABYLON {
  47776. /** @hidden */
  47777. export var glowMapMergeVertexShader: {
  47778. name: string;
  47779. shader: string;
  47780. };
  47781. }
  47782. declare module BABYLON {
  47783. interface AbstractScene {
  47784. /**
  47785. * Return a the first highlight layer of the scene with a given name.
  47786. * @param name The name of the highlight layer to look for.
  47787. * @return The highlight layer if found otherwise null.
  47788. */
  47789. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47790. }
  47791. /**
  47792. * Glow layer options. This helps customizing the behaviour
  47793. * of the glow layer.
  47794. */
  47795. export interface IGlowLayerOptions {
  47796. /**
  47797. * Multiplication factor apply to the canvas size to compute the render target size
  47798. * used to generated the glowing objects (the smaller the faster).
  47799. */
  47800. mainTextureRatio: number;
  47801. /**
  47802. * Enforces a fixed size texture to ensure resize independant blur.
  47803. */
  47804. mainTextureFixedSize?: number;
  47805. /**
  47806. * How big is the kernel of the blur texture.
  47807. */
  47808. blurKernelSize: number;
  47809. /**
  47810. * The camera attached to the layer.
  47811. */
  47812. camera: Nullable<Camera>;
  47813. /**
  47814. * Enable MSAA by chosing the number of samples.
  47815. */
  47816. mainTextureSamples?: number;
  47817. /**
  47818. * The rendering group to draw the layer in.
  47819. */
  47820. renderingGroupId: number;
  47821. }
  47822. /**
  47823. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47824. *
  47825. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47826. * glowy meshes to your scene.
  47827. *
  47828. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47829. */
  47830. export class GlowLayer extends EffectLayer {
  47831. /**
  47832. * Effect Name of the layer.
  47833. */
  47834. static readonly EffectName: string;
  47835. /**
  47836. * The default blur kernel size used for the glow.
  47837. */
  47838. static DefaultBlurKernelSize: number;
  47839. /**
  47840. * The default texture size ratio used for the glow.
  47841. */
  47842. static DefaultTextureRatio: number;
  47843. /**
  47844. * Sets the kernel size of the blur.
  47845. */
  47846. /**
  47847. * Gets the kernel size of the blur.
  47848. */
  47849. blurKernelSize: number;
  47850. /**
  47851. * Sets the glow intensity.
  47852. */
  47853. /**
  47854. * Gets the glow intensity.
  47855. */
  47856. intensity: number;
  47857. private _options;
  47858. private _intensity;
  47859. private _horizontalBlurPostprocess1;
  47860. private _verticalBlurPostprocess1;
  47861. private _horizontalBlurPostprocess2;
  47862. private _verticalBlurPostprocess2;
  47863. private _blurTexture1;
  47864. private _blurTexture2;
  47865. private _postProcesses1;
  47866. private _postProcesses2;
  47867. private _includedOnlyMeshes;
  47868. private _excludedMeshes;
  47869. /**
  47870. * Callback used to let the user override the color selection on a per mesh basis
  47871. */
  47872. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47873. /**
  47874. * Callback used to let the user override the texture selection on a per mesh basis
  47875. */
  47876. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47877. /**
  47878. * Instantiates a new glow Layer and references it to the scene.
  47879. * @param name The name of the layer
  47880. * @param scene The scene to use the layer in
  47881. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47882. */
  47883. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47884. /**
  47885. * Get the effect name of the layer.
  47886. * @return The effect name
  47887. */
  47888. getEffectName(): string;
  47889. /**
  47890. * Create the merge effect. This is the shader use to blit the information back
  47891. * to the main canvas at the end of the scene rendering.
  47892. */
  47893. protected _createMergeEffect(): Effect;
  47894. /**
  47895. * Creates the render target textures and post processes used in the glow layer.
  47896. */
  47897. protected _createTextureAndPostProcesses(): void;
  47898. /**
  47899. * Checks for the readiness of the element composing the layer.
  47900. * @param subMesh the mesh to check for
  47901. * @param useInstances specify wether or not to use instances to render the mesh
  47902. * @param emissiveTexture the associated emissive texture used to generate the glow
  47903. * @return true if ready otherwise, false
  47904. */
  47905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47906. /**
  47907. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47908. */
  47909. needStencil(): boolean;
  47910. /**
  47911. * Returns true if the mesh can be rendered, otherwise false.
  47912. * @param mesh The mesh to render
  47913. * @param material The material used on the mesh
  47914. * @returns true if it can be rendered otherwise false
  47915. */
  47916. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47917. /**
  47918. * Implementation specific of rendering the generating effect on the main canvas.
  47919. * @param effect The effect used to render through
  47920. */
  47921. protected _internalRender(effect: Effect): void;
  47922. /**
  47923. * Sets the required values for both the emissive texture and and the main color.
  47924. */
  47925. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47926. /**
  47927. * Returns true if the mesh should render, otherwise false.
  47928. * @param mesh The mesh to render
  47929. * @returns true if it should render otherwise false
  47930. */
  47931. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47932. /**
  47933. * Adds specific effects defines.
  47934. * @param defines The defines to add specifics to.
  47935. */
  47936. protected _addCustomEffectDefines(defines: string[]): void;
  47937. /**
  47938. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47939. * @param mesh The mesh to exclude from the glow layer
  47940. */
  47941. addExcludedMesh(mesh: Mesh): void;
  47942. /**
  47943. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47944. * @param mesh The mesh to remove
  47945. */
  47946. removeExcludedMesh(mesh: Mesh): void;
  47947. /**
  47948. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47949. * @param mesh The mesh to include in the glow layer
  47950. */
  47951. addIncludedOnlyMesh(mesh: Mesh): void;
  47952. /**
  47953. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47954. * @param mesh The mesh to remove
  47955. */
  47956. removeIncludedOnlyMesh(mesh: Mesh): void;
  47957. /**
  47958. * Determine if a given mesh will be used in the glow layer
  47959. * @param mesh The mesh to test
  47960. * @returns true if the mesh will be highlighted by the current glow layer
  47961. */
  47962. hasMesh(mesh: AbstractMesh): boolean;
  47963. /**
  47964. * Free any resources and references associated to a mesh.
  47965. * Internal use
  47966. * @param mesh The mesh to free.
  47967. * @hidden
  47968. */
  47969. _disposeMesh(mesh: Mesh): void;
  47970. /**
  47971. * Gets the class name of the effect layer
  47972. * @returns the string with the class name of the effect layer
  47973. */
  47974. getClassName(): string;
  47975. /**
  47976. * Serializes this glow layer
  47977. * @returns a serialized glow layer object
  47978. */
  47979. serialize(): any;
  47980. /**
  47981. * Creates a Glow Layer from parsed glow layer data
  47982. * @param parsedGlowLayer defines glow layer data
  47983. * @param scene defines the current scene
  47984. * @param rootUrl defines the root URL containing the glow layer information
  47985. * @returns a parsed Glow Layer
  47986. */
  47987. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47988. }
  47989. }
  47990. declare module BABYLON {
  47991. /** @hidden */
  47992. export var glowBlurPostProcessPixelShader: {
  47993. name: string;
  47994. shader: string;
  47995. };
  47996. }
  47997. declare module BABYLON {
  47998. interface AbstractScene {
  47999. /**
  48000. * Return a the first highlight layer of the scene with a given name.
  48001. * @param name The name of the highlight layer to look for.
  48002. * @return The highlight layer if found otherwise null.
  48003. */
  48004. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48005. }
  48006. /**
  48007. * Highlight layer options. This helps customizing the behaviour
  48008. * of the highlight layer.
  48009. */
  48010. export interface IHighlightLayerOptions {
  48011. /**
  48012. * Multiplication factor apply to the canvas size to compute the render target size
  48013. * used to generated the glowing objects (the smaller the faster).
  48014. */
  48015. mainTextureRatio: number;
  48016. /**
  48017. * Enforces a fixed size texture to ensure resize independant blur.
  48018. */
  48019. mainTextureFixedSize?: number;
  48020. /**
  48021. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48022. * of the picture to blur (the smaller the faster).
  48023. */
  48024. blurTextureSizeRatio: number;
  48025. /**
  48026. * How big in texel of the blur texture is the vertical blur.
  48027. */
  48028. blurVerticalSize: number;
  48029. /**
  48030. * How big in texel of the blur texture is the horizontal blur.
  48031. */
  48032. blurHorizontalSize: number;
  48033. /**
  48034. * Alpha blending mode used to apply the blur. Default is combine.
  48035. */
  48036. alphaBlendingMode: number;
  48037. /**
  48038. * The camera attached to the layer.
  48039. */
  48040. camera: Nullable<Camera>;
  48041. /**
  48042. * Should we display highlight as a solid stroke?
  48043. */
  48044. isStroke?: boolean;
  48045. /**
  48046. * The rendering group to draw the layer in.
  48047. */
  48048. renderingGroupId: number;
  48049. }
  48050. /**
  48051. * The highlight layer Helps adding a glow effect around a mesh.
  48052. *
  48053. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48054. * glowy meshes to your scene.
  48055. *
  48056. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48057. */
  48058. export class HighlightLayer extends EffectLayer {
  48059. name: string;
  48060. /**
  48061. * Effect Name of the highlight layer.
  48062. */
  48063. static readonly EffectName: string;
  48064. /**
  48065. * The neutral color used during the preparation of the glow effect.
  48066. * This is black by default as the blend operation is a blend operation.
  48067. */
  48068. static NeutralColor: Color4;
  48069. /**
  48070. * Stencil value used for glowing meshes.
  48071. */
  48072. static GlowingMeshStencilReference: number;
  48073. /**
  48074. * Stencil value used for the other meshes in the scene.
  48075. */
  48076. static NormalMeshStencilReference: number;
  48077. /**
  48078. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48079. */
  48080. innerGlow: boolean;
  48081. /**
  48082. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48083. */
  48084. outerGlow: boolean;
  48085. /**
  48086. * Specifies the horizontal size of the blur.
  48087. */
  48088. /**
  48089. * Gets the horizontal size of the blur.
  48090. */
  48091. blurHorizontalSize: number;
  48092. /**
  48093. * Specifies the vertical size of the blur.
  48094. */
  48095. /**
  48096. * Gets the vertical size of the blur.
  48097. */
  48098. blurVerticalSize: number;
  48099. /**
  48100. * An event triggered when the highlight layer is being blurred.
  48101. */
  48102. onBeforeBlurObservable: Observable<HighlightLayer>;
  48103. /**
  48104. * An event triggered when the highlight layer has been blurred.
  48105. */
  48106. onAfterBlurObservable: Observable<HighlightLayer>;
  48107. private _instanceGlowingMeshStencilReference;
  48108. private _options;
  48109. private _downSamplePostprocess;
  48110. private _horizontalBlurPostprocess;
  48111. private _verticalBlurPostprocess;
  48112. private _blurTexture;
  48113. private _meshes;
  48114. private _excludedMeshes;
  48115. /**
  48116. * Instantiates a new highlight Layer and references it to the scene..
  48117. * @param name The name of the layer
  48118. * @param scene The scene to use the layer in
  48119. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48120. */
  48121. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48122. /**
  48123. * Get the effect name of the layer.
  48124. * @return The effect name
  48125. */
  48126. getEffectName(): string;
  48127. /**
  48128. * Create the merge effect. This is the shader use to blit the information back
  48129. * to the main canvas at the end of the scene rendering.
  48130. */
  48131. protected _createMergeEffect(): Effect;
  48132. /**
  48133. * Creates the render target textures and post processes used in the highlight layer.
  48134. */
  48135. protected _createTextureAndPostProcesses(): void;
  48136. /**
  48137. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48138. */
  48139. needStencil(): boolean;
  48140. /**
  48141. * Checks for the readiness of the element composing the layer.
  48142. * @param subMesh the mesh to check for
  48143. * @param useInstances specify wether or not to use instances to render the mesh
  48144. * @param emissiveTexture the associated emissive texture used to generate the glow
  48145. * @return true if ready otherwise, false
  48146. */
  48147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48148. /**
  48149. * Implementation specific of rendering the generating effect on the main canvas.
  48150. * @param effect The effect used to render through
  48151. */
  48152. protected _internalRender(effect: Effect): void;
  48153. /**
  48154. * Returns true if the layer contains information to display, otherwise false.
  48155. */
  48156. shouldRender(): boolean;
  48157. /**
  48158. * Returns true if the mesh should render, otherwise false.
  48159. * @param mesh The mesh to render
  48160. * @returns true if it should render otherwise false
  48161. */
  48162. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48163. /**
  48164. * Sets the required values for both the emissive texture and and the main color.
  48165. */
  48166. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48167. /**
  48168. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48169. * @param mesh The mesh to exclude from the highlight layer
  48170. */
  48171. addExcludedMesh(mesh: Mesh): void;
  48172. /**
  48173. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48174. * @param mesh The mesh to highlight
  48175. */
  48176. removeExcludedMesh(mesh: Mesh): void;
  48177. /**
  48178. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48179. * @param mesh mesh to test
  48180. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48181. */
  48182. hasMesh(mesh: AbstractMesh): boolean;
  48183. /**
  48184. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48185. * @param mesh The mesh to highlight
  48186. * @param color The color of the highlight
  48187. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48188. */
  48189. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48190. /**
  48191. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48192. * @param mesh The mesh to highlight
  48193. */
  48194. removeMesh(mesh: Mesh): void;
  48195. /**
  48196. * Force the stencil to the normal expected value for none glowing parts
  48197. */
  48198. private _defaultStencilReference;
  48199. /**
  48200. * Free any resources and references associated to a mesh.
  48201. * Internal use
  48202. * @param mesh The mesh to free.
  48203. * @hidden
  48204. */
  48205. _disposeMesh(mesh: Mesh): void;
  48206. /**
  48207. * Dispose the highlight layer and free resources.
  48208. */
  48209. dispose(): void;
  48210. /**
  48211. * Gets the class name of the effect layer
  48212. * @returns the string with the class name of the effect layer
  48213. */
  48214. getClassName(): string;
  48215. /**
  48216. * Serializes this Highlight layer
  48217. * @returns a serialized Highlight layer object
  48218. */
  48219. serialize(): any;
  48220. /**
  48221. * Creates a Highlight layer from parsed Highlight layer data
  48222. * @param parsedHightlightLayer defines the Highlight layer data
  48223. * @param scene defines the current scene
  48224. * @param rootUrl defines the root URL containing the Highlight layer information
  48225. * @returns a parsed Highlight layer
  48226. */
  48227. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48228. }
  48229. }
  48230. declare module BABYLON {
  48231. interface AbstractScene {
  48232. /**
  48233. * The list of layers (background and foreground) of the scene
  48234. */
  48235. layers: Array<Layer>;
  48236. }
  48237. /**
  48238. * Defines the layer scene component responsible to manage any layers
  48239. * in a given scene.
  48240. */
  48241. export class LayerSceneComponent implements ISceneComponent {
  48242. /**
  48243. * The component name helpfull to identify the component in the list of scene components.
  48244. */
  48245. readonly name: string;
  48246. /**
  48247. * The scene the component belongs to.
  48248. */
  48249. scene: Scene;
  48250. private _engine;
  48251. /**
  48252. * Creates a new instance of the component for the given scene
  48253. * @param scene Defines the scene to register the component in
  48254. */
  48255. constructor(scene: Scene);
  48256. /**
  48257. * Registers the component in a given scene
  48258. */
  48259. register(): void;
  48260. /**
  48261. * Rebuilds the elements related to this component in case of
  48262. * context lost for instance.
  48263. */
  48264. rebuild(): void;
  48265. /**
  48266. * Disposes the component and the associated ressources.
  48267. */
  48268. dispose(): void;
  48269. private _draw;
  48270. private _drawCameraPredicate;
  48271. private _drawCameraBackground;
  48272. private _drawCameraForeground;
  48273. private _drawRenderTargetPredicate;
  48274. private _drawRenderTargetBackground;
  48275. private _drawRenderTargetForeground;
  48276. /**
  48277. * Adds all the elements from the container to the scene
  48278. * @param container the container holding the elements
  48279. */
  48280. addFromContainer(container: AbstractScene): void;
  48281. /**
  48282. * Removes all the elements in the container from the scene
  48283. * @param container contains the elements to remove
  48284. * @param dispose if the removed element should be disposed (default: false)
  48285. */
  48286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48287. }
  48288. }
  48289. declare module BABYLON {
  48290. /** @hidden */
  48291. export var layerPixelShader: {
  48292. name: string;
  48293. shader: string;
  48294. };
  48295. }
  48296. declare module BABYLON {
  48297. /** @hidden */
  48298. export var layerVertexShader: {
  48299. name: string;
  48300. shader: string;
  48301. };
  48302. }
  48303. declare module BABYLON {
  48304. /**
  48305. * This represents a full screen 2d layer.
  48306. * This can be useful to display a picture in the background of your scene for instance.
  48307. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48308. */
  48309. export class Layer {
  48310. /**
  48311. * Define the name of the layer.
  48312. */
  48313. name: string;
  48314. /**
  48315. * Define the texture the layer should display.
  48316. */
  48317. texture: Nullable<Texture>;
  48318. /**
  48319. * Is the layer in background or foreground.
  48320. */
  48321. isBackground: boolean;
  48322. /**
  48323. * Define the color of the layer (instead of texture).
  48324. */
  48325. color: Color4;
  48326. /**
  48327. * Define the scale of the layer in order to zoom in out of the texture.
  48328. */
  48329. scale: Vector2;
  48330. /**
  48331. * Define an offset for the layer in order to shift the texture.
  48332. */
  48333. offset: Vector2;
  48334. /**
  48335. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48336. */
  48337. alphaBlendingMode: number;
  48338. /**
  48339. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48340. * Alpha test will not mix with the background color in case of transparency.
  48341. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48342. */
  48343. alphaTest: boolean;
  48344. /**
  48345. * Define a mask to restrict the layer to only some of the scene cameras.
  48346. */
  48347. layerMask: number;
  48348. /**
  48349. * Define the list of render target the layer is visible into.
  48350. */
  48351. renderTargetTextures: RenderTargetTexture[];
  48352. /**
  48353. * Define if the layer is only used in renderTarget or if it also
  48354. * renders in the main frame buffer of the canvas.
  48355. */
  48356. renderOnlyInRenderTargetTextures: boolean;
  48357. private _scene;
  48358. private _vertexBuffers;
  48359. private _indexBuffer;
  48360. private _effect;
  48361. private _alphaTestEffect;
  48362. /**
  48363. * An event triggered when the layer is disposed.
  48364. */
  48365. onDisposeObservable: Observable<Layer>;
  48366. private _onDisposeObserver;
  48367. /**
  48368. * Back compatibility with callback before the onDisposeObservable existed.
  48369. * The set callback will be triggered when the layer has been disposed.
  48370. */
  48371. onDispose: () => void;
  48372. /**
  48373. * An event triggered before rendering the scene
  48374. */
  48375. onBeforeRenderObservable: Observable<Layer>;
  48376. private _onBeforeRenderObserver;
  48377. /**
  48378. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48379. * The set callback will be triggered just before rendering the layer.
  48380. */
  48381. onBeforeRender: () => void;
  48382. /**
  48383. * An event triggered after rendering the scene
  48384. */
  48385. onAfterRenderObservable: Observable<Layer>;
  48386. private _onAfterRenderObserver;
  48387. /**
  48388. * Back compatibility with callback before the onAfterRenderObservable existed.
  48389. * The set callback will be triggered just after rendering the layer.
  48390. */
  48391. onAfterRender: () => void;
  48392. /**
  48393. * Instantiates a new layer.
  48394. * This represents a full screen 2d layer.
  48395. * This can be useful to display a picture in the background of your scene for instance.
  48396. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48397. * @param name Define the name of the layer in the scene
  48398. * @param imgUrl Define the url of the texture to display in the layer
  48399. * @param scene Define the scene the layer belongs to
  48400. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48401. * @param color Defines a color for the layer
  48402. */
  48403. constructor(
  48404. /**
  48405. * Define the name of the layer.
  48406. */
  48407. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48408. private _createIndexBuffer;
  48409. /** @hidden */
  48410. _rebuild(): void;
  48411. /**
  48412. * Renders the layer in the scene.
  48413. */
  48414. render(): void;
  48415. /**
  48416. * Disposes and releases the associated ressources.
  48417. */
  48418. dispose(): void;
  48419. }
  48420. }
  48421. declare module BABYLON {
  48422. /** @hidden */
  48423. export var lensFlarePixelShader: {
  48424. name: string;
  48425. shader: string;
  48426. };
  48427. }
  48428. declare module BABYLON {
  48429. /** @hidden */
  48430. export var lensFlareVertexShader: {
  48431. name: string;
  48432. shader: string;
  48433. };
  48434. }
  48435. declare module BABYLON {
  48436. /**
  48437. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48438. * It is usually composed of several `lensFlare`.
  48439. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48440. */
  48441. export class LensFlareSystem {
  48442. /**
  48443. * Define the name of the lens flare system
  48444. */
  48445. name: string;
  48446. /**
  48447. * List of lens flares used in this system.
  48448. */
  48449. lensFlares: LensFlare[];
  48450. /**
  48451. * Define a limit from the border the lens flare can be visible.
  48452. */
  48453. borderLimit: number;
  48454. /**
  48455. * Define a viewport border we do not want to see the lens flare in.
  48456. */
  48457. viewportBorder: number;
  48458. /**
  48459. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48460. */
  48461. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48462. /**
  48463. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48464. */
  48465. layerMask: number;
  48466. /**
  48467. * Define the id of the lens flare system in the scene.
  48468. * (equal to name by default)
  48469. */
  48470. id: string;
  48471. private _scene;
  48472. private _emitter;
  48473. private _vertexBuffers;
  48474. private _indexBuffer;
  48475. private _effect;
  48476. private _positionX;
  48477. private _positionY;
  48478. private _isEnabled;
  48479. /** @hidden */
  48480. static _SceneComponentInitialization: (scene: Scene) => void;
  48481. /**
  48482. * Instantiates a lens flare system.
  48483. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48484. * It is usually composed of several `lensFlare`.
  48485. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48486. * @param name Define the name of the lens flare system in the scene
  48487. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48488. * @param scene Define the scene the lens flare system belongs to
  48489. */
  48490. constructor(
  48491. /**
  48492. * Define the name of the lens flare system
  48493. */
  48494. name: string, emitter: any, scene: Scene);
  48495. /**
  48496. * Define if the lens flare system is enabled.
  48497. */
  48498. isEnabled: boolean;
  48499. /**
  48500. * Get the scene the effects belongs to.
  48501. * @returns the scene holding the lens flare system
  48502. */
  48503. getScene(): Scene;
  48504. /**
  48505. * Get the emitter of the lens flare system.
  48506. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48507. * @returns the emitter of the lens flare system
  48508. */
  48509. getEmitter(): any;
  48510. /**
  48511. * Set the emitter of the lens flare system.
  48512. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48513. * @param newEmitter Define the new emitter of the system
  48514. */
  48515. setEmitter(newEmitter: any): void;
  48516. /**
  48517. * Get the lens flare system emitter position.
  48518. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48519. * @returns the position
  48520. */
  48521. getEmitterPosition(): Vector3;
  48522. /**
  48523. * @hidden
  48524. */
  48525. computeEffectivePosition(globalViewport: Viewport): boolean;
  48526. /** @hidden */
  48527. _isVisible(): boolean;
  48528. /**
  48529. * @hidden
  48530. */
  48531. render(): boolean;
  48532. /**
  48533. * Dispose and release the lens flare with its associated resources.
  48534. */
  48535. dispose(): void;
  48536. /**
  48537. * Parse a lens flare system from a JSON repressentation
  48538. * @param parsedLensFlareSystem Define the JSON to parse
  48539. * @param scene Define the scene the parsed system should be instantiated in
  48540. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48541. * @returns the parsed system
  48542. */
  48543. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48544. /**
  48545. * Serialize the current Lens Flare System into a JSON representation.
  48546. * @returns the serialized JSON
  48547. */
  48548. serialize(): any;
  48549. }
  48550. }
  48551. declare module BABYLON {
  48552. /**
  48553. * This represents one of the lens effect in a `lensFlareSystem`.
  48554. * It controls one of the indiviual texture used in the effect.
  48555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48556. */
  48557. export class LensFlare {
  48558. /**
  48559. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48560. */
  48561. size: number;
  48562. /**
  48563. * 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.
  48564. */
  48565. position: number;
  48566. /**
  48567. * Define the lens color.
  48568. */
  48569. color: Color3;
  48570. /**
  48571. * Define the lens texture.
  48572. */
  48573. texture: Nullable<Texture>;
  48574. /**
  48575. * Define the alpha mode to render this particular lens.
  48576. */
  48577. alphaMode: number;
  48578. private _system;
  48579. /**
  48580. * Creates a new Lens Flare.
  48581. * This represents one of the lens effect in a `lensFlareSystem`.
  48582. * It controls one of the indiviual texture used in the effect.
  48583. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48584. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48585. * @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.
  48586. * @param color Define the lens color
  48587. * @param imgUrl Define the lens texture url
  48588. * @param system Define the `lensFlareSystem` this flare is part of
  48589. * @returns The newly created Lens Flare
  48590. */
  48591. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48592. /**
  48593. * Instantiates a new Lens Flare.
  48594. * This represents one of the lens effect in a `lensFlareSystem`.
  48595. * It controls one of the indiviual texture used in the effect.
  48596. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48597. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48598. * @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.
  48599. * @param color Define the lens color
  48600. * @param imgUrl Define the lens texture url
  48601. * @param system Define the `lensFlareSystem` this flare is part of
  48602. */
  48603. constructor(
  48604. /**
  48605. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48606. */
  48607. size: number,
  48608. /**
  48609. * 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.
  48610. */
  48611. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48612. /**
  48613. * Dispose and release the lens flare with its associated resources.
  48614. */
  48615. dispose(): void;
  48616. }
  48617. }
  48618. declare module BABYLON {
  48619. interface AbstractScene {
  48620. /**
  48621. * The list of lens flare system added to the scene
  48622. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48623. */
  48624. lensFlareSystems: Array<LensFlareSystem>;
  48625. /**
  48626. * Removes the given lens flare system from this scene.
  48627. * @param toRemove The lens flare system to remove
  48628. * @returns The index of the removed lens flare system
  48629. */
  48630. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48631. /**
  48632. * Adds the given lens flare system to this scene
  48633. * @param newLensFlareSystem The lens flare system to add
  48634. */
  48635. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48636. /**
  48637. * Gets a lens flare system using its name
  48638. * @param name defines the name to look for
  48639. * @returns the lens flare system or null if not found
  48640. */
  48641. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48642. /**
  48643. * Gets a lens flare system using its id
  48644. * @param id defines the id to look for
  48645. * @returns the lens flare system or null if not found
  48646. */
  48647. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48648. }
  48649. /**
  48650. * Defines the lens flare scene component responsible to manage any lens flares
  48651. * in a given scene.
  48652. */
  48653. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48654. /**
  48655. * The component name helpfull to identify the component in the list of scene components.
  48656. */
  48657. readonly name: string;
  48658. /**
  48659. * The scene the component belongs to.
  48660. */
  48661. scene: Scene;
  48662. /**
  48663. * Creates a new instance of the component for the given scene
  48664. * @param scene Defines the scene to register the component in
  48665. */
  48666. constructor(scene: Scene);
  48667. /**
  48668. * Registers the component in a given scene
  48669. */
  48670. register(): void;
  48671. /**
  48672. * Rebuilds the elements related to this component in case of
  48673. * context lost for instance.
  48674. */
  48675. rebuild(): void;
  48676. /**
  48677. * Adds all the elements from the container to the scene
  48678. * @param container the container holding the elements
  48679. */
  48680. addFromContainer(container: AbstractScene): void;
  48681. /**
  48682. * Removes all the elements in the container from the scene
  48683. * @param container contains the elements to remove
  48684. * @param dispose if the removed element should be disposed (default: false)
  48685. */
  48686. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48687. /**
  48688. * Serializes the component data to the specified json object
  48689. * @param serializationObject The object to serialize to
  48690. */
  48691. serialize(serializationObject: any): void;
  48692. /**
  48693. * Disposes the component and the associated ressources.
  48694. */
  48695. dispose(): void;
  48696. private _draw;
  48697. }
  48698. }
  48699. declare module BABYLON {
  48700. /**
  48701. * Defines the shadow generator component responsible to manage any shadow generators
  48702. * in a given scene.
  48703. */
  48704. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48705. /**
  48706. * The component name helpfull to identify the component in the list of scene components.
  48707. */
  48708. readonly name: string;
  48709. /**
  48710. * The scene the component belongs to.
  48711. */
  48712. scene: Scene;
  48713. /**
  48714. * Creates a new instance of the component for the given scene
  48715. * @param scene Defines the scene to register the component in
  48716. */
  48717. constructor(scene: Scene);
  48718. /**
  48719. * Registers the component in a given scene
  48720. */
  48721. register(): void;
  48722. /**
  48723. * Rebuilds the elements related to this component in case of
  48724. * context lost for instance.
  48725. */
  48726. rebuild(): void;
  48727. /**
  48728. * Serializes the component data to the specified json object
  48729. * @param serializationObject The object to serialize to
  48730. */
  48731. serialize(serializationObject: any): void;
  48732. /**
  48733. * Adds all the elements from the container to the scene
  48734. * @param container the container holding the elements
  48735. */
  48736. addFromContainer(container: AbstractScene): void;
  48737. /**
  48738. * Removes all the elements in the container from the scene
  48739. * @param container contains the elements to remove
  48740. * @param dispose if the removed element should be disposed (default: false)
  48741. */
  48742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48743. /**
  48744. * Rebuilds the elements related to this component in case of
  48745. * context lost for instance.
  48746. */
  48747. dispose(): void;
  48748. private _gatherRenderTargets;
  48749. }
  48750. }
  48751. declare module BABYLON {
  48752. /**
  48753. * A point light is a light defined by an unique point in world space.
  48754. * The light is emitted in every direction from this point.
  48755. * A good example of a point light is a standard light bulb.
  48756. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48757. */
  48758. export class PointLight extends ShadowLight {
  48759. private _shadowAngle;
  48760. /**
  48761. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48762. * This specifies what angle the shadow will use to be created.
  48763. *
  48764. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48765. */
  48766. /**
  48767. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48768. * This specifies what angle the shadow will use to be created.
  48769. *
  48770. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48771. */
  48772. shadowAngle: number;
  48773. /**
  48774. * Gets the direction if it has been set.
  48775. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48776. */
  48777. /**
  48778. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48779. */
  48780. direction: Vector3;
  48781. /**
  48782. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48783. * A PointLight emits the light in every direction.
  48784. * It can cast shadows.
  48785. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48786. * ```javascript
  48787. * var pointLight = new PointLight("pl", camera.position, scene);
  48788. * ```
  48789. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48790. * @param name The light friendly name
  48791. * @param position The position of the point light in the scene
  48792. * @param scene The scene the lights belongs to
  48793. */
  48794. constructor(name: string, position: Vector3, scene: Scene);
  48795. /**
  48796. * Returns the string "PointLight"
  48797. * @returns the class name
  48798. */
  48799. getClassName(): string;
  48800. /**
  48801. * Returns the integer 0.
  48802. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48803. */
  48804. getTypeID(): number;
  48805. /**
  48806. * Specifies wether or not the shadowmap should be a cube texture.
  48807. * @returns true if the shadowmap needs to be a cube texture.
  48808. */
  48809. needCube(): boolean;
  48810. /**
  48811. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48812. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48813. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48814. */
  48815. getShadowDirection(faceIndex?: number): Vector3;
  48816. /**
  48817. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48818. * - fov = PI / 2
  48819. * - aspect ratio : 1.0
  48820. * - z-near and far equal to the active camera minZ and maxZ.
  48821. * Returns the PointLight.
  48822. */
  48823. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48824. protected _buildUniformLayout(): void;
  48825. /**
  48826. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48827. * @param effect The effect to update
  48828. * @param lightIndex The index of the light in the effect to update
  48829. * @returns The point light
  48830. */
  48831. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48832. /**
  48833. * Prepares the list of defines specific to the light type.
  48834. * @param defines the list of defines
  48835. * @param lightIndex defines the index of the light for the effect
  48836. */
  48837. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * Header information of HDR texture files.
  48843. */
  48844. export interface HDRInfo {
  48845. /**
  48846. * The height of the texture in pixels.
  48847. */
  48848. height: number;
  48849. /**
  48850. * The width of the texture in pixels.
  48851. */
  48852. width: number;
  48853. /**
  48854. * The index of the beginning of the data in the binary file.
  48855. */
  48856. dataPosition: number;
  48857. }
  48858. /**
  48859. * This groups tools to convert HDR texture to native colors array.
  48860. */
  48861. export class HDRTools {
  48862. private static Ldexp;
  48863. private static Rgbe2float;
  48864. private static readStringLine;
  48865. /**
  48866. * Reads header information from an RGBE texture stored in a native array.
  48867. * More information on this format are available here:
  48868. * https://en.wikipedia.org/wiki/RGBE_image_format
  48869. *
  48870. * @param uint8array The binary file stored in native array.
  48871. * @return The header information.
  48872. */
  48873. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48874. /**
  48875. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48876. * This RGBE texture needs to store the information as a panorama.
  48877. *
  48878. * More information on this format are available here:
  48879. * https://en.wikipedia.org/wiki/RGBE_image_format
  48880. *
  48881. * @param buffer The binary file stored in an array buffer.
  48882. * @param size The expected size of the extracted cubemap.
  48883. * @return The Cube Map information.
  48884. */
  48885. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48886. /**
  48887. * Returns the pixels data extracted from an RGBE texture.
  48888. * This pixels will be stored left to right up to down in the R G B order in one array.
  48889. *
  48890. * More information on this format are available here:
  48891. * https://en.wikipedia.org/wiki/RGBE_image_format
  48892. *
  48893. * @param uint8array The binary file stored in an array buffer.
  48894. * @param hdrInfo The header information of the file.
  48895. * @return The pixels data in RGB right to left up to down order.
  48896. */
  48897. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48898. private static RGBE_ReadPixels_RLE;
  48899. }
  48900. }
  48901. declare module BABYLON {
  48902. /**
  48903. * This represents a texture coming from an HDR input.
  48904. *
  48905. * The only supported format is currently panorama picture stored in RGBE format.
  48906. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48907. */
  48908. export class HDRCubeTexture extends BaseTexture {
  48909. private static _facesMapping;
  48910. private _generateHarmonics;
  48911. private _noMipmap;
  48912. private _textureMatrix;
  48913. private _size;
  48914. private _onLoad;
  48915. private _onError;
  48916. /**
  48917. * The texture URL.
  48918. */
  48919. url: string;
  48920. /**
  48921. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48922. */
  48923. coordinatesMode: number;
  48924. protected _isBlocking: boolean;
  48925. /**
  48926. * Sets wether or not the texture is blocking during loading.
  48927. */
  48928. /**
  48929. * Gets wether or not the texture is blocking during loading.
  48930. */
  48931. isBlocking: boolean;
  48932. protected _rotationY: number;
  48933. /**
  48934. * Sets texture matrix rotation angle around Y axis in radians.
  48935. */
  48936. /**
  48937. * Gets texture matrix rotation angle around Y axis radians.
  48938. */
  48939. rotationY: number;
  48940. /**
  48941. * Gets or sets the center of the bounding box associated with the cube texture
  48942. * It must define where the camera used to render the texture was set
  48943. */
  48944. boundingBoxPosition: Vector3;
  48945. private _boundingBoxSize;
  48946. /**
  48947. * Gets or sets the size of the bounding box associated with the cube texture
  48948. * When defined, the cubemap will switch to local mode
  48949. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48950. * @example https://www.babylonjs-playground.com/#RNASML
  48951. */
  48952. boundingBoxSize: Vector3;
  48953. /**
  48954. * Instantiates an HDRTexture from the following parameters.
  48955. *
  48956. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48957. * @param scene The scene the texture will be used in
  48958. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48959. * @param noMipmap Forces to not generate the mipmap if true
  48960. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48961. * @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)
  48962. * @param reserved Reserved flag for internal use.
  48963. */
  48964. 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>);
  48965. /**
  48966. * Get the current class name of the texture useful for serialization or dynamic coding.
  48967. * @returns "HDRCubeTexture"
  48968. */
  48969. getClassName(): string;
  48970. /**
  48971. * Occurs when the file is raw .hdr file.
  48972. */
  48973. private loadTexture;
  48974. clone(): HDRCubeTexture;
  48975. delayLoad(): void;
  48976. /**
  48977. * Get the texture reflection matrix used to rotate/transform the reflection.
  48978. * @returns the reflection matrix
  48979. */
  48980. getReflectionTextureMatrix(): Matrix;
  48981. /**
  48982. * Set the texture reflection matrix used to rotate/transform the reflection.
  48983. * @param value Define the reflection matrix to set
  48984. */
  48985. setReflectionTextureMatrix(value: Matrix): void;
  48986. /**
  48987. * Parses a JSON representation of an HDR Texture in order to create the texture
  48988. * @param parsedTexture Define the JSON representation
  48989. * @param scene Define the scene the texture should be created in
  48990. * @param rootUrl Define the root url in case we need to load relative dependencies
  48991. * @returns the newly created texture after parsing
  48992. */
  48993. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48994. serialize(): any;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. /**
  48999. * Class used to control physics engine
  49000. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49001. */
  49002. export class PhysicsEngine implements IPhysicsEngine {
  49003. private _physicsPlugin;
  49004. /**
  49005. * Global value used to control the smallest number supported by the simulation
  49006. */
  49007. static Epsilon: number;
  49008. private _impostors;
  49009. private _joints;
  49010. /**
  49011. * Gets the gravity vector used by the simulation
  49012. */
  49013. gravity: Vector3;
  49014. /**
  49015. * Factory used to create the default physics plugin.
  49016. * @returns The default physics plugin
  49017. */
  49018. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49019. /**
  49020. * Creates a new Physics Engine
  49021. * @param gravity defines the gravity vector used by the simulation
  49022. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49023. */
  49024. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49025. /**
  49026. * Sets the gravity vector used by the simulation
  49027. * @param gravity defines the gravity vector to use
  49028. */
  49029. setGravity(gravity: Vector3): void;
  49030. /**
  49031. * Set the time step of the physics engine.
  49032. * Default is 1/60.
  49033. * To slow it down, enter 1/600 for example.
  49034. * To speed it up, 1/30
  49035. * @param newTimeStep defines the new timestep to apply to this world.
  49036. */
  49037. setTimeStep(newTimeStep?: number): void;
  49038. /**
  49039. * Get the time step of the physics engine.
  49040. * @returns the current time step
  49041. */
  49042. getTimeStep(): number;
  49043. /**
  49044. * Release all resources
  49045. */
  49046. dispose(): void;
  49047. /**
  49048. * Gets the name of the current physics plugin
  49049. * @returns the name of the plugin
  49050. */
  49051. getPhysicsPluginName(): string;
  49052. /**
  49053. * Adding a new impostor for the impostor tracking.
  49054. * This will be done by the impostor itself.
  49055. * @param impostor the impostor to add
  49056. */
  49057. addImpostor(impostor: PhysicsImpostor): void;
  49058. /**
  49059. * Remove an impostor from the engine.
  49060. * This impostor and its mesh will not longer be updated by the physics engine.
  49061. * @param impostor the impostor to remove
  49062. */
  49063. removeImpostor(impostor: PhysicsImpostor): void;
  49064. /**
  49065. * Add a joint to the physics engine
  49066. * @param mainImpostor defines the main impostor to which the joint is added.
  49067. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49068. * @param joint defines the joint that will connect both impostors.
  49069. */
  49070. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49071. /**
  49072. * Removes a joint from the simulation
  49073. * @param mainImpostor defines the impostor used with the joint
  49074. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49075. * @param joint defines the joint to remove
  49076. */
  49077. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49078. /**
  49079. * Called by the scene. No need to call it.
  49080. * @param delta defines the timespam between frames
  49081. */
  49082. _step(delta: number): void;
  49083. /**
  49084. * Gets the current plugin used to run the simulation
  49085. * @returns current plugin
  49086. */
  49087. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49088. /**
  49089. * Gets the list of physic impostors
  49090. * @returns an array of PhysicsImpostor
  49091. */
  49092. getImpostors(): Array<PhysicsImpostor>;
  49093. /**
  49094. * Gets the impostor for a physics enabled object
  49095. * @param object defines the object impersonated by the impostor
  49096. * @returns the PhysicsImpostor or null if not found
  49097. */
  49098. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49099. /**
  49100. * Gets the impostor for a physics body object
  49101. * @param body defines physics body used by the impostor
  49102. * @returns the PhysicsImpostor or null if not found
  49103. */
  49104. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49105. /**
  49106. * Does a raycast in the physics world
  49107. * @param from when should the ray start?
  49108. * @param to when should the ray end?
  49109. * @returns PhysicsRaycastResult
  49110. */
  49111. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49112. }
  49113. }
  49114. declare module BABYLON {
  49115. /** @hidden */
  49116. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49117. private _useDeltaForWorldStep;
  49118. world: any;
  49119. name: string;
  49120. private _physicsMaterials;
  49121. private _fixedTimeStep;
  49122. private _cannonRaycastResult;
  49123. private _raycastResult;
  49124. private _physicsBodysToRemoveAfterStep;
  49125. BJSCANNON: any;
  49126. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49127. setGravity(gravity: Vector3): void;
  49128. setTimeStep(timeStep: number): void;
  49129. getTimeStep(): number;
  49130. executeStep(delta: number): void;
  49131. private _removeMarkedPhysicsBodiesFromWorld;
  49132. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49133. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49134. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49135. private _processChildMeshes;
  49136. removePhysicsBody(impostor: PhysicsImpostor): void;
  49137. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49138. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49139. private _addMaterial;
  49140. private _checkWithEpsilon;
  49141. private _createShape;
  49142. private _createHeightmap;
  49143. private _minus90X;
  49144. private _plus90X;
  49145. private _tmpPosition;
  49146. private _tmpDeltaPosition;
  49147. private _tmpUnityRotation;
  49148. private _updatePhysicsBodyTransformation;
  49149. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49150. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49151. isSupported(): boolean;
  49152. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49153. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49154. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49155. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49156. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49157. getBodyMass(impostor: PhysicsImpostor): number;
  49158. getBodyFriction(impostor: PhysicsImpostor): number;
  49159. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49160. getBodyRestitution(impostor: PhysicsImpostor): number;
  49161. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49162. sleepBody(impostor: PhysicsImpostor): void;
  49163. wakeUpBody(impostor: PhysicsImpostor): void;
  49164. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49165. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49166. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49167. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49168. getRadius(impostor: PhysicsImpostor): number;
  49169. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49170. dispose(): void;
  49171. private _extendNamespace;
  49172. /**
  49173. * Does a raycast in the physics world
  49174. * @param from when should the ray start?
  49175. * @param to when should the ray end?
  49176. * @returns PhysicsRaycastResult
  49177. */
  49178. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49179. }
  49180. }
  49181. declare module BABYLON {
  49182. /** @hidden */
  49183. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49184. world: any;
  49185. name: string;
  49186. BJSOIMO: any;
  49187. private _raycastResult;
  49188. constructor(iterations?: number, oimoInjection?: any);
  49189. setGravity(gravity: Vector3): void;
  49190. setTimeStep(timeStep: number): void;
  49191. getTimeStep(): number;
  49192. private _tmpImpostorsArray;
  49193. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49194. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49195. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49196. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49197. private _tmpPositionVector;
  49198. removePhysicsBody(impostor: PhysicsImpostor): void;
  49199. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49200. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49201. isSupported(): boolean;
  49202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49203. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49204. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49205. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49206. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49207. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49208. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49209. getBodyMass(impostor: PhysicsImpostor): number;
  49210. getBodyFriction(impostor: PhysicsImpostor): number;
  49211. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49212. getBodyRestitution(impostor: PhysicsImpostor): number;
  49213. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49214. sleepBody(impostor: PhysicsImpostor): void;
  49215. wakeUpBody(impostor: PhysicsImpostor): void;
  49216. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49217. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49218. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49219. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49220. getRadius(impostor: PhysicsImpostor): number;
  49221. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49222. dispose(): void;
  49223. /**
  49224. * Does a raycast in the physics world
  49225. * @param from when should the ray start?
  49226. * @param to when should the ray end?
  49227. * @returns PhysicsRaycastResult
  49228. */
  49229. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49230. }
  49231. }
  49232. declare module BABYLON {
  49233. /**
  49234. * Class containing static functions to help procedurally build meshes
  49235. */
  49236. export class RibbonBuilder {
  49237. /**
  49238. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49239. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49240. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49241. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49242. * * 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
  49243. * * 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
  49244. * * 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
  49245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49246. * * 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
  49247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49248. * * 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
  49249. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49250. * * 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
  49251. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49253. * @param name defines the name of the mesh
  49254. * @param options defines the options used to create the mesh
  49255. * @param scene defines the hosting scene
  49256. * @returns the ribbon mesh
  49257. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49258. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49259. */
  49260. static CreateRibbon(name: string, options: {
  49261. pathArray: Vector3[][];
  49262. closeArray?: boolean;
  49263. closePath?: boolean;
  49264. offset?: number;
  49265. updatable?: boolean;
  49266. sideOrientation?: number;
  49267. frontUVs?: Vector4;
  49268. backUVs?: Vector4;
  49269. instance?: Mesh;
  49270. invertUV?: boolean;
  49271. uvs?: Vector2[];
  49272. colors?: Color4[];
  49273. }, scene?: Nullable<Scene>): Mesh;
  49274. }
  49275. }
  49276. declare module BABYLON {
  49277. /**
  49278. * Class containing static functions to help procedurally build meshes
  49279. */
  49280. export class ShapeBuilder {
  49281. /**
  49282. * 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.
  49283. * * 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.
  49284. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49285. * * 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.
  49286. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49287. * * 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
  49288. * * 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
  49289. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49291. * * 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
  49292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49294. * @param name defines the name of the mesh
  49295. * @param options defines the options used to create the mesh
  49296. * @param scene defines the hosting scene
  49297. * @returns the extruded shape mesh
  49298. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49300. */
  49301. static ExtrudeShape(name: string, options: {
  49302. shape: Vector3[];
  49303. path: Vector3[];
  49304. scale?: number;
  49305. rotation?: number;
  49306. cap?: number;
  49307. updatable?: boolean;
  49308. sideOrientation?: number;
  49309. frontUVs?: Vector4;
  49310. backUVs?: Vector4;
  49311. instance?: Mesh;
  49312. invertUV?: boolean;
  49313. }, scene?: Nullable<Scene>): Mesh;
  49314. /**
  49315. * Creates an custom extruded shape mesh.
  49316. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49317. * * 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.
  49318. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49319. * * 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
  49320. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49321. * * 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
  49322. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49323. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49324. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49325. * * 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
  49326. * * 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
  49327. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49329. * * 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
  49330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49332. * @param name defines the name of the mesh
  49333. * @param options defines the options used to create the mesh
  49334. * @param scene defines the hosting scene
  49335. * @returns the custom extruded shape mesh
  49336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49337. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49339. */
  49340. static ExtrudeShapeCustom(name: string, options: {
  49341. shape: Vector3[];
  49342. path: Vector3[];
  49343. scaleFunction?: any;
  49344. rotationFunction?: any;
  49345. ribbonCloseArray?: boolean;
  49346. ribbonClosePath?: boolean;
  49347. cap?: number;
  49348. updatable?: boolean;
  49349. sideOrientation?: number;
  49350. frontUVs?: Vector4;
  49351. backUVs?: Vector4;
  49352. instance?: Mesh;
  49353. invertUV?: boolean;
  49354. }, scene?: Nullable<Scene>): Mesh;
  49355. private static _ExtrudeShapeGeneric;
  49356. }
  49357. }
  49358. declare module BABYLON {
  49359. /**
  49360. * AmmoJS Physics plugin
  49361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49362. * @see https://github.com/kripken/ammo.js/
  49363. */
  49364. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49365. private _useDeltaForWorldStep;
  49366. /**
  49367. * Reference to the Ammo library
  49368. */
  49369. bjsAMMO: any;
  49370. /**
  49371. * Created ammoJS world which physics bodies are added to
  49372. */
  49373. world: any;
  49374. /**
  49375. * Name of the plugin
  49376. */
  49377. name: string;
  49378. private _timeStep;
  49379. private _fixedTimeStep;
  49380. private _maxSteps;
  49381. private _tmpQuaternion;
  49382. private _tmpAmmoTransform;
  49383. private _tmpAmmoQuaternion;
  49384. private _tmpAmmoConcreteContactResultCallback;
  49385. private _collisionConfiguration;
  49386. private _dispatcher;
  49387. private _overlappingPairCache;
  49388. private _solver;
  49389. private _softBodySolver;
  49390. private _tmpAmmoVectorA;
  49391. private _tmpAmmoVectorB;
  49392. private _tmpAmmoVectorC;
  49393. private _tmpAmmoVectorD;
  49394. private _tmpContactCallbackResult;
  49395. private _tmpAmmoVectorRCA;
  49396. private _tmpAmmoVectorRCB;
  49397. private _raycastResult;
  49398. private static readonly DISABLE_COLLISION_FLAG;
  49399. private static readonly KINEMATIC_FLAG;
  49400. private static readonly DISABLE_DEACTIVATION_FLAG;
  49401. /**
  49402. * Initializes the ammoJS plugin
  49403. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49404. * @param ammoInjection can be used to inject your own ammo reference
  49405. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49406. */
  49407. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49408. /**
  49409. * Sets the gravity of the physics world (m/(s^2))
  49410. * @param gravity Gravity to set
  49411. */
  49412. setGravity(gravity: Vector3): void;
  49413. /**
  49414. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49415. * @param timeStep timestep to use in seconds
  49416. */
  49417. setTimeStep(timeStep: number): void;
  49418. /**
  49419. * 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)
  49420. * @param fixedTimeStep fixedTimeStep to use in seconds
  49421. */
  49422. setFixedTimeStep(fixedTimeStep: number): void;
  49423. /**
  49424. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49425. * @param maxSteps the maximum number of steps by the physics engine per frame
  49426. */
  49427. setMaxSteps(maxSteps: number): void;
  49428. /**
  49429. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49430. * @returns the current timestep in seconds
  49431. */
  49432. getTimeStep(): number;
  49433. private _isImpostorInContact;
  49434. private _isImpostorPairInContact;
  49435. private _stepSimulation;
  49436. /**
  49437. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49438. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49439. * After the step the babylon meshes are set to the position of the physics imposters
  49440. * @param delta amount of time to step forward
  49441. * @param impostors array of imposters to update before/after the step
  49442. */
  49443. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49444. /**
  49445. * Update babylon mesh to match physics world object
  49446. * @param impostor imposter to match
  49447. */
  49448. private _afterSoftStep;
  49449. /**
  49450. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49451. * @param impostor imposter to match
  49452. */
  49453. private _ropeStep;
  49454. /**
  49455. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49456. * @param impostor imposter to match
  49457. */
  49458. private _softbodyOrClothStep;
  49459. private _tmpVector;
  49460. private _tmpMatrix;
  49461. /**
  49462. * Applies an impulse on the imposter
  49463. * @param impostor imposter to apply impulse to
  49464. * @param force amount of force to be applied to the imposter
  49465. * @param contactPoint the location to apply the impulse on the imposter
  49466. */
  49467. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49468. /**
  49469. * Applies a force on the imposter
  49470. * @param impostor imposter to apply force
  49471. * @param force amount of force to be applied to the imposter
  49472. * @param contactPoint the location to apply the force on the imposter
  49473. */
  49474. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49475. /**
  49476. * Creates a physics body using the plugin
  49477. * @param impostor the imposter to create the physics body on
  49478. */
  49479. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49480. /**
  49481. * Removes the physics body from the imposter and disposes of the body's memory
  49482. * @param impostor imposter to remove the physics body from
  49483. */
  49484. removePhysicsBody(impostor: PhysicsImpostor): void;
  49485. /**
  49486. * Generates a joint
  49487. * @param impostorJoint the imposter joint to create the joint with
  49488. */
  49489. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49490. /**
  49491. * Removes a joint
  49492. * @param impostorJoint the imposter joint to remove the joint from
  49493. */
  49494. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49495. private _addMeshVerts;
  49496. /**
  49497. * Initialise the soft body vertices to match its object's (mesh) vertices
  49498. * Softbody vertices (nodes) are in world space and to match this
  49499. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49500. * @param impostor to create the softbody for
  49501. */
  49502. private _softVertexData;
  49503. /**
  49504. * Create an impostor's soft body
  49505. * @param impostor to create the softbody for
  49506. */
  49507. private _createSoftbody;
  49508. /**
  49509. * Create cloth for an impostor
  49510. * @param impostor to create the softbody for
  49511. */
  49512. private _createCloth;
  49513. /**
  49514. * Create rope for an impostor
  49515. * @param impostor to create the softbody for
  49516. */
  49517. private _createRope;
  49518. private _addHullVerts;
  49519. private _createShape;
  49520. /**
  49521. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49522. * @param impostor imposter containing the physics body and babylon object
  49523. */
  49524. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49525. /**
  49526. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49527. * @param impostor imposter containing the physics body and babylon object
  49528. * @param newPosition new position
  49529. * @param newRotation new rotation
  49530. */
  49531. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49532. /**
  49533. * If this plugin is supported
  49534. * @returns true if its supported
  49535. */
  49536. isSupported(): boolean;
  49537. /**
  49538. * Sets the linear velocity of the physics body
  49539. * @param impostor imposter to set the velocity on
  49540. * @param velocity velocity to set
  49541. */
  49542. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49543. /**
  49544. * Sets the angular velocity of the physics body
  49545. * @param impostor imposter to set the velocity on
  49546. * @param velocity velocity to set
  49547. */
  49548. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49549. /**
  49550. * gets the linear velocity
  49551. * @param impostor imposter to get linear velocity from
  49552. * @returns linear velocity
  49553. */
  49554. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49555. /**
  49556. * gets the angular velocity
  49557. * @param impostor imposter to get angular velocity from
  49558. * @returns angular velocity
  49559. */
  49560. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49561. /**
  49562. * Sets the mass of physics body
  49563. * @param impostor imposter to set the mass on
  49564. * @param mass mass to set
  49565. */
  49566. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49567. /**
  49568. * Gets the mass of the physics body
  49569. * @param impostor imposter to get the mass from
  49570. * @returns mass
  49571. */
  49572. getBodyMass(impostor: PhysicsImpostor): number;
  49573. /**
  49574. * Gets friction of the impostor
  49575. * @param impostor impostor to get friction from
  49576. * @returns friction value
  49577. */
  49578. getBodyFriction(impostor: PhysicsImpostor): number;
  49579. /**
  49580. * Sets friction of the impostor
  49581. * @param impostor impostor to set friction on
  49582. * @param friction friction value
  49583. */
  49584. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49585. /**
  49586. * Gets restitution of the impostor
  49587. * @param impostor impostor to get restitution from
  49588. * @returns restitution value
  49589. */
  49590. getBodyRestitution(impostor: PhysicsImpostor): number;
  49591. /**
  49592. * Sets resitution of the impostor
  49593. * @param impostor impostor to set resitution on
  49594. * @param restitution resitution value
  49595. */
  49596. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49597. /**
  49598. * Gets pressure inside the impostor
  49599. * @param impostor impostor to get pressure from
  49600. * @returns pressure value
  49601. */
  49602. getBodyPressure(impostor: PhysicsImpostor): number;
  49603. /**
  49604. * Sets pressure inside a soft body impostor
  49605. * Cloth and rope must remain 0 pressure
  49606. * @param impostor impostor to set pressure on
  49607. * @param pressure pressure value
  49608. */
  49609. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49610. /**
  49611. * Gets stiffness of the impostor
  49612. * @param impostor impostor to get stiffness from
  49613. * @returns pressure value
  49614. */
  49615. getBodyStiffness(impostor: PhysicsImpostor): number;
  49616. /**
  49617. * Sets stiffness of the impostor
  49618. * @param impostor impostor to set stiffness on
  49619. * @param stiffness stiffness value from 0 to 1
  49620. */
  49621. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49622. /**
  49623. * Gets velocityIterations of the impostor
  49624. * @param impostor impostor to get velocity iterations from
  49625. * @returns velocityIterations value
  49626. */
  49627. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49628. /**
  49629. * Sets velocityIterations of the impostor
  49630. * @param impostor impostor to set velocity iterations on
  49631. * @param velocityIterations velocityIterations value
  49632. */
  49633. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49634. /**
  49635. * Gets positionIterations of the impostor
  49636. * @param impostor impostor to get position iterations from
  49637. * @returns positionIterations value
  49638. */
  49639. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49640. /**
  49641. * Sets positionIterations of the impostor
  49642. * @param impostor impostor to set position on
  49643. * @param positionIterations positionIterations value
  49644. */
  49645. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49646. /**
  49647. * Append an anchor to a cloth object
  49648. * @param impostor is the cloth impostor to add anchor to
  49649. * @param otherImpostor is the rigid impostor to anchor to
  49650. * @param width ratio across width from 0 to 1
  49651. * @param height ratio up height from 0 to 1
  49652. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49653. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49654. */
  49655. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49656. /**
  49657. * Append an hook to a rope object
  49658. * @param impostor is the rope impostor to add hook to
  49659. * @param otherImpostor is the rigid impostor to hook to
  49660. * @param length ratio along the rope from 0 to 1
  49661. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49662. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49663. */
  49664. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49665. /**
  49666. * Sleeps the physics body and stops it from being active
  49667. * @param impostor impostor to sleep
  49668. */
  49669. sleepBody(impostor: PhysicsImpostor): void;
  49670. /**
  49671. * Activates the physics body
  49672. * @param impostor impostor to activate
  49673. */
  49674. wakeUpBody(impostor: PhysicsImpostor): void;
  49675. /**
  49676. * Updates the distance parameters of the joint
  49677. * @param joint joint to update
  49678. * @param maxDistance maximum distance of the joint
  49679. * @param minDistance minimum distance of the joint
  49680. */
  49681. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49682. /**
  49683. * Sets a motor on the joint
  49684. * @param joint joint to set motor on
  49685. * @param speed speed of the motor
  49686. * @param maxForce maximum force of the motor
  49687. * @param motorIndex index of the motor
  49688. */
  49689. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49690. /**
  49691. * Sets the motors limit
  49692. * @param joint joint to set limit on
  49693. * @param upperLimit upper limit
  49694. * @param lowerLimit lower limit
  49695. */
  49696. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49697. /**
  49698. * Syncs the position and rotation of a mesh with the impostor
  49699. * @param mesh mesh to sync
  49700. * @param impostor impostor to update the mesh with
  49701. */
  49702. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49703. /**
  49704. * Gets the radius of the impostor
  49705. * @param impostor impostor to get radius from
  49706. * @returns the radius
  49707. */
  49708. getRadius(impostor: PhysicsImpostor): number;
  49709. /**
  49710. * Gets the box size of the impostor
  49711. * @param impostor impostor to get box size from
  49712. * @param result the resulting box size
  49713. */
  49714. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49715. /**
  49716. * Disposes of the impostor
  49717. */
  49718. dispose(): void;
  49719. /**
  49720. * Does a raycast in the physics world
  49721. * @param from when should the ray start?
  49722. * @param to when should the ray end?
  49723. * @returns PhysicsRaycastResult
  49724. */
  49725. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49726. }
  49727. }
  49728. declare module BABYLON {
  49729. interface AbstractScene {
  49730. /**
  49731. * The list of reflection probes added to the scene
  49732. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49733. */
  49734. reflectionProbes: Array<ReflectionProbe>;
  49735. /**
  49736. * Removes the given reflection probe from this scene.
  49737. * @param toRemove The reflection probe to remove
  49738. * @returns The index of the removed reflection probe
  49739. */
  49740. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49741. /**
  49742. * Adds the given reflection probe to this scene.
  49743. * @param newReflectionProbe The reflection probe to add
  49744. */
  49745. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49746. }
  49747. /**
  49748. * Class used to generate realtime reflection / refraction cube textures
  49749. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49750. */
  49751. export class ReflectionProbe {
  49752. /** defines the name of the probe */
  49753. name: string;
  49754. private _scene;
  49755. private _renderTargetTexture;
  49756. private _projectionMatrix;
  49757. private _viewMatrix;
  49758. private _target;
  49759. private _add;
  49760. private _attachedMesh;
  49761. private _invertYAxis;
  49762. /** Gets or sets probe position (center of the cube map) */
  49763. position: Vector3;
  49764. /**
  49765. * Creates a new reflection probe
  49766. * @param name defines the name of the probe
  49767. * @param size defines the texture resolution (for each face)
  49768. * @param scene defines the hosting scene
  49769. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49770. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49771. */
  49772. constructor(
  49773. /** defines the name of the probe */
  49774. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49775. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49776. samples: number;
  49777. /** Gets or sets the refresh rate to use (on every frame by default) */
  49778. refreshRate: number;
  49779. /**
  49780. * Gets the hosting scene
  49781. * @returns a Scene
  49782. */
  49783. getScene(): Scene;
  49784. /** Gets the internal CubeTexture used to render to */
  49785. readonly cubeTexture: RenderTargetTexture;
  49786. /** Gets the list of meshes to render */
  49787. readonly renderList: Nullable<AbstractMesh[]>;
  49788. /**
  49789. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49790. * @param mesh defines the mesh to attach to
  49791. */
  49792. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49793. /**
  49794. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49795. * @param renderingGroupId The rendering group id corresponding to its index
  49796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49797. */
  49798. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49799. /**
  49800. * Clean all associated resources
  49801. */
  49802. dispose(): void;
  49803. /**
  49804. * Converts the reflection probe information to a readable string for debug purpose.
  49805. * @param fullDetails Supports for multiple levels of logging within scene loading
  49806. * @returns the human readable reflection probe info
  49807. */
  49808. toString(fullDetails?: boolean): string;
  49809. /**
  49810. * Get the class name of the relfection probe.
  49811. * @returns "ReflectionProbe"
  49812. */
  49813. getClassName(): string;
  49814. /**
  49815. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49816. * @returns The JSON representation of the texture
  49817. */
  49818. serialize(): any;
  49819. /**
  49820. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49821. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49822. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49823. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49824. * @returns The parsed reflection probe if successful
  49825. */
  49826. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49827. }
  49828. }
  49829. declare module BABYLON {
  49830. /** @hidden */
  49831. export var _BabylonLoaderRegistered: boolean;
  49832. }
  49833. declare module BABYLON {
  49834. /**
  49835. * The Physically based simple base material of BJS.
  49836. *
  49837. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49838. * It is used as the base class for both the specGloss and metalRough conventions.
  49839. */
  49840. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49841. /**
  49842. * Number of Simultaneous lights allowed on the material.
  49843. */
  49844. maxSimultaneousLights: number;
  49845. /**
  49846. * If sets to true, disables all the lights affecting the material.
  49847. */
  49848. disableLighting: boolean;
  49849. /**
  49850. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49851. */
  49852. environmentTexture: BaseTexture;
  49853. /**
  49854. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49855. */
  49856. invertNormalMapX: boolean;
  49857. /**
  49858. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49859. */
  49860. invertNormalMapY: boolean;
  49861. /**
  49862. * Normal map used in the model.
  49863. */
  49864. normalTexture: BaseTexture;
  49865. /**
  49866. * Emissivie color used to self-illuminate the model.
  49867. */
  49868. emissiveColor: Color3;
  49869. /**
  49870. * Emissivie texture used to self-illuminate the model.
  49871. */
  49872. emissiveTexture: BaseTexture;
  49873. /**
  49874. * Occlusion Channel Strenght.
  49875. */
  49876. occlusionStrength: number;
  49877. /**
  49878. * Occlusion Texture of the material (adding extra occlusion effects).
  49879. */
  49880. occlusionTexture: BaseTexture;
  49881. /**
  49882. * Defines the alpha limits in alpha test mode.
  49883. */
  49884. alphaCutOff: number;
  49885. /**
  49886. * Gets the current double sided mode.
  49887. */
  49888. /**
  49889. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49890. */
  49891. doubleSided: boolean;
  49892. /**
  49893. * Stores the pre-calculated light information of a mesh in a texture.
  49894. */
  49895. lightmapTexture: BaseTexture;
  49896. /**
  49897. * If true, the light map contains occlusion information instead of lighting info.
  49898. */
  49899. useLightmapAsShadowmap: boolean;
  49900. /**
  49901. * Instantiates a new PBRMaterial instance.
  49902. *
  49903. * @param name The material name
  49904. * @param scene The scene the material will be use in.
  49905. */
  49906. constructor(name: string, scene: Scene);
  49907. getClassName(): string;
  49908. }
  49909. }
  49910. declare module BABYLON {
  49911. /**
  49912. * The PBR material of BJS following the metal roughness convention.
  49913. *
  49914. * This fits to the PBR convention in the GLTF definition:
  49915. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49916. */
  49917. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49918. /**
  49919. * The base color has two different interpretations depending on the value of metalness.
  49920. * When the material is a metal, the base color is the specific measured reflectance value
  49921. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49922. * of the material.
  49923. */
  49924. baseColor: Color3;
  49925. /**
  49926. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49927. * well as opacity information in the alpha channel.
  49928. */
  49929. baseTexture: BaseTexture;
  49930. /**
  49931. * Specifies the metallic scalar value of the material.
  49932. * Can also be used to scale the metalness values of the metallic texture.
  49933. */
  49934. metallic: number;
  49935. /**
  49936. * Specifies the roughness scalar value of the material.
  49937. * Can also be used to scale the roughness values of the metallic texture.
  49938. */
  49939. roughness: number;
  49940. /**
  49941. * Texture containing both the metallic value in the B channel and the
  49942. * roughness value in the G channel to keep better precision.
  49943. */
  49944. metallicRoughnessTexture: BaseTexture;
  49945. /**
  49946. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49947. *
  49948. * @param name The material name
  49949. * @param scene The scene the material will be use in.
  49950. */
  49951. constructor(name: string, scene: Scene);
  49952. /**
  49953. * Return the currrent class name of the material.
  49954. */
  49955. getClassName(): string;
  49956. /**
  49957. * Makes a duplicate of the current material.
  49958. * @param name - name to use for the new material.
  49959. */
  49960. clone(name: string): PBRMetallicRoughnessMaterial;
  49961. /**
  49962. * Serialize the material to a parsable JSON object.
  49963. */
  49964. serialize(): any;
  49965. /**
  49966. * Parses a JSON object correponding to the serialize function.
  49967. */
  49968. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49969. }
  49970. }
  49971. declare module BABYLON {
  49972. /**
  49973. * The PBR material of BJS following the specular glossiness convention.
  49974. *
  49975. * This fits to the PBR convention in the GLTF definition:
  49976. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49977. */
  49978. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49979. /**
  49980. * Specifies the diffuse color of the material.
  49981. */
  49982. diffuseColor: Color3;
  49983. /**
  49984. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49985. * channel.
  49986. */
  49987. diffuseTexture: BaseTexture;
  49988. /**
  49989. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49990. */
  49991. specularColor: Color3;
  49992. /**
  49993. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49994. */
  49995. glossiness: number;
  49996. /**
  49997. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49998. */
  49999. specularGlossinessTexture: BaseTexture;
  50000. /**
  50001. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50002. *
  50003. * @param name The material name
  50004. * @param scene The scene the material will be use in.
  50005. */
  50006. constructor(name: string, scene: Scene);
  50007. /**
  50008. * Return the currrent class name of the material.
  50009. */
  50010. getClassName(): string;
  50011. /**
  50012. * Makes a duplicate of the current material.
  50013. * @param name - name to use for the new material.
  50014. */
  50015. clone(name: string): PBRSpecularGlossinessMaterial;
  50016. /**
  50017. * Serialize the material to a parsable JSON object.
  50018. */
  50019. serialize(): any;
  50020. /**
  50021. * Parses a JSON object correponding to the serialize function.
  50022. */
  50023. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50024. }
  50025. }
  50026. declare module BABYLON {
  50027. /**
  50028. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50029. * It can help converting any input color in a desired output one. This can then be used to create effects
  50030. * from sepia, black and white to sixties or futuristic rendering...
  50031. *
  50032. * The only supported format is currently 3dl.
  50033. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50034. */
  50035. export class ColorGradingTexture extends BaseTexture {
  50036. /**
  50037. * The current texture matrix. (will always be identity in color grading texture)
  50038. */
  50039. private _textureMatrix;
  50040. /**
  50041. * The texture URL.
  50042. */
  50043. url: string;
  50044. /**
  50045. * Empty line regex stored for GC.
  50046. */
  50047. private static _noneEmptyLineRegex;
  50048. private _engine;
  50049. /**
  50050. * Instantiates a ColorGradingTexture from the following parameters.
  50051. *
  50052. * @param url The location of the color gradind data (currently only supporting 3dl)
  50053. * @param scene The scene the texture will be used in
  50054. */
  50055. constructor(url: string, scene: Scene);
  50056. /**
  50057. * Returns the texture matrix used in most of the material.
  50058. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50059. */
  50060. getTextureMatrix(): Matrix;
  50061. /**
  50062. * Occurs when the file being loaded is a .3dl LUT file.
  50063. */
  50064. private load3dlTexture;
  50065. /**
  50066. * Starts the loading process of the texture.
  50067. */
  50068. private loadTexture;
  50069. /**
  50070. * Clones the color gradind texture.
  50071. */
  50072. clone(): ColorGradingTexture;
  50073. /**
  50074. * Called during delayed load for textures.
  50075. */
  50076. delayLoad(): void;
  50077. /**
  50078. * Parses a color grading texture serialized by Babylon.
  50079. * @param parsedTexture The texture information being parsedTexture
  50080. * @param scene The scene to load the texture in
  50081. * @param rootUrl The root url of the data assets to load
  50082. * @return A color gradind texture
  50083. */
  50084. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50085. /**
  50086. * Serializes the LUT texture to json format.
  50087. */
  50088. serialize(): any;
  50089. }
  50090. }
  50091. declare module BABYLON {
  50092. /**
  50093. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50094. */
  50095. export class EquiRectangularCubeTexture extends BaseTexture {
  50096. /** The six faces of the cube. */
  50097. private static _FacesMapping;
  50098. private _noMipmap;
  50099. private _onLoad;
  50100. private _onError;
  50101. /** The size of the cubemap. */
  50102. private _size;
  50103. /** The buffer of the image. */
  50104. private _buffer;
  50105. /** The width of the input image. */
  50106. private _width;
  50107. /** The height of the input image. */
  50108. private _height;
  50109. /** The URL to the image. */
  50110. url: string;
  50111. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50112. coordinatesMode: number;
  50113. /**
  50114. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50115. * @param url The location of the image
  50116. * @param scene The scene the texture will be used in
  50117. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50118. * @param noMipmap Forces to not generate the mipmap if true
  50119. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50120. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50121. * @param onLoad — defines a callback called when texture is loaded
  50122. * @param onError — defines a callback called if there is an error
  50123. */
  50124. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50125. /**
  50126. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50127. */
  50128. private loadImage;
  50129. /**
  50130. * Convert the image buffer into a cubemap and create a CubeTexture.
  50131. */
  50132. private loadTexture;
  50133. /**
  50134. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50135. * @param buffer The ArrayBuffer that should be converted.
  50136. * @returns The buffer as Float32Array.
  50137. */
  50138. private getFloat32ArrayFromArrayBuffer;
  50139. /**
  50140. * Get the current class name of the texture useful for serialization or dynamic coding.
  50141. * @returns "EquiRectangularCubeTexture"
  50142. */
  50143. getClassName(): string;
  50144. /**
  50145. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50146. * @returns A clone of the current EquiRectangularCubeTexture.
  50147. */
  50148. clone(): EquiRectangularCubeTexture;
  50149. }
  50150. }
  50151. declare module BABYLON {
  50152. /**
  50153. * Based on jsTGALoader - Javascript loader for TGA file
  50154. * By Vincent Thibault
  50155. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50156. */
  50157. export class TGATools {
  50158. private static _TYPE_INDEXED;
  50159. private static _TYPE_RGB;
  50160. private static _TYPE_GREY;
  50161. private static _TYPE_RLE_INDEXED;
  50162. private static _TYPE_RLE_RGB;
  50163. private static _TYPE_RLE_GREY;
  50164. private static _ORIGIN_MASK;
  50165. private static _ORIGIN_SHIFT;
  50166. private static _ORIGIN_BL;
  50167. private static _ORIGIN_BR;
  50168. private static _ORIGIN_UL;
  50169. private static _ORIGIN_UR;
  50170. /**
  50171. * Gets the header of a TGA file
  50172. * @param data defines the TGA data
  50173. * @returns the header
  50174. */
  50175. static GetTGAHeader(data: Uint8Array): any;
  50176. /**
  50177. * Uploads TGA content to a Babylon Texture
  50178. * @hidden
  50179. */
  50180. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50181. /** @hidden */
  50182. 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;
  50183. /** @hidden */
  50184. 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;
  50185. /** @hidden */
  50186. 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;
  50187. /** @hidden */
  50188. 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;
  50189. /** @hidden */
  50190. 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;
  50191. /** @hidden */
  50192. 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;
  50193. }
  50194. }
  50195. declare module BABYLON {
  50196. /**
  50197. * Implementation of the TGA Texture Loader.
  50198. * @hidden
  50199. */
  50200. export class _TGATextureLoader implements IInternalTextureLoader {
  50201. /**
  50202. * Defines wether the loader supports cascade loading the different faces.
  50203. */
  50204. readonly supportCascades: boolean;
  50205. /**
  50206. * This returns if the loader support the current file information.
  50207. * @param extension defines the file extension of the file being loaded
  50208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50209. * @param fallback defines the fallback internal texture if any
  50210. * @param isBase64 defines whether the texture is encoded as a base64
  50211. * @param isBuffer defines whether the texture data are stored as a buffer
  50212. * @returns true if the loader can load the specified file
  50213. */
  50214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50215. /**
  50216. * Transform the url before loading if required.
  50217. * @param rootUrl the url of the texture
  50218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50219. * @returns the transformed texture
  50220. */
  50221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50222. /**
  50223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50224. * @param rootUrl the url of the texture
  50225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50226. * @returns the fallback texture
  50227. */
  50228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50229. /**
  50230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50231. * @param data contains the texture data
  50232. * @param texture defines the BabylonJS internal texture
  50233. * @param createPolynomials will be true if polynomials have been requested
  50234. * @param onLoad defines the callback to trigger once the texture is ready
  50235. * @param onError defines the callback to trigger in case of error
  50236. */
  50237. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50238. /**
  50239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50240. * @param data contains the texture data
  50241. * @param texture defines the BabylonJS internal texture
  50242. * @param callback defines the method to call once ready to upload
  50243. */
  50244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50245. }
  50246. }
  50247. declare module BABYLON {
  50248. /**
  50249. * Info about the .basis files
  50250. */
  50251. class BasisFileInfo {
  50252. /**
  50253. * If the file has alpha
  50254. */
  50255. hasAlpha: boolean;
  50256. /**
  50257. * Info about each image of the basis file
  50258. */
  50259. images: Array<{
  50260. levels: Array<{
  50261. width: number;
  50262. height: number;
  50263. transcodedPixels: ArrayBufferView;
  50264. }>;
  50265. }>;
  50266. }
  50267. /**
  50268. * Result of transcoding a basis file
  50269. */
  50270. class TranscodeResult {
  50271. /**
  50272. * Info about the .basis file
  50273. */
  50274. fileInfo: BasisFileInfo;
  50275. /**
  50276. * Format to use when loading the file
  50277. */
  50278. format: number;
  50279. }
  50280. /**
  50281. * Configuration options for the Basis transcoder
  50282. */
  50283. export class BasisTranscodeConfiguration {
  50284. /**
  50285. * Supported compression formats used to determine the supported output format of the transcoder
  50286. */
  50287. supportedCompressionFormats?: {
  50288. /**
  50289. * etc1 compression format
  50290. */
  50291. etc1?: boolean;
  50292. /**
  50293. * s3tc compression format
  50294. */
  50295. s3tc?: boolean;
  50296. /**
  50297. * pvrtc compression format
  50298. */
  50299. pvrtc?: boolean;
  50300. /**
  50301. * etc2 compression format
  50302. */
  50303. etc2?: boolean;
  50304. };
  50305. /**
  50306. * If mipmap levels should be loaded for transcoded images (Default: true)
  50307. */
  50308. loadMipmapLevels?: boolean;
  50309. /**
  50310. * Index of a single image to load (Default: all images)
  50311. */
  50312. loadSingleImage?: number;
  50313. }
  50314. /**
  50315. * Used to load .Basis files
  50316. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50317. */
  50318. export class BasisTools {
  50319. private static _IgnoreSupportedFormats;
  50320. /**
  50321. * URL to use when loading the basis transcoder
  50322. */
  50323. static JSModuleURL: string;
  50324. /**
  50325. * URL to use when loading the wasm module for the transcoder
  50326. */
  50327. static WasmModuleURL: string;
  50328. /**
  50329. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50330. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50331. * @returns internal format corresponding to the Basis format
  50332. */
  50333. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50334. private static _WorkerPromise;
  50335. private static _Worker;
  50336. private static _actionId;
  50337. private static _CreateWorkerAsync;
  50338. /**
  50339. * Transcodes a loaded image file to compressed pixel data
  50340. * @param imageData image data to transcode
  50341. * @param config configuration options for the transcoding
  50342. * @returns a promise resulting in the transcoded image
  50343. */
  50344. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50345. /**
  50346. * Loads a texture from the transcode result
  50347. * @param texture texture load to
  50348. * @param transcodeResult the result of transcoding the basis file to load from
  50349. */
  50350. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50351. }
  50352. }
  50353. declare module BABYLON {
  50354. /**
  50355. * Loader for .basis file format
  50356. */
  50357. export class _BasisTextureLoader implements IInternalTextureLoader {
  50358. /**
  50359. * Defines whether the loader supports cascade loading the different faces.
  50360. */
  50361. readonly supportCascades: boolean;
  50362. /**
  50363. * This returns if the loader support the current file information.
  50364. * @param extension defines the file extension of the file being loaded
  50365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50366. * @param fallback defines the fallback internal texture if any
  50367. * @param isBase64 defines whether the texture is encoded as a base64
  50368. * @param isBuffer defines whether the texture data are stored as a buffer
  50369. * @returns true if the loader can load the specified file
  50370. */
  50371. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50372. /**
  50373. * Transform the url before loading if required.
  50374. * @param rootUrl the url of the texture
  50375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50376. * @returns the transformed texture
  50377. */
  50378. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50379. /**
  50380. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50381. * @param rootUrl the url of the texture
  50382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50383. * @returns the fallback texture
  50384. */
  50385. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50386. /**
  50387. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50388. * @param data contains the texture data
  50389. * @param texture defines the BabylonJS internal texture
  50390. * @param createPolynomials will be true if polynomials have been requested
  50391. * @param onLoad defines the callback to trigger once the texture is ready
  50392. * @param onError defines the callback to trigger in case of error
  50393. */
  50394. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50395. /**
  50396. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50397. * @param data contains the texture data
  50398. * @param texture defines the BabylonJS internal texture
  50399. * @param callback defines the method to call once ready to upload
  50400. */
  50401. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50402. }
  50403. }
  50404. declare module BABYLON {
  50405. /**
  50406. * 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.
  50407. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50408. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50409. */
  50410. export class CustomProceduralTexture extends ProceduralTexture {
  50411. private _animate;
  50412. private _time;
  50413. private _config;
  50414. private _texturePath;
  50415. /**
  50416. * Instantiates a new Custom Procedural Texture.
  50417. * 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.
  50418. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50419. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50420. * @param name Define the name of the texture
  50421. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50422. * @param size Define the size of the texture to create
  50423. * @param scene Define the scene the texture belongs to
  50424. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50425. * @param generateMipMaps Define if the texture should creates mip maps or not
  50426. */
  50427. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50428. private _loadJson;
  50429. /**
  50430. * Is the texture ready to be used ? (rendered at least once)
  50431. * @returns true if ready, otherwise, false.
  50432. */
  50433. isReady(): boolean;
  50434. /**
  50435. * Render the texture to its associated render target.
  50436. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50437. */
  50438. render(useCameraPostProcess?: boolean): void;
  50439. /**
  50440. * Update the list of dependant textures samplers in the shader.
  50441. */
  50442. updateTextures(): void;
  50443. /**
  50444. * Update the uniform values of the procedural texture in the shader.
  50445. */
  50446. updateShaderUniforms(): void;
  50447. /**
  50448. * Define if the texture animates or not.
  50449. */
  50450. animate: boolean;
  50451. }
  50452. }
  50453. declare module BABYLON {
  50454. /** @hidden */
  50455. export var noisePixelShader: {
  50456. name: string;
  50457. shader: string;
  50458. };
  50459. }
  50460. declare module BABYLON {
  50461. /**
  50462. * Class used to generate noise procedural textures
  50463. */
  50464. export class NoiseProceduralTexture extends ProceduralTexture {
  50465. private _time;
  50466. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50467. brightness: number;
  50468. /** Defines the number of octaves to process */
  50469. octaves: number;
  50470. /** Defines the level of persistence (0.8 by default) */
  50471. persistence: number;
  50472. /** Gets or sets animation speed factor (default is 1) */
  50473. animationSpeedFactor: number;
  50474. /**
  50475. * Creates a new NoiseProceduralTexture
  50476. * @param name defines the name fo the texture
  50477. * @param size defines the size of the texture (default is 256)
  50478. * @param scene defines the hosting scene
  50479. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50480. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50481. */
  50482. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50483. private _updateShaderUniforms;
  50484. protected _getDefines(): string;
  50485. /** Generate the current state of the procedural texture */
  50486. render(useCameraPostProcess?: boolean): void;
  50487. /**
  50488. * Serializes this noise procedural texture
  50489. * @returns a serialized noise procedural texture object
  50490. */
  50491. serialize(): any;
  50492. /**
  50493. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50494. * @param parsedTexture defines parsed texture data
  50495. * @param scene defines the current scene
  50496. * @param rootUrl defines the root URL containing noise procedural texture information
  50497. * @returns a parsed NoiseProceduralTexture
  50498. */
  50499. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50500. }
  50501. }
  50502. declare module BABYLON {
  50503. /**
  50504. * Raw cube texture where the raw buffers are passed in
  50505. */
  50506. export class RawCubeTexture extends CubeTexture {
  50507. /**
  50508. * Creates a cube texture where the raw buffers are passed in.
  50509. * @param scene defines the scene the texture is attached to
  50510. * @param data defines the array of data to use to create each face
  50511. * @param size defines the size of the textures
  50512. * @param format defines the format of the data
  50513. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50514. * @param generateMipMaps defines if the engine should generate the mip levels
  50515. * @param invertY defines if data must be stored with Y axis inverted
  50516. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50517. * @param compression defines the compression used (null by default)
  50518. */
  50519. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50520. /**
  50521. * Updates the raw cube texture.
  50522. * @param data defines the data to store
  50523. * @param format defines the data format
  50524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50525. * @param invertY defines if data must be stored with Y axis inverted
  50526. * @param compression defines the compression used (null by default)
  50527. * @param level defines which level of the texture to update
  50528. */
  50529. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50530. /**
  50531. * Updates a raw cube texture with RGBD encoded data.
  50532. * @param data defines the array of data [mipmap][face] to use to create each face
  50533. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50534. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50535. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50536. * @returns a promsie that resolves when the operation is complete
  50537. */
  50538. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50539. /**
  50540. * Clones the raw cube texture.
  50541. * @return a new cube texture
  50542. */
  50543. clone(): CubeTexture;
  50544. /** @hidden */
  50545. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50546. }
  50547. }
  50548. declare module BABYLON {
  50549. /**
  50550. * Class used to store 3D textures containing user data
  50551. */
  50552. export class RawTexture3D extends Texture {
  50553. /** Gets or sets the texture format to use */
  50554. format: number;
  50555. private _engine;
  50556. /**
  50557. * Create a new RawTexture3D
  50558. * @param data defines the data of the texture
  50559. * @param width defines the width of the texture
  50560. * @param height defines the height of the texture
  50561. * @param depth defines the depth of the texture
  50562. * @param format defines the texture format to use
  50563. * @param scene defines the hosting scene
  50564. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50565. * @param invertY defines if texture must be stored with Y axis inverted
  50566. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50567. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50568. */
  50569. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50570. /** Gets or sets the texture format to use */
  50571. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50572. /**
  50573. * Update the texture with new data
  50574. * @param data defines the data to store in the texture
  50575. */
  50576. update(data: ArrayBufferView): void;
  50577. }
  50578. }
  50579. declare module BABYLON {
  50580. /**
  50581. * Creates a refraction texture used by refraction channel of the standard material.
  50582. * It is like a mirror but to see through a material.
  50583. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50584. */
  50585. export class RefractionTexture extends RenderTargetTexture {
  50586. /**
  50587. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50588. * 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.
  50589. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50590. */
  50591. refractionPlane: Plane;
  50592. /**
  50593. * Define how deep under the surface we should see.
  50594. */
  50595. depth: number;
  50596. /**
  50597. * Creates a refraction texture used by refraction channel of the standard material.
  50598. * It is like a mirror but to see through a material.
  50599. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50600. * @param name Define the texture name
  50601. * @param size Define the size of the underlying texture
  50602. * @param scene Define the scene the refraction belongs to
  50603. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50604. */
  50605. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50606. /**
  50607. * Clone the refraction texture.
  50608. * @returns the cloned texture
  50609. */
  50610. clone(): RefractionTexture;
  50611. /**
  50612. * Serialize the texture to a JSON representation you could use in Parse later on
  50613. * @returns the serialized JSON representation
  50614. */
  50615. serialize(): any;
  50616. }
  50617. }
  50618. declare module BABYLON {
  50619. /**
  50620. * Defines the options related to the creation of an HtmlElementTexture
  50621. */
  50622. export interface IHtmlElementTextureOptions {
  50623. /**
  50624. * Defines wether mip maps should be created or not.
  50625. */
  50626. generateMipMaps?: boolean;
  50627. /**
  50628. * Defines the sampling mode of the texture.
  50629. */
  50630. samplingMode?: number;
  50631. /**
  50632. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50633. */
  50634. engine: Nullable<Engine>;
  50635. /**
  50636. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50637. */
  50638. scene: Nullable<Scene>;
  50639. }
  50640. /**
  50641. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50642. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50643. * is automatically managed.
  50644. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50645. * in your application.
  50646. *
  50647. * As the update is not automatic, you need to call them manually.
  50648. */
  50649. export class HtmlElementTexture extends BaseTexture {
  50650. /**
  50651. * The texture URL.
  50652. */
  50653. element: HTMLVideoElement | HTMLCanvasElement;
  50654. private static readonly DefaultOptions;
  50655. private _textureMatrix;
  50656. private _engine;
  50657. private _isVideo;
  50658. private _generateMipMaps;
  50659. private _samplingMode;
  50660. /**
  50661. * Instantiates a HtmlElementTexture from the following parameters.
  50662. *
  50663. * @param name Defines the name of the texture
  50664. * @param element Defines the video or canvas the texture is filled with
  50665. * @param options Defines the other none mandatory texture creation options
  50666. */
  50667. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50668. private _createInternalTexture;
  50669. /**
  50670. * Returns the texture matrix used in most of the material.
  50671. */
  50672. getTextureMatrix(): Matrix;
  50673. /**
  50674. * Updates the content of the texture.
  50675. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50676. */
  50677. update(invertY?: Nullable<boolean>): void;
  50678. }
  50679. }
  50680. declare module BABYLON {
  50681. /**
  50682. * Enum used to define the target of a block
  50683. */
  50684. export enum NodeMaterialBlockTargets {
  50685. /** Vertex shader */
  50686. Vertex = 1,
  50687. /** Fragment shader */
  50688. Fragment = 2,
  50689. /** Vertex and Fragment */
  50690. VertexAndFragment = 3
  50691. }
  50692. }
  50693. declare module BABYLON {
  50694. /**
  50695. * Defines the kind of connection point for node based material
  50696. */
  50697. export enum NodeMaterialBlockConnectionPointTypes {
  50698. /** Float */
  50699. Float = 1,
  50700. /** Int */
  50701. Int = 2,
  50702. /** Vector2 */
  50703. Vector2 = 4,
  50704. /** Vector3 */
  50705. Vector3 = 8,
  50706. /** Vector4 */
  50707. Vector4 = 16,
  50708. /** Color3 */
  50709. Color3 = 32,
  50710. /** Color4 */
  50711. Color4 = 64,
  50712. /** Matrix */
  50713. Matrix = 128,
  50714. /** Texture */
  50715. Texture = 256,
  50716. /** Texture3D */
  50717. Texture3D = 512,
  50718. /** Vector3 or Color3 */
  50719. Vector3OrColor3 = 40,
  50720. /** Vector3 or Vector4 */
  50721. Vector3OrVector4 = 24,
  50722. /** Vector4 or Color4 */
  50723. Vector4OrColor4 = 80,
  50724. /** Color3 or Color4 */
  50725. Color3OrColor4 = 96,
  50726. /** Vector3 or Color3 */
  50727. Vector3OrColor3OrVector4OrColor4 = 120,
  50728. /** Detect type based on connection */
  50729. AutoDetect = 1024,
  50730. /** Output type that will be defined by input type */
  50731. BasedOnInput = 2048,
  50732. /** Light */
  50733. Light = 4096
  50734. }
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * Enum used to define well known values e.g. values automatically provided by the system
  50739. */
  50740. export enum NodeMaterialWellKnownValues {
  50741. /** World */
  50742. World = 1,
  50743. /** View */
  50744. View = 2,
  50745. /** Projection */
  50746. Projection = 3,
  50747. /** ViewProjection */
  50748. ViewProjection = 4,
  50749. /** WorldView */
  50750. WorldView = 5,
  50751. /** WorldViewProjection */
  50752. WorldViewProjection = 6,
  50753. /** CameraPosition */
  50754. CameraPosition = 7,
  50755. /** Will be filled by the block itself */
  50756. Automatic = 8
  50757. }
  50758. }
  50759. declare module BABYLON {
  50760. /**
  50761. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50762. */
  50763. export enum NodeMaterialBlockConnectionPointMode {
  50764. /** Value is an uniform */
  50765. Uniform = 0,
  50766. /** Value is a mesh attribute */
  50767. Attribute = 1,
  50768. /** Value is a varying between vertex and fragment shaders */
  50769. Varying = 2,
  50770. /** Mode is undefined */
  50771. Undefined = 3
  50772. }
  50773. }
  50774. declare module BABYLON {
  50775. /**
  50776. * Class used to store shared data between 2 NodeMaterialBuildState
  50777. */
  50778. export class NodeMaterialBuildStateSharedData {
  50779. /**
  50780. * Gets the list of emitted varyings
  50781. */
  50782. varyings: string[];
  50783. /**
  50784. * Gets the varying declaration string
  50785. */
  50786. varyingDeclaration: string;
  50787. /**
  50788. * Uniform connection points
  50789. */
  50790. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50791. /**
  50792. * Bindable blocks (Blocks that need to set data to the effect)
  50793. */
  50794. bindableBlocks: NodeMaterialBlock[];
  50795. /**
  50796. * List of blocks that can provide a compilation fallback
  50797. */
  50798. blocksWithFallbacks: NodeMaterialBlock[];
  50799. /**
  50800. * List of blocks that can provide a define update
  50801. */
  50802. blocksWithDefines: NodeMaterialBlock[];
  50803. /**
  50804. * List of blocks that can provide a repeatable content
  50805. */
  50806. repeatableContentBlocks: NodeMaterialBlock[];
  50807. /**
  50808. * List of blocks that can block the isReady function for the material
  50809. */
  50810. blockingBlocks: NodeMaterialBlock[];
  50811. /**
  50812. * Build Id used to avoid multiple recompilations
  50813. */
  50814. buildId: number;
  50815. /** List of emitted variables */
  50816. variableNames: {
  50817. [key: string]: number;
  50818. };
  50819. /** List of emitted defines */
  50820. defineNames: {
  50821. [key: string]: number;
  50822. };
  50823. /** Should emit comments? */
  50824. emitComments: boolean;
  50825. /** Emit build activity */
  50826. verbose: boolean;
  50827. /**
  50828. * Gets the compilation hints emitted at compilation time
  50829. */
  50830. hints: {
  50831. needWorldViewMatrix: boolean;
  50832. needWorldViewProjectionMatrix: boolean;
  50833. needAlphaBlending: boolean;
  50834. needAlphaTesting: boolean;
  50835. };
  50836. /**
  50837. * List of compilation checks
  50838. */
  50839. checks: {
  50840. emitVertex: boolean;
  50841. emitFragment: boolean;
  50842. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50843. };
  50844. /** Creates a new shared data */
  50845. constructor();
  50846. /**
  50847. * Emits console errors and exceptions if there is a failing check
  50848. */
  50849. emitErrors(): void;
  50850. }
  50851. }
  50852. declare module BABYLON {
  50853. /**
  50854. * Class used to store node based material build state
  50855. */
  50856. export class NodeMaterialBuildState {
  50857. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50858. supportUniformBuffers: boolean;
  50859. /**
  50860. * Gets the list of emitted attributes
  50861. */
  50862. attributes: string[];
  50863. /**
  50864. * Gets the list of emitted uniforms
  50865. */
  50866. uniforms: string[];
  50867. /**
  50868. * Gets the list of emitted uniform buffers
  50869. */
  50870. uniformBuffers: string[];
  50871. /**
  50872. * Gets the list of emitted samplers
  50873. */
  50874. samplers: string[];
  50875. /**
  50876. * Gets the list of emitted functions
  50877. */
  50878. functions: {
  50879. [key: string]: string;
  50880. };
  50881. /**
  50882. * Gets the target of the compilation state
  50883. */
  50884. target: NodeMaterialBlockTargets;
  50885. /**
  50886. * Gets the list of emitted counters
  50887. */
  50888. counters: {
  50889. [key: string]: number;
  50890. };
  50891. /**
  50892. * Shared data between multiple NodeMaterialBuildState instances
  50893. */
  50894. sharedData: NodeMaterialBuildStateSharedData;
  50895. /** @hidden */
  50896. _vertexState: NodeMaterialBuildState;
  50897. private _attributeDeclaration;
  50898. private _uniformDeclaration;
  50899. private _samplerDeclaration;
  50900. private _varyingTransfer;
  50901. private _repeatableContentAnchorIndex;
  50902. /** @hidden */
  50903. _builtCompilationString: string;
  50904. /**
  50905. * Gets the emitted compilation strings
  50906. */
  50907. compilationString: string;
  50908. /**
  50909. * Finalize the compilation strings
  50910. * @param state defines the current compilation state
  50911. */
  50912. finalize(state: NodeMaterialBuildState): void;
  50913. /** @hidden */
  50914. readonly _repeatableContentAnchor: string;
  50915. /** @hidden */
  50916. _getFreeVariableName(prefix: string): string;
  50917. /** @hidden */
  50918. _getFreeDefineName(prefix: string): string;
  50919. /** @hidden */
  50920. _excludeVariableName(name: string): void;
  50921. /** @hidden */
  50922. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50923. /** @hidden */
  50924. _emitFunction(name: string, code: string, comments: string): void;
  50925. /** @hidden */
  50926. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50927. replaceStrings?: {
  50928. search: RegExp;
  50929. replace: string;
  50930. }[];
  50931. }): string;
  50932. /** @hidden */
  50933. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50934. repeatKey?: string;
  50935. removeAttributes?: boolean;
  50936. removeUniforms?: boolean;
  50937. removeVaryings?: boolean;
  50938. removeIfDef?: boolean;
  50939. replaceStrings?: {
  50940. search: RegExp;
  50941. replace: string;
  50942. }[];
  50943. }, storeKey?: string): void;
  50944. /** @hidden */
  50945. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50946. private _emitDefine;
  50947. /** @hidden */
  50948. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50949. }
  50950. }
  50951. declare module BABYLON {
  50952. /**
  50953. * Root class for all node material optimizers
  50954. */
  50955. export class NodeMaterialOptimizer {
  50956. /**
  50957. * Function used to optimize a NodeMaterial graph
  50958. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50959. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50960. */
  50961. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * Block used to transform a vector4 with a matrix
  50967. */
  50968. export class Vector4TransformBlock extends NodeMaterialBlock {
  50969. /**
  50970. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50971. */
  50972. complementW: number;
  50973. /**
  50974. * Creates a new Vector4TransformBlock
  50975. * @param name defines the block name
  50976. */
  50977. constructor(name: string);
  50978. /**
  50979. * Gets the current class name
  50980. * @returns the class name
  50981. */
  50982. getClassName(): string;
  50983. /**
  50984. * Gets the vector input
  50985. */
  50986. readonly vector: NodeMaterialConnectionPoint;
  50987. /**
  50988. * Gets the output component
  50989. */
  50990. readonly output: NodeMaterialConnectionPoint;
  50991. /**
  50992. * Gets the matrix transform input
  50993. */
  50994. readonly transform: NodeMaterialConnectionPoint;
  50995. protected _buildBlock(state: NodeMaterialBuildState): this;
  50996. }
  50997. }
  50998. declare module BABYLON {
  50999. /**
  51000. * Block used to output the vertex position
  51001. */
  51002. export class VertexOutputBlock extends NodeMaterialBlock {
  51003. /**
  51004. * Creates a new VertexOutputBlock
  51005. * @param name defines the block name
  51006. */
  51007. constructor(name: string);
  51008. /**
  51009. * Gets the current class name
  51010. * @returns the class name
  51011. */
  51012. getClassName(): string;
  51013. /**
  51014. * Gets the vector input component
  51015. */
  51016. readonly vector: NodeMaterialConnectionPoint;
  51017. protected _buildBlock(state: NodeMaterialBuildState): this;
  51018. }
  51019. }
  51020. declare module BABYLON {
  51021. /**
  51022. * Block used to output the final color
  51023. */
  51024. export class FragmentOutputBlock extends NodeMaterialBlock {
  51025. /**
  51026. * Gets or sets a boolean indicating if this block will output an alpha value
  51027. */
  51028. alphaBlendingEnabled: boolean;
  51029. /**
  51030. * Create a new FragmentOutputBlock
  51031. * @param name defines the block name
  51032. */
  51033. constructor(name: string);
  51034. /**
  51035. * Gets the current class name
  51036. * @returns the class name
  51037. */
  51038. getClassName(): string;
  51039. /**
  51040. * Gets the color input component
  51041. */
  51042. readonly color: NodeMaterialConnectionPoint;
  51043. protected _buildBlock(state: NodeMaterialBuildState): this;
  51044. }
  51045. }
  51046. declare module BABYLON {
  51047. /**
  51048. * Interface used to configure the node material editor
  51049. */
  51050. export interface INodeMaterialEditorOptions {
  51051. /** Define the URl to load node editor script */
  51052. editorURL?: string;
  51053. }
  51054. /** @hidden */
  51055. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51056. /** BONES */
  51057. NUM_BONE_INFLUENCERS: number;
  51058. BonesPerMesh: number;
  51059. BONETEXTURE: boolean;
  51060. /** MORPH TARGETS */
  51061. MORPHTARGETS: boolean;
  51062. MORPHTARGETS_NORMAL: boolean;
  51063. MORPHTARGETS_TANGENT: boolean;
  51064. MORPHTARGETS_UV: boolean;
  51065. NUM_MORPH_INFLUENCERS: number;
  51066. /** IMAGE PROCESSING */
  51067. IMAGEPROCESSING: boolean;
  51068. VIGNETTE: boolean;
  51069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51070. VIGNETTEBLENDMODEOPAQUE: boolean;
  51071. TONEMAPPING: boolean;
  51072. TONEMAPPING_ACES: boolean;
  51073. CONTRAST: boolean;
  51074. EXPOSURE: boolean;
  51075. COLORCURVES: boolean;
  51076. COLORGRADING: boolean;
  51077. COLORGRADING3D: boolean;
  51078. SAMPLER3DGREENDEPTH: boolean;
  51079. SAMPLER3DBGRMAP: boolean;
  51080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51081. constructor();
  51082. setValue(name: string, value: boolean): void;
  51083. }
  51084. /**
  51085. * Class used to configure NodeMaterial
  51086. */
  51087. export interface INodeMaterialOptions {
  51088. /**
  51089. * Defines if blocks should emit comments
  51090. */
  51091. emitComments: boolean;
  51092. }
  51093. /**
  51094. * Class used to create a node based material built by assembling shader blocks
  51095. */
  51096. export class NodeMaterial extends PushMaterial {
  51097. private _options;
  51098. private _vertexCompilationState;
  51099. private _fragmentCompilationState;
  51100. private _sharedData;
  51101. private _buildId;
  51102. private _buildWasSuccessful;
  51103. private _cachedWorldViewMatrix;
  51104. private _cachedWorldViewProjectionMatrix;
  51105. private _textureConnectionPoints;
  51106. private _optimizers;
  51107. /** Define the URl to load node editor script */
  51108. static EditorURL: string;
  51109. private BJSNODEMATERIALEDITOR;
  51110. /** Get the inspector from bundle or global */
  51111. private _getGlobalNodeMaterialEditor;
  51112. /**
  51113. * Defines the maximum number of lights that can be used in the material
  51114. */
  51115. maxSimultaneousLights: number;
  51116. /**
  51117. * Observable raised when the material is built
  51118. */
  51119. onBuildObservable: Observable<NodeMaterial>;
  51120. /**
  51121. * Gets or sets the root nodes of the material vertex shader
  51122. */
  51123. _vertexOutputNodes: NodeMaterialBlock[];
  51124. /**
  51125. * Gets or sets the root nodes of the material fragment (pixel) shader
  51126. */
  51127. _fragmentOutputNodes: NodeMaterialBlock[];
  51128. /** Gets or sets options to control the node material overall behavior */
  51129. options: INodeMaterialOptions;
  51130. /**
  51131. * Default configuration related to image processing available in the standard Material.
  51132. */
  51133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51134. /**
  51135. * Gets the image processing configuration used either in this material.
  51136. */
  51137. /**
  51138. * Sets the Default image processing configuration used either in the this material.
  51139. *
  51140. * If sets to null, the scene one is in use.
  51141. */
  51142. imageProcessingConfiguration: ImageProcessingConfiguration;
  51143. /**
  51144. * Create a new node based material
  51145. * @param name defines the material name
  51146. * @param scene defines the hosting scene
  51147. * @param options defines creation option
  51148. */
  51149. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51150. /**
  51151. * Gets the current class name of the material e.g. "NodeMaterial"
  51152. * @returns the class name
  51153. */
  51154. getClassName(): string;
  51155. /**
  51156. * Keep track of the image processing observer to allow dispose and replace.
  51157. */
  51158. private _imageProcessingObserver;
  51159. /**
  51160. * Attaches a new image processing configuration to the Standard Material.
  51161. * @param configuration
  51162. */
  51163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51164. /**
  51165. * Adds a new optimizer to the list of optimizers
  51166. * @param optimizer defines the optimizers to add
  51167. * @returns the current material
  51168. */
  51169. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51170. /**
  51171. * Remove an optimizer from the list of optimizers
  51172. * @param optimizer defines the optimizers to remove
  51173. * @returns the current material
  51174. */
  51175. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51176. /**
  51177. * Add a new block to the list of output nodes
  51178. * @param node defines the node to add
  51179. * @returns the current material
  51180. */
  51181. addOutputNode(node: NodeMaterialBlock): this;
  51182. /**
  51183. * Remove a block from the list of root nodes
  51184. * @param node defines the node to remove
  51185. * @returns the current material
  51186. */
  51187. removeOutputNode(node: NodeMaterialBlock): this;
  51188. private _addVertexOutputNode;
  51189. private _removeVertexOutputNode;
  51190. private _addFragmentOutputNode;
  51191. private _removeFragmentOutputNode;
  51192. /**
  51193. * Specifies if the material will require alpha blending
  51194. * @returns a boolean specifying if alpha blending is needed
  51195. */
  51196. needAlphaBlending(): boolean;
  51197. /**
  51198. * Specifies if this material should be rendered in alpha test mode
  51199. * @returns a boolean specifying if an alpha test is needed.
  51200. */
  51201. needAlphaTesting(): boolean;
  51202. private _initializeBlock;
  51203. private _resetDualBlocks;
  51204. /**
  51205. * Build the material and generates the inner effect
  51206. * @param verbose defines if the build should log activity
  51207. */
  51208. build(verbose?: boolean): void;
  51209. /**
  51210. * Runs an otpimization phase to try to improve the shader code
  51211. */
  51212. optimize(): void;
  51213. private _prepareDefinesForAttributes;
  51214. /**
  51215. * Get if the submesh is ready to be used and all its information available.
  51216. * Child classes can use it to update shaders
  51217. * @param mesh defines the mesh to check
  51218. * @param subMesh defines which submesh to check
  51219. * @param useInstances specifies that instances should be used
  51220. * @returns a boolean indicating that the submesh is ready or not
  51221. */
  51222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51223. /**
  51224. * Binds the world matrix to the material
  51225. * @param world defines the world transformation matrix
  51226. */
  51227. bindOnlyWorldMatrix(world: Matrix): void;
  51228. /**
  51229. * Binds the submesh to this material by preparing the effect and shader to draw
  51230. * @param world defines the world transformation matrix
  51231. * @param mesh defines the mesh containing the submesh
  51232. * @param subMesh defines the submesh to bind the material to
  51233. */
  51234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51235. /**
  51236. * Gets the active textures from the material
  51237. * @returns an array of textures
  51238. */
  51239. getActiveTextures(): BaseTexture[];
  51240. /**
  51241. * Specifies if the material uses a texture
  51242. * @param texture defines the texture to check against the material
  51243. * @returns a boolean specifying if the material uses the texture
  51244. */
  51245. hasTexture(texture: BaseTexture): boolean;
  51246. /**
  51247. * Disposes the material
  51248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51250. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51251. */
  51252. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51253. /** Creates the node editor window. */
  51254. private _createNodeEditor;
  51255. /**
  51256. * Launch the node material editor
  51257. * @param config Define the configuration of the editor
  51258. * @return a promise fulfilled when the node editor is visible
  51259. */
  51260. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51261. /**
  51262. * Clear the current material
  51263. */
  51264. clear(): void;
  51265. /**
  51266. * Clear the current material and set it to a default state
  51267. */
  51268. setToDefault(): void;
  51269. }
  51270. }
  51271. declare module BABYLON {
  51272. /**
  51273. * Defines a block that can be used inside a node based material
  51274. */
  51275. export class NodeMaterialBlock {
  51276. private _buildId;
  51277. private _target;
  51278. private _isFinalMerger;
  51279. /** @hidden */
  51280. _inputs: NodeMaterialConnectionPoint[];
  51281. /** @hidden */
  51282. _outputs: NodeMaterialConnectionPoint[];
  51283. /**
  51284. * Gets or sets the name of the block
  51285. */
  51286. name: string;
  51287. /**
  51288. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51289. */
  51290. readonly isFinalMerger: boolean;
  51291. /**
  51292. * Gets or sets the build Id
  51293. */
  51294. buildId: number;
  51295. /**
  51296. * Gets or sets the target of the block
  51297. */
  51298. target: NodeMaterialBlockTargets;
  51299. /**
  51300. * Gets the list of input points
  51301. */
  51302. readonly inputs: NodeMaterialConnectionPoint[];
  51303. /** Gets the list of output points */
  51304. readonly outputs: NodeMaterialConnectionPoint[];
  51305. /**
  51306. * Find an input by its name
  51307. * @param name defines the name of the input to look for
  51308. * @returns the input or null if not found
  51309. */
  51310. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51311. /**
  51312. * Find an output by its name
  51313. * @param name defines the name of the outputto look for
  51314. * @returns the output or null if not found
  51315. */
  51316. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51317. /**
  51318. * Creates a new NodeMaterialBlock
  51319. * @param name defines the block name
  51320. * @param target defines the target of that block (Vertex by default)
  51321. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51322. */
  51323. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  51324. /**
  51325. * Initialize the block and prepare the context for build
  51326. * @param state defines the state that will be used for the build
  51327. */
  51328. initialize(state: NodeMaterialBuildState): void;
  51329. /**
  51330. * Bind data to effect. Will only be called for blocks with isBindable === true
  51331. * @param effect defines the effect to bind data to
  51332. * @param nodeMaterial defines the hosting NodeMaterial
  51333. * @param mesh defines the mesh that will be rendered
  51334. */
  51335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51336. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51337. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51338. protected _writeFloat(value: number): string;
  51339. /**
  51340. * Gets the current class name e.g. "NodeMaterialBlock"
  51341. * @returns the class name
  51342. */
  51343. getClassName(): string;
  51344. /**
  51345. * Register a new input. Must be called inside a block constructor
  51346. * @param name defines the connection point name
  51347. * @param type defines the connection point type
  51348. * @param isOptional defines a boolean indicating that this input can be omitted
  51349. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51350. * @returns the current block
  51351. */
  51352. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51353. /**
  51354. * Register a new output. Must be called inside a block constructor
  51355. * @param name defines the connection point name
  51356. * @param type defines the connection point type
  51357. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51358. * @returns the current block
  51359. */
  51360. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51361. /**
  51362. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51363. * @param forOutput defines an optional connection point to check compatibility with
  51364. * @returns the first available input or null
  51365. */
  51366. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51367. /**
  51368. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51369. * @param forBlock defines an optional block to check compatibility with
  51370. * @returns the first available input or null
  51371. */
  51372. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51373. /**
  51374. * Connect current block with another block
  51375. * @param other defines the block to connect with
  51376. * @param options define the various options to help pick the right connections
  51377. * @returns the current block
  51378. */
  51379. connectTo(other: NodeMaterialBlock, options?: {
  51380. input?: string;
  51381. output?: string;
  51382. outputSwizzle?: string;
  51383. }): this | undefined;
  51384. protected _buildBlock(state: NodeMaterialBuildState): void;
  51385. /**
  51386. * Add potential fallbacks if shader compilation fails
  51387. * @param mesh defines the mesh to be rendered
  51388. * @param fallbacks defines the current prioritized list of fallbacks
  51389. */
  51390. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51391. /**
  51392. * Update defines for shader compilation
  51393. * @param mesh defines the mesh to be rendered
  51394. * @param nodeMaterial defines the node material requesting the update
  51395. * @param defines defines the material defines to update
  51396. * @param useInstances specifies that instances should be used
  51397. */
  51398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51399. /**
  51400. * Lets the block try to connect some inputs automatically
  51401. */
  51402. autoConfigure(): void;
  51403. /**
  51404. * Function called when a block is declared as repeatable content generator
  51405. * @param vertexShaderState defines the current compilation state for the vertex shader
  51406. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51407. * @param mesh defines the mesh to be rendered
  51408. * @param defines defines the material defines to update
  51409. */
  51410. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51411. /**
  51412. * Checks if the block is ready
  51413. * @param mesh defines the mesh to be rendered
  51414. * @param nodeMaterial defines the node material requesting the update
  51415. * @param defines defines the material defines to update
  51416. * @param useInstances specifies that instances should be used
  51417. * @returns true if the block is ready
  51418. */
  51419. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51420. /**
  51421. * Compile the current node and generate the shader code
  51422. * @param state defines the current compilation state (uniforms, samplers, current string)
  51423. * @returns the current block
  51424. */
  51425. build(state: NodeMaterialBuildState): this | undefined;
  51426. }
  51427. }
  51428. declare module BABYLON {
  51429. /**
  51430. * Defines a connection point for a block
  51431. */
  51432. export class NodeMaterialConnectionPoint {
  51433. /** @hidden */
  51434. _ownerBlock: NodeMaterialBlock;
  51435. /** @hidden */
  51436. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51437. private _associatedVariableName;
  51438. private _endpoints;
  51439. private _storedValue;
  51440. private _valueCallback;
  51441. private _mode;
  51442. /** @hidden */
  51443. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51444. /** @hidden */
  51445. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51446. /** @hidden */
  51447. _needToEmitVarying: boolean;
  51448. /** @hidden */
  51449. _forceUniformInVertexShaderOnly: boolean;
  51450. private _type;
  51451. /**
  51452. * Gets or sets the connection point type (default is float)
  51453. */
  51454. type: NodeMaterialBlockConnectionPointTypes;
  51455. /**
  51456. * Gets or sets the connection point name
  51457. */
  51458. name: string;
  51459. /**
  51460. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51461. */
  51462. swizzle: string;
  51463. /**
  51464. * Gets or sets a boolean indicating that this connection point can be omitted
  51465. */
  51466. isOptional: boolean;
  51467. /**
  51468. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51469. */
  51470. define: string;
  51471. /** Gets or sets the target of that connection point */
  51472. target: NodeMaterialBlockTargets;
  51473. /**
  51474. * Gets or sets the value of that point.
  51475. * Please note that this value will be ignored if valueCallback is defined
  51476. */
  51477. value: any;
  51478. /**
  51479. * Gets or sets a callback used to get the value of that point.
  51480. * Please note that setting this value will force the connection point to ignore the value property
  51481. */
  51482. valueCallback: () => any;
  51483. /**
  51484. * Gets or sets the associated variable name in the shader
  51485. */
  51486. associatedVariableName: string;
  51487. /**
  51488. * Gets a boolean indicating that this connection point not defined yet
  51489. */
  51490. readonly isUndefined: boolean;
  51491. /**
  51492. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51493. * In this case the connection point name must be the name of the uniform to use.
  51494. * Can only be set on inputs
  51495. */
  51496. isUniform: boolean;
  51497. /**
  51498. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51499. * In this case the connection point name must be the name of the attribute to use
  51500. * Can only be set on inputs
  51501. */
  51502. isAttribute: boolean;
  51503. /**
  51504. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51505. * Can only be set on exit points
  51506. */
  51507. isVarying: boolean;
  51508. /** Get the other side of the connection (if any) */
  51509. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51510. /** Get the block that owns this connection point */
  51511. readonly ownerBlock: NodeMaterialBlock;
  51512. /** Get the block connected on the other side of this connection (if any) */
  51513. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51514. /** Get the block connected on the endpoints of this connection (if any) */
  51515. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51516. /**
  51517. * Creates a new connection point
  51518. * @param name defines the connection point name
  51519. * @param ownerBlock defines the block hosting this connection point
  51520. */
  51521. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51522. /**
  51523. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51524. * @returns the class name
  51525. */
  51526. getClassName(): string;
  51527. /**
  51528. * Set the source of this connection point to a vertex attribute
  51529. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51530. * @returns the current connection point
  51531. */
  51532. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51533. /**
  51534. * Set the source of this connection point to a well known value
  51535. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51536. * @returns the current connection point
  51537. */
  51538. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51539. /**
  51540. * Gets a boolean indicating that the current connection point is a well known value
  51541. */
  51542. readonly isWellKnownValue: boolean;
  51543. /**
  51544. * Gets or sets the current well known value or null if not defined as well know value
  51545. */
  51546. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51547. private _getTypeLength;
  51548. /**
  51549. * Connect this point to another connection point
  51550. * @param connectionPoint defines the other connection point
  51551. * @returns the current connection point
  51552. */
  51553. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51554. /**
  51555. * Disconnect this point from one of his endpoint
  51556. * @param endpoint defines the other connection point
  51557. * @returns the current connection point
  51558. */
  51559. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51560. /**
  51561. * When connection point is an uniform, this function will send its value to the effect
  51562. * @param effect defines the effect to transmit value to
  51563. * @param world defines the world matrix
  51564. * @param worldView defines the worldxview matrix
  51565. * @param worldViewProjection defines the worldxviewxprojection matrix
  51566. */
  51567. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51568. /**
  51569. * When connection point is an uniform, this function will send its value to the effect
  51570. * @param effect defines the effect to transmit value to
  51571. * @param scene defines the hosting scene
  51572. */
  51573. transmit(effect: Effect, scene: Scene): void;
  51574. }
  51575. }
  51576. declare module BABYLON {
  51577. /**
  51578. * Block used to add support for vertex skinning (bones)
  51579. */
  51580. export class BonesBlock extends NodeMaterialBlock {
  51581. /**
  51582. * Creates a new BonesBlock
  51583. * @param name defines the block name
  51584. */
  51585. constructor(name: string);
  51586. /**
  51587. * Initialize the block and prepare the context for build
  51588. * @param state defines the state that will be used for the build
  51589. */
  51590. initialize(state: NodeMaterialBuildState): void;
  51591. /**
  51592. * Gets the current class name
  51593. * @returns the class name
  51594. */
  51595. getClassName(): string;
  51596. /**
  51597. * Gets the matrix indices input component
  51598. */
  51599. readonly matricesIndices: NodeMaterialConnectionPoint;
  51600. /**
  51601. * Gets the matrix weights input component
  51602. */
  51603. readonly matricesWeights: NodeMaterialConnectionPoint;
  51604. /**
  51605. * Gets the extra matrix indices input component
  51606. */
  51607. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51608. /**
  51609. * Gets the extra matrix weights input component
  51610. */
  51611. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51612. /**
  51613. * Gets the world input component
  51614. */
  51615. readonly world: NodeMaterialConnectionPoint;
  51616. /**
  51617. * Gets the output component
  51618. */
  51619. readonly output: NodeMaterialConnectionPoint;
  51620. autoConfigure(): void;
  51621. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51624. protected _buildBlock(state: NodeMaterialBuildState): this;
  51625. }
  51626. }
  51627. declare module BABYLON {
  51628. /**
  51629. * Block used to add support for instances
  51630. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51631. */
  51632. export class InstancesBlock extends NodeMaterialBlock {
  51633. /**
  51634. * Creates a new InstancesBlock
  51635. * @param name defines the block name
  51636. */
  51637. constructor(name: string);
  51638. /**
  51639. * Gets the current class name
  51640. * @returns the class name
  51641. */
  51642. getClassName(): string;
  51643. /**
  51644. * Gets the first world row input component
  51645. */
  51646. readonly world0: NodeMaterialConnectionPoint;
  51647. /**
  51648. * Gets the second world row input component
  51649. */
  51650. readonly world1: NodeMaterialConnectionPoint;
  51651. /**
  51652. * Gets the third world row input component
  51653. */
  51654. readonly world2: NodeMaterialConnectionPoint;
  51655. /**
  51656. * Gets the forth world row input component
  51657. */
  51658. readonly world3: NodeMaterialConnectionPoint;
  51659. /**
  51660. * Gets the world input component
  51661. */
  51662. readonly world: NodeMaterialConnectionPoint;
  51663. /**
  51664. * Gets the output component
  51665. */
  51666. readonly output: NodeMaterialConnectionPoint;
  51667. autoConfigure(): void;
  51668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51669. protected _buildBlock(state: NodeMaterialBuildState): this;
  51670. }
  51671. }
  51672. declare module BABYLON {
  51673. /**
  51674. * Block used to add morph targets support to vertex shader
  51675. */
  51676. export class MorphTargetsBlock extends NodeMaterialBlock {
  51677. private _repeatableContentAnchor;
  51678. private _repeatebleContentGenerated;
  51679. /**
  51680. * Create a new MorphTargetsBlock
  51681. * @param name defines the block name
  51682. */
  51683. constructor(name: string);
  51684. /**
  51685. * Gets the current class name
  51686. * @returns the class name
  51687. */
  51688. getClassName(): string;
  51689. /**
  51690. * Gets the position input component
  51691. */
  51692. readonly position: NodeMaterialConnectionPoint;
  51693. /**
  51694. * Gets the normal input component
  51695. */
  51696. readonly normal: NodeMaterialConnectionPoint;
  51697. /**
  51698. * Gets the tangent input component
  51699. */
  51700. readonly tangent: NodeMaterialConnectionPoint;
  51701. /**
  51702. * Gets the tangent input component
  51703. */
  51704. readonly uv: NodeMaterialConnectionPoint;
  51705. /**
  51706. * Gets the position output component
  51707. */
  51708. readonly positionOutput: NodeMaterialConnectionPoint;
  51709. /**
  51710. * Gets the normal output component
  51711. */
  51712. readonly normalOutput: NodeMaterialConnectionPoint;
  51713. /**
  51714. * Gets the tangent output component
  51715. */
  51716. readonly tangentOutput: NodeMaterialConnectionPoint;
  51717. /**
  51718. * Gets the tangent output component
  51719. */
  51720. readonly uvOutput: NodeMaterialConnectionPoint;
  51721. initialize(state: NodeMaterialBuildState): void;
  51722. autoConfigure(): void;
  51723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51724. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51725. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51726. protected _buildBlock(state: NodeMaterialBuildState): this;
  51727. }
  51728. }
  51729. declare module BABYLON {
  51730. /**
  51731. * Block used to add an alpha test in the fragment shader
  51732. */
  51733. export class AlphaTestBlock extends NodeMaterialBlock {
  51734. /**
  51735. * Gets or sets the alpha value where alpha testing happens
  51736. */
  51737. alphaCutOff: number;
  51738. /**
  51739. * Create a new AlphaTestBlock
  51740. * @param name defines the block name
  51741. */
  51742. constructor(name: string);
  51743. /**
  51744. * Gets the current class name
  51745. * @returns the class name
  51746. */
  51747. getClassName(): string;
  51748. /**
  51749. * Gets the color input component
  51750. */
  51751. readonly color: NodeMaterialConnectionPoint;
  51752. protected _buildBlock(state: NodeMaterialBuildState): this;
  51753. }
  51754. }
  51755. declare module BABYLON {
  51756. /**
  51757. * Block used to create a Color4 out of 4 inputs (one for each component)
  51758. */
  51759. export class RGBAMergerBlock extends NodeMaterialBlock {
  51760. /**
  51761. * Create a new RGBAMergerBlock
  51762. * @param name defines the block name
  51763. */
  51764. constructor(name: string);
  51765. /**
  51766. * Gets the current class name
  51767. * @returns the class name
  51768. */
  51769. getClassName(): string;
  51770. /**
  51771. * Gets the R input component
  51772. */
  51773. readonly r: NodeMaterialConnectionPoint;
  51774. /**
  51775. * Gets the G input component
  51776. */
  51777. readonly g: NodeMaterialConnectionPoint;
  51778. /**
  51779. * Gets the B input component
  51780. */
  51781. readonly b: NodeMaterialConnectionPoint;
  51782. /**
  51783. * Gets the RGB input component
  51784. */
  51785. readonly rgb: NodeMaterialConnectionPoint;
  51786. /**
  51787. * Gets the R input component
  51788. */
  51789. readonly a: NodeMaterialConnectionPoint;
  51790. /**
  51791. * Gets the output component
  51792. */
  51793. readonly output: NodeMaterialConnectionPoint;
  51794. protected _buildBlock(state: NodeMaterialBuildState): this;
  51795. }
  51796. }
  51797. declare module BABYLON {
  51798. /**
  51799. * Block used to create a Color3 out of 3 inputs (one for each component)
  51800. */
  51801. export class RGBMergerBlock extends NodeMaterialBlock {
  51802. /**
  51803. * Create a new RGBMergerBlock
  51804. * @param name defines the block name
  51805. */
  51806. constructor(name: string);
  51807. /**
  51808. * Gets the current class name
  51809. * @returns the class name
  51810. */
  51811. getClassName(): string;
  51812. /**
  51813. * Gets the R component input
  51814. */
  51815. readonly r: NodeMaterialConnectionPoint;
  51816. /**
  51817. * Gets the G component input
  51818. */
  51819. readonly g: NodeMaterialConnectionPoint;
  51820. /**
  51821. * Gets the B component input
  51822. */
  51823. readonly b: NodeMaterialConnectionPoint;
  51824. /**
  51825. * Gets the output component
  51826. */
  51827. readonly output: NodeMaterialConnectionPoint;
  51828. protected _buildBlock(state: NodeMaterialBuildState): this;
  51829. }
  51830. }
  51831. declare module BABYLON {
  51832. /**
  51833. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51834. */
  51835. export class RGBASplitterBlock extends NodeMaterialBlock {
  51836. /**
  51837. * Create a new RGBASplitterBlock
  51838. * @param name defines the block name
  51839. */
  51840. constructor(name: string);
  51841. /**
  51842. * Gets the current class name
  51843. * @returns the class name
  51844. */
  51845. getClassName(): string;
  51846. /**
  51847. * Gets the input component
  51848. */
  51849. readonly input: NodeMaterialConnectionPoint;
  51850. protected _buildBlock(state: NodeMaterialBuildState): this;
  51851. }
  51852. }
  51853. declare module BABYLON {
  51854. /**
  51855. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51856. */
  51857. export class RGBSplitterBlock extends NodeMaterialBlock {
  51858. /**
  51859. * Create a new RGBSplitterBlock
  51860. * @param name defines the block name
  51861. */
  51862. constructor(name: string);
  51863. /**
  51864. * Gets the current class name
  51865. * @returns the class name
  51866. */
  51867. getClassName(): string;
  51868. /**
  51869. * Gets the input component
  51870. */
  51871. readonly input: NodeMaterialConnectionPoint;
  51872. protected _buildBlock(state: NodeMaterialBuildState): this;
  51873. }
  51874. }
  51875. declare module BABYLON {
  51876. /**
  51877. * Block used to read a texture from a sampler
  51878. */
  51879. export class TextureBlock extends NodeMaterialBlock {
  51880. private _defineName;
  51881. /**
  51882. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51883. */
  51884. autoConnectTextureMatrix: boolean;
  51885. /**
  51886. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51887. */
  51888. autoSelectUV: boolean;
  51889. /**
  51890. * Create a new TextureBlock
  51891. * @param name defines the block name
  51892. */
  51893. constructor(name: string);
  51894. /**
  51895. * Gets the current class name
  51896. * @returns the class name
  51897. */
  51898. getClassName(): string;
  51899. /**
  51900. * Gets the uv input component
  51901. */
  51902. readonly uv: NodeMaterialConnectionPoint;
  51903. /**
  51904. * Gets the texture information input component
  51905. */
  51906. readonly textureInfo: NodeMaterialConnectionPoint;
  51907. /**
  51908. * Gets the transformed uv input component
  51909. */
  51910. readonly transformedUV: NodeMaterialConnectionPoint;
  51911. /**
  51912. * Gets the texture input component
  51913. */
  51914. readonly texture: NodeMaterialConnectionPoint;
  51915. /**
  51916. * Gets the texture transform input component
  51917. */
  51918. readonly textureTransform: NodeMaterialConnectionPoint;
  51919. /**
  51920. * Gets the output component
  51921. */
  51922. readonly output: NodeMaterialConnectionPoint;
  51923. autoConfigure(): void;
  51924. initialize(state: NodeMaterialBuildState): void;
  51925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51926. isReady(): boolean;
  51927. private _injectVertexCode;
  51928. protected _buildBlock(state: NodeMaterialBuildState): this;
  51929. }
  51930. }
  51931. declare module BABYLON {
  51932. /**
  51933. * Block used to add image processing support to fragment shader
  51934. */
  51935. export class ImageProcessingBlock extends NodeMaterialBlock {
  51936. /**
  51937. * Create a new ImageProcessingBlock
  51938. * @param name defines the block name
  51939. */
  51940. constructor(name: string);
  51941. /**
  51942. * Gets the current class name
  51943. * @returns the class name
  51944. */
  51945. getClassName(): string;
  51946. /**
  51947. * Gets the color input component
  51948. */
  51949. readonly color: NodeMaterialConnectionPoint;
  51950. /**
  51951. * Gets the output component
  51952. */
  51953. readonly output: NodeMaterialConnectionPoint;
  51954. /**
  51955. * Initialize the block and prepare the context for build
  51956. * @param state defines the state that will be used for the build
  51957. */
  51958. initialize(state: NodeMaterialBuildState): void;
  51959. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51962. protected _buildBlock(state: NodeMaterialBuildState): this;
  51963. }
  51964. }
  51965. declare module BABYLON {
  51966. /**
  51967. * Block used to add support for scene fog
  51968. */
  51969. export class FogBlock extends NodeMaterialBlock {
  51970. /**
  51971. * Create a new FogBlock
  51972. * @param name defines the block name
  51973. */
  51974. constructor(name: string);
  51975. /**
  51976. * Gets the current class name
  51977. * @returns the class name
  51978. */
  51979. getClassName(): string;
  51980. /**
  51981. * Gets the world position input component
  51982. */
  51983. readonly worldPosition: NodeMaterialConnectionPoint;
  51984. /**
  51985. * Gets the view input component
  51986. */
  51987. readonly view: NodeMaterialConnectionPoint;
  51988. /**
  51989. * Gets the color input component
  51990. */
  51991. readonly color: NodeMaterialConnectionPoint;
  51992. /**
  51993. * Gets the fog color input component
  51994. */
  51995. readonly fogColor: NodeMaterialConnectionPoint;
  51996. /**
  51997. * Gets the for parameter input component
  51998. */
  51999. readonly fogParameters: NodeMaterialConnectionPoint;
  52000. /**
  52001. * Gets the output component
  52002. */
  52003. readonly output: NodeMaterialConnectionPoint;
  52004. autoConfigure(): void;
  52005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52007. protected _buildBlock(state: NodeMaterialBuildState): this;
  52008. }
  52009. }
  52010. declare module BABYLON {
  52011. /**
  52012. * Block used to add light in the fragment shader
  52013. */
  52014. export class LightBlock extends NodeMaterialBlock {
  52015. private _lightId;
  52016. /**
  52017. * Create a new LightBlock
  52018. * @param name defines the block name
  52019. */
  52020. constructor(name: string);
  52021. /**
  52022. * Gets the current class name
  52023. * @returns the class name
  52024. */
  52025. getClassName(): string;
  52026. /**
  52027. * Gets the world position input component
  52028. */
  52029. readonly worldPosition: NodeMaterialConnectionPoint;
  52030. /**
  52031. * Gets the world normal input component
  52032. */
  52033. readonly worldNormal: NodeMaterialConnectionPoint;
  52034. /**
  52035. * Gets the light input component
  52036. */
  52037. readonly light: NodeMaterialConnectionPoint;
  52038. /**
  52039. * Gets the camera (or eye) position component
  52040. */
  52041. readonly cameraPosition: NodeMaterialConnectionPoint;
  52042. /**
  52043. * Gets the diffuse output component
  52044. */
  52045. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52046. /**
  52047. * Gets the specular output component
  52048. */
  52049. readonly specularOutput: NodeMaterialConnectionPoint;
  52050. autoConfigure(): void;
  52051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52053. private _injectVertexCode;
  52054. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52055. }
  52056. }
  52057. declare module BABYLON {
  52058. /**
  52059. * Block used to multiply 2 vector4
  52060. */
  52061. export class MultiplyBlock extends NodeMaterialBlock {
  52062. /**
  52063. * Creates a new MultiplyBlock
  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 left operand input component
  52074. */
  52075. readonly left: NodeMaterialConnectionPoint;
  52076. /**
  52077. * Gets the right operand input component
  52078. */
  52079. readonly right: NodeMaterialConnectionPoint;
  52080. /**
  52081. * Gets the output component
  52082. */
  52083. readonly output: NodeMaterialConnectionPoint;
  52084. protected _buildBlock(state: NodeMaterialBuildState): this;
  52085. }
  52086. }
  52087. declare module BABYLON {
  52088. /**
  52089. * Block used to add 2 vector4
  52090. */
  52091. export class AddBlock extends NodeMaterialBlock {
  52092. /**
  52093. * Creates a new AddBlock
  52094. * @param name defines the block name
  52095. */
  52096. constructor(name: string);
  52097. /**
  52098. * Gets the current class name
  52099. * @returns the class name
  52100. */
  52101. getClassName(): string;
  52102. /**
  52103. * Gets the left operand input component
  52104. */
  52105. readonly left: NodeMaterialConnectionPoint;
  52106. /**
  52107. * Gets the right operand input component
  52108. */
  52109. readonly right: NodeMaterialConnectionPoint;
  52110. /**
  52111. * Gets the output component
  52112. */
  52113. readonly output: NodeMaterialConnectionPoint;
  52114. protected _buildBlock(state: NodeMaterialBuildState): this;
  52115. }
  52116. }
  52117. declare module BABYLON {
  52118. /**
  52119. * Block used to clamp a float
  52120. */
  52121. export class ClampBlock extends NodeMaterialBlock {
  52122. /** Gets or sets the minimum range */
  52123. minimum: number;
  52124. /** Gets or sets the maximum range */
  52125. maximum: number;
  52126. /**
  52127. * Creates a new ClampBlock
  52128. * @param name defines the block name
  52129. */
  52130. constructor(name: string);
  52131. /**
  52132. * Gets the current class name
  52133. * @returns the class name
  52134. */
  52135. getClassName(): string;
  52136. /**
  52137. * Gets the value input component
  52138. */
  52139. readonly value: NodeMaterialConnectionPoint;
  52140. /**
  52141. * Gets the output component
  52142. */
  52143. readonly output: NodeMaterialConnectionPoint;
  52144. protected _buildBlock(state: NodeMaterialBuildState): this;
  52145. }
  52146. }
  52147. declare module BABYLON {
  52148. /**
  52149. * Block used to scale a value
  52150. */
  52151. export class ScaleBlock extends NodeMaterialBlock {
  52152. /**
  52153. * Creates a new ScaleBlock
  52154. * @param name defines the block name
  52155. */
  52156. constructor(name: string);
  52157. /**
  52158. * Gets the current class name
  52159. * @returns the class name
  52160. */
  52161. getClassName(): string;
  52162. /**
  52163. * Gets the value operand input component
  52164. */
  52165. readonly value: NodeMaterialConnectionPoint;
  52166. /**
  52167. * Gets the scale operand input component
  52168. */
  52169. readonly scale: NodeMaterialConnectionPoint;
  52170. /**
  52171. * Gets the output component
  52172. */
  52173. readonly output: NodeMaterialConnectionPoint;
  52174. protected _buildBlock(state: NodeMaterialBuildState): this;
  52175. }
  52176. }
  52177. declare module BABYLON {
  52178. /**
  52179. * Block used to transform a vector2 with a matrix
  52180. */
  52181. export class Vector2TransformBlock extends NodeMaterialBlock {
  52182. /**
  52183. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52184. */
  52185. complementZ: number;
  52186. /**
  52187. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52188. */
  52189. complementW: number;
  52190. /**
  52191. * Creates a new Vector2TransformBlock
  52192. * @param name defines the block name
  52193. */
  52194. constructor(name: string);
  52195. /**
  52196. * Gets the vector input
  52197. */
  52198. readonly vector: NodeMaterialConnectionPoint;
  52199. /**
  52200. * Gets the matrix transform input
  52201. */
  52202. readonly transform: NodeMaterialConnectionPoint;
  52203. /**
  52204. * Gets the output component
  52205. */
  52206. readonly output: NodeMaterialConnectionPoint;
  52207. /**
  52208. * Gets the current class name
  52209. * @returns the class name
  52210. */
  52211. getClassName(): string;
  52212. protected _buildBlock(state: NodeMaterialBuildState): this;
  52213. }
  52214. }
  52215. declare module BABYLON {
  52216. /**
  52217. * Block used to transform a vector3 with a matrix
  52218. */
  52219. export class Vector3TransformBlock extends NodeMaterialBlock {
  52220. /**
  52221. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52222. */
  52223. complement: number;
  52224. /**
  52225. * Creates a new Vector3TransformBlock
  52226. * @param name defines the block name
  52227. */
  52228. constructor(name: string);
  52229. /**
  52230. * Gets the vector input
  52231. */
  52232. readonly vector: NodeMaterialConnectionPoint;
  52233. /**
  52234. * Gets the matrix transform input
  52235. */
  52236. readonly transform: NodeMaterialConnectionPoint;
  52237. /**
  52238. * Gets the output component
  52239. */
  52240. readonly output: NodeMaterialConnectionPoint;
  52241. /**
  52242. * Gets the current class name
  52243. * @returns the class name
  52244. */
  52245. getClassName(): string;
  52246. protected _buildBlock(state: NodeMaterialBuildState): this;
  52247. }
  52248. }
  52249. declare module BABYLON {
  52250. /**
  52251. * Block used to multiply two matrices
  52252. */
  52253. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  52254. /**
  52255. * Creates a new MatrixMultiplicationBlock
  52256. * @param name defines the block name
  52257. */
  52258. constructor(name: string);
  52259. /**
  52260. * Gets the left operand
  52261. */
  52262. readonly left: NodeMaterialConnectionPoint;
  52263. /**
  52264. * Gets the right operand
  52265. */
  52266. readonly right: NodeMaterialConnectionPoint;
  52267. /**
  52268. * Gets the output component
  52269. */
  52270. readonly output: NodeMaterialConnectionPoint;
  52271. /**
  52272. * Gets the current class name
  52273. * @returns the class name
  52274. */
  52275. getClassName(): string;
  52276. protected _buildBlock(state: NodeMaterialBuildState): this;
  52277. }
  52278. }
  52279. declare module BABYLON {
  52280. /**
  52281. * Helper class to push actions to a pool of workers.
  52282. */
  52283. export class WorkerPool implements IDisposable {
  52284. private _workerInfos;
  52285. private _pendingActions;
  52286. /**
  52287. * Constructor
  52288. * @param workers Array of workers to use for actions
  52289. */
  52290. constructor(workers: Array<Worker>);
  52291. /**
  52292. * Terminates all workers and clears any pending actions.
  52293. */
  52294. dispose(): void;
  52295. /**
  52296. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52297. * pended until a worker has completed its action.
  52298. * @param action The action to perform. Call onComplete when the action is complete.
  52299. */
  52300. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52301. private _execute;
  52302. }
  52303. }
  52304. declare module BABYLON {
  52305. /**
  52306. * Configuration for Draco compression
  52307. */
  52308. export interface IDracoCompressionConfiguration {
  52309. /**
  52310. * Configuration for the decoder.
  52311. */
  52312. decoder: {
  52313. /**
  52314. * The url to the WebAssembly module.
  52315. */
  52316. wasmUrl?: string;
  52317. /**
  52318. * The url to the WebAssembly binary.
  52319. */
  52320. wasmBinaryUrl?: string;
  52321. /**
  52322. * The url to the fallback JavaScript module.
  52323. */
  52324. fallbackUrl?: string;
  52325. };
  52326. }
  52327. /**
  52328. * Draco compression (https://google.github.io/draco/)
  52329. *
  52330. * This class wraps the Draco module.
  52331. *
  52332. * **Encoder**
  52333. *
  52334. * The encoder is not currently implemented.
  52335. *
  52336. * **Decoder**
  52337. *
  52338. * 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.
  52339. *
  52340. * To update the configuration, use the following code:
  52341. * ```javascript
  52342. * DracoCompression.Configuration = {
  52343. * decoder: {
  52344. * wasmUrl: "<url to the WebAssembly library>",
  52345. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52346. * fallbackUrl: "<url to the fallback JavaScript library>",
  52347. * }
  52348. * };
  52349. * ```
  52350. *
  52351. * 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.
  52352. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52353. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52354. *
  52355. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52356. * ```javascript
  52357. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52358. * ```
  52359. *
  52360. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52361. */
  52362. export class DracoCompression implements IDisposable {
  52363. private _workerPoolPromise?;
  52364. private _decoderModulePromise?;
  52365. /**
  52366. * The configuration. Defaults to the following urls:
  52367. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52368. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52369. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52370. */
  52371. static Configuration: IDracoCompressionConfiguration;
  52372. /**
  52373. * Returns true if the decoder configuration is available.
  52374. */
  52375. static readonly DecoderAvailable: boolean;
  52376. /**
  52377. * Default number of workers to create when creating the draco compression object.
  52378. */
  52379. static DefaultNumWorkers: number;
  52380. private static GetDefaultNumWorkers;
  52381. private static _Default;
  52382. /**
  52383. * Default instance for the draco compression object.
  52384. */
  52385. static readonly Default: DracoCompression;
  52386. /**
  52387. * Constructor
  52388. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52389. */
  52390. constructor(numWorkers?: number);
  52391. /**
  52392. * Stop all async operations and release resources.
  52393. */
  52394. dispose(): void;
  52395. /**
  52396. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52397. * @returns a promise that resolves when ready
  52398. */
  52399. whenReadyAsync(): Promise<void>;
  52400. /**
  52401. * Decode Draco compressed mesh data to vertex data.
  52402. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52403. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52404. * @returns A promise that resolves with the decoded vertex data
  52405. */
  52406. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52407. [kind: string]: number;
  52408. }): Promise<VertexData>;
  52409. }
  52410. }
  52411. declare module BABYLON {
  52412. /**
  52413. * Class for building Constructive Solid Geometry
  52414. */
  52415. export class CSG {
  52416. private polygons;
  52417. /**
  52418. * The world matrix
  52419. */
  52420. matrix: Matrix;
  52421. /**
  52422. * Stores the position
  52423. */
  52424. position: Vector3;
  52425. /**
  52426. * Stores the rotation
  52427. */
  52428. rotation: Vector3;
  52429. /**
  52430. * Stores the rotation quaternion
  52431. */
  52432. rotationQuaternion: Nullable<Quaternion>;
  52433. /**
  52434. * Stores the scaling vector
  52435. */
  52436. scaling: Vector3;
  52437. /**
  52438. * Convert the Mesh to CSG
  52439. * @param mesh The Mesh to convert to CSG
  52440. * @returns A new CSG from the Mesh
  52441. */
  52442. static FromMesh(mesh: Mesh): CSG;
  52443. /**
  52444. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52445. * @param polygons Polygons used to construct a CSG solid
  52446. */
  52447. private static FromPolygons;
  52448. /**
  52449. * Clones, or makes a deep copy, of the CSG
  52450. * @returns A new CSG
  52451. */
  52452. clone(): CSG;
  52453. /**
  52454. * Unions this CSG with another CSG
  52455. * @param csg The CSG to union against this CSG
  52456. * @returns The unioned CSG
  52457. */
  52458. union(csg: CSG): CSG;
  52459. /**
  52460. * Unions this CSG with another CSG in place
  52461. * @param csg The CSG to union against this CSG
  52462. */
  52463. unionInPlace(csg: CSG): void;
  52464. /**
  52465. * Subtracts this CSG with another CSG
  52466. * @param csg The CSG to subtract against this CSG
  52467. * @returns A new CSG
  52468. */
  52469. subtract(csg: CSG): CSG;
  52470. /**
  52471. * Subtracts this CSG with another CSG in place
  52472. * @param csg The CSG to subtact against this CSG
  52473. */
  52474. subtractInPlace(csg: CSG): void;
  52475. /**
  52476. * Intersect this CSG with another CSG
  52477. * @param csg The CSG to intersect against this CSG
  52478. * @returns A new CSG
  52479. */
  52480. intersect(csg: CSG): CSG;
  52481. /**
  52482. * Intersects this CSG with another CSG in place
  52483. * @param csg The CSG to intersect against this CSG
  52484. */
  52485. intersectInPlace(csg: CSG): void;
  52486. /**
  52487. * Return a new CSG solid with solid and empty space switched. This solid is
  52488. * not modified.
  52489. * @returns A new CSG solid with solid and empty space switched
  52490. */
  52491. inverse(): CSG;
  52492. /**
  52493. * Inverses the CSG in place
  52494. */
  52495. inverseInPlace(): void;
  52496. /**
  52497. * This is used to keep meshes transformations so they can be restored
  52498. * when we build back a Babylon Mesh
  52499. * NB : All CSG operations are performed in world coordinates
  52500. * @param csg The CSG to copy the transform attributes from
  52501. * @returns This CSG
  52502. */
  52503. copyTransformAttributes(csg: CSG): CSG;
  52504. /**
  52505. * Build Raw mesh from CSG
  52506. * Coordinates here are in world space
  52507. * @param name The name of the mesh geometry
  52508. * @param scene The Scene
  52509. * @param keepSubMeshes Specifies if the submeshes should be kept
  52510. * @returns A new Mesh
  52511. */
  52512. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52513. /**
  52514. * Build Mesh from CSG taking material and transforms into account
  52515. * @param name The name of the Mesh
  52516. * @param material The material of the Mesh
  52517. * @param scene The Scene
  52518. * @param keepSubMeshes Specifies if submeshes should be kept
  52519. * @returns The new Mesh
  52520. */
  52521. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52522. }
  52523. }
  52524. declare module BABYLON {
  52525. /**
  52526. * Class used to create a trail following a mesh
  52527. */
  52528. export class TrailMesh extends Mesh {
  52529. private _generator;
  52530. private _autoStart;
  52531. private _running;
  52532. private _diameter;
  52533. private _length;
  52534. private _sectionPolygonPointsCount;
  52535. private _sectionVectors;
  52536. private _sectionNormalVectors;
  52537. private _beforeRenderObserver;
  52538. /**
  52539. * @constructor
  52540. * @param name The value used by scene.getMeshByName() to do a lookup.
  52541. * @param generator The mesh to generate a trail.
  52542. * @param scene The scene to add this mesh to.
  52543. * @param diameter Diameter of trailing mesh. Default is 1.
  52544. * @param length Length of trailing mesh. Default is 60.
  52545. * @param autoStart Automatically start trailing mesh. Default true.
  52546. */
  52547. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52548. /**
  52549. * "TrailMesh"
  52550. * @returns "TrailMesh"
  52551. */
  52552. getClassName(): string;
  52553. private _createMesh;
  52554. /**
  52555. * Start trailing mesh.
  52556. */
  52557. start(): void;
  52558. /**
  52559. * Stop trailing mesh.
  52560. */
  52561. stop(): void;
  52562. /**
  52563. * Update trailing mesh geometry.
  52564. */
  52565. update(): void;
  52566. /**
  52567. * Returns a new TrailMesh object.
  52568. * @param name is a string, the name given to the new mesh
  52569. * @param newGenerator use new generator object for cloned trail mesh
  52570. * @returns a new mesh
  52571. */
  52572. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52573. /**
  52574. * Serializes this trail mesh
  52575. * @param serializationObject object to write serialization to
  52576. */
  52577. serialize(serializationObject: any): void;
  52578. /**
  52579. * Parses a serialized trail mesh
  52580. * @param parsedMesh the serialized mesh
  52581. * @param scene the scene to create the trail mesh in
  52582. * @returns the created trail mesh
  52583. */
  52584. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52585. }
  52586. }
  52587. declare module BABYLON {
  52588. /**
  52589. * Class containing static functions to help procedurally build meshes
  52590. */
  52591. export class TiledBoxBuilder {
  52592. /**
  52593. * Creates a box mesh
  52594. * 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)
  52595. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52597. * * 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
  52598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52599. * @param name defines the name of the mesh
  52600. * @param options defines the options used to create the mesh
  52601. * @param scene defines the hosting scene
  52602. * @returns the box mesh
  52603. */
  52604. static CreateTiledBox(name: string, options: {
  52605. pattern?: number;
  52606. width?: number;
  52607. height?: number;
  52608. depth?: number;
  52609. tileSize?: number;
  52610. tileWidth?: number;
  52611. tileHeight?: number;
  52612. alignHorizontal?: number;
  52613. alignVertical?: number;
  52614. faceUV?: Vector4[];
  52615. faceColors?: Color4[];
  52616. sideOrientation?: number;
  52617. updatable?: boolean;
  52618. }, scene?: Nullable<Scene>): Mesh;
  52619. }
  52620. }
  52621. declare module BABYLON {
  52622. /**
  52623. * Class containing static functions to help procedurally build meshes
  52624. */
  52625. export class TorusKnotBuilder {
  52626. /**
  52627. * Creates a torus knot mesh
  52628. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52629. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52630. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52631. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52633. * * 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
  52634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52635. * @param name defines the name of the mesh
  52636. * @param options defines the options used to create the mesh
  52637. * @param scene defines the hosting scene
  52638. * @returns the torus knot mesh
  52639. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52640. */
  52641. static CreateTorusKnot(name: string, options: {
  52642. radius?: number;
  52643. tube?: number;
  52644. radialSegments?: number;
  52645. tubularSegments?: number;
  52646. p?: number;
  52647. q?: number;
  52648. updatable?: boolean;
  52649. sideOrientation?: number;
  52650. frontUVs?: Vector4;
  52651. backUVs?: Vector4;
  52652. }, scene: any): Mesh;
  52653. }
  52654. }
  52655. declare module BABYLON {
  52656. /**
  52657. * Polygon
  52658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52659. */
  52660. export class Polygon {
  52661. /**
  52662. * Creates a rectangle
  52663. * @param xmin bottom X coord
  52664. * @param ymin bottom Y coord
  52665. * @param xmax top X coord
  52666. * @param ymax top Y coord
  52667. * @returns points that make the resulting rectation
  52668. */
  52669. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52670. /**
  52671. * Creates a circle
  52672. * @param radius radius of circle
  52673. * @param cx scale in x
  52674. * @param cy scale in y
  52675. * @param numberOfSides number of sides that make up the circle
  52676. * @returns points that make the resulting circle
  52677. */
  52678. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52679. /**
  52680. * Creates a polygon from input string
  52681. * @param input Input polygon data
  52682. * @returns the parsed points
  52683. */
  52684. static Parse(input: string): Vector2[];
  52685. /**
  52686. * Starts building a polygon from x and y coordinates
  52687. * @param x x coordinate
  52688. * @param y y coordinate
  52689. * @returns the started path2
  52690. */
  52691. static StartingAt(x: number, y: number): Path2;
  52692. }
  52693. /**
  52694. * Builds a polygon
  52695. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52696. */
  52697. export class PolygonMeshBuilder {
  52698. private _points;
  52699. private _outlinepoints;
  52700. private _holes;
  52701. private _name;
  52702. private _scene;
  52703. private _epoints;
  52704. private _eholes;
  52705. private _addToepoint;
  52706. /**
  52707. * Babylon reference to the earcut plugin.
  52708. */
  52709. bjsEarcut: any;
  52710. /**
  52711. * Creates a PolygonMeshBuilder
  52712. * @param name name of the builder
  52713. * @param contours Path of the polygon
  52714. * @param scene scene to add to when creating the mesh
  52715. * @param earcutInjection can be used to inject your own earcut reference
  52716. */
  52717. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52718. /**
  52719. * Adds a whole within the polygon
  52720. * @param hole Array of points defining the hole
  52721. * @returns this
  52722. */
  52723. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52724. /**
  52725. * Creates the polygon
  52726. * @param updatable If the mesh should be updatable
  52727. * @param depth The depth of the mesh created
  52728. * @returns the created mesh
  52729. */
  52730. build(updatable?: boolean, depth?: number): Mesh;
  52731. /**
  52732. * Creates the polygon
  52733. * @param depth The depth of the mesh created
  52734. * @returns the created VertexData
  52735. */
  52736. buildVertexData(depth?: number): VertexData;
  52737. /**
  52738. * Adds a side to the polygon
  52739. * @param positions points that make the polygon
  52740. * @param normals normals of the polygon
  52741. * @param uvs uvs of the polygon
  52742. * @param indices indices of the polygon
  52743. * @param bounds bounds of the polygon
  52744. * @param points points of the polygon
  52745. * @param depth depth of the polygon
  52746. * @param flip flip of the polygon
  52747. */
  52748. private addSide;
  52749. }
  52750. }
  52751. declare module BABYLON {
  52752. /**
  52753. * Class containing static functions to help procedurally build meshes
  52754. */
  52755. export class PolygonBuilder {
  52756. /**
  52757. * Creates a polygon mesh
  52758. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52759. * * 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
  52760. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52762. * * 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)
  52763. * * Remember you can only change the shape positions, not their number when updating a polygon
  52764. * @param name defines the name of the mesh
  52765. * @param options defines the options used to create the mesh
  52766. * @param scene defines the hosting scene
  52767. * @param earcutInjection can be used to inject your own earcut reference
  52768. * @returns the polygon mesh
  52769. */
  52770. static CreatePolygon(name: string, options: {
  52771. shape: Vector3[];
  52772. holes?: Vector3[][];
  52773. depth?: number;
  52774. faceUV?: Vector4[];
  52775. faceColors?: Color4[];
  52776. updatable?: boolean;
  52777. sideOrientation?: number;
  52778. frontUVs?: Vector4;
  52779. backUVs?: Vector4;
  52780. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52781. /**
  52782. * Creates an extruded polygon mesh, with depth in the Y direction.
  52783. * * 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)
  52784. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52785. * @param name defines the name of the mesh
  52786. * @param options defines the options used to create the mesh
  52787. * @param scene defines the hosting scene
  52788. * @param earcutInjection can be used to inject your own earcut reference
  52789. * @returns the polygon mesh
  52790. */
  52791. static ExtrudePolygon(name: string, options: {
  52792. shape: Vector3[];
  52793. holes?: Vector3[][];
  52794. depth?: number;
  52795. faceUV?: Vector4[];
  52796. faceColors?: Color4[];
  52797. updatable?: boolean;
  52798. sideOrientation?: number;
  52799. frontUVs?: Vector4;
  52800. backUVs?: Vector4;
  52801. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52802. }
  52803. }
  52804. declare module BABYLON {
  52805. /**
  52806. * Class containing static functions to help procedurally build meshes
  52807. */
  52808. export class LatheBuilder {
  52809. /**
  52810. * Creates lathe mesh.
  52811. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52812. * * 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
  52813. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52814. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52815. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52816. * * 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
  52817. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52818. * * 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
  52819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52820. * * 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
  52821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52823. * @param name defines the name of the mesh
  52824. * @param options defines the options used to create the mesh
  52825. * @param scene defines the hosting scene
  52826. * @returns the lathe mesh
  52827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52828. */
  52829. static CreateLathe(name: string, options: {
  52830. shape: Vector3[];
  52831. radius?: number;
  52832. tessellation?: number;
  52833. clip?: number;
  52834. arc?: number;
  52835. closed?: boolean;
  52836. updatable?: boolean;
  52837. sideOrientation?: number;
  52838. frontUVs?: Vector4;
  52839. backUVs?: Vector4;
  52840. cap?: number;
  52841. invertUV?: boolean;
  52842. }, scene?: Nullable<Scene>): Mesh;
  52843. }
  52844. }
  52845. declare module BABYLON {
  52846. /**
  52847. * Class containing static functions to help procedurally build meshes
  52848. */
  52849. export class TiledPlaneBuilder {
  52850. /**
  52851. * Creates a tiled plane mesh
  52852. * * The parameter `pattern` will, depending on value, do nothing or
  52853. * * * flip (reflect about central vertical) alternate tiles across and up
  52854. * * * flip every tile on alternate rows
  52855. * * * rotate (180 degs) alternate tiles across and up
  52856. * * * rotate every tile on alternate rows
  52857. * * * flip and rotate alternate tiles across and up
  52858. * * * flip and rotate every tile on alternate rows
  52859. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52860. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52861. * * 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
  52862. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52863. * * 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)
  52864. * * 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)
  52865. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52866. * @param name defines the name of the mesh
  52867. * @param options defines the options used to create the mesh
  52868. * @param scene defines the hosting scene
  52869. * @returns the box mesh
  52870. */
  52871. static CreateTiledPlane(name: string, options: {
  52872. pattern?: number;
  52873. tileSize?: number;
  52874. tileWidth?: number;
  52875. tileHeight?: number;
  52876. size?: number;
  52877. width?: number;
  52878. height?: number;
  52879. alignHorizontal?: number;
  52880. alignVertical?: number;
  52881. sideOrientation?: number;
  52882. frontUVs?: Vector4;
  52883. backUVs?: Vector4;
  52884. updatable?: boolean;
  52885. }, scene?: Nullable<Scene>): Mesh;
  52886. }
  52887. }
  52888. declare module BABYLON {
  52889. /**
  52890. * Class containing static functions to help procedurally build meshes
  52891. */
  52892. export class TubeBuilder {
  52893. /**
  52894. * Creates a tube mesh.
  52895. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52896. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52897. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52898. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52899. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52900. * * 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)
  52901. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52902. * * 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
  52903. * * 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
  52904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52905. * * 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
  52906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52908. * @param name defines the name of the mesh
  52909. * @param options defines the options used to create the mesh
  52910. * @param scene defines the hosting scene
  52911. * @returns the tube mesh
  52912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52913. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52914. */
  52915. static CreateTube(name: string, options: {
  52916. path: Vector3[];
  52917. radius?: number;
  52918. tessellation?: number;
  52919. radiusFunction?: {
  52920. (i: number, distance: number): number;
  52921. };
  52922. cap?: number;
  52923. arc?: number;
  52924. updatable?: boolean;
  52925. sideOrientation?: number;
  52926. frontUVs?: Vector4;
  52927. backUVs?: Vector4;
  52928. instance?: Mesh;
  52929. invertUV?: boolean;
  52930. }, scene?: Nullable<Scene>): Mesh;
  52931. }
  52932. }
  52933. declare module BABYLON {
  52934. /**
  52935. * Class containing static functions to help procedurally build meshes
  52936. */
  52937. export class IcoSphereBuilder {
  52938. /**
  52939. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52940. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52941. * * 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`)
  52942. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52943. * * 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
  52944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52945. * * 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
  52946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52947. * @param name defines the name of the mesh
  52948. * @param options defines the options used to create the mesh
  52949. * @param scene defines the hosting scene
  52950. * @returns the icosahedron mesh
  52951. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52952. */
  52953. static CreateIcoSphere(name: string, options: {
  52954. radius?: number;
  52955. radiusX?: number;
  52956. radiusY?: number;
  52957. radiusZ?: number;
  52958. flat?: boolean;
  52959. subdivisions?: number;
  52960. sideOrientation?: number;
  52961. frontUVs?: Vector4;
  52962. backUVs?: Vector4;
  52963. updatable?: boolean;
  52964. }, scene?: Nullable<Scene>): Mesh;
  52965. }
  52966. }
  52967. declare module BABYLON {
  52968. /**
  52969. * Class containing static functions to help procedurally build meshes
  52970. */
  52971. export class DecalBuilder {
  52972. /**
  52973. * Creates a decal mesh.
  52974. * 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
  52975. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52976. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52977. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52978. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52979. * @param name defines the name of the mesh
  52980. * @param sourceMesh defines the mesh where the decal must be applied
  52981. * @param options defines the options used to create the mesh
  52982. * @param scene defines the hosting scene
  52983. * @returns the decal mesh
  52984. * @see https://doc.babylonjs.com/how_to/decals
  52985. */
  52986. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52987. position?: Vector3;
  52988. normal?: Vector3;
  52989. size?: Vector3;
  52990. angle?: number;
  52991. }): Mesh;
  52992. }
  52993. }
  52994. declare module BABYLON {
  52995. /**
  52996. * Class containing static functions to help procedurally build meshes
  52997. */
  52998. export class MeshBuilder {
  52999. /**
  53000. * Creates a box mesh
  53001. * * The parameter `size` sets the size (float) of each box side (default 1)
  53002. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53003. * * 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)
  53004. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53006. * * 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
  53007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53008. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53009. * @param name defines the name of the mesh
  53010. * @param options defines the options used to create the mesh
  53011. * @param scene defines the hosting scene
  53012. * @returns the box mesh
  53013. */
  53014. static CreateBox(name: string, options: {
  53015. size?: number;
  53016. width?: number;
  53017. height?: number;
  53018. depth?: number;
  53019. faceUV?: Vector4[];
  53020. faceColors?: Color4[];
  53021. sideOrientation?: number;
  53022. frontUVs?: Vector4;
  53023. backUVs?: Vector4;
  53024. updatable?: boolean;
  53025. }, scene?: Nullable<Scene>): Mesh;
  53026. /**
  53027. * Creates a tiled box mesh
  53028. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53030. * @param name defines the name of the mesh
  53031. * @param options defines the options used to create the mesh
  53032. * @param scene defines the hosting scene
  53033. * @returns the tiled box mesh
  53034. */
  53035. static CreateTiledBox(name: string, options: {
  53036. pattern?: number;
  53037. size?: number;
  53038. width?: number;
  53039. height?: number;
  53040. depth: number;
  53041. tileSize?: number;
  53042. tileWidth?: number;
  53043. tileHeight?: number;
  53044. faceUV?: Vector4[];
  53045. faceColors?: Color4[];
  53046. alignHorizontal?: number;
  53047. alignVertical?: number;
  53048. sideOrientation?: number;
  53049. updatable?: boolean;
  53050. }, scene?: Nullable<Scene>): Mesh;
  53051. /**
  53052. * Creates a sphere mesh
  53053. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53054. * * 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`)
  53055. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53056. * * 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
  53057. * * 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)
  53058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53059. * * 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
  53060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53061. * @param name defines the name of the mesh
  53062. * @param options defines the options used to create the mesh
  53063. * @param scene defines the hosting scene
  53064. * @returns the sphere mesh
  53065. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53066. */
  53067. static CreateSphere(name: string, options: {
  53068. segments?: number;
  53069. diameter?: number;
  53070. diameterX?: number;
  53071. diameterY?: number;
  53072. diameterZ?: number;
  53073. arc?: number;
  53074. slice?: number;
  53075. sideOrientation?: number;
  53076. frontUVs?: Vector4;
  53077. backUVs?: Vector4;
  53078. updatable?: boolean;
  53079. }, scene?: Nullable<Scene>): Mesh;
  53080. /**
  53081. * Creates a plane polygonal mesh. By default, this is a disc
  53082. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53083. * * 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
  53084. * * 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
  53085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53086. * * 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
  53087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53088. * @param name defines the name of the mesh
  53089. * @param options defines the options used to create the mesh
  53090. * @param scene defines the hosting scene
  53091. * @returns the plane polygonal mesh
  53092. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53093. */
  53094. static CreateDisc(name: string, options: {
  53095. radius?: number;
  53096. tessellation?: number;
  53097. arc?: number;
  53098. updatable?: boolean;
  53099. sideOrientation?: number;
  53100. frontUVs?: Vector4;
  53101. backUVs?: Vector4;
  53102. }, scene?: Nullable<Scene>): Mesh;
  53103. /**
  53104. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53105. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53106. * * 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`)
  53107. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53108. * * 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
  53109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53110. * * 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
  53111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53112. * @param name defines the name of the mesh
  53113. * @param options defines the options used to create the mesh
  53114. * @param scene defines the hosting scene
  53115. * @returns the icosahedron mesh
  53116. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53117. */
  53118. static CreateIcoSphere(name: string, options: {
  53119. radius?: number;
  53120. radiusX?: number;
  53121. radiusY?: number;
  53122. radiusZ?: number;
  53123. flat?: boolean;
  53124. subdivisions?: number;
  53125. sideOrientation?: number;
  53126. frontUVs?: Vector4;
  53127. backUVs?: Vector4;
  53128. updatable?: boolean;
  53129. }, scene?: Nullable<Scene>): Mesh;
  53130. /**
  53131. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53132. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53133. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53134. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53135. * * 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
  53136. * * 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
  53137. * * 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
  53138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53139. * * 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
  53140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53141. * * 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
  53142. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53143. * * 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
  53144. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53146. * @param name defines the name of the mesh
  53147. * @param options defines the options used to create the mesh
  53148. * @param scene defines the hosting scene
  53149. * @returns the ribbon mesh
  53150. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53151. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53152. */
  53153. static CreateRibbon(name: string, options: {
  53154. pathArray: Vector3[][];
  53155. closeArray?: boolean;
  53156. closePath?: boolean;
  53157. offset?: number;
  53158. updatable?: boolean;
  53159. sideOrientation?: number;
  53160. frontUVs?: Vector4;
  53161. backUVs?: Vector4;
  53162. instance?: Mesh;
  53163. invertUV?: boolean;
  53164. uvs?: Vector2[];
  53165. colors?: Color4[];
  53166. }, scene?: Nullable<Scene>): Mesh;
  53167. /**
  53168. * Creates a cylinder or a cone mesh
  53169. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53170. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53171. * * 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.
  53172. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53173. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53174. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53175. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53176. * * 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).
  53177. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53178. * * 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).
  53179. * * 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
  53180. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53181. * * 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
  53182. * * 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.
  53183. * * If `enclose` is false, a ring surface is one element.
  53184. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53185. * * 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
  53186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53187. * * 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
  53188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53189. * @param name defines the name of the mesh
  53190. * @param options defines the options used to create the mesh
  53191. * @param scene defines the hosting scene
  53192. * @returns the cylinder mesh
  53193. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53194. */
  53195. static CreateCylinder(name: string, options: {
  53196. height?: number;
  53197. diameterTop?: number;
  53198. diameterBottom?: number;
  53199. diameter?: number;
  53200. tessellation?: number;
  53201. subdivisions?: number;
  53202. arc?: number;
  53203. faceColors?: Color4[];
  53204. faceUV?: Vector4[];
  53205. updatable?: boolean;
  53206. hasRings?: boolean;
  53207. enclose?: boolean;
  53208. cap?: number;
  53209. sideOrientation?: number;
  53210. frontUVs?: Vector4;
  53211. backUVs?: Vector4;
  53212. }, scene?: Nullable<Scene>): Mesh;
  53213. /**
  53214. * Creates a torus mesh
  53215. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53216. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53217. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53219. * * 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
  53220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53221. * @param name defines the name of the mesh
  53222. * @param options defines the options used to create the mesh
  53223. * @param scene defines the hosting scene
  53224. * @returns the torus mesh
  53225. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53226. */
  53227. static CreateTorus(name: string, options: {
  53228. diameter?: number;
  53229. thickness?: number;
  53230. tessellation?: number;
  53231. updatable?: boolean;
  53232. sideOrientation?: number;
  53233. frontUVs?: Vector4;
  53234. backUVs?: Vector4;
  53235. }, scene?: Nullable<Scene>): Mesh;
  53236. /**
  53237. * Creates a torus knot mesh
  53238. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53239. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53240. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53241. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53243. * * 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
  53244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53245. * @param name defines the name of the mesh
  53246. * @param options defines the options used to create the mesh
  53247. * @param scene defines the hosting scene
  53248. * @returns the torus knot mesh
  53249. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53250. */
  53251. static CreateTorusKnot(name: string, options: {
  53252. radius?: number;
  53253. tube?: number;
  53254. radialSegments?: number;
  53255. tubularSegments?: number;
  53256. p?: number;
  53257. q?: number;
  53258. updatable?: boolean;
  53259. sideOrientation?: number;
  53260. frontUVs?: Vector4;
  53261. backUVs?: Vector4;
  53262. }, scene?: Nullable<Scene>): Mesh;
  53263. /**
  53264. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53265. * * 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
  53266. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53267. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53268. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53269. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53270. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53271. * * 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
  53272. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53275. * @param name defines the name of the new line system
  53276. * @param options defines the options used to create the line system
  53277. * @param scene defines the hosting scene
  53278. * @returns a new line system mesh
  53279. */
  53280. static CreateLineSystem(name: string, options: {
  53281. lines: Vector3[][];
  53282. updatable?: boolean;
  53283. instance?: Nullable<LinesMesh>;
  53284. colors?: Nullable<Color4[][]>;
  53285. useVertexAlpha?: boolean;
  53286. }, scene: Nullable<Scene>): LinesMesh;
  53287. /**
  53288. * Creates a line mesh
  53289. * 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
  53290. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53291. * * The parameter `points` is an array successive Vector3
  53292. * * 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
  53293. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53294. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53295. * * When updating an instance, remember that only point positions can change, not the number of points
  53296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53298. * @param name defines the name of the new line system
  53299. * @param options defines the options used to create the line system
  53300. * @param scene defines the hosting scene
  53301. * @returns a new line mesh
  53302. */
  53303. static CreateLines(name: string, options: {
  53304. points: Vector3[];
  53305. updatable?: boolean;
  53306. instance?: Nullable<LinesMesh>;
  53307. colors?: Color4[];
  53308. useVertexAlpha?: boolean;
  53309. }, scene?: Nullable<Scene>): LinesMesh;
  53310. /**
  53311. * Creates a dashed line mesh
  53312. * * 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
  53313. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53314. * * The parameter `points` is an array successive Vector3
  53315. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53316. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53317. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53318. * * 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
  53319. * * When updating an instance, remember that only point positions can change, not the number of points
  53320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53321. * @param name defines the name of the mesh
  53322. * @param options defines the options used to create the mesh
  53323. * @param scene defines the hosting scene
  53324. * @returns the dashed line mesh
  53325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53326. */
  53327. static CreateDashedLines(name: string, options: {
  53328. points: Vector3[];
  53329. dashSize?: number;
  53330. gapSize?: number;
  53331. dashNb?: number;
  53332. updatable?: boolean;
  53333. instance?: LinesMesh;
  53334. }, scene?: Nullable<Scene>): LinesMesh;
  53335. /**
  53336. * 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.
  53337. * * 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.
  53338. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53339. * * 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.
  53340. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53341. * * 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
  53342. * * 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
  53343. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53345. * * 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
  53346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53348. * @param name defines the name of the mesh
  53349. * @param options defines the options used to create the mesh
  53350. * @param scene defines the hosting scene
  53351. * @returns the extruded shape mesh
  53352. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53354. */
  53355. static ExtrudeShape(name: string, options: {
  53356. shape: Vector3[];
  53357. path: Vector3[];
  53358. scale?: number;
  53359. rotation?: number;
  53360. cap?: number;
  53361. updatable?: boolean;
  53362. sideOrientation?: number;
  53363. frontUVs?: Vector4;
  53364. backUVs?: Vector4;
  53365. instance?: Mesh;
  53366. invertUV?: boolean;
  53367. }, scene?: Nullable<Scene>): Mesh;
  53368. /**
  53369. * Creates an custom extruded shape mesh.
  53370. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53371. * * 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.
  53372. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53373. * * 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
  53374. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53375. * * 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
  53376. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53377. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53378. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53379. * * 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
  53380. * * 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
  53381. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53383. * * 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
  53384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53386. * @param name defines the name of the mesh
  53387. * @param options defines the options used to create the mesh
  53388. * @param scene defines the hosting scene
  53389. * @returns the custom extruded shape mesh
  53390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53393. */
  53394. static ExtrudeShapeCustom(name: string, options: {
  53395. shape: Vector3[];
  53396. path: Vector3[];
  53397. scaleFunction?: any;
  53398. rotationFunction?: any;
  53399. ribbonCloseArray?: boolean;
  53400. ribbonClosePath?: boolean;
  53401. cap?: number;
  53402. updatable?: boolean;
  53403. sideOrientation?: number;
  53404. frontUVs?: Vector4;
  53405. backUVs?: Vector4;
  53406. instance?: Mesh;
  53407. invertUV?: boolean;
  53408. }, scene?: Nullable<Scene>): Mesh;
  53409. /**
  53410. * Creates lathe mesh.
  53411. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53412. * * 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
  53413. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53414. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53415. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53416. * * 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
  53417. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53418. * * 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
  53419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53420. * * 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
  53421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53423. * @param name defines the name of the mesh
  53424. * @param options defines the options used to create the mesh
  53425. * @param scene defines the hosting scene
  53426. * @returns the lathe mesh
  53427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53428. */
  53429. static CreateLathe(name: string, options: {
  53430. shape: Vector3[];
  53431. radius?: number;
  53432. tessellation?: number;
  53433. clip?: number;
  53434. arc?: number;
  53435. closed?: boolean;
  53436. updatable?: boolean;
  53437. sideOrientation?: number;
  53438. frontUVs?: Vector4;
  53439. backUVs?: Vector4;
  53440. cap?: number;
  53441. invertUV?: boolean;
  53442. }, scene?: Nullable<Scene>): Mesh;
  53443. /**
  53444. * Creates a tiled plane mesh
  53445. * * You can set a limited pattern arrangement with the tiles
  53446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53447. * * 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
  53448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53449. * @param name defines the name of the mesh
  53450. * @param options defines the options used to create the mesh
  53451. * @param scene defines the hosting scene
  53452. * @returns the plane mesh
  53453. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53454. */
  53455. static CreateTiledPlane(name: string, options: {
  53456. pattern?: number;
  53457. tileSize?: number;
  53458. tileWidth?: number;
  53459. tileHeight?: number;
  53460. size?: number;
  53461. width?: number;
  53462. height?: number;
  53463. alignHorizontal?: number;
  53464. alignVertical?: number;
  53465. sideOrientation?: number;
  53466. frontUVs?: Vector4;
  53467. backUVs?: Vector4;
  53468. updatable?: boolean;
  53469. }, scene?: Nullable<Scene>): Mesh;
  53470. /**
  53471. * Creates a plane mesh
  53472. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53473. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53474. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53476. * * 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
  53477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53478. * @param name defines the name of the mesh
  53479. * @param options defines the options used to create the mesh
  53480. * @param scene defines the hosting scene
  53481. * @returns the plane mesh
  53482. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53483. */
  53484. static CreatePlane(name: string, options: {
  53485. size?: number;
  53486. width?: number;
  53487. height?: number;
  53488. sideOrientation?: number;
  53489. frontUVs?: Vector4;
  53490. backUVs?: Vector4;
  53491. updatable?: boolean;
  53492. sourcePlane?: Plane;
  53493. }, scene?: Nullable<Scene>): Mesh;
  53494. /**
  53495. * Creates a ground mesh
  53496. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53497. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53499. * @param name defines the name of the mesh
  53500. * @param options defines the options used to create the mesh
  53501. * @param scene defines the hosting scene
  53502. * @returns the ground mesh
  53503. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53504. */
  53505. static CreateGround(name: string, options: {
  53506. width?: number;
  53507. height?: number;
  53508. subdivisions?: number;
  53509. subdivisionsX?: number;
  53510. subdivisionsY?: number;
  53511. updatable?: boolean;
  53512. }, scene?: Nullable<Scene>): Mesh;
  53513. /**
  53514. * Creates a tiled ground mesh
  53515. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53516. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53517. * * 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
  53518. * * 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
  53519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53520. * @param name defines the name of the mesh
  53521. * @param options defines the options used to create the mesh
  53522. * @param scene defines the hosting scene
  53523. * @returns the tiled ground mesh
  53524. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53525. */
  53526. static CreateTiledGround(name: string, options: {
  53527. xmin: number;
  53528. zmin: number;
  53529. xmax: number;
  53530. zmax: number;
  53531. subdivisions?: {
  53532. w: number;
  53533. h: number;
  53534. };
  53535. precision?: {
  53536. w: number;
  53537. h: number;
  53538. };
  53539. updatable?: boolean;
  53540. }, scene?: Nullable<Scene>): Mesh;
  53541. /**
  53542. * Creates a ground mesh from a height map
  53543. * * The parameter `url` sets the URL of the height map image resource.
  53544. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53545. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53546. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53547. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53548. * * 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.
  53549. * * 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).
  53550. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53552. * @param name defines the name of the mesh
  53553. * @param url defines the url to the height map
  53554. * @param options defines the options used to create the mesh
  53555. * @param scene defines the hosting scene
  53556. * @returns the ground mesh
  53557. * @see https://doc.babylonjs.com/babylon101/height_map
  53558. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53559. */
  53560. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53561. width?: number;
  53562. height?: number;
  53563. subdivisions?: number;
  53564. minHeight?: number;
  53565. maxHeight?: number;
  53566. colorFilter?: Color3;
  53567. alphaFilter?: number;
  53568. updatable?: boolean;
  53569. onReady?: (mesh: GroundMesh) => void;
  53570. }, scene?: Nullable<Scene>): GroundMesh;
  53571. /**
  53572. * Creates a polygon mesh
  53573. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53574. * * 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
  53575. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53577. * * 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)
  53578. * * Remember you can only change the shape positions, not their number when updating a polygon
  53579. * @param name defines the name of the mesh
  53580. * @param options defines the options used to create the mesh
  53581. * @param scene defines the hosting scene
  53582. * @param earcutInjection can be used to inject your own earcut reference
  53583. * @returns the polygon mesh
  53584. */
  53585. static CreatePolygon(name: string, options: {
  53586. shape: Vector3[];
  53587. holes?: Vector3[][];
  53588. depth?: number;
  53589. faceUV?: Vector4[];
  53590. faceColors?: Color4[];
  53591. updatable?: boolean;
  53592. sideOrientation?: number;
  53593. frontUVs?: Vector4;
  53594. backUVs?: Vector4;
  53595. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53596. /**
  53597. * Creates an extruded polygon mesh, with depth in the Y direction.
  53598. * * 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)
  53599. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53600. * @param name defines the name of the mesh
  53601. * @param options defines the options used to create the mesh
  53602. * @param scene defines the hosting scene
  53603. * @param earcutInjection can be used to inject your own earcut reference
  53604. * @returns the polygon mesh
  53605. */
  53606. static ExtrudePolygon(name: string, options: {
  53607. shape: Vector3[];
  53608. holes?: Vector3[][];
  53609. depth?: number;
  53610. faceUV?: Vector4[];
  53611. faceColors?: Color4[];
  53612. updatable?: boolean;
  53613. sideOrientation?: number;
  53614. frontUVs?: Vector4;
  53615. backUVs?: Vector4;
  53616. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53617. /**
  53618. * Creates a tube mesh.
  53619. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53620. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53621. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53622. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53623. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53624. * * 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)
  53625. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53626. * * 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
  53627. * * 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
  53628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53629. * * 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
  53630. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53632. * @param name defines the name of the mesh
  53633. * @param options defines the options used to create the mesh
  53634. * @param scene defines the hosting scene
  53635. * @returns the tube mesh
  53636. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53637. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53638. */
  53639. static CreateTube(name: string, options: {
  53640. path: Vector3[];
  53641. radius?: number;
  53642. tessellation?: number;
  53643. radiusFunction?: {
  53644. (i: number, distance: number): number;
  53645. };
  53646. cap?: number;
  53647. arc?: number;
  53648. updatable?: boolean;
  53649. sideOrientation?: number;
  53650. frontUVs?: Vector4;
  53651. backUVs?: Vector4;
  53652. instance?: Mesh;
  53653. invertUV?: boolean;
  53654. }, scene?: Nullable<Scene>): Mesh;
  53655. /**
  53656. * Creates a polyhedron mesh
  53657. * * 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
  53658. * * The parameter `size` (positive float, default 1) sets the polygon size
  53659. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53660. * * 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`
  53661. * * 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
  53662. * * 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)`)
  53663. * * 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
  53664. * * 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
  53665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53666. * * 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
  53667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53668. * @param name defines the name of the mesh
  53669. * @param options defines the options used to create the mesh
  53670. * @param scene defines the hosting scene
  53671. * @returns the polyhedron mesh
  53672. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53673. */
  53674. static CreatePolyhedron(name: string, options: {
  53675. type?: number;
  53676. size?: number;
  53677. sizeX?: number;
  53678. sizeY?: number;
  53679. sizeZ?: number;
  53680. custom?: any;
  53681. faceUV?: Vector4[];
  53682. faceColors?: Color4[];
  53683. flat?: boolean;
  53684. updatable?: boolean;
  53685. sideOrientation?: number;
  53686. frontUVs?: Vector4;
  53687. backUVs?: Vector4;
  53688. }, scene?: Nullable<Scene>): Mesh;
  53689. /**
  53690. * Creates a decal mesh.
  53691. * 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
  53692. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53693. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53694. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53695. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53696. * @param name defines the name of the mesh
  53697. * @param sourceMesh defines the mesh where the decal must be applied
  53698. * @param options defines the options used to create the mesh
  53699. * @param scene defines the hosting scene
  53700. * @returns the decal mesh
  53701. * @see https://doc.babylonjs.com/how_to/decals
  53702. */
  53703. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53704. position?: Vector3;
  53705. normal?: Vector3;
  53706. size?: Vector3;
  53707. angle?: number;
  53708. }): Mesh;
  53709. }
  53710. }
  53711. declare module BABYLON {
  53712. /**
  53713. * A simplifier interface for future simplification implementations
  53714. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53715. */
  53716. export interface ISimplifier {
  53717. /**
  53718. * Simplification of a given mesh according to the given settings.
  53719. * Since this requires computation, it is assumed that the function runs async.
  53720. * @param settings The settings of the simplification, including quality and distance
  53721. * @param successCallback A callback that will be called after the mesh was simplified.
  53722. * @param errorCallback in case of an error, this callback will be called. optional.
  53723. */
  53724. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53725. }
  53726. /**
  53727. * Expected simplification settings.
  53728. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53729. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53730. */
  53731. export interface ISimplificationSettings {
  53732. /**
  53733. * Gets or sets the expected quality
  53734. */
  53735. quality: number;
  53736. /**
  53737. * Gets or sets the distance when this optimized version should be used
  53738. */
  53739. distance: number;
  53740. /**
  53741. * Gets an already optimized mesh
  53742. */
  53743. optimizeMesh?: boolean;
  53744. }
  53745. /**
  53746. * Class used to specify simplification options
  53747. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53748. */
  53749. export class SimplificationSettings implements ISimplificationSettings {
  53750. /** expected quality */
  53751. quality: number;
  53752. /** distance when this optimized version should be used */
  53753. distance: number;
  53754. /** already optimized mesh */
  53755. optimizeMesh?: boolean | undefined;
  53756. /**
  53757. * Creates a SimplificationSettings
  53758. * @param quality expected quality
  53759. * @param distance distance when this optimized version should be used
  53760. * @param optimizeMesh already optimized mesh
  53761. */
  53762. constructor(
  53763. /** expected quality */
  53764. quality: number,
  53765. /** distance when this optimized version should be used */
  53766. distance: number,
  53767. /** already optimized mesh */
  53768. optimizeMesh?: boolean | undefined);
  53769. }
  53770. /**
  53771. * Interface used to define a simplification task
  53772. */
  53773. export interface ISimplificationTask {
  53774. /**
  53775. * Array of settings
  53776. */
  53777. settings: Array<ISimplificationSettings>;
  53778. /**
  53779. * Simplification type
  53780. */
  53781. simplificationType: SimplificationType;
  53782. /**
  53783. * Mesh to simplify
  53784. */
  53785. mesh: Mesh;
  53786. /**
  53787. * Callback called on success
  53788. */
  53789. successCallback?: () => void;
  53790. /**
  53791. * Defines if parallel processing can be used
  53792. */
  53793. parallelProcessing: boolean;
  53794. }
  53795. /**
  53796. * Queue used to order the simplification tasks
  53797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53798. */
  53799. export class SimplificationQueue {
  53800. private _simplificationArray;
  53801. /**
  53802. * Gets a boolean indicating that the process is still running
  53803. */
  53804. running: boolean;
  53805. /**
  53806. * Creates a new queue
  53807. */
  53808. constructor();
  53809. /**
  53810. * Adds a new simplification task
  53811. * @param task defines a task to add
  53812. */
  53813. addTask(task: ISimplificationTask): void;
  53814. /**
  53815. * Execute next task
  53816. */
  53817. executeNext(): void;
  53818. /**
  53819. * Execute a simplification task
  53820. * @param task defines the task to run
  53821. */
  53822. runSimplification(task: ISimplificationTask): void;
  53823. private getSimplifier;
  53824. }
  53825. /**
  53826. * The implemented types of simplification
  53827. * At the moment only Quadratic Error Decimation is implemented
  53828. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53829. */
  53830. export enum SimplificationType {
  53831. /** Quadratic error decimation */
  53832. QUADRATIC = 0
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. interface Scene {
  53837. /** @hidden (Backing field) */
  53838. _simplificationQueue: SimplificationQueue;
  53839. /**
  53840. * Gets or sets the simplification queue attached to the scene
  53841. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53842. */
  53843. simplificationQueue: SimplificationQueue;
  53844. }
  53845. interface Mesh {
  53846. /**
  53847. * Simplify the mesh according to the given array of settings.
  53848. * Function will return immediately and will simplify async
  53849. * @param settings a collection of simplification settings
  53850. * @param parallelProcessing should all levels calculate parallel or one after the other
  53851. * @param simplificationType the type of simplification to run
  53852. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53853. * @returns the current mesh
  53854. */
  53855. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53856. }
  53857. /**
  53858. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53859. * created in a scene
  53860. */
  53861. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53862. /**
  53863. * The component name helpfull to identify the component in the list of scene components.
  53864. */
  53865. readonly name: string;
  53866. /**
  53867. * The scene the component belongs to.
  53868. */
  53869. scene: Scene;
  53870. /**
  53871. * Creates a new instance of the component for the given scene
  53872. * @param scene Defines the scene to register the component in
  53873. */
  53874. constructor(scene: Scene);
  53875. /**
  53876. * Registers the component in a given scene
  53877. */
  53878. register(): void;
  53879. /**
  53880. * Rebuilds the elements related to this component in case of
  53881. * context lost for instance.
  53882. */
  53883. rebuild(): void;
  53884. /**
  53885. * Disposes the component and the associated ressources
  53886. */
  53887. dispose(): void;
  53888. private _beforeCameraUpdate;
  53889. }
  53890. }
  53891. declare module BABYLON {
  53892. /**
  53893. * Class used to enable access to IndexedDB
  53894. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53895. */
  53896. export class Database implements IOfflineProvider {
  53897. private _callbackManifestChecked;
  53898. private _currentSceneUrl;
  53899. private _db;
  53900. private _enableSceneOffline;
  53901. private _enableTexturesOffline;
  53902. private _manifestVersionFound;
  53903. private _mustUpdateRessources;
  53904. private _hasReachedQuota;
  53905. private _isSupported;
  53906. private _idbFactory;
  53907. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53908. private static IsUASupportingBlobStorage;
  53909. /**
  53910. * Gets a boolean indicating if Database storate is enabled (off by default)
  53911. */
  53912. static IDBStorageEnabled: boolean;
  53913. /**
  53914. * Gets a boolean indicating if scene must be saved in the database
  53915. */
  53916. readonly enableSceneOffline: boolean;
  53917. /**
  53918. * Gets a boolean indicating if textures must be saved in the database
  53919. */
  53920. readonly enableTexturesOffline: boolean;
  53921. /**
  53922. * Creates a new Database
  53923. * @param urlToScene defines the url to load the scene
  53924. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53925. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53926. */
  53927. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53928. private static _ParseURL;
  53929. private static _ReturnFullUrlLocation;
  53930. private _checkManifestFile;
  53931. /**
  53932. * Open the database and make it available
  53933. * @param successCallback defines the callback to call on success
  53934. * @param errorCallback defines the callback to call on error
  53935. */
  53936. open(successCallback: () => void, errorCallback: () => void): void;
  53937. /**
  53938. * Loads an image from the database
  53939. * @param url defines the url to load from
  53940. * @param image defines the target DOM image
  53941. */
  53942. loadImage(url: string, image: HTMLImageElement): void;
  53943. private _loadImageFromDBAsync;
  53944. private _saveImageIntoDBAsync;
  53945. private _checkVersionFromDB;
  53946. private _loadVersionFromDBAsync;
  53947. private _saveVersionIntoDBAsync;
  53948. /**
  53949. * Loads a file from database
  53950. * @param url defines the URL to load from
  53951. * @param sceneLoaded defines a callback to call on success
  53952. * @param progressCallBack defines a callback to call when progress changed
  53953. * @param errorCallback defines a callback to call on error
  53954. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53955. */
  53956. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53957. private _loadFileAsync;
  53958. private _saveFileAsync;
  53959. /**
  53960. * Validates if xhr data is correct
  53961. * @param xhr defines the request to validate
  53962. * @param dataType defines the expected data type
  53963. * @returns true if data is correct
  53964. */
  53965. private static _ValidateXHRData;
  53966. }
  53967. }
  53968. declare module BABYLON {
  53969. /** @hidden */
  53970. export var gpuUpdateParticlesPixelShader: {
  53971. name: string;
  53972. shader: string;
  53973. };
  53974. }
  53975. declare module BABYLON {
  53976. /** @hidden */
  53977. export var gpuUpdateParticlesVertexShader: {
  53978. name: string;
  53979. shader: string;
  53980. };
  53981. }
  53982. declare module BABYLON {
  53983. /** @hidden */
  53984. export var clipPlaneFragmentDeclaration2: {
  53985. name: string;
  53986. shader: string;
  53987. };
  53988. }
  53989. declare module BABYLON {
  53990. /** @hidden */
  53991. export var gpuRenderParticlesPixelShader: {
  53992. name: string;
  53993. shader: string;
  53994. };
  53995. }
  53996. declare module BABYLON {
  53997. /** @hidden */
  53998. export var clipPlaneVertexDeclaration2: {
  53999. name: string;
  54000. shader: string;
  54001. };
  54002. }
  54003. declare module BABYLON {
  54004. /** @hidden */
  54005. export var gpuRenderParticlesVertexShader: {
  54006. name: string;
  54007. shader: string;
  54008. };
  54009. }
  54010. declare module BABYLON {
  54011. /**
  54012. * This represents a GPU particle system in Babylon
  54013. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54014. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54015. */
  54016. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54017. /**
  54018. * The layer mask we are rendering the particles through.
  54019. */
  54020. layerMask: number;
  54021. private _capacity;
  54022. private _activeCount;
  54023. private _currentActiveCount;
  54024. private _accumulatedCount;
  54025. private _renderEffect;
  54026. private _updateEffect;
  54027. private _buffer0;
  54028. private _buffer1;
  54029. private _spriteBuffer;
  54030. private _updateVAO;
  54031. private _renderVAO;
  54032. private _targetIndex;
  54033. private _sourceBuffer;
  54034. private _targetBuffer;
  54035. private _engine;
  54036. private _currentRenderId;
  54037. private _started;
  54038. private _stopped;
  54039. private _timeDelta;
  54040. private _randomTexture;
  54041. private _randomTexture2;
  54042. private _attributesStrideSize;
  54043. private _updateEffectOptions;
  54044. private _randomTextureSize;
  54045. private _actualFrame;
  54046. private readonly _rawTextureWidth;
  54047. /**
  54048. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54049. */
  54050. static readonly IsSupported: boolean;
  54051. /**
  54052. * An event triggered when the system is disposed.
  54053. */
  54054. onDisposeObservable: Observable<GPUParticleSystem>;
  54055. /**
  54056. * Gets the maximum number of particles active at the same time.
  54057. * @returns The max number of active particles.
  54058. */
  54059. getCapacity(): number;
  54060. /**
  54061. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54062. * to override the particles.
  54063. */
  54064. forceDepthWrite: boolean;
  54065. /**
  54066. * Gets or set the number of active particles
  54067. */
  54068. activeParticleCount: number;
  54069. private _preWarmDone;
  54070. /**
  54071. * Is this system ready to be used/rendered
  54072. * @return true if the system is ready
  54073. */
  54074. isReady(): boolean;
  54075. /**
  54076. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54077. * @returns True if it has been started, otherwise false.
  54078. */
  54079. isStarted(): boolean;
  54080. /**
  54081. * Starts the particle system and begins to emit
  54082. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54083. */
  54084. start(delay?: number): void;
  54085. /**
  54086. * Stops the particle system.
  54087. */
  54088. stop(): void;
  54089. /**
  54090. * Remove all active particles
  54091. */
  54092. reset(): void;
  54093. /**
  54094. * Returns the string "GPUParticleSystem"
  54095. * @returns a string containing the class name
  54096. */
  54097. getClassName(): string;
  54098. private _colorGradientsTexture;
  54099. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54100. /**
  54101. * Adds a new color gradient
  54102. * @param gradient defines the gradient to use (between 0 and 1)
  54103. * @param color1 defines the color to affect to the specified gradient
  54104. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54105. * @returns the current particle system
  54106. */
  54107. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54108. /**
  54109. * Remove a specific color gradient
  54110. * @param gradient defines the gradient to remove
  54111. * @returns the current particle system
  54112. */
  54113. removeColorGradient(gradient: number): GPUParticleSystem;
  54114. private _angularSpeedGradientsTexture;
  54115. private _sizeGradientsTexture;
  54116. private _velocityGradientsTexture;
  54117. private _limitVelocityGradientsTexture;
  54118. private _dragGradientsTexture;
  54119. private _addFactorGradient;
  54120. /**
  54121. * Adds a new size gradient
  54122. * @param gradient defines the gradient to use (between 0 and 1)
  54123. * @param factor defines the size factor to affect to the specified gradient
  54124. * @returns the current particle system
  54125. */
  54126. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54127. /**
  54128. * Remove a specific size gradient
  54129. * @param gradient defines the gradient to remove
  54130. * @returns the current particle system
  54131. */
  54132. removeSizeGradient(gradient: number): GPUParticleSystem;
  54133. /**
  54134. * Adds a new angular speed gradient
  54135. * @param gradient defines the gradient to use (between 0 and 1)
  54136. * @param factor defines the angular speed to affect to the specified gradient
  54137. * @returns the current particle system
  54138. */
  54139. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54140. /**
  54141. * Remove a specific angular speed gradient
  54142. * @param gradient defines the gradient to remove
  54143. * @returns the current particle system
  54144. */
  54145. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54146. /**
  54147. * Adds a new velocity gradient
  54148. * @param gradient defines the gradient to use (between 0 and 1)
  54149. * @param factor defines the velocity to affect to the specified gradient
  54150. * @returns the current particle system
  54151. */
  54152. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54153. /**
  54154. * Remove a specific velocity gradient
  54155. * @param gradient defines the gradient to remove
  54156. * @returns the current particle system
  54157. */
  54158. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54159. /**
  54160. * Adds a new limit velocity gradient
  54161. * @param gradient defines the gradient to use (between 0 and 1)
  54162. * @param factor defines the limit velocity value to affect to the specified gradient
  54163. * @returns the current particle system
  54164. */
  54165. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54166. /**
  54167. * Remove a specific limit velocity gradient
  54168. * @param gradient defines the gradient to remove
  54169. * @returns the current particle system
  54170. */
  54171. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54172. /**
  54173. * Adds a new drag gradient
  54174. * @param gradient defines the gradient to use (between 0 and 1)
  54175. * @param factor defines the drag value to affect to the specified gradient
  54176. * @returns the current particle system
  54177. */
  54178. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54179. /**
  54180. * Remove a specific drag gradient
  54181. * @param gradient defines the gradient to remove
  54182. * @returns the current particle system
  54183. */
  54184. removeDragGradient(gradient: number): GPUParticleSystem;
  54185. /**
  54186. * Not supported by GPUParticleSystem
  54187. * @param gradient defines the gradient to use (between 0 and 1)
  54188. * @param factor defines the emit rate value to affect to the specified gradient
  54189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54190. * @returns the current particle system
  54191. */
  54192. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54193. /**
  54194. * Not supported by GPUParticleSystem
  54195. * @param gradient defines the gradient to remove
  54196. * @returns the current particle system
  54197. */
  54198. removeEmitRateGradient(gradient: number): IParticleSystem;
  54199. /**
  54200. * Not supported by GPUParticleSystem
  54201. * @param gradient defines the gradient to use (between 0 and 1)
  54202. * @param factor defines the start size value to affect to the specified gradient
  54203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54204. * @returns the current particle system
  54205. */
  54206. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54207. /**
  54208. * Not supported by GPUParticleSystem
  54209. * @param gradient defines the gradient to remove
  54210. * @returns the current particle system
  54211. */
  54212. removeStartSizeGradient(gradient: number): IParticleSystem;
  54213. /**
  54214. * Not supported by GPUParticleSystem
  54215. * @param gradient defines the gradient to use (between 0 and 1)
  54216. * @param min defines the color remap minimal range
  54217. * @param max defines the color remap maximal range
  54218. * @returns the current particle system
  54219. */
  54220. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54221. /**
  54222. * Not supported by GPUParticleSystem
  54223. * @param gradient defines the gradient to remove
  54224. * @returns the current particle system
  54225. */
  54226. removeColorRemapGradient(): IParticleSystem;
  54227. /**
  54228. * Not supported by GPUParticleSystem
  54229. * @param gradient defines the gradient to use (between 0 and 1)
  54230. * @param min defines the alpha remap minimal range
  54231. * @param max defines the alpha remap maximal range
  54232. * @returns the current particle system
  54233. */
  54234. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54235. /**
  54236. * Not supported by GPUParticleSystem
  54237. * @param gradient defines the gradient to remove
  54238. * @returns the current particle system
  54239. */
  54240. removeAlphaRemapGradient(): IParticleSystem;
  54241. /**
  54242. * Not supported by GPUParticleSystem
  54243. * @param gradient defines the gradient to use (between 0 and 1)
  54244. * @param color defines the color to affect to the specified gradient
  54245. * @returns the current particle system
  54246. */
  54247. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54248. /**
  54249. * Not supported by GPUParticleSystem
  54250. * @param gradient defines the gradient to remove
  54251. * @returns the current particle system
  54252. */
  54253. removeRampGradient(): IParticleSystem;
  54254. /**
  54255. * Not supported by GPUParticleSystem
  54256. * @returns the list of ramp gradients
  54257. */
  54258. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54259. /**
  54260. * Not supported by GPUParticleSystem
  54261. * Gets or sets a boolean indicating that ramp gradients must be used
  54262. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54263. */
  54264. useRampGradients: boolean;
  54265. /**
  54266. * Not supported by GPUParticleSystem
  54267. * @param gradient defines the gradient to use (between 0 and 1)
  54268. * @param factor defines the life time factor to affect to the specified gradient
  54269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54270. * @returns the current particle system
  54271. */
  54272. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54273. /**
  54274. * Not supported by GPUParticleSystem
  54275. * @param gradient defines the gradient to remove
  54276. * @returns the current particle system
  54277. */
  54278. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54279. /**
  54280. * Instantiates a GPU particle system.
  54281. * 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.
  54282. * @param name The name of the particle system
  54283. * @param options The options used to create the system
  54284. * @param scene The scene the particle system belongs to
  54285. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54286. */
  54287. constructor(name: string, options: Partial<{
  54288. capacity: number;
  54289. randomTextureSize: number;
  54290. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54291. protected _reset(): void;
  54292. private _createUpdateVAO;
  54293. private _createRenderVAO;
  54294. private _initialize;
  54295. /** @hidden */
  54296. _recreateUpdateEffect(): void;
  54297. /** @hidden */
  54298. _recreateRenderEffect(): void;
  54299. /**
  54300. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54301. * @param preWarm defines if we are in the pre-warmimg phase
  54302. */
  54303. animate(preWarm?: boolean): void;
  54304. private _createFactorGradientTexture;
  54305. private _createSizeGradientTexture;
  54306. private _createAngularSpeedGradientTexture;
  54307. private _createVelocityGradientTexture;
  54308. private _createLimitVelocityGradientTexture;
  54309. private _createDragGradientTexture;
  54310. private _createColorGradientTexture;
  54311. /**
  54312. * Renders the particle system in its current state
  54313. * @param preWarm defines if the system should only update the particles but not render them
  54314. * @returns the current number of particles
  54315. */
  54316. render(preWarm?: boolean): number;
  54317. /**
  54318. * Rebuilds the particle system
  54319. */
  54320. rebuild(): void;
  54321. private _releaseBuffers;
  54322. private _releaseVAOs;
  54323. /**
  54324. * Disposes the particle system and free the associated resources
  54325. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54326. */
  54327. dispose(disposeTexture?: boolean): void;
  54328. /**
  54329. * Clones the particle system.
  54330. * @param name The name of the cloned object
  54331. * @param newEmitter The new emitter to use
  54332. * @returns the cloned particle system
  54333. */
  54334. clone(name: string, newEmitter: any): GPUParticleSystem;
  54335. /**
  54336. * Serializes the particle system to a JSON object.
  54337. * @returns the JSON object
  54338. */
  54339. serialize(): any;
  54340. /**
  54341. * Parses a JSON object to create a GPU particle system.
  54342. * @param parsedParticleSystem The JSON object to parse
  54343. * @param scene The scene to create the particle system in
  54344. * @param rootUrl The root url to use to load external dependencies like texture
  54345. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54346. * @returns the parsed GPU particle system
  54347. */
  54348. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54349. }
  54350. }
  54351. declare module BABYLON {
  54352. /**
  54353. * Represents a set of particle systems working together to create a specific effect
  54354. */
  54355. export class ParticleSystemSet implements IDisposable {
  54356. private _emitterCreationOptions;
  54357. private _emitterNode;
  54358. /**
  54359. * Gets the particle system list
  54360. */
  54361. systems: IParticleSystem[];
  54362. /**
  54363. * Gets the emitter node used with this set
  54364. */
  54365. readonly emitterNode: Nullable<TransformNode>;
  54366. /**
  54367. * Creates a new emitter mesh as a sphere
  54368. * @param options defines the options used to create the sphere
  54369. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54370. * @param scene defines the hosting scene
  54371. */
  54372. setEmitterAsSphere(options: {
  54373. diameter: number;
  54374. segments: number;
  54375. color: Color3;
  54376. }, renderingGroupId: number, scene: Scene): void;
  54377. /**
  54378. * Starts all particle systems of the set
  54379. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54380. */
  54381. start(emitter?: AbstractMesh): void;
  54382. /**
  54383. * Release all associated resources
  54384. */
  54385. dispose(): void;
  54386. /**
  54387. * Serialize the set into a JSON compatible object
  54388. * @returns a JSON compatible representation of the set
  54389. */
  54390. serialize(): any;
  54391. /**
  54392. * Parse a new ParticleSystemSet from a serialized source
  54393. * @param data defines a JSON compatible representation of the set
  54394. * @param scene defines the hosting scene
  54395. * @param gpu defines if we want GPU particles or CPU particles
  54396. * @returns a new ParticleSystemSet
  54397. */
  54398. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54399. }
  54400. }
  54401. declare module BABYLON {
  54402. /**
  54403. * This class is made for on one-liner static method to help creating particle system set.
  54404. */
  54405. export class ParticleHelper {
  54406. /**
  54407. * Gets or sets base Assets URL
  54408. */
  54409. static BaseAssetsUrl: string;
  54410. /**
  54411. * Create a default particle system that you can tweak
  54412. * @param emitter defines the emitter to use
  54413. * @param capacity defines the system capacity (default is 500 particles)
  54414. * @param scene defines the hosting scene
  54415. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54416. * @returns the new Particle system
  54417. */
  54418. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54419. /**
  54420. * This is the main static method (one-liner) of this helper to create different particle systems
  54421. * @param type This string represents the type to the particle system to create
  54422. * @param scene The scene where the particle system should live
  54423. * @param gpu If the system will use gpu
  54424. * @returns the ParticleSystemSet created
  54425. */
  54426. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54427. /**
  54428. * Static function used to export a particle system to a ParticleSystemSet variable.
  54429. * Please note that the emitter shape is not exported
  54430. * @param systems defines the particle systems to export
  54431. * @returns the created particle system set
  54432. */
  54433. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. interface Engine {
  54438. /**
  54439. * Create an effect to use with particle systems.
  54440. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54441. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54442. * @param uniformsNames defines a list of attribute names
  54443. * @param samplers defines an array of string used to represent textures
  54444. * @param defines defines the string containing the defines to use to compile the shaders
  54445. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54446. * @param onCompiled defines a function to call when the effect creation is successful
  54447. * @param onError defines a function to call when the effect creation has failed
  54448. * @returns the new Effect
  54449. */
  54450. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54451. }
  54452. interface Mesh {
  54453. /**
  54454. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54455. * @returns an array of IParticleSystem
  54456. */
  54457. getEmittedParticleSystems(): IParticleSystem[];
  54458. /**
  54459. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54460. * @returns an array of IParticleSystem
  54461. */
  54462. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54463. }
  54464. /**
  54465. * @hidden
  54466. */
  54467. export var _IDoNeedToBeInTheBuild: number;
  54468. }
  54469. declare module BABYLON {
  54470. interface Scene {
  54471. /** @hidden (Backing field) */
  54472. _physicsEngine: Nullable<IPhysicsEngine>;
  54473. /**
  54474. * Gets the current physics engine
  54475. * @returns a IPhysicsEngine or null if none attached
  54476. */
  54477. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54478. /**
  54479. * Enables physics to the current scene
  54480. * @param gravity defines the scene's gravity for the physics engine
  54481. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54482. * @return a boolean indicating if the physics engine was initialized
  54483. */
  54484. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54485. /**
  54486. * Disables and disposes the physics engine associated with the scene
  54487. */
  54488. disablePhysicsEngine(): void;
  54489. /**
  54490. * Gets a boolean indicating if there is an active physics engine
  54491. * @returns a boolean indicating if there is an active physics engine
  54492. */
  54493. isPhysicsEnabled(): boolean;
  54494. /**
  54495. * Deletes a physics compound impostor
  54496. * @param compound defines the compound to delete
  54497. */
  54498. deleteCompoundImpostor(compound: any): void;
  54499. /**
  54500. * An event triggered when physic simulation is about to be run
  54501. */
  54502. onBeforePhysicsObservable: Observable<Scene>;
  54503. /**
  54504. * An event triggered when physic simulation has been done
  54505. */
  54506. onAfterPhysicsObservable: Observable<Scene>;
  54507. }
  54508. interface AbstractMesh {
  54509. /** @hidden */
  54510. _physicsImpostor: Nullable<PhysicsImpostor>;
  54511. /**
  54512. * Gets or sets impostor used for physic simulation
  54513. * @see http://doc.babylonjs.com/features/physics_engine
  54514. */
  54515. physicsImpostor: Nullable<PhysicsImpostor>;
  54516. /**
  54517. * Gets the current physics impostor
  54518. * @see http://doc.babylonjs.com/features/physics_engine
  54519. * @returns a physics impostor or null
  54520. */
  54521. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54522. /** Apply a physic impulse to the mesh
  54523. * @param force defines the force to apply
  54524. * @param contactPoint defines where to apply the force
  54525. * @returns the current mesh
  54526. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54527. */
  54528. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54529. /**
  54530. * Creates a physic joint between two meshes
  54531. * @param otherMesh defines the other mesh to use
  54532. * @param pivot1 defines the pivot to use on this mesh
  54533. * @param pivot2 defines the pivot to use on the other mesh
  54534. * @param options defines additional options (can be plugin dependent)
  54535. * @returns the current mesh
  54536. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54537. */
  54538. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54539. /** @hidden */
  54540. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54541. }
  54542. /**
  54543. * Defines the physics engine scene component responsible to manage a physics engine
  54544. */
  54545. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54546. /**
  54547. * The component name helpful to identify the component in the list of scene components.
  54548. */
  54549. readonly name: string;
  54550. /**
  54551. * The scene the component belongs to.
  54552. */
  54553. scene: Scene;
  54554. /**
  54555. * Creates a new instance of the component for the given scene
  54556. * @param scene Defines the scene to register the component in
  54557. */
  54558. constructor(scene: Scene);
  54559. /**
  54560. * Registers the component in a given scene
  54561. */
  54562. register(): void;
  54563. /**
  54564. * Rebuilds the elements related to this component in case of
  54565. * context lost for instance.
  54566. */
  54567. rebuild(): void;
  54568. /**
  54569. * Disposes the component and the associated ressources
  54570. */
  54571. dispose(): void;
  54572. }
  54573. }
  54574. declare module BABYLON {
  54575. /**
  54576. * A helper for physics simulations
  54577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54578. */
  54579. export class PhysicsHelper {
  54580. private _scene;
  54581. private _physicsEngine;
  54582. /**
  54583. * Initializes the Physics helper
  54584. * @param scene Babylon.js scene
  54585. */
  54586. constructor(scene: Scene);
  54587. /**
  54588. * Applies a radial explosion impulse
  54589. * @param origin the origin of the explosion
  54590. * @param radiusOrEventOptions the radius or the options of radial explosion
  54591. * @param strength the explosion strength
  54592. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54593. * @returns A physics radial explosion event, or null
  54594. */
  54595. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54596. /**
  54597. * Applies a radial explosion force
  54598. * @param origin the origin of the explosion
  54599. * @param radiusOrEventOptions the radius or the options of radial explosion
  54600. * @param strength the explosion strength
  54601. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54602. * @returns A physics radial explosion event, or null
  54603. */
  54604. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54605. /**
  54606. * Creates a gravitational field
  54607. * @param origin the origin of the explosion
  54608. * @param radiusOrEventOptions the radius or the options of radial explosion
  54609. * @param strength the explosion strength
  54610. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54611. * @returns A physics gravitational field event, or null
  54612. */
  54613. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54614. /**
  54615. * Creates a physics updraft event
  54616. * @param origin the origin of the updraft
  54617. * @param radiusOrEventOptions the radius or the options of the updraft
  54618. * @param strength the strength of the updraft
  54619. * @param height the height of the updraft
  54620. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54621. * @returns A physics updraft event, or null
  54622. */
  54623. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54624. /**
  54625. * Creates a physics vortex event
  54626. * @param origin the of the vortex
  54627. * @param radiusOrEventOptions the radius or the options of the vortex
  54628. * @param strength the strength of the vortex
  54629. * @param height the height of the vortex
  54630. * @returns a Physics vortex event, or null
  54631. * A physics vortex event or null
  54632. */
  54633. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54634. }
  54635. /**
  54636. * Represents a physics radial explosion event
  54637. */
  54638. class PhysicsRadialExplosionEvent {
  54639. private _scene;
  54640. private _options;
  54641. private _sphere;
  54642. private _dataFetched;
  54643. /**
  54644. * Initializes a radial explosioin event
  54645. * @param _scene BabylonJS scene
  54646. * @param _options The options for the vortex event
  54647. */
  54648. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54649. /**
  54650. * Returns the data related to the radial explosion event (sphere).
  54651. * @returns The radial explosion event data
  54652. */
  54653. getData(): PhysicsRadialExplosionEventData;
  54654. /**
  54655. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54656. * @param impostor A physics imposter
  54657. * @param origin the origin of the explosion
  54658. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54659. */
  54660. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54661. /**
  54662. * Triggers affecterd impostors callbacks
  54663. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54664. */
  54665. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54666. /**
  54667. * Disposes the sphere.
  54668. * @param force Specifies if the sphere should be disposed by force
  54669. */
  54670. dispose(force?: boolean): void;
  54671. /*** Helpers ***/
  54672. private _prepareSphere;
  54673. private _intersectsWithSphere;
  54674. }
  54675. /**
  54676. * Represents a gravitational field event
  54677. */
  54678. class PhysicsGravitationalFieldEvent {
  54679. private _physicsHelper;
  54680. private _scene;
  54681. private _origin;
  54682. private _options;
  54683. private _tickCallback;
  54684. private _sphere;
  54685. private _dataFetched;
  54686. /**
  54687. * Initializes the physics gravitational field event
  54688. * @param _physicsHelper A physics helper
  54689. * @param _scene BabylonJS scene
  54690. * @param _origin The origin position of the gravitational field event
  54691. * @param _options The options for the vortex event
  54692. */
  54693. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54694. /**
  54695. * Returns the data related to the gravitational field event (sphere).
  54696. * @returns A gravitational field event
  54697. */
  54698. getData(): PhysicsGravitationalFieldEventData;
  54699. /**
  54700. * Enables the gravitational field.
  54701. */
  54702. enable(): void;
  54703. /**
  54704. * Disables the gravitational field.
  54705. */
  54706. disable(): void;
  54707. /**
  54708. * Disposes the sphere.
  54709. * @param force The force to dispose from the gravitational field event
  54710. */
  54711. dispose(force?: boolean): void;
  54712. private _tick;
  54713. }
  54714. /**
  54715. * Represents a physics updraft event
  54716. */
  54717. class PhysicsUpdraftEvent {
  54718. private _scene;
  54719. private _origin;
  54720. private _options;
  54721. private _physicsEngine;
  54722. private _originTop;
  54723. private _originDirection;
  54724. private _tickCallback;
  54725. private _cylinder;
  54726. private _cylinderPosition;
  54727. private _dataFetched;
  54728. /**
  54729. * Initializes the physics updraft event
  54730. * @param _scene BabylonJS scene
  54731. * @param _origin The origin position of the updraft
  54732. * @param _options The options for the updraft event
  54733. */
  54734. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54735. /**
  54736. * Returns the data related to the updraft event (cylinder).
  54737. * @returns A physics updraft event
  54738. */
  54739. getData(): PhysicsUpdraftEventData;
  54740. /**
  54741. * Enables the updraft.
  54742. */
  54743. enable(): void;
  54744. /**
  54745. * Disables the updraft.
  54746. */
  54747. disable(): void;
  54748. /**
  54749. * Disposes the cylinder.
  54750. * @param force Specifies if the updraft should be disposed by force
  54751. */
  54752. dispose(force?: boolean): void;
  54753. private getImpostorHitData;
  54754. private _tick;
  54755. /*** Helpers ***/
  54756. private _prepareCylinder;
  54757. private _intersectsWithCylinder;
  54758. }
  54759. /**
  54760. * Represents a physics vortex event
  54761. */
  54762. class PhysicsVortexEvent {
  54763. private _scene;
  54764. private _origin;
  54765. private _options;
  54766. private _physicsEngine;
  54767. private _originTop;
  54768. private _tickCallback;
  54769. private _cylinder;
  54770. private _cylinderPosition;
  54771. private _dataFetched;
  54772. /**
  54773. * Initializes the physics vortex event
  54774. * @param _scene The BabylonJS scene
  54775. * @param _origin The origin position of the vortex
  54776. * @param _options The options for the vortex event
  54777. */
  54778. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54779. /**
  54780. * Returns the data related to the vortex event (cylinder).
  54781. * @returns The physics vortex event data
  54782. */
  54783. getData(): PhysicsVortexEventData;
  54784. /**
  54785. * Enables the vortex.
  54786. */
  54787. enable(): void;
  54788. /**
  54789. * Disables the cortex.
  54790. */
  54791. disable(): void;
  54792. /**
  54793. * Disposes the sphere.
  54794. * @param force
  54795. */
  54796. dispose(force?: boolean): void;
  54797. private getImpostorHitData;
  54798. private _tick;
  54799. /*** Helpers ***/
  54800. private _prepareCylinder;
  54801. private _intersectsWithCylinder;
  54802. }
  54803. /**
  54804. * Options fot the radial explosion event
  54805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54806. */
  54807. export class PhysicsRadialExplosionEventOptions {
  54808. /**
  54809. * The radius of the sphere for the radial explosion.
  54810. */
  54811. radius: number;
  54812. /**
  54813. * The strenth of the explosion.
  54814. */
  54815. strength: number;
  54816. /**
  54817. * The strenght of the force in correspondence to the distance of the affected object
  54818. */
  54819. falloff: PhysicsRadialImpulseFalloff;
  54820. /**
  54821. * Sphere options for the radial explosion.
  54822. */
  54823. sphere: {
  54824. segments: number;
  54825. diameter: number;
  54826. };
  54827. /**
  54828. * Sphere options for the radial explosion.
  54829. */
  54830. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54831. }
  54832. /**
  54833. * Options fot the updraft event
  54834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54835. */
  54836. export class PhysicsUpdraftEventOptions {
  54837. /**
  54838. * The radius of the cylinder for the vortex
  54839. */
  54840. radius: number;
  54841. /**
  54842. * The strenth of the updraft.
  54843. */
  54844. strength: number;
  54845. /**
  54846. * The height of the cylinder for the updraft.
  54847. */
  54848. height: number;
  54849. /**
  54850. * The mode for the the updraft.
  54851. */
  54852. updraftMode: PhysicsUpdraftMode;
  54853. }
  54854. /**
  54855. * Options fot the vortex event
  54856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54857. */
  54858. export class PhysicsVortexEventOptions {
  54859. /**
  54860. * The radius of the cylinder for the vortex
  54861. */
  54862. radius: number;
  54863. /**
  54864. * The strenth of the vortex.
  54865. */
  54866. strength: number;
  54867. /**
  54868. * The height of the cylinder for the vortex.
  54869. */
  54870. height: number;
  54871. /**
  54872. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54873. */
  54874. centripetalForceThreshold: number;
  54875. /**
  54876. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54877. */
  54878. centripetalForceMultiplier: number;
  54879. /**
  54880. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54881. */
  54882. centrifugalForceMultiplier: number;
  54883. /**
  54884. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54885. */
  54886. updraftForceMultiplier: number;
  54887. }
  54888. /**
  54889. * The strenght of the force in correspondence to the distance of the affected object
  54890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54891. */
  54892. export enum PhysicsRadialImpulseFalloff {
  54893. /** Defines that impulse is constant in strength across it's whole radius */
  54894. Constant = 0,
  54895. /** Defines that impulse gets weaker if it's further from the origin */
  54896. Linear = 1
  54897. }
  54898. /**
  54899. * The strength of the force in correspondence to the distance of the affected object
  54900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54901. */
  54902. export enum PhysicsUpdraftMode {
  54903. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54904. Center = 0,
  54905. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54906. Perpendicular = 1
  54907. }
  54908. /**
  54909. * Interface for a physics hit data
  54910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54911. */
  54912. export interface PhysicsHitData {
  54913. /**
  54914. * The force applied at the contact point
  54915. */
  54916. force: Vector3;
  54917. /**
  54918. * The contact point
  54919. */
  54920. contactPoint: Vector3;
  54921. /**
  54922. * The distance from the origin to the contact point
  54923. */
  54924. distanceFromOrigin: number;
  54925. }
  54926. /**
  54927. * Interface for radial explosion event data
  54928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54929. */
  54930. export interface PhysicsRadialExplosionEventData {
  54931. /**
  54932. * A sphere used for the radial explosion event
  54933. */
  54934. sphere: Mesh;
  54935. }
  54936. /**
  54937. * Interface for gravitational field event data
  54938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54939. */
  54940. export interface PhysicsGravitationalFieldEventData {
  54941. /**
  54942. * A sphere mesh used for the gravitational field event
  54943. */
  54944. sphere: Mesh;
  54945. }
  54946. /**
  54947. * Interface for updraft event data
  54948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54949. */
  54950. export interface PhysicsUpdraftEventData {
  54951. /**
  54952. * A cylinder used for the updraft event
  54953. */
  54954. cylinder: Mesh;
  54955. }
  54956. /**
  54957. * Interface for vortex event data
  54958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54959. */
  54960. export interface PhysicsVortexEventData {
  54961. /**
  54962. * A cylinder used for the vortex event
  54963. */
  54964. cylinder: Mesh;
  54965. }
  54966. /**
  54967. * Interface for an affected physics impostor
  54968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54969. */
  54970. export interface PhysicsAffectedImpostorWithData {
  54971. /**
  54972. * The impostor affected by the effect
  54973. */
  54974. impostor: PhysicsImpostor;
  54975. /**
  54976. * The data about the hit/horce from the explosion
  54977. */
  54978. hitData: PhysicsHitData;
  54979. }
  54980. }
  54981. declare module BABYLON {
  54982. /** @hidden */
  54983. export var blackAndWhitePixelShader: {
  54984. name: string;
  54985. shader: string;
  54986. };
  54987. }
  54988. declare module BABYLON {
  54989. /**
  54990. * Post process used to render in black and white
  54991. */
  54992. export class BlackAndWhitePostProcess extends PostProcess {
  54993. /**
  54994. * Linear about to convert he result to black and white (default: 1)
  54995. */
  54996. degree: number;
  54997. /**
  54998. * Creates a black and white post process
  54999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55000. * @param name The name of the effect.
  55001. * @param options The required width/height ratio to downsize to before computing the render pass.
  55002. * @param camera The camera to apply the render pass to.
  55003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55004. * @param engine The engine which the post process will be applied. (default: current engine)
  55005. * @param reusable If the post process can be reused on the same frame. (default: false)
  55006. */
  55007. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55008. }
  55009. }
  55010. declare module BABYLON {
  55011. /**
  55012. * This represents a set of one or more post processes in Babylon.
  55013. * A post process can be used to apply a shader to a texture after it is rendered.
  55014. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55015. */
  55016. export class PostProcessRenderEffect {
  55017. private _postProcesses;
  55018. private _getPostProcesses;
  55019. private _singleInstance;
  55020. private _cameras;
  55021. private _indicesForCamera;
  55022. /**
  55023. * Name of the effect
  55024. * @hidden
  55025. */
  55026. _name: string;
  55027. /**
  55028. * Instantiates a post process render effect.
  55029. * A post process can be used to apply a shader to a texture after it is rendered.
  55030. * @param engine The engine the effect is tied to
  55031. * @param name The name of the effect
  55032. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55033. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55034. */
  55035. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55036. /**
  55037. * Checks if all the post processes in the effect are supported.
  55038. */
  55039. readonly isSupported: boolean;
  55040. /**
  55041. * Updates the current state of the effect
  55042. * @hidden
  55043. */
  55044. _update(): void;
  55045. /**
  55046. * Attaches the effect on cameras
  55047. * @param cameras The camera to attach to.
  55048. * @hidden
  55049. */
  55050. _attachCameras(cameras: Camera): void;
  55051. /**
  55052. * Attaches the effect on cameras
  55053. * @param cameras The camera to attach to.
  55054. * @hidden
  55055. */
  55056. _attachCameras(cameras: Camera[]): void;
  55057. /**
  55058. * Detaches the effect on cameras
  55059. * @param cameras The camera to detatch from.
  55060. * @hidden
  55061. */
  55062. _detachCameras(cameras: Camera): void;
  55063. /**
  55064. * Detatches the effect on cameras
  55065. * @param cameras The camera to detatch from.
  55066. * @hidden
  55067. */
  55068. _detachCameras(cameras: Camera[]): void;
  55069. /**
  55070. * Enables the effect on given cameras
  55071. * @param cameras The camera to enable.
  55072. * @hidden
  55073. */
  55074. _enable(cameras: Camera): void;
  55075. /**
  55076. * Enables the effect on given cameras
  55077. * @param cameras The camera to enable.
  55078. * @hidden
  55079. */
  55080. _enable(cameras: Nullable<Camera[]>): void;
  55081. /**
  55082. * Disables the effect on the given cameras
  55083. * @param cameras The camera to disable.
  55084. * @hidden
  55085. */
  55086. _disable(cameras: Camera): void;
  55087. /**
  55088. * Disables the effect on the given cameras
  55089. * @param cameras The camera to disable.
  55090. * @hidden
  55091. */
  55092. _disable(cameras: Nullable<Camera[]>): void;
  55093. /**
  55094. * Gets a list of the post processes contained in the effect.
  55095. * @param camera The camera to get the post processes on.
  55096. * @returns The list of the post processes in the effect.
  55097. */
  55098. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55099. }
  55100. }
  55101. declare module BABYLON {
  55102. /** @hidden */
  55103. export var extractHighlightsPixelShader: {
  55104. name: string;
  55105. shader: string;
  55106. };
  55107. }
  55108. declare module BABYLON {
  55109. /**
  55110. * 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.
  55111. */
  55112. export class ExtractHighlightsPostProcess extends PostProcess {
  55113. /**
  55114. * The luminance threshold, pixels below this value will be set to black.
  55115. */
  55116. threshold: number;
  55117. /** @hidden */
  55118. _exposure: number;
  55119. /**
  55120. * Post process which has the input texture to be used when performing highlight extraction
  55121. * @hidden
  55122. */
  55123. _inputPostProcess: Nullable<PostProcess>;
  55124. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55125. }
  55126. }
  55127. declare module BABYLON {
  55128. /** @hidden */
  55129. export var bloomMergePixelShader: {
  55130. name: string;
  55131. shader: string;
  55132. };
  55133. }
  55134. declare module BABYLON {
  55135. /**
  55136. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55137. */
  55138. export class BloomMergePostProcess extends PostProcess {
  55139. /** Weight of the bloom to be added to the original input. */
  55140. weight: number;
  55141. /**
  55142. * Creates a new instance of @see BloomMergePostProcess
  55143. * @param name The name of the effect.
  55144. * @param originalFromInput Post process which's input will be used for the merge.
  55145. * @param blurred Blurred highlights post process which's output will be used.
  55146. * @param weight Weight of the bloom to be added to the original input.
  55147. * @param options The required width/height ratio to downsize to before computing the render pass.
  55148. * @param camera The camera to apply the render pass to.
  55149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55150. * @param engine The engine which the post process will be applied. (default: current engine)
  55151. * @param reusable If the post process can be reused on the same frame. (default: false)
  55152. * @param textureType Type of textures used when performing the post process. (default: 0)
  55153. * @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)
  55154. */
  55155. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55156. /** Weight of the bloom to be added to the original input. */
  55157. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55158. }
  55159. }
  55160. declare module BABYLON {
  55161. /**
  55162. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55163. */
  55164. export class BloomEffect extends PostProcessRenderEffect {
  55165. private bloomScale;
  55166. /**
  55167. * @hidden Internal
  55168. */
  55169. _effects: Array<PostProcess>;
  55170. /**
  55171. * @hidden Internal
  55172. */
  55173. _downscale: ExtractHighlightsPostProcess;
  55174. private _blurX;
  55175. private _blurY;
  55176. private _merge;
  55177. /**
  55178. * The luminance threshold to find bright areas of the image to bloom.
  55179. */
  55180. threshold: number;
  55181. /**
  55182. * The strength of the bloom.
  55183. */
  55184. weight: number;
  55185. /**
  55186. * Specifies the size of the bloom blur kernel, relative to the final output size
  55187. */
  55188. kernel: number;
  55189. /**
  55190. * Creates a new instance of @see BloomEffect
  55191. * @param scene The scene the effect belongs to.
  55192. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55193. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55194. * @param bloomWeight The the strength of bloom.
  55195. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55196. * @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)
  55197. */
  55198. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55199. /**
  55200. * Disposes each of the internal effects for a given camera.
  55201. * @param camera The camera to dispose the effect on.
  55202. */
  55203. disposeEffects(camera: Camera): void;
  55204. /**
  55205. * @hidden Internal
  55206. */
  55207. _updateEffects(): void;
  55208. /**
  55209. * Internal
  55210. * @returns if all the contained post processes are ready.
  55211. * @hidden
  55212. */
  55213. _isReady(): boolean;
  55214. }
  55215. }
  55216. declare module BABYLON {
  55217. /** @hidden */
  55218. export var chromaticAberrationPixelShader: {
  55219. name: string;
  55220. shader: string;
  55221. };
  55222. }
  55223. declare module BABYLON {
  55224. /**
  55225. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55226. */
  55227. export class ChromaticAberrationPostProcess extends PostProcess {
  55228. /**
  55229. * The amount of seperation of rgb channels (default: 30)
  55230. */
  55231. aberrationAmount: number;
  55232. /**
  55233. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55234. */
  55235. radialIntensity: number;
  55236. /**
  55237. * 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))
  55238. */
  55239. direction: Vector2;
  55240. /**
  55241. * 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))
  55242. */
  55243. centerPosition: Vector2;
  55244. /**
  55245. * Creates a new instance ChromaticAberrationPostProcess
  55246. * @param name The name of the effect.
  55247. * @param screenWidth The width of the screen to apply the effect on.
  55248. * @param screenHeight The height of the screen to apply the effect on.
  55249. * @param options The required width/height ratio to downsize to before computing the render pass.
  55250. * @param camera The camera to apply the render pass to.
  55251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55252. * @param engine The engine which the post process will be applied. (default: current engine)
  55253. * @param reusable If the post process can be reused on the same frame. (default: false)
  55254. * @param textureType Type of textures used when performing the post process. (default: 0)
  55255. * @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)
  55256. */
  55257. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55258. }
  55259. }
  55260. declare module BABYLON {
  55261. /** @hidden */
  55262. export var circleOfConfusionPixelShader: {
  55263. name: string;
  55264. shader: string;
  55265. };
  55266. }
  55267. declare module BABYLON {
  55268. /**
  55269. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55270. */
  55271. export class CircleOfConfusionPostProcess extends PostProcess {
  55272. /**
  55273. * 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.
  55274. */
  55275. lensSize: number;
  55276. /**
  55277. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55278. */
  55279. fStop: number;
  55280. /**
  55281. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55282. */
  55283. focusDistance: number;
  55284. /**
  55285. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55286. */
  55287. focalLength: number;
  55288. private _depthTexture;
  55289. /**
  55290. * Creates a new instance CircleOfConfusionPostProcess
  55291. * @param name The name of the effect.
  55292. * @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.
  55293. * @param options The required width/height ratio to downsize to before computing the render pass.
  55294. * @param camera The camera to apply the render pass to.
  55295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55296. * @param engine The engine which the post process will be applied. (default: current engine)
  55297. * @param reusable If the post process can be reused on the same frame. (default: false)
  55298. * @param textureType Type of textures used when performing the post process. (default: 0)
  55299. * @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)
  55300. */
  55301. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55302. /**
  55303. * 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.
  55304. */
  55305. depthTexture: RenderTargetTexture;
  55306. }
  55307. }
  55308. declare module BABYLON {
  55309. /** @hidden */
  55310. export var colorCorrectionPixelShader: {
  55311. name: string;
  55312. shader: string;
  55313. };
  55314. }
  55315. declare module BABYLON {
  55316. /**
  55317. *
  55318. * This post-process allows the modification of rendered colors by using
  55319. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55320. *
  55321. * The object needs to be provided an url to a texture containing the color
  55322. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55323. * Use an image editing software to tweak the LUT to match your needs.
  55324. *
  55325. * For an example of a color LUT, see here:
  55326. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55327. * For explanations on color grading, see here:
  55328. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55329. *
  55330. */
  55331. export class ColorCorrectionPostProcess extends PostProcess {
  55332. private _colorTableTexture;
  55333. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55334. }
  55335. }
  55336. declare module BABYLON {
  55337. /** @hidden */
  55338. export var convolutionPixelShader: {
  55339. name: string;
  55340. shader: string;
  55341. };
  55342. }
  55343. declare module BABYLON {
  55344. /**
  55345. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55346. * input texture to perform effects such as edge detection or sharpening
  55347. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55348. */
  55349. export class ConvolutionPostProcess extends PostProcess {
  55350. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55351. kernel: number[];
  55352. /**
  55353. * Creates a new instance ConvolutionPostProcess
  55354. * @param name The name of the effect.
  55355. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55356. * @param options The required width/height ratio to downsize to before computing the render pass.
  55357. * @param camera The camera to apply the render pass to.
  55358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55359. * @param engine The engine which the post process will be applied. (default: current engine)
  55360. * @param reusable If the post process can be reused on the same frame. (default: false)
  55361. * @param textureType Type of textures used when performing the post process. (default: 0)
  55362. */
  55363. constructor(name: string,
  55364. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55365. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55366. /**
  55367. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55368. */
  55369. static EdgeDetect0Kernel: number[];
  55370. /**
  55371. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55372. */
  55373. static EdgeDetect1Kernel: number[];
  55374. /**
  55375. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55376. */
  55377. static EdgeDetect2Kernel: number[];
  55378. /**
  55379. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55380. */
  55381. static SharpenKernel: number[];
  55382. /**
  55383. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55384. */
  55385. static EmbossKernel: number[];
  55386. /**
  55387. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55388. */
  55389. static GaussianKernel: number[];
  55390. }
  55391. }
  55392. declare module BABYLON {
  55393. /**
  55394. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55395. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55396. * based on samples that have a large difference in distance than the center pixel.
  55397. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55398. */
  55399. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55400. direction: Vector2;
  55401. /**
  55402. * Creates a new instance CircleOfConfusionPostProcess
  55403. * @param name The name of the effect.
  55404. * @param scene The scene the effect belongs to.
  55405. * @param direction The direction the blur should be applied.
  55406. * @param kernel The size of the kernel used to blur.
  55407. * @param options The required width/height ratio to downsize to before computing the render pass.
  55408. * @param camera The camera to apply the render pass to.
  55409. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55410. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55412. * @param engine The engine which the post process will be applied. (default: current engine)
  55413. * @param reusable If the post process can be reused on the same frame. (default: false)
  55414. * @param textureType Type of textures used when performing the post process. (default: 0)
  55415. * @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)
  55416. */
  55417. 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);
  55418. }
  55419. }
  55420. declare module BABYLON {
  55421. /** @hidden */
  55422. export var depthOfFieldMergePixelShader: {
  55423. name: string;
  55424. shader: string;
  55425. };
  55426. }
  55427. declare module BABYLON {
  55428. /**
  55429. * Options to be set when merging outputs from the default pipeline.
  55430. */
  55431. export class DepthOfFieldMergePostProcessOptions {
  55432. /**
  55433. * The original image to merge on top of
  55434. */
  55435. originalFromInput: PostProcess;
  55436. /**
  55437. * Parameters to perform the merge of the depth of field effect
  55438. */
  55439. depthOfField?: {
  55440. circleOfConfusion: PostProcess;
  55441. blurSteps: Array<PostProcess>;
  55442. };
  55443. /**
  55444. * Parameters to perform the merge of bloom effect
  55445. */
  55446. bloom?: {
  55447. blurred: PostProcess;
  55448. weight: number;
  55449. };
  55450. }
  55451. /**
  55452. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55453. */
  55454. export class DepthOfFieldMergePostProcess extends PostProcess {
  55455. private blurSteps;
  55456. /**
  55457. * Creates a new instance of DepthOfFieldMergePostProcess
  55458. * @param name The name of the effect.
  55459. * @param originalFromInput Post process which's input will be used for the merge.
  55460. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55461. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55462. * @param options The required width/height ratio to downsize to before computing the render pass.
  55463. * @param camera The camera to apply the render pass to.
  55464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55465. * @param engine The engine which the post process will be applied. (default: current engine)
  55466. * @param reusable If the post process can be reused on the same frame. (default: false)
  55467. * @param textureType Type of textures used when performing the post process. (default: 0)
  55468. * @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)
  55469. */
  55470. 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);
  55471. /**
  55472. * Updates the effect with the current post process compile time values and recompiles the shader.
  55473. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55474. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55475. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55476. * @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
  55477. * @param onCompiled Called when the shader has been compiled.
  55478. * @param onError Called if there is an error when compiling a shader.
  55479. */
  55480. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55481. }
  55482. }
  55483. declare module BABYLON {
  55484. /**
  55485. * Specifies the level of max blur that should be applied when using the depth of field effect
  55486. */
  55487. export enum DepthOfFieldEffectBlurLevel {
  55488. /**
  55489. * Subtle blur
  55490. */
  55491. Low = 0,
  55492. /**
  55493. * Medium blur
  55494. */
  55495. Medium = 1,
  55496. /**
  55497. * Large blur
  55498. */
  55499. High = 2
  55500. }
  55501. /**
  55502. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55503. */
  55504. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55505. private _circleOfConfusion;
  55506. /**
  55507. * @hidden Internal, blurs from high to low
  55508. */
  55509. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55510. private _depthOfFieldBlurY;
  55511. private _dofMerge;
  55512. /**
  55513. * @hidden Internal post processes in depth of field effect
  55514. */
  55515. _effects: Array<PostProcess>;
  55516. /**
  55517. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55518. */
  55519. focalLength: number;
  55520. /**
  55521. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55522. */
  55523. fStop: number;
  55524. /**
  55525. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55526. */
  55527. focusDistance: number;
  55528. /**
  55529. * 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.
  55530. */
  55531. lensSize: number;
  55532. /**
  55533. * Creates a new instance DepthOfFieldEffect
  55534. * @param scene The scene the effect belongs to.
  55535. * @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.
  55536. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55537. * @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)
  55538. */
  55539. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55540. /**
  55541. * Get the current class name of the current effet
  55542. * @returns "DepthOfFieldEffect"
  55543. */
  55544. getClassName(): string;
  55545. /**
  55546. * 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.
  55547. */
  55548. depthTexture: RenderTargetTexture;
  55549. /**
  55550. * Disposes each of the internal effects for a given camera.
  55551. * @param camera The camera to dispose the effect on.
  55552. */
  55553. disposeEffects(camera: Camera): void;
  55554. /**
  55555. * @hidden Internal
  55556. */
  55557. _updateEffects(): void;
  55558. /**
  55559. * Internal
  55560. * @returns if all the contained post processes are ready.
  55561. * @hidden
  55562. */
  55563. _isReady(): boolean;
  55564. }
  55565. }
  55566. declare module BABYLON {
  55567. /** @hidden */
  55568. export var displayPassPixelShader: {
  55569. name: string;
  55570. shader: string;
  55571. };
  55572. }
  55573. declare module BABYLON {
  55574. /**
  55575. * DisplayPassPostProcess which produces an output the same as it's input
  55576. */
  55577. export class DisplayPassPostProcess extends PostProcess {
  55578. /**
  55579. * Creates the DisplayPassPostProcess
  55580. * @param name The name of the effect.
  55581. * @param options The required width/height ratio to downsize to before computing the render pass.
  55582. * @param camera The camera to apply the render pass to.
  55583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55584. * @param engine The engine which the post process will be applied. (default: current engine)
  55585. * @param reusable If the post process can be reused on the same frame. (default: false)
  55586. */
  55587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55588. }
  55589. }
  55590. declare module BABYLON {
  55591. /** @hidden */
  55592. export var filterPixelShader: {
  55593. name: string;
  55594. shader: string;
  55595. };
  55596. }
  55597. declare module BABYLON {
  55598. /**
  55599. * Applies a kernel filter to the image
  55600. */
  55601. export class FilterPostProcess extends PostProcess {
  55602. /** The matrix to be applied to the image */
  55603. kernelMatrix: Matrix;
  55604. /**
  55605. *
  55606. * @param name The name of the effect.
  55607. * @param kernelMatrix The matrix to be applied to the image
  55608. * @param options The required width/height ratio to downsize to before computing the render pass.
  55609. * @param camera The camera to apply the render pass to.
  55610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55611. * @param engine The engine which the post process will be applied. (default: current engine)
  55612. * @param reusable If the post process can be reused on the same frame. (default: false)
  55613. */
  55614. constructor(name: string,
  55615. /** The matrix to be applied to the image */
  55616. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55617. }
  55618. }
  55619. declare module BABYLON {
  55620. /** @hidden */
  55621. export var fxaaPixelShader: {
  55622. name: string;
  55623. shader: string;
  55624. };
  55625. }
  55626. declare module BABYLON {
  55627. /** @hidden */
  55628. export var fxaaVertexShader: {
  55629. name: string;
  55630. shader: string;
  55631. };
  55632. }
  55633. declare module BABYLON {
  55634. /**
  55635. * Fxaa post process
  55636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55637. */
  55638. export class FxaaPostProcess extends PostProcess {
  55639. /** @hidden */
  55640. texelWidth: number;
  55641. /** @hidden */
  55642. texelHeight: number;
  55643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55644. private _getDefines;
  55645. }
  55646. }
  55647. declare module BABYLON {
  55648. /** @hidden */
  55649. export var grainPixelShader: {
  55650. name: string;
  55651. shader: string;
  55652. };
  55653. }
  55654. declare module BABYLON {
  55655. /**
  55656. * The GrainPostProcess adds noise to the image at mid luminance levels
  55657. */
  55658. export class GrainPostProcess extends PostProcess {
  55659. /**
  55660. * The intensity of the grain added (default: 30)
  55661. */
  55662. intensity: number;
  55663. /**
  55664. * If the grain should be randomized on every frame
  55665. */
  55666. animated: boolean;
  55667. /**
  55668. * Creates a new instance of @see GrainPostProcess
  55669. * @param name The name of the effect.
  55670. * @param options The required width/height ratio to downsize to before computing the render pass.
  55671. * @param camera The camera to apply the render pass to.
  55672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55673. * @param engine The engine which the post process will be applied. (default: current engine)
  55674. * @param reusable If the post process can be reused on the same frame. (default: false)
  55675. * @param textureType Type of textures used when performing the post process. (default: 0)
  55676. * @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)
  55677. */
  55678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55679. }
  55680. }
  55681. declare module BABYLON {
  55682. /** @hidden */
  55683. export var highlightsPixelShader: {
  55684. name: string;
  55685. shader: string;
  55686. };
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * Extracts highlights from the image
  55691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55692. */
  55693. export class HighlightsPostProcess extends PostProcess {
  55694. /**
  55695. * Extracts highlights from the image
  55696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55697. * @param name The name of the effect.
  55698. * @param options The required width/height ratio to downsize to before computing the render pass.
  55699. * @param camera The camera to apply the render pass to.
  55700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55701. * @param engine The engine which the post process will be applied. (default: current engine)
  55702. * @param reusable If the post process can be reused on the same frame. (default: false)
  55703. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55704. */
  55705. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55706. }
  55707. }
  55708. declare module BABYLON {
  55709. /** @hidden */
  55710. export var mrtFragmentDeclaration: {
  55711. name: string;
  55712. shader: string;
  55713. };
  55714. }
  55715. declare module BABYLON {
  55716. /** @hidden */
  55717. export var geometryPixelShader: {
  55718. name: string;
  55719. shader: string;
  55720. };
  55721. }
  55722. declare module BABYLON {
  55723. /** @hidden */
  55724. export var geometryVertexShader: {
  55725. name: string;
  55726. shader: string;
  55727. };
  55728. }
  55729. declare module BABYLON {
  55730. /** @hidden */
  55731. interface ISavedTransformationMatrix {
  55732. world: Matrix;
  55733. viewProjection: Matrix;
  55734. }
  55735. /**
  55736. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55737. */
  55738. export class GeometryBufferRenderer {
  55739. /**
  55740. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55741. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55742. */
  55743. static readonly POSITION_TEXTURE_TYPE: number;
  55744. /**
  55745. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55746. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55747. */
  55748. static readonly VELOCITY_TEXTURE_TYPE: number;
  55749. /**
  55750. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55751. * in order to compute objects velocities when enableVelocity is set to "true"
  55752. * @hidden
  55753. */
  55754. _previousTransformationMatrices: {
  55755. [index: number]: ISavedTransformationMatrix;
  55756. };
  55757. /**
  55758. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55759. * in order to compute objects velocities when enableVelocity is set to "true"
  55760. * @hidden
  55761. */
  55762. _previousBonesTransformationMatrices: {
  55763. [index: number]: Float32Array;
  55764. };
  55765. /**
  55766. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55767. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55768. */
  55769. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55770. private _scene;
  55771. private _multiRenderTarget;
  55772. private _ratio;
  55773. private _enablePosition;
  55774. private _enableVelocity;
  55775. private _positionIndex;
  55776. private _velocityIndex;
  55777. protected _effect: Effect;
  55778. protected _cachedDefines: string;
  55779. /**
  55780. * Set the render list (meshes to be rendered) used in the G buffer.
  55781. */
  55782. renderList: Mesh[];
  55783. /**
  55784. * Gets wether or not G buffer are supported by the running hardware.
  55785. * This requires draw buffer supports
  55786. */
  55787. readonly isSupported: boolean;
  55788. /**
  55789. * Returns the index of the given texture type in the G-Buffer textures array
  55790. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55791. * @returns the index of the given texture type in the G-Buffer textures array
  55792. */
  55793. getTextureIndex(textureType: number): number;
  55794. /**
  55795. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55796. */
  55797. /**
  55798. * Sets whether or not objects positions are enabled for the G buffer.
  55799. */
  55800. enablePosition: boolean;
  55801. /**
  55802. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55803. */
  55804. /**
  55805. * Sets wether or not objects velocities are enabled for the G buffer.
  55806. */
  55807. enableVelocity: boolean;
  55808. /**
  55809. * Gets the scene associated with the buffer.
  55810. */
  55811. readonly scene: Scene;
  55812. /**
  55813. * Gets the ratio used by the buffer during its creation.
  55814. * How big is the buffer related to the main canvas.
  55815. */
  55816. readonly ratio: number;
  55817. /** @hidden */
  55818. static _SceneComponentInitialization: (scene: Scene) => void;
  55819. /**
  55820. * Creates a new G Buffer for the scene
  55821. * @param scene The scene the buffer belongs to
  55822. * @param ratio How big is the buffer related to the main canvas.
  55823. */
  55824. constructor(scene: Scene, ratio?: number);
  55825. /**
  55826. * Checks wether everything is ready to render a submesh to the G buffer.
  55827. * @param subMesh the submesh to check readiness for
  55828. * @param useInstances is the mesh drawn using instance or not
  55829. * @returns true if ready otherwise false
  55830. */
  55831. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55832. /**
  55833. * Gets the current underlying G Buffer.
  55834. * @returns the buffer
  55835. */
  55836. getGBuffer(): MultiRenderTarget;
  55837. /**
  55838. * Gets the number of samples used to render the buffer (anti aliasing).
  55839. */
  55840. /**
  55841. * Sets the number of samples used to render the buffer (anti aliasing).
  55842. */
  55843. samples: number;
  55844. /**
  55845. * Disposes the renderer and frees up associated resources.
  55846. */
  55847. dispose(): void;
  55848. protected _createRenderTargets(): void;
  55849. private _copyBonesTransformationMatrices;
  55850. }
  55851. }
  55852. declare module BABYLON {
  55853. interface Scene {
  55854. /** @hidden (Backing field) */
  55855. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55856. /**
  55857. * Gets or Sets the current geometry buffer associated to the scene.
  55858. */
  55859. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55860. /**
  55861. * Enables a GeometryBufferRender and associates it with the scene
  55862. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55863. * @returns the GeometryBufferRenderer
  55864. */
  55865. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55866. /**
  55867. * Disables the GeometryBufferRender associated with the scene
  55868. */
  55869. disableGeometryBufferRenderer(): void;
  55870. }
  55871. /**
  55872. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55873. * in several rendering techniques.
  55874. */
  55875. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55876. /**
  55877. * The component name helpful to identify the component in the list of scene components.
  55878. */
  55879. readonly name: string;
  55880. /**
  55881. * The scene the component belongs to.
  55882. */
  55883. scene: Scene;
  55884. /**
  55885. * Creates a new instance of the component for the given scene
  55886. * @param scene Defines the scene to register the component in
  55887. */
  55888. constructor(scene: Scene);
  55889. /**
  55890. * Registers the component in a given scene
  55891. */
  55892. register(): void;
  55893. /**
  55894. * Rebuilds the elements related to this component in case of
  55895. * context lost for instance.
  55896. */
  55897. rebuild(): void;
  55898. /**
  55899. * Disposes the component and the associated ressources
  55900. */
  55901. dispose(): void;
  55902. private _gatherRenderTargets;
  55903. }
  55904. }
  55905. declare module BABYLON {
  55906. /** @hidden */
  55907. export var motionBlurPixelShader: {
  55908. name: string;
  55909. shader: string;
  55910. };
  55911. }
  55912. declare module BABYLON {
  55913. /**
  55914. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55915. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55916. * As an example, all you have to do is to create the post-process:
  55917. * var mb = new BABYLON.MotionBlurPostProcess(
  55918. * 'mb', // The name of the effect.
  55919. * scene, // The scene containing the objects to blur according to their velocity.
  55920. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55921. * camera // The camera to apply the render pass to.
  55922. * );
  55923. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55924. */
  55925. export class MotionBlurPostProcess extends PostProcess {
  55926. /**
  55927. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55928. */
  55929. motionStrength: number;
  55930. /**
  55931. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55932. */
  55933. /**
  55934. * Sets the number of iterations to be used for motion blur quality
  55935. */
  55936. motionBlurSamples: number;
  55937. private _motionBlurSamples;
  55938. private _geometryBufferRenderer;
  55939. /**
  55940. * Creates a new instance MotionBlurPostProcess
  55941. * @param name The name of the effect.
  55942. * @param scene The scene containing the objects to blur according to their velocity.
  55943. * @param options The required width/height ratio to downsize to before computing the render pass.
  55944. * @param camera The camera to apply the render pass to.
  55945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55946. * @param engine The engine which the post process will be applied. (default: current engine)
  55947. * @param reusable If the post process can be reused on the same frame. (default: false)
  55948. * @param textureType Type of textures used when performing the post process. (default: 0)
  55949. * @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)
  55950. */
  55951. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55952. /**
  55953. * Excludes the given skinned mesh from computing bones velocities.
  55954. * 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.
  55955. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55956. */
  55957. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55958. /**
  55959. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55960. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55961. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55962. */
  55963. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55964. /**
  55965. * Disposes the post process.
  55966. * @param camera The camera to dispose the post process on.
  55967. */
  55968. dispose(camera?: Camera): void;
  55969. }
  55970. }
  55971. declare module BABYLON {
  55972. /** @hidden */
  55973. export var refractionPixelShader: {
  55974. name: string;
  55975. shader: string;
  55976. };
  55977. }
  55978. declare module BABYLON {
  55979. /**
  55980. * Post process which applies a refractin texture
  55981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55982. */
  55983. export class RefractionPostProcess extends PostProcess {
  55984. /** the base color of the refraction (used to taint the rendering) */
  55985. color: Color3;
  55986. /** simulated refraction depth */
  55987. depth: number;
  55988. /** the coefficient of the base color (0 to remove base color tainting) */
  55989. colorLevel: number;
  55990. private _refTexture;
  55991. private _ownRefractionTexture;
  55992. /**
  55993. * Gets or sets the refraction texture
  55994. * Please note that you are responsible for disposing the texture if you set it manually
  55995. */
  55996. refractionTexture: Texture;
  55997. /**
  55998. * Initializes the RefractionPostProcess
  55999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56000. * @param name The name of the effect.
  56001. * @param refractionTextureUrl Url of the refraction texture to use
  56002. * @param color the base color of the refraction (used to taint the rendering)
  56003. * @param depth simulated refraction depth
  56004. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56005. * @param camera The camera to apply the render pass to.
  56006. * @param options The required width/height ratio to downsize to before computing the render pass.
  56007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56008. * @param engine The engine which the post process will be applied. (default: current engine)
  56009. * @param reusable If the post process can be reused on the same frame. (default: false)
  56010. */
  56011. constructor(name: string, refractionTextureUrl: string,
  56012. /** the base color of the refraction (used to taint the rendering) */
  56013. color: Color3,
  56014. /** simulated refraction depth */
  56015. depth: number,
  56016. /** the coefficient of the base color (0 to remove base color tainting) */
  56017. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56018. /**
  56019. * Disposes of the post process
  56020. * @param camera Camera to dispose post process on
  56021. */
  56022. dispose(camera: Camera): void;
  56023. }
  56024. }
  56025. declare module BABYLON {
  56026. /** @hidden */
  56027. export var sharpenPixelShader: {
  56028. name: string;
  56029. shader: string;
  56030. };
  56031. }
  56032. declare module BABYLON {
  56033. /**
  56034. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56035. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56036. */
  56037. export class SharpenPostProcess extends PostProcess {
  56038. /**
  56039. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56040. */
  56041. colorAmount: number;
  56042. /**
  56043. * How much sharpness should be applied (default: 0.3)
  56044. */
  56045. edgeAmount: number;
  56046. /**
  56047. * Creates a new instance ConvolutionPostProcess
  56048. * @param name The name of the effect.
  56049. * @param options The required width/height ratio to downsize to before computing the render pass.
  56050. * @param camera The camera to apply the render pass to.
  56051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56052. * @param engine The engine which the post process will be applied. (default: current engine)
  56053. * @param reusable If the post process can be reused on the same frame. (default: false)
  56054. * @param textureType Type of textures used when performing the post process. (default: 0)
  56055. * @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)
  56056. */
  56057. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56058. }
  56059. }
  56060. declare module BABYLON {
  56061. /**
  56062. * PostProcessRenderPipeline
  56063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56064. */
  56065. export class PostProcessRenderPipeline {
  56066. private engine;
  56067. private _renderEffects;
  56068. private _renderEffectsForIsolatedPass;
  56069. /**
  56070. * List of inspectable custom properties (used by the Inspector)
  56071. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56072. */
  56073. inspectableCustomProperties: IInspectable[];
  56074. /**
  56075. * @hidden
  56076. */
  56077. protected _cameras: Camera[];
  56078. /** @hidden */
  56079. _name: string;
  56080. /**
  56081. * Gets pipeline name
  56082. */
  56083. readonly name: string;
  56084. /**
  56085. * Initializes a PostProcessRenderPipeline
  56086. * @param engine engine to add the pipeline to
  56087. * @param name name of the pipeline
  56088. */
  56089. constructor(engine: Engine, name: string);
  56090. /**
  56091. * Gets the class name
  56092. * @returns "PostProcessRenderPipeline"
  56093. */
  56094. getClassName(): string;
  56095. /**
  56096. * If all the render effects in the pipeline are supported
  56097. */
  56098. readonly isSupported: boolean;
  56099. /**
  56100. * Adds an effect to the pipeline
  56101. * @param renderEffect the effect to add
  56102. */
  56103. addEffect(renderEffect: PostProcessRenderEffect): void;
  56104. /** @hidden */
  56105. _rebuild(): void;
  56106. /** @hidden */
  56107. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56108. /** @hidden */
  56109. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56110. /** @hidden */
  56111. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56112. /** @hidden */
  56113. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56114. /** @hidden */
  56115. _attachCameras(cameras: Camera, unique: boolean): void;
  56116. /** @hidden */
  56117. _attachCameras(cameras: Camera[], unique: boolean): void;
  56118. /** @hidden */
  56119. _detachCameras(cameras: Camera): void;
  56120. /** @hidden */
  56121. _detachCameras(cameras: Nullable<Camera[]>): void;
  56122. /** @hidden */
  56123. _update(): void;
  56124. /** @hidden */
  56125. _reset(): void;
  56126. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56127. /**
  56128. * Disposes of the pipeline
  56129. */
  56130. dispose(): void;
  56131. }
  56132. }
  56133. declare module BABYLON {
  56134. /**
  56135. * PostProcessRenderPipelineManager class
  56136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56137. */
  56138. export class PostProcessRenderPipelineManager {
  56139. private _renderPipelines;
  56140. /**
  56141. * Initializes a PostProcessRenderPipelineManager
  56142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56143. */
  56144. constructor();
  56145. /**
  56146. * Gets the list of supported render pipelines
  56147. */
  56148. readonly supportedPipelines: PostProcessRenderPipeline[];
  56149. /**
  56150. * Adds a pipeline to the manager
  56151. * @param renderPipeline The pipeline to add
  56152. */
  56153. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56154. /**
  56155. * Attaches a camera to the pipeline
  56156. * @param renderPipelineName The name of the pipeline to attach to
  56157. * @param cameras the camera to attach
  56158. * @param unique if the camera can be attached multiple times to the pipeline
  56159. */
  56160. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56161. /**
  56162. * Detaches a camera from the pipeline
  56163. * @param renderPipelineName The name of the pipeline to detach from
  56164. * @param cameras the camera to detach
  56165. */
  56166. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56167. /**
  56168. * Enables an effect by name on a pipeline
  56169. * @param renderPipelineName the name of the pipeline to enable the effect in
  56170. * @param renderEffectName the name of the effect to enable
  56171. * @param cameras the cameras that the effect should be enabled on
  56172. */
  56173. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56174. /**
  56175. * Disables an effect by name on a pipeline
  56176. * @param renderPipelineName the name of the pipeline to disable the effect in
  56177. * @param renderEffectName the name of the effect to disable
  56178. * @param cameras the cameras that the effect should be disabled on
  56179. */
  56180. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56181. /**
  56182. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56183. */
  56184. update(): void;
  56185. /** @hidden */
  56186. _rebuild(): void;
  56187. /**
  56188. * Disposes of the manager and pipelines
  56189. */
  56190. dispose(): void;
  56191. }
  56192. }
  56193. declare module BABYLON {
  56194. interface Scene {
  56195. /** @hidden (Backing field) */
  56196. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56197. /**
  56198. * Gets the postprocess render pipeline manager
  56199. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56200. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56201. */
  56202. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56203. }
  56204. /**
  56205. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56206. */
  56207. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56208. /**
  56209. * The component name helpfull to identify the component in the list of scene components.
  56210. */
  56211. readonly name: string;
  56212. /**
  56213. * The scene the component belongs to.
  56214. */
  56215. scene: Scene;
  56216. /**
  56217. * Creates a new instance of the component for the given scene
  56218. * @param scene Defines the scene to register the component in
  56219. */
  56220. constructor(scene: Scene);
  56221. /**
  56222. * Registers the component in a given scene
  56223. */
  56224. register(): void;
  56225. /**
  56226. * Rebuilds the elements related to this component in case of
  56227. * context lost for instance.
  56228. */
  56229. rebuild(): void;
  56230. /**
  56231. * Disposes the component and the associated ressources
  56232. */
  56233. dispose(): void;
  56234. private _gatherRenderTargets;
  56235. }
  56236. }
  56237. declare module BABYLON {
  56238. /**
  56239. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56240. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56241. */
  56242. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56243. private _scene;
  56244. private _camerasToBeAttached;
  56245. /**
  56246. * ID of the sharpen post process,
  56247. */
  56248. private readonly SharpenPostProcessId;
  56249. /**
  56250. * @ignore
  56251. * ID of the image processing post process;
  56252. */
  56253. readonly ImageProcessingPostProcessId: string;
  56254. /**
  56255. * @ignore
  56256. * ID of the Fast Approximate Anti-Aliasing post process;
  56257. */
  56258. readonly FxaaPostProcessId: string;
  56259. /**
  56260. * ID of the chromatic aberration post process,
  56261. */
  56262. private readonly ChromaticAberrationPostProcessId;
  56263. /**
  56264. * ID of the grain post process
  56265. */
  56266. private readonly GrainPostProcessId;
  56267. /**
  56268. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56269. */
  56270. sharpen: SharpenPostProcess;
  56271. private _sharpenEffect;
  56272. private bloom;
  56273. /**
  56274. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56275. */
  56276. depthOfField: DepthOfFieldEffect;
  56277. /**
  56278. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56279. */
  56280. fxaa: FxaaPostProcess;
  56281. /**
  56282. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56283. */
  56284. imageProcessing: ImageProcessingPostProcess;
  56285. /**
  56286. * Chromatic aberration post process which will shift rgb colors in the image
  56287. */
  56288. chromaticAberration: ChromaticAberrationPostProcess;
  56289. private _chromaticAberrationEffect;
  56290. /**
  56291. * Grain post process which add noise to the image
  56292. */
  56293. grain: GrainPostProcess;
  56294. private _grainEffect;
  56295. /**
  56296. * Glow post process which adds a glow to emissive areas of the image
  56297. */
  56298. private _glowLayer;
  56299. /**
  56300. * Animations which can be used to tweak settings over a period of time
  56301. */
  56302. animations: Animation[];
  56303. private _imageProcessingConfigurationObserver;
  56304. private _sharpenEnabled;
  56305. private _bloomEnabled;
  56306. private _depthOfFieldEnabled;
  56307. private _depthOfFieldBlurLevel;
  56308. private _fxaaEnabled;
  56309. private _imageProcessingEnabled;
  56310. private _defaultPipelineTextureType;
  56311. private _bloomScale;
  56312. private _chromaticAberrationEnabled;
  56313. private _grainEnabled;
  56314. private _buildAllowed;
  56315. /**
  56316. * Gets active scene
  56317. */
  56318. readonly scene: Scene;
  56319. /**
  56320. * Enable or disable the sharpen process from the pipeline
  56321. */
  56322. sharpenEnabled: boolean;
  56323. private _resizeObserver;
  56324. private _hardwareScaleLevel;
  56325. private _bloomKernel;
  56326. /**
  56327. * Specifies the size of the bloom blur kernel, relative to the final output size
  56328. */
  56329. bloomKernel: number;
  56330. /**
  56331. * Specifies the weight of the bloom in the final rendering
  56332. */
  56333. private _bloomWeight;
  56334. /**
  56335. * Specifies the luma threshold for the area that will be blurred by the bloom
  56336. */
  56337. private _bloomThreshold;
  56338. private _hdr;
  56339. /**
  56340. * The strength of the bloom.
  56341. */
  56342. bloomWeight: number;
  56343. /**
  56344. * The strength of the bloom.
  56345. */
  56346. bloomThreshold: number;
  56347. /**
  56348. * The scale of the bloom, lower value will provide better performance.
  56349. */
  56350. bloomScale: number;
  56351. /**
  56352. * Enable or disable the bloom from the pipeline
  56353. */
  56354. bloomEnabled: boolean;
  56355. private _rebuildBloom;
  56356. /**
  56357. * If the depth of field is enabled.
  56358. */
  56359. depthOfFieldEnabled: boolean;
  56360. /**
  56361. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56362. */
  56363. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56364. /**
  56365. * If the anti aliasing is enabled.
  56366. */
  56367. fxaaEnabled: boolean;
  56368. private _samples;
  56369. /**
  56370. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56371. */
  56372. samples: number;
  56373. /**
  56374. * If image processing is enabled.
  56375. */
  56376. imageProcessingEnabled: boolean;
  56377. /**
  56378. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56379. */
  56380. glowLayerEnabled: boolean;
  56381. /**
  56382. * Gets the glow layer (or null if not defined)
  56383. */
  56384. readonly glowLayer: Nullable<GlowLayer>;
  56385. /**
  56386. * Enable or disable the chromaticAberration process from the pipeline
  56387. */
  56388. chromaticAberrationEnabled: boolean;
  56389. /**
  56390. * Enable or disable the grain process from the pipeline
  56391. */
  56392. grainEnabled: boolean;
  56393. /**
  56394. * @constructor
  56395. * @param name - The rendering pipeline name (default: "")
  56396. * @param hdr - If high dynamic range textures should be used (default: true)
  56397. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56398. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56399. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56400. */
  56401. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56402. /**
  56403. * Get the class name
  56404. * @returns "DefaultRenderingPipeline"
  56405. */
  56406. getClassName(): string;
  56407. /**
  56408. * Force the compilation of the entire pipeline.
  56409. */
  56410. prepare(): void;
  56411. private _hasCleared;
  56412. private _prevPostProcess;
  56413. private _prevPrevPostProcess;
  56414. private _setAutoClearAndTextureSharing;
  56415. private _depthOfFieldSceneObserver;
  56416. private _buildPipeline;
  56417. private _disposePostProcesses;
  56418. /**
  56419. * Adds a camera to the pipeline
  56420. * @param camera the camera to be added
  56421. */
  56422. addCamera(camera: Camera): void;
  56423. /**
  56424. * Removes a camera from the pipeline
  56425. * @param camera the camera to remove
  56426. */
  56427. removeCamera(camera: Camera): void;
  56428. /**
  56429. * Dispose of the pipeline and stop all post processes
  56430. */
  56431. dispose(): void;
  56432. /**
  56433. * Serialize the rendering pipeline (Used when exporting)
  56434. * @returns the serialized object
  56435. */
  56436. serialize(): any;
  56437. /**
  56438. * Parse the serialized pipeline
  56439. * @param source Source pipeline.
  56440. * @param scene The scene to load the pipeline to.
  56441. * @param rootUrl The URL of the serialized pipeline.
  56442. * @returns An instantiated pipeline from the serialized object.
  56443. */
  56444. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56445. }
  56446. }
  56447. declare module BABYLON {
  56448. /** @hidden */
  56449. export var lensHighlightsPixelShader: {
  56450. name: string;
  56451. shader: string;
  56452. };
  56453. }
  56454. declare module BABYLON {
  56455. /** @hidden */
  56456. export var depthOfFieldPixelShader: {
  56457. name: string;
  56458. shader: string;
  56459. };
  56460. }
  56461. declare module BABYLON {
  56462. /**
  56463. * BABYLON.JS Chromatic Aberration GLSL Shader
  56464. * Author: Olivier Guyot
  56465. * Separates very slightly R, G and B colors on the edges of the screen
  56466. * Inspired by Francois Tarlier & Martins Upitis
  56467. */
  56468. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56469. /**
  56470. * @ignore
  56471. * The chromatic aberration PostProcess id in the pipeline
  56472. */
  56473. LensChromaticAberrationEffect: string;
  56474. /**
  56475. * @ignore
  56476. * The highlights enhancing PostProcess id in the pipeline
  56477. */
  56478. HighlightsEnhancingEffect: string;
  56479. /**
  56480. * @ignore
  56481. * The depth-of-field PostProcess id in the pipeline
  56482. */
  56483. LensDepthOfFieldEffect: string;
  56484. private _scene;
  56485. private _depthTexture;
  56486. private _grainTexture;
  56487. private _chromaticAberrationPostProcess;
  56488. private _highlightsPostProcess;
  56489. private _depthOfFieldPostProcess;
  56490. private _edgeBlur;
  56491. private _grainAmount;
  56492. private _chromaticAberration;
  56493. private _distortion;
  56494. private _highlightsGain;
  56495. private _highlightsThreshold;
  56496. private _dofDistance;
  56497. private _dofAperture;
  56498. private _dofDarken;
  56499. private _dofPentagon;
  56500. private _blurNoise;
  56501. /**
  56502. * @constructor
  56503. *
  56504. * Effect parameters are as follow:
  56505. * {
  56506. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56507. * edge_blur: number; // from 0 to x (1 for realism)
  56508. * distortion: number; // from 0 to x (1 for realism)
  56509. * grain_amount: number; // from 0 to 1
  56510. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56511. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56512. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56513. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56514. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56515. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56516. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56517. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56518. * }
  56519. * Note: if an effect parameter is unset, effect is disabled
  56520. *
  56521. * @param name The rendering pipeline name
  56522. * @param parameters - An object containing all parameters (see above)
  56523. * @param scene The scene linked to this pipeline
  56524. * @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)
  56525. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56526. */
  56527. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56528. /**
  56529. * Get the class name
  56530. * @returns "LensRenderingPipeline"
  56531. */
  56532. getClassName(): string;
  56533. /**
  56534. * Gets associated scene
  56535. */
  56536. readonly scene: Scene;
  56537. /**
  56538. * Gets or sets the edge blur
  56539. */
  56540. edgeBlur: number;
  56541. /**
  56542. * Gets or sets the grain amount
  56543. */
  56544. grainAmount: number;
  56545. /**
  56546. * Gets or sets the chromatic aberration amount
  56547. */
  56548. chromaticAberration: number;
  56549. /**
  56550. * Gets or sets the depth of field aperture
  56551. */
  56552. dofAperture: number;
  56553. /**
  56554. * Gets or sets the edge distortion
  56555. */
  56556. edgeDistortion: number;
  56557. /**
  56558. * Gets or sets the depth of field distortion
  56559. */
  56560. dofDistortion: number;
  56561. /**
  56562. * Gets or sets the darken out of focus amount
  56563. */
  56564. darkenOutOfFocus: number;
  56565. /**
  56566. * Gets or sets a boolean indicating if blur noise is enabled
  56567. */
  56568. blurNoise: boolean;
  56569. /**
  56570. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56571. */
  56572. pentagonBokeh: boolean;
  56573. /**
  56574. * Gets or sets the highlight grain amount
  56575. */
  56576. highlightsGain: number;
  56577. /**
  56578. * Gets or sets the highlight threshold
  56579. */
  56580. highlightsThreshold: number;
  56581. /**
  56582. * Sets the amount of blur at the edges
  56583. * @param amount blur amount
  56584. */
  56585. setEdgeBlur(amount: number): void;
  56586. /**
  56587. * Sets edge blur to 0
  56588. */
  56589. disableEdgeBlur(): void;
  56590. /**
  56591. * Sets the amout of grain
  56592. * @param amount Amount of grain
  56593. */
  56594. setGrainAmount(amount: number): void;
  56595. /**
  56596. * Set grain amount to 0
  56597. */
  56598. disableGrain(): void;
  56599. /**
  56600. * Sets the chromatic aberration amount
  56601. * @param amount amount of chromatic aberration
  56602. */
  56603. setChromaticAberration(amount: number): void;
  56604. /**
  56605. * Sets chromatic aberration amount to 0
  56606. */
  56607. disableChromaticAberration(): void;
  56608. /**
  56609. * Sets the EdgeDistortion amount
  56610. * @param amount amount of EdgeDistortion
  56611. */
  56612. setEdgeDistortion(amount: number): void;
  56613. /**
  56614. * Sets edge distortion to 0
  56615. */
  56616. disableEdgeDistortion(): void;
  56617. /**
  56618. * Sets the FocusDistance amount
  56619. * @param amount amount of FocusDistance
  56620. */
  56621. setFocusDistance(amount: number): void;
  56622. /**
  56623. * Disables depth of field
  56624. */
  56625. disableDepthOfField(): void;
  56626. /**
  56627. * Sets the Aperture amount
  56628. * @param amount amount of Aperture
  56629. */
  56630. setAperture(amount: number): void;
  56631. /**
  56632. * Sets the DarkenOutOfFocus amount
  56633. * @param amount amount of DarkenOutOfFocus
  56634. */
  56635. setDarkenOutOfFocus(amount: number): void;
  56636. private _pentagonBokehIsEnabled;
  56637. /**
  56638. * Creates a pentagon bokeh effect
  56639. */
  56640. enablePentagonBokeh(): void;
  56641. /**
  56642. * Disables the pentagon bokeh effect
  56643. */
  56644. disablePentagonBokeh(): void;
  56645. /**
  56646. * Enables noise blur
  56647. */
  56648. enableNoiseBlur(): void;
  56649. /**
  56650. * Disables noise blur
  56651. */
  56652. disableNoiseBlur(): void;
  56653. /**
  56654. * Sets the HighlightsGain amount
  56655. * @param amount amount of HighlightsGain
  56656. */
  56657. setHighlightsGain(amount: number): void;
  56658. /**
  56659. * Sets the HighlightsThreshold amount
  56660. * @param amount amount of HighlightsThreshold
  56661. */
  56662. setHighlightsThreshold(amount: number): void;
  56663. /**
  56664. * Disables highlights
  56665. */
  56666. disableHighlights(): void;
  56667. /**
  56668. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56669. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56670. */
  56671. dispose(disableDepthRender?: boolean): void;
  56672. private _createChromaticAberrationPostProcess;
  56673. private _createHighlightsPostProcess;
  56674. private _createDepthOfFieldPostProcess;
  56675. private _createGrainTexture;
  56676. }
  56677. }
  56678. declare module BABYLON {
  56679. /** @hidden */
  56680. export var ssao2PixelShader: {
  56681. name: string;
  56682. shader: string;
  56683. };
  56684. }
  56685. declare module BABYLON {
  56686. /** @hidden */
  56687. export var ssaoCombinePixelShader: {
  56688. name: string;
  56689. shader: string;
  56690. };
  56691. }
  56692. declare module BABYLON {
  56693. /**
  56694. * Render pipeline to produce ssao effect
  56695. */
  56696. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56697. /**
  56698. * @ignore
  56699. * The PassPostProcess id in the pipeline that contains the original scene color
  56700. */
  56701. SSAOOriginalSceneColorEffect: string;
  56702. /**
  56703. * @ignore
  56704. * The SSAO PostProcess id in the pipeline
  56705. */
  56706. SSAORenderEffect: string;
  56707. /**
  56708. * @ignore
  56709. * The horizontal blur PostProcess id in the pipeline
  56710. */
  56711. SSAOBlurHRenderEffect: string;
  56712. /**
  56713. * @ignore
  56714. * The vertical blur PostProcess id in the pipeline
  56715. */
  56716. SSAOBlurVRenderEffect: string;
  56717. /**
  56718. * @ignore
  56719. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56720. */
  56721. SSAOCombineRenderEffect: string;
  56722. /**
  56723. * The output strength of the SSAO post-process. Default value is 1.0.
  56724. */
  56725. totalStrength: number;
  56726. /**
  56727. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56728. */
  56729. maxZ: number;
  56730. /**
  56731. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56732. */
  56733. minZAspect: number;
  56734. private _samples;
  56735. /**
  56736. * Number of samples used for the SSAO calculations. Default value is 8
  56737. */
  56738. samples: number;
  56739. private _textureSamples;
  56740. /**
  56741. * Number of samples to use for antialiasing
  56742. */
  56743. textureSamples: number;
  56744. /**
  56745. * Ratio object used for SSAO ratio and blur ratio
  56746. */
  56747. private _ratio;
  56748. /**
  56749. * Dynamically generated sphere sampler.
  56750. */
  56751. private _sampleSphere;
  56752. /**
  56753. * Blur filter offsets
  56754. */
  56755. private _samplerOffsets;
  56756. private _expensiveBlur;
  56757. /**
  56758. * If bilateral blur should be used
  56759. */
  56760. expensiveBlur: boolean;
  56761. /**
  56762. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56763. */
  56764. radius: number;
  56765. /**
  56766. * The base color of the SSAO post-process
  56767. * The final result is "base + ssao" between [0, 1]
  56768. */
  56769. base: number;
  56770. /**
  56771. * Support test.
  56772. */
  56773. static readonly IsSupported: boolean;
  56774. private _scene;
  56775. private _depthTexture;
  56776. private _normalTexture;
  56777. private _randomTexture;
  56778. private _originalColorPostProcess;
  56779. private _ssaoPostProcess;
  56780. private _blurHPostProcess;
  56781. private _blurVPostProcess;
  56782. private _ssaoCombinePostProcess;
  56783. private _firstUpdate;
  56784. /**
  56785. * Gets active scene
  56786. */
  56787. readonly scene: Scene;
  56788. /**
  56789. * @constructor
  56790. * @param name The rendering pipeline name
  56791. * @param scene The scene linked to this pipeline
  56792. * @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 }
  56793. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56794. */
  56795. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56796. /**
  56797. * Get the class name
  56798. * @returns "SSAO2RenderingPipeline"
  56799. */
  56800. getClassName(): string;
  56801. /**
  56802. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56803. */
  56804. dispose(disableGeometryBufferRenderer?: boolean): void;
  56805. private _createBlurPostProcess;
  56806. /** @hidden */
  56807. _rebuild(): void;
  56808. private _bits;
  56809. private _radicalInverse_VdC;
  56810. private _hammersley;
  56811. private _hemisphereSample_uniform;
  56812. private _generateHemisphere;
  56813. private _createSSAOPostProcess;
  56814. private _createSSAOCombinePostProcess;
  56815. private _createRandomTexture;
  56816. /**
  56817. * Serialize the rendering pipeline (Used when exporting)
  56818. * @returns the serialized object
  56819. */
  56820. serialize(): any;
  56821. /**
  56822. * Parse the serialized pipeline
  56823. * @param source Source pipeline.
  56824. * @param scene The scene to load the pipeline to.
  56825. * @param rootUrl The URL of the serialized pipeline.
  56826. * @returns An instantiated pipeline from the serialized object.
  56827. */
  56828. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56829. }
  56830. }
  56831. declare module BABYLON {
  56832. /** @hidden */
  56833. export var ssaoPixelShader: {
  56834. name: string;
  56835. shader: string;
  56836. };
  56837. }
  56838. declare module BABYLON {
  56839. /**
  56840. * Render pipeline to produce ssao effect
  56841. */
  56842. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56843. /**
  56844. * @ignore
  56845. * The PassPostProcess id in the pipeline that contains the original scene color
  56846. */
  56847. SSAOOriginalSceneColorEffect: string;
  56848. /**
  56849. * @ignore
  56850. * The SSAO PostProcess id in the pipeline
  56851. */
  56852. SSAORenderEffect: string;
  56853. /**
  56854. * @ignore
  56855. * The horizontal blur PostProcess id in the pipeline
  56856. */
  56857. SSAOBlurHRenderEffect: string;
  56858. /**
  56859. * @ignore
  56860. * The vertical blur PostProcess id in the pipeline
  56861. */
  56862. SSAOBlurVRenderEffect: string;
  56863. /**
  56864. * @ignore
  56865. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56866. */
  56867. SSAOCombineRenderEffect: string;
  56868. /**
  56869. * The output strength of the SSAO post-process. Default value is 1.0.
  56870. */
  56871. totalStrength: number;
  56872. /**
  56873. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56874. */
  56875. radius: number;
  56876. /**
  56877. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56878. * Must not be equal to fallOff and superior to fallOff.
  56879. * Default value is 0.0075
  56880. */
  56881. area: number;
  56882. /**
  56883. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56884. * Must not be equal to area and inferior to area.
  56885. * Default value is 0.000001
  56886. */
  56887. fallOff: number;
  56888. /**
  56889. * The base color of the SSAO post-process
  56890. * The final result is "base + ssao" between [0, 1]
  56891. */
  56892. base: number;
  56893. private _scene;
  56894. private _depthTexture;
  56895. private _randomTexture;
  56896. private _originalColorPostProcess;
  56897. private _ssaoPostProcess;
  56898. private _blurHPostProcess;
  56899. private _blurVPostProcess;
  56900. private _ssaoCombinePostProcess;
  56901. private _firstUpdate;
  56902. /**
  56903. * Gets active scene
  56904. */
  56905. readonly scene: Scene;
  56906. /**
  56907. * @constructor
  56908. * @param name - The rendering pipeline name
  56909. * @param scene - The scene linked to this pipeline
  56910. * @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 }
  56911. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56912. */
  56913. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56914. /**
  56915. * Get the class name
  56916. * @returns "SSAORenderingPipeline"
  56917. */
  56918. getClassName(): string;
  56919. /**
  56920. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56921. */
  56922. dispose(disableDepthRender?: boolean): void;
  56923. private _createBlurPostProcess;
  56924. /** @hidden */
  56925. _rebuild(): void;
  56926. private _createSSAOPostProcess;
  56927. private _createSSAOCombinePostProcess;
  56928. private _createRandomTexture;
  56929. }
  56930. }
  56931. declare module BABYLON {
  56932. /** @hidden */
  56933. export var standardPixelShader: {
  56934. name: string;
  56935. shader: string;
  56936. };
  56937. }
  56938. declare module BABYLON {
  56939. /**
  56940. * Standard rendering pipeline
  56941. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56942. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56943. */
  56944. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56945. /**
  56946. * Public members
  56947. */
  56948. /**
  56949. * Post-process which contains the original scene color before the pipeline applies all the effects
  56950. */
  56951. originalPostProcess: Nullable<PostProcess>;
  56952. /**
  56953. * Post-process used to down scale an image x4
  56954. */
  56955. downSampleX4PostProcess: Nullable<PostProcess>;
  56956. /**
  56957. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56958. */
  56959. brightPassPostProcess: Nullable<PostProcess>;
  56960. /**
  56961. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56962. */
  56963. blurHPostProcesses: PostProcess[];
  56964. /**
  56965. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56966. */
  56967. blurVPostProcesses: PostProcess[];
  56968. /**
  56969. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56970. */
  56971. textureAdderPostProcess: Nullable<PostProcess>;
  56972. /**
  56973. * Post-process used to create volumetric lighting effect
  56974. */
  56975. volumetricLightPostProcess: Nullable<PostProcess>;
  56976. /**
  56977. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56978. */
  56979. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56980. /**
  56981. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56982. */
  56983. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56984. /**
  56985. * Post-process used to merge the volumetric light effect and the real scene color
  56986. */
  56987. volumetricLightMergePostProces: Nullable<PostProcess>;
  56988. /**
  56989. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56990. */
  56991. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56992. /**
  56993. * Base post-process used to calculate the average luminance of the final image for HDR
  56994. */
  56995. luminancePostProcess: Nullable<PostProcess>;
  56996. /**
  56997. * Post-processes used to create down sample post-processes in order to get
  56998. * the average luminance of the final image for HDR
  56999. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57000. */
  57001. luminanceDownSamplePostProcesses: PostProcess[];
  57002. /**
  57003. * Post-process used to create a HDR effect (light adaptation)
  57004. */
  57005. hdrPostProcess: Nullable<PostProcess>;
  57006. /**
  57007. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57008. */
  57009. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57010. /**
  57011. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57012. */
  57013. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57014. /**
  57015. * Post-process used to merge the final HDR post-process and the real scene color
  57016. */
  57017. hdrFinalPostProcess: Nullable<PostProcess>;
  57018. /**
  57019. * Post-process used to create a lens flare effect
  57020. */
  57021. lensFlarePostProcess: Nullable<PostProcess>;
  57022. /**
  57023. * Post-process that merges the result of the lens flare post-process and the real scene color
  57024. */
  57025. lensFlareComposePostProcess: Nullable<PostProcess>;
  57026. /**
  57027. * Post-process used to create a motion blur effect
  57028. */
  57029. motionBlurPostProcess: Nullable<PostProcess>;
  57030. /**
  57031. * Post-process used to create a depth of field effect
  57032. */
  57033. depthOfFieldPostProcess: Nullable<PostProcess>;
  57034. /**
  57035. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57036. */
  57037. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57038. /**
  57039. * Represents the brightness threshold in order to configure the illuminated surfaces
  57040. */
  57041. brightThreshold: number;
  57042. /**
  57043. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57044. */
  57045. blurWidth: number;
  57046. /**
  57047. * Sets if the blur for highlighted surfaces must be only horizontal
  57048. */
  57049. horizontalBlur: boolean;
  57050. /**
  57051. * Gets the overall exposure used by the pipeline
  57052. */
  57053. /**
  57054. * Sets the overall exposure used by the pipeline
  57055. */
  57056. exposure: number;
  57057. /**
  57058. * Texture used typically to simulate "dirty" on camera lens
  57059. */
  57060. lensTexture: Nullable<Texture>;
  57061. /**
  57062. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57063. */
  57064. volumetricLightCoefficient: number;
  57065. /**
  57066. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57067. */
  57068. volumetricLightPower: number;
  57069. /**
  57070. * Used the set the blur intensity to smooth the volumetric lights
  57071. */
  57072. volumetricLightBlurScale: number;
  57073. /**
  57074. * Light (spot or directional) used to generate the volumetric lights rays
  57075. * The source light must have a shadow generate so the pipeline can get its
  57076. * depth map
  57077. */
  57078. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57079. /**
  57080. * For eye adaptation, represents the minimum luminance the eye can see
  57081. */
  57082. hdrMinimumLuminance: number;
  57083. /**
  57084. * For eye adaptation, represents the decrease luminance speed
  57085. */
  57086. hdrDecreaseRate: number;
  57087. /**
  57088. * For eye adaptation, represents the increase luminance speed
  57089. */
  57090. hdrIncreaseRate: number;
  57091. /**
  57092. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57093. */
  57094. /**
  57095. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57096. */
  57097. hdrAutoExposure: boolean;
  57098. /**
  57099. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57100. */
  57101. lensColorTexture: Nullable<Texture>;
  57102. /**
  57103. * The overall strengh for the lens flare effect
  57104. */
  57105. lensFlareStrength: number;
  57106. /**
  57107. * Dispersion coefficient for lens flare ghosts
  57108. */
  57109. lensFlareGhostDispersal: number;
  57110. /**
  57111. * Main lens flare halo width
  57112. */
  57113. lensFlareHaloWidth: number;
  57114. /**
  57115. * Based on the lens distortion effect, defines how much the lens flare result
  57116. * is distorted
  57117. */
  57118. lensFlareDistortionStrength: number;
  57119. /**
  57120. * Lens star texture must be used to simulate rays on the flares and is available
  57121. * in the documentation
  57122. */
  57123. lensStarTexture: Nullable<Texture>;
  57124. /**
  57125. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57126. * flare effect by taking account of the dirt texture
  57127. */
  57128. lensFlareDirtTexture: Nullable<Texture>;
  57129. /**
  57130. * Represents the focal length for the depth of field effect
  57131. */
  57132. depthOfFieldDistance: number;
  57133. /**
  57134. * Represents the blur intensity for the blurred part of the depth of field effect
  57135. */
  57136. depthOfFieldBlurWidth: number;
  57137. /**
  57138. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57139. */
  57140. /**
  57141. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57142. */
  57143. motionStrength: number;
  57144. /**
  57145. * Gets wether or not the motion blur post-process is object based or screen based.
  57146. */
  57147. /**
  57148. * Sets wether or not the motion blur post-process should be object based or screen based
  57149. */
  57150. objectBasedMotionBlur: boolean;
  57151. /**
  57152. * List of animations for the pipeline (IAnimatable implementation)
  57153. */
  57154. animations: Animation[];
  57155. /**
  57156. * Private members
  57157. */
  57158. private _scene;
  57159. private _currentDepthOfFieldSource;
  57160. private _basePostProcess;
  57161. private _fixedExposure;
  57162. private _currentExposure;
  57163. private _hdrAutoExposure;
  57164. private _hdrCurrentLuminance;
  57165. private _motionStrength;
  57166. private _isObjectBasedMotionBlur;
  57167. private _floatTextureType;
  57168. private _ratio;
  57169. private _bloomEnabled;
  57170. private _depthOfFieldEnabled;
  57171. private _vlsEnabled;
  57172. private _lensFlareEnabled;
  57173. private _hdrEnabled;
  57174. private _motionBlurEnabled;
  57175. private _fxaaEnabled;
  57176. private _motionBlurSamples;
  57177. private _volumetricLightStepsCount;
  57178. private _samples;
  57179. /**
  57180. * @ignore
  57181. * Specifies if the bloom pipeline is enabled
  57182. */
  57183. BloomEnabled: boolean;
  57184. /**
  57185. * @ignore
  57186. * Specifies if the depth of field pipeline is enabed
  57187. */
  57188. DepthOfFieldEnabled: boolean;
  57189. /**
  57190. * @ignore
  57191. * Specifies if the lens flare pipeline is enabed
  57192. */
  57193. LensFlareEnabled: boolean;
  57194. /**
  57195. * @ignore
  57196. * Specifies if the HDR pipeline is enabled
  57197. */
  57198. HDREnabled: boolean;
  57199. /**
  57200. * @ignore
  57201. * Specifies if the volumetric lights scattering effect is enabled
  57202. */
  57203. VLSEnabled: boolean;
  57204. /**
  57205. * @ignore
  57206. * Specifies if the motion blur effect is enabled
  57207. */
  57208. MotionBlurEnabled: boolean;
  57209. /**
  57210. * Specifies if anti-aliasing is enabled
  57211. */
  57212. fxaaEnabled: boolean;
  57213. /**
  57214. * Specifies the number of steps used to calculate the volumetric lights
  57215. * Typically in interval [50, 200]
  57216. */
  57217. volumetricLightStepsCount: number;
  57218. /**
  57219. * Specifies the number of samples used for the motion blur effect
  57220. * Typically in interval [16, 64]
  57221. */
  57222. motionBlurSamples: number;
  57223. /**
  57224. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57225. */
  57226. samples: number;
  57227. /**
  57228. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57229. * @constructor
  57230. * @param name The rendering pipeline name
  57231. * @param scene The scene linked to this pipeline
  57232. * @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)
  57233. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57234. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57235. */
  57236. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57237. private _buildPipeline;
  57238. private _createDownSampleX4PostProcess;
  57239. private _createBrightPassPostProcess;
  57240. private _createBlurPostProcesses;
  57241. private _createTextureAdderPostProcess;
  57242. private _createVolumetricLightPostProcess;
  57243. private _createLuminancePostProcesses;
  57244. private _createHdrPostProcess;
  57245. private _createLensFlarePostProcess;
  57246. private _createDepthOfFieldPostProcess;
  57247. private _createMotionBlurPostProcess;
  57248. private _getDepthTexture;
  57249. private _disposePostProcesses;
  57250. /**
  57251. * Dispose of the pipeline and stop all post processes
  57252. */
  57253. dispose(): void;
  57254. /**
  57255. * Serialize the rendering pipeline (Used when exporting)
  57256. * @returns the serialized object
  57257. */
  57258. serialize(): any;
  57259. /**
  57260. * Parse the serialized pipeline
  57261. * @param source Source pipeline.
  57262. * @param scene The scene to load the pipeline to.
  57263. * @param rootUrl The URL of the serialized pipeline.
  57264. * @returns An instantiated pipeline from the serialized object.
  57265. */
  57266. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57267. /**
  57268. * Luminance steps
  57269. */
  57270. static LuminanceSteps: number;
  57271. }
  57272. }
  57273. declare module BABYLON {
  57274. /** @hidden */
  57275. export var tonemapPixelShader: {
  57276. name: string;
  57277. shader: string;
  57278. };
  57279. }
  57280. declare module BABYLON {
  57281. /** Defines operator used for tonemapping */
  57282. export enum TonemappingOperator {
  57283. /** Hable */
  57284. Hable = 0,
  57285. /** Reinhard */
  57286. Reinhard = 1,
  57287. /** HejiDawson */
  57288. HejiDawson = 2,
  57289. /** Photographic */
  57290. Photographic = 3
  57291. }
  57292. /**
  57293. * Defines a post process to apply tone mapping
  57294. */
  57295. export class TonemapPostProcess extends PostProcess {
  57296. private _operator;
  57297. /** Defines the required exposure adjustement */
  57298. exposureAdjustment: number;
  57299. /**
  57300. * Creates a new TonemapPostProcess
  57301. * @param name defines the name of the postprocess
  57302. * @param _operator defines the operator to use
  57303. * @param exposureAdjustment defines the required exposure adjustement
  57304. * @param camera defines the camera to use (can be null)
  57305. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57306. * @param engine defines the hosting engine (can be ignore if camera is set)
  57307. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57308. */
  57309. constructor(name: string, _operator: TonemappingOperator,
  57310. /** Defines the required exposure adjustement */
  57311. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57312. }
  57313. }
  57314. declare module BABYLON {
  57315. /** @hidden */
  57316. export var depthVertexShader: {
  57317. name: string;
  57318. shader: string;
  57319. };
  57320. }
  57321. declare module BABYLON {
  57322. /** @hidden */
  57323. export var volumetricLightScatteringPixelShader: {
  57324. name: string;
  57325. shader: string;
  57326. };
  57327. }
  57328. declare module BABYLON {
  57329. /** @hidden */
  57330. export var volumetricLightScatteringPassPixelShader: {
  57331. name: string;
  57332. shader: string;
  57333. };
  57334. }
  57335. declare module BABYLON {
  57336. /**
  57337. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57338. */
  57339. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57340. private _volumetricLightScatteringPass;
  57341. private _volumetricLightScatteringRTT;
  57342. private _viewPort;
  57343. private _screenCoordinates;
  57344. private _cachedDefines;
  57345. /**
  57346. * If not undefined, the mesh position is computed from the attached node position
  57347. */
  57348. attachedNode: {
  57349. position: Vector3;
  57350. };
  57351. /**
  57352. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57353. */
  57354. customMeshPosition: Vector3;
  57355. /**
  57356. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57357. */
  57358. useCustomMeshPosition: boolean;
  57359. /**
  57360. * If the post-process should inverse the light scattering direction
  57361. */
  57362. invert: boolean;
  57363. /**
  57364. * The internal mesh used by the post-process
  57365. */
  57366. mesh: Mesh;
  57367. /**
  57368. * @hidden
  57369. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57370. */
  57371. useDiffuseColor: boolean;
  57372. /**
  57373. * Array containing the excluded meshes not rendered in the internal pass
  57374. */
  57375. excludedMeshes: AbstractMesh[];
  57376. /**
  57377. * Controls the overall intensity of the post-process
  57378. */
  57379. exposure: number;
  57380. /**
  57381. * Dissipates each sample's contribution in range [0, 1]
  57382. */
  57383. decay: number;
  57384. /**
  57385. * Controls the overall intensity of each sample
  57386. */
  57387. weight: number;
  57388. /**
  57389. * Controls the density of each sample
  57390. */
  57391. density: number;
  57392. /**
  57393. * @constructor
  57394. * @param name The post-process name
  57395. * @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)
  57396. * @param camera The camera that the post-process will be attached to
  57397. * @param mesh The mesh used to create the light scattering
  57398. * @param samples The post-process quality, default 100
  57399. * @param samplingModeThe post-process filtering mode
  57400. * @param engine The babylon engine
  57401. * @param reusable If the post-process is reusable
  57402. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57403. */
  57404. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57405. /**
  57406. * Returns the string "VolumetricLightScatteringPostProcess"
  57407. * @returns "VolumetricLightScatteringPostProcess"
  57408. */
  57409. getClassName(): string;
  57410. private _isReady;
  57411. /**
  57412. * Sets the new light position for light scattering effect
  57413. * @param position The new custom light position
  57414. */
  57415. setCustomMeshPosition(position: Vector3): void;
  57416. /**
  57417. * Returns the light position for light scattering effect
  57418. * @return Vector3 The custom light position
  57419. */
  57420. getCustomMeshPosition(): Vector3;
  57421. /**
  57422. * Disposes the internal assets and detaches the post-process from the camera
  57423. */
  57424. dispose(camera: Camera): void;
  57425. /**
  57426. * Returns the render target texture used by the post-process
  57427. * @return the render target texture used by the post-process
  57428. */
  57429. getPass(): RenderTargetTexture;
  57430. private _meshExcluded;
  57431. private _createPass;
  57432. private _updateMeshScreenCoordinates;
  57433. /**
  57434. * Creates a default mesh for the Volumeric Light Scattering post-process
  57435. * @param name The mesh name
  57436. * @param scene The scene where to create the mesh
  57437. * @return the default mesh
  57438. */
  57439. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57440. }
  57441. }
  57442. declare module BABYLON {
  57443. interface Scene {
  57444. /** @hidden (Backing field) */
  57445. _boundingBoxRenderer: BoundingBoxRenderer;
  57446. /** @hidden (Backing field) */
  57447. _forceShowBoundingBoxes: boolean;
  57448. /**
  57449. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57450. */
  57451. forceShowBoundingBoxes: boolean;
  57452. /**
  57453. * Gets the bounding box renderer associated with the scene
  57454. * @returns a BoundingBoxRenderer
  57455. */
  57456. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57457. }
  57458. interface AbstractMesh {
  57459. /** @hidden (Backing field) */
  57460. _showBoundingBox: boolean;
  57461. /**
  57462. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57463. */
  57464. showBoundingBox: boolean;
  57465. }
  57466. /**
  57467. * Component responsible of rendering the bounding box of the meshes in a scene.
  57468. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57469. */
  57470. export class BoundingBoxRenderer implements ISceneComponent {
  57471. /**
  57472. * The component name helpfull to identify the component in the list of scene components.
  57473. */
  57474. readonly name: string;
  57475. /**
  57476. * The scene the component belongs to.
  57477. */
  57478. scene: Scene;
  57479. /**
  57480. * Color of the bounding box lines placed in front of an object
  57481. */
  57482. frontColor: Color3;
  57483. /**
  57484. * Color of the bounding box lines placed behind an object
  57485. */
  57486. backColor: Color3;
  57487. /**
  57488. * Defines if the renderer should show the back lines or not
  57489. */
  57490. showBackLines: boolean;
  57491. /**
  57492. * @hidden
  57493. */
  57494. renderList: SmartArray<BoundingBox>;
  57495. private _colorShader;
  57496. private _vertexBuffers;
  57497. private _indexBuffer;
  57498. private _fillIndexBuffer;
  57499. private _fillIndexData;
  57500. /**
  57501. * Instantiates a new bounding box renderer in a scene.
  57502. * @param scene the scene the renderer renders in
  57503. */
  57504. constructor(scene: Scene);
  57505. /**
  57506. * Registers the component in a given scene
  57507. */
  57508. register(): void;
  57509. private _evaluateSubMesh;
  57510. private _activeMesh;
  57511. private _prepareRessources;
  57512. private _createIndexBuffer;
  57513. /**
  57514. * Rebuilds the elements related to this component in case of
  57515. * context lost for instance.
  57516. */
  57517. rebuild(): void;
  57518. /**
  57519. * @hidden
  57520. */
  57521. reset(): void;
  57522. /**
  57523. * Render the bounding boxes of a specific rendering group
  57524. * @param renderingGroupId defines the rendering group to render
  57525. */
  57526. render(renderingGroupId: number): void;
  57527. /**
  57528. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57529. * @param mesh Define the mesh to render the occlusion bounding box for
  57530. */
  57531. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57532. /**
  57533. * Dispose and release the resources attached to this renderer.
  57534. */
  57535. dispose(): void;
  57536. }
  57537. }
  57538. declare module BABYLON {
  57539. /** @hidden */
  57540. export var depthPixelShader: {
  57541. name: string;
  57542. shader: string;
  57543. };
  57544. }
  57545. declare module BABYLON {
  57546. /**
  57547. * This represents a depth renderer in Babylon.
  57548. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57549. */
  57550. export class DepthRenderer {
  57551. private _scene;
  57552. private _depthMap;
  57553. private _effect;
  57554. private _cachedDefines;
  57555. private _camera;
  57556. /**
  57557. * Specifiess that the depth renderer will only be used within
  57558. * the camera it is created for.
  57559. * This can help forcing its rendering during the camera processing.
  57560. */
  57561. useOnlyInActiveCamera: boolean;
  57562. /** @hidden */
  57563. static _SceneComponentInitialization: (scene: Scene) => void;
  57564. /**
  57565. * Instantiates a depth renderer
  57566. * @param scene The scene the renderer belongs to
  57567. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57568. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57569. */
  57570. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57571. /**
  57572. * Creates the depth rendering effect and checks if the effect is ready.
  57573. * @param subMesh The submesh to be used to render the depth map of
  57574. * @param useInstances If multiple world instances should be used
  57575. * @returns if the depth renderer is ready to render the depth map
  57576. */
  57577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57578. /**
  57579. * Gets the texture which the depth map will be written to.
  57580. * @returns The depth map texture
  57581. */
  57582. getDepthMap(): RenderTargetTexture;
  57583. /**
  57584. * Disposes of the depth renderer.
  57585. */
  57586. dispose(): void;
  57587. }
  57588. }
  57589. declare module BABYLON {
  57590. interface Scene {
  57591. /** @hidden (Backing field) */
  57592. _depthRenderer: {
  57593. [id: string]: DepthRenderer;
  57594. };
  57595. /**
  57596. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57597. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57598. * @returns the created depth renderer
  57599. */
  57600. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57601. /**
  57602. * Disables a depth renderer for a given camera
  57603. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57604. */
  57605. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57606. }
  57607. /**
  57608. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57609. * in several rendering techniques.
  57610. */
  57611. export class DepthRendererSceneComponent implements ISceneComponent {
  57612. /**
  57613. * The component name helpfull to identify the component in the list of scene components.
  57614. */
  57615. readonly name: string;
  57616. /**
  57617. * The scene the component belongs to.
  57618. */
  57619. scene: Scene;
  57620. /**
  57621. * Creates a new instance of the component for the given scene
  57622. * @param scene Defines the scene to register the component in
  57623. */
  57624. constructor(scene: Scene);
  57625. /**
  57626. * Registers the component in a given scene
  57627. */
  57628. register(): void;
  57629. /**
  57630. * Rebuilds the elements related to this component in case of
  57631. * context lost for instance.
  57632. */
  57633. rebuild(): void;
  57634. /**
  57635. * Disposes the component and the associated ressources
  57636. */
  57637. dispose(): void;
  57638. private _gatherRenderTargets;
  57639. private _gatherActiveCameraRenderTargets;
  57640. }
  57641. }
  57642. declare module BABYLON {
  57643. /** @hidden */
  57644. export var outlinePixelShader: {
  57645. name: string;
  57646. shader: string;
  57647. };
  57648. }
  57649. declare module BABYLON {
  57650. /** @hidden */
  57651. export var outlineVertexShader: {
  57652. name: string;
  57653. shader: string;
  57654. };
  57655. }
  57656. declare module BABYLON {
  57657. interface Scene {
  57658. /** @hidden */
  57659. _outlineRenderer: OutlineRenderer;
  57660. /**
  57661. * Gets the outline renderer associated with the scene
  57662. * @returns a OutlineRenderer
  57663. */
  57664. getOutlineRenderer(): OutlineRenderer;
  57665. }
  57666. interface AbstractMesh {
  57667. /** @hidden (Backing field) */
  57668. _renderOutline: boolean;
  57669. /**
  57670. * Gets or sets a boolean indicating if the outline must be rendered as well
  57671. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57672. */
  57673. renderOutline: boolean;
  57674. /** @hidden (Backing field) */
  57675. _renderOverlay: boolean;
  57676. /**
  57677. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57678. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57679. */
  57680. renderOverlay: boolean;
  57681. }
  57682. /**
  57683. * This class is responsible to draw bothe outline/overlay of meshes.
  57684. * It should not be used directly but through the available method on mesh.
  57685. */
  57686. export class OutlineRenderer implements ISceneComponent {
  57687. /**
  57688. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57689. */
  57690. private static _StencilReference;
  57691. /**
  57692. * The name of the component. Each component must have a unique name.
  57693. */
  57694. name: string;
  57695. /**
  57696. * The scene the component belongs to.
  57697. */
  57698. scene: Scene;
  57699. /**
  57700. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57701. */
  57702. zOffset: number;
  57703. private _engine;
  57704. private _effect;
  57705. private _cachedDefines;
  57706. private _savedDepthWrite;
  57707. /**
  57708. * Instantiates a new outline renderer. (There could be only one per scene).
  57709. * @param scene Defines the scene it belongs to
  57710. */
  57711. constructor(scene: Scene);
  57712. /**
  57713. * Register the component to one instance of a scene.
  57714. */
  57715. register(): void;
  57716. /**
  57717. * Rebuilds the elements related to this component in case of
  57718. * context lost for instance.
  57719. */
  57720. rebuild(): void;
  57721. /**
  57722. * Disposes the component and the associated ressources.
  57723. */
  57724. dispose(): void;
  57725. /**
  57726. * Renders the outline in the canvas.
  57727. * @param subMesh Defines the sumesh to render
  57728. * @param batch Defines the batch of meshes in case of instances
  57729. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57730. */
  57731. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57732. /**
  57733. * Returns whether or not the outline renderer is ready for a given submesh.
  57734. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57735. * @param subMesh Defines the submesh to check readyness for
  57736. * @param useInstances Defines wheter wee are trying to render instances or not
  57737. * @returns true if ready otherwise false
  57738. */
  57739. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57740. private _beforeRenderingMesh;
  57741. private _afterRenderingMesh;
  57742. }
  57743. }
  57744. declare module BABYLON {
  57745. /**
  57746. * Defines the list of states available for a task inside a AssetsManager
  57747. */
  57748. export enum AssetTaskState {
  57749. /**
  57750. * Initialization
  57751. */
  57752. INIT = 0,
  57753. /**
  57754. * Running
  57755. */
  57756. RUNNING = 1,
  57757. /**
  57758. * Done
  57759. */
  57760. DONE = 2,
  57761. /**
  57762. * Error
  57763. */
  57764. ERROR = 3
  57765. }
  57766. /**
  57767. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57768. */
  57769. export abstract class AbstractAssetTask {
  57770. /**
  57771. * Task name
  57772. */ name: string;
  57773. /**
  57774. * Callback called when the task is successful
  57775. */
  57776. onSuccess: (task: any) => void;
  57777. /**
  57778. * Callback called when the task is not successful
  57779. */
  57780. onError: (task: any, message?: string, exception?: any) => void;
  57781. /**
  57782. * Creates a new AssetsManager
  57783. * @param name defines the name of the task
  57784. */
  57785. constructor(
  57786. /**
  57787. * Task name
  57788. */ name: string);
  57789. private _isCompleted;
  57790. private _taskState;
  57791. private _errorObject;
  57792. /**
  57793. * Get if the task is completed
  57794. */
  57795. readonly isCompleted: boolean;
  57796. /**
  57797. * Gets the current state of the task
  57798. */
  57799. readonly taskState: AssetTaskState;
  57800. /**
  57801. * Gets the current error object (if task is in error)
  57802. */
  57803. readonly errorObject: {
  57804. message?: string;
  57805. exception?: any;
  57806. };
  57807. /**
  57808. * Internal only
  57809. * @hidden
  57810. */
  57811. _setErrorObject(message?: string, exception?: any): void;
  57812. /**
  57813. * Execute the current task
  57814. * @param scene defines the scene where you want your assets to be loaded
  57815. * @param onSuccess is a callback called when the task is successfully executed
  57816. * @param onError is a callback called if an error occurs
  57817. */
  57818. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57819. /**
  57820. * Execute the current task
  57821. * @param scene defines the scene where you want your assets to be loaded
  57822. * @param onSuccess is a callback called when the task is successfully executed
  57823. * @param onError is a callback called if an error occurs
  57824. */
  57825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57826. /**
  57827. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57828. * This can be used with failed tasks that have the reason for failure fixed.
  57829. */
  57830. reset(): void;
  57831. private onErrorCallback;
  57832. private onDoneCallback;
  57833. }
  57834. /**
  57835. * Define the interface used by progress events raised during assets loading
  57836. */
  57837. export interface IAssetsProgressEvent {
  57838. /**
  57839. * Defines the number of remaining tasks to process
  57840. */
  57841. remainingCount: number;
  57842. /**
  57843. * Defines the total number of tasks
  57844. */
  57845. totalCount: number;
  57846. /**
  57847. * Defines the task that was just processed
  57848. */
  57849. task: AbstractAssetTask;
  57850. }
  57851. /**
  57852. * Class used to share progress information about assets loading
  57853. */
  57854. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57855. /**
  57856. * Defines the number of remaining tasks to process
  57857. */
  57858. remainingCount: number;
  57859. /**
  57860. * Defines the total number of tasks
  57861. */
  57862. totalCount: number;
  57863. /**
  57864. * Defines the task that was just processed
  57865. */
  57866. task: AbstractAssetTask;
  57867. /**
  57868. * Creates a AssetsProgressEvent
  57869. * @param remainingCount defines the number of remaining tasks to process
  57870. * @param totalCount defines the total number of tasks
  57871. * @param task defines the task that was just processed
  57872. */
  57873. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57874. }
  57875. /**
  57876. * Define a task used by AssetsManager to load meshes
  57877. */
  57878. export class MeshAssetTask extends AbstractAssetTask {
  57879. /**
  57880. * Defines the name of the task
  57881. */
  57882. name: string;
  57883. /**
  57884. * Defines the list of mesh's names you want to load
  57885. */
  57886. meshesNames: any;
  57887. /**
  57888. * Defines the root url to use as a base to load your meshes and associated resources
  57889. */
  57890. rootUrl: string;
  57891. /**
  57892. * Defines the filename of the scene to load from
  57893. */
  57894. sceneFilename: string;
  57895. /**
  57896. * Gets the list of loaded meshes
  57897. */
  57898. loadedMeshes: Array<AbstractMesh>;
  57899. /**
  57900. * Gets the list of loaded particle systems
  57901. */
  57902. loadedParticleSystems: Array<IParticleSystem>;
  57903. /**
  57904. * Gets the list of loaded skeletons
  57905. */
  57906. loadedSkeletons: Array<Skeleton>;
  57907. /**
  57908. * Gets the list of loaded animation groups
  57909. */
  57910. loadedAnimationGroups: Array<AnimationGroup>;
  57911. /**
  57912. * Callback called when the task is successful
  57913. */
  57914. onSuccess: (task: MeshAssetTask) => void;
  57915. /**
  57916. * Callback called when the task is successful
  57917. */
  57918. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57919. /**
  57920. * Creates a new MeshAssetTask
  57921. * @param name defines the name of the task
  57922. * @param meshesNames defines the list of mesh's names you want to load
  57923. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57924. * @param sceneFilename defines the filename of the scene to load from
  57925. */
  57926. constructor(
  57927. /**
  57928. * Defines the name of the task
  57929. */
  57930. name: string,
  57931. /**
  57932. * Defines the list of mesh's names you want to load
  57933. */
  57934. meshesNames: any,
  57935. /**
  57936. * Defines the root url to use as a base to load your meshes and associated resources
  57937. */
  57938. rootUrl: string,
  57939. /**
  57940. * Defines the filename of the scene to load from
  57941. */
  57942. sceneFilename: string);
  57943. /**
  57944. * Execute the current task
  57945. * @param scene defines the scene where you want your assets to be loaded
  57946. * @param onSuccess is a callback called when the task is successfully executed
  57947. * @param onError is a callback called if an error occurs
  57948. */
  57949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57950. }
  57951. /**
  57952. * Define a task used by AssetsManager to load text content
  57953. */
  57954. export class TextFileAssetTask extends AbstractAssetTask {
  57955. /**
  57956. * Defines the name of the task
  57957. */
  57958. name: string;
  57959. /**
  57960. * Defines the location of the file to load
  57961. */
  57962. url: string;
  57963. /**
  57964. * Gets the loaded text string
  57965. */
  57966. text: string;
  57967. /**
  57968. * Callback called when the task is successful
  57969. */
  57970. onSuccess: (task: TextFileAssetTask) => void;
  57971. /**
  57972. * Callback called when the task is successful
  57973. */
  57974. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57975. /**
  57976. * Creates a new TextFileAssetTask object
  57977. * @param name defines the name of the task
  57978. * @param url defines the location of the file to load
  57979. */
  57980. constructor(
  57981. /**
  57982. * Defines the name of the task
  57983. */
  57984. name: string,
  57985. /**
  57986. * Defines the location of the file to load
  57987. */
  57988. url: string);
  57989. /**
  57990. * Execute the current task
  57991. * @param scene defines the scene where you want your assets to be loaded
  57992. * @param onSuccess is a callback called when the task is successfully executed
  57993. * @param onError is a callback called if an error occurs
  57994. */
  57995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57996. }
  57997. /**
  57998. * Define a task used by AssetsManager to load binary data
  57999. */
  58000. export class BinaryFileAssetTask extends AbstractAssetTask {
  58001. /**
  58002. * Defines the name of the task
  58003. */
  58004. name: string;
  58005. /**
  58006. * Defines the location of the file to load
  58007. */
  58008. url: string;
  58009. /**
  58010. * Gets the lodaded data (as an array buffer)
  58011. */
  58012. data: ArrayBuffer;
  58013. /**
  58014. * Callback called when the task is successful
  58015. */
  58016. onSuccess: (task: BinaryFileAssetTask) => void;
  58017. /**
  58018. * Callback called when the task is successful
  58019. */
  58020. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58021. /**
  58022. * Creates a new BinaryFileAssetTask object
  58023. * @param name defines the name of the new task
  58024. * @param url defines the location of the file to load
  58025. */
  58026. constructor(
  58027. /**
  58028. * Defines the name of the task
  58029. */
  58030. name: string,
  58031. /**
  58032. * Defines the location of the file to load
  58033. */
  58034. url: string);
  58035. /**
  58036. * Execute the current task
  58037. * @param scene defines the scene where you want your assets to be loaded
  58038. * @param onSuccess is a callback called when the task is successfully executed
  58039. * @param onError is a callback called if an error occurs
  58040. */
  58041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58042. }
  58043. /**
  58044. * Define a task used by AssetsManager to load images
  58045. */
  58046. export class ImageAssetTask extends AbstractAssetTask {
  58047. /**
  58048. * Defines the name of the task
  58049. */
  58050. name: string;
  58051. /**
  58052. * Defines the location of the image to load
  58053. */
  58054. url: string;
  58055. /**
  58056. * Gets the loaded images
  58057. */
  58058. image: HTMLImageElement;
  58059. /**
  58060. * Callback called when the task is successful
  58061. */
  58062. onSuccess: (task: ImageAssetTask) => void;
  58063. /**
  58064. * Callback called when the task is successful
  58065. */
  58066. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58067. /**
  58068. * Creates a new ImageAssetTask
  58069. * @param name defines the name of the task
  58070. * @param url defines the location of the image to load
  58071. */
  58072. constructor(
  58073. /**
  58074. * Defines the name of the task
  58075. */
  58076. name: string,
  58077. /**
  58078. * Defines the location of the image to load
  58079. */
  58080. url: string);
  58081. /**
  58082. * Execute the current task
  58083. * @param scene defines the scene where you want your assets to be loaded
  58084. * @param onSuccess is a callback called when the task is successfully executed
  58085. * @param onError is a callback called if an error occurs
  58086. */
  58087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58088. }
  58089. /**
  58090. * Defines the interface used by texture loading tasks
  58091. */
  58092. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58093. /**
  58094. * Gets the loaded texture
  58095. */
  58096. texture: TEX;
  58097. }
  58098. /**
  58099. * Define a task used by AssetsManager to load 2D textures
  58100. */
  58101. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58102. /**
  58103. * Defines the name of the task
  58104. */
  58105. name: string;
  58106. /**
  58107. * Defines the location of the file to load
  58108. */
  58109. url: string;
  58110. /**
  58111. * Defines if mipmap should not be generated (default is false)
  58112. */
  58113. noMipmap?: boolean | undefined;
  58114. /**
  58115. * Defines if texture must be inverted on Y axis (default is false)
  58116. */
  58117. invertY?: boolean | undefined;
  58118. /**
  58119. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58120. */
  58121. samplingMode: number;
  58122. /**
  58123. * Gets the loaded texture
  58124. */
  58125. texture: Texture;
  58126. /**
  58127. * Callback called when the task is successful
  58128. */
  58129. onSuccess: (task: TextureAssetTask) => void;
  58130. /**
  58131. * Callback called when the task is successful
  58132. */
  58133. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58134. /**
  58135. * Creates a new TextureAssetTask object
  58136. * @param name defines the name of the task
  58137. * @param url defines the location of the file to load
  58138. * @param noMipmap defines if mipmap should not be generated (default is false)
  58139. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58140. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58141. */
  58142. constructor(
  58143. /**
  58144. * Defines the name of the task
  58145. */
  58146. name: string,
  58147. /**
  58148. * Defines the location of the file to load
  58149. */
  58150. url: string,
  58151. /**
  58152. * Defines if mipmap should not be generated (default is false)
  58153. */
  58154. noMipmap?: boolean | undefined,
  58155. /**
  58156. * Defines if texture must be inverted on Y axis (default is false)
  58157. */
  58158. invertY?: boolean | undefined,
  58159. /**
  58160. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58161. */
  58162. samplingMode?: number);
  58163. /**
  58164. * Execute the current task
  58165. * @param scene defines the scene where you want your assets to be loaded
  58166. * @param onSuccess is a callback called when the task is successfully executed
  58167. * @param onError is a callback called if an error occurs
  58168. */
  58169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58170. }
  58171. /**
  58172. * Define a task used by AssetsManager to load cube textures
  58173. */
  58174. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58175. /**
  58176. * Defines the name of the task
  58177. */
  58178. name: string;
  58179. /**
  58180. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58181. */
  58182. url: string;
  58183. /**
  58184. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58185. */
  58186. extensions?: string[] | undefined;
  58187. /**
  58188. * Defines if mipmaps should not be generated (default is false)
  58189. */
  58190. noMipmap?: boolean | undefined;
  58191. /**
  58192. * Defines the explicit list of files (undefined by default)
  58193. */
  58194. files?: string[] | undefined;
  58195. /**
  58196. * Gets the loaded texture
  58197. */
  58198. texture: CubeTexture;
  58199. /**
  58200. * Callback called when the task is successful
  58201. */
  58202. onSuccess: (task: CubeTextureAssetTask) => void;
  58203. /**
  58204. * Callback called when the task is successful
  58205. */
  58206. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58207. /**
  58208. * Creates a new CubeTextureAssetTask
  58209. * @param name defines the name of the task
  58210. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58211. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58212. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58213. * @param files defines the explicit list of files (undefined by default)
  58214. */
  58215. constructor(
  58216. /**
  58217. * Defines the name of the task
  58218. */
  58219. name: string,
  58220. /**
  58221. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58222. */
  58223. url: string,
  58224. /**
  58225. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58226. */
  58227. extensions?: string[] | undefined,
  58228. /**
  58229. * Defines if mipmaps should not be generated (default is false)
  58230. */
  58231. noMipmap?: boolean | undefined,
  58232. /**
  58233. * Defines the explicit list of files (undefined by default)
  58234. */
  58235. files?: string[] | undefined);
  58236. /**
  58237. * Execute the current task
  58238. * @param scene defines the scene where you want your assets to be loaded
  58239. * @param onSuccess is a callback called when the task is successfully executed
  58240. * @param onError is a callback called if an error occurs
  58241. */
  58242. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58243. }
  58244. /**
  58245. * Define a task used by AssetsManager to load HDR cube textures
  58246. */
  58247. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58248. /**
  58249. * Defines the name of the task
  58250. */
  58251. name: string;
  58252. /**
  58253. * Defines the location of the file to load
  58254. */
  58255. url: string;
  58256. /**
  58257. * Defines the desired size (the more it increases the longer the generation will be)
  58258. */
  58259. size: number;
  58260. /**
  58261. * Defines if mipmaps should not be generated (default is false)
  58262. */
  58263. noMipmap: boolean;
  58264. /**
  58265. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58266. */
  58267. generateHarmonics: boolean;
  58268. /**
  58269. * 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)
  58270. */
  58271. gammaSpace: boolean;
  58272. /**
  58273. * Internal Use Only
  58274. */
  58275. reserved: boolean;
  58276. /**
  58277. * Gets the loaded texture
  58278. */
  58279. texture: HDRCubeTexture;
  58280. /**
  58281. * Callback called when the task is successful
  58282. */
  58283. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58284. /**
  58285. * Callback called when the task is successful
  58286. */
  58287. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58288. /**
  58289. * Creates a new HDRCubeTextureAssetTask object
  58290. * @param name defines the name of the task
  58291. * @param url defines the location of the file to load
  58292. * @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.
  58293. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58294. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58295. * @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)
  58296. * @param reserved Internal use only
  58297. */
  58298. constructor(
  58299. /**
  58300. * Defines the name of the task
  58301. */
  58302. name: string,
  58303. /**
  58304. * Defines the location of the file to load
  58305. */
  58306. url: string,
  58307. /**
  58308. * Defines the desired size (the more it increases the longer the generation will be)
  58309. */
  58310. size: number,
  58311. /**
  58312. * Defines if mipmaps should not be generated (default is false)
  58313. */
  58314. noMipmap?: boolean,
  58315. /**
  58316. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58317. */
  58318. generateHarmonics?: boolean,
  58319. /**
  58320. * 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)
  58321. */
  58322. gammaSpace?: boolean,
  58323. /**
  58324. * Internal Use Only
  58325. */
  58326. reserved?: boolean);
  58327. /**
  58328. * Execute the current task
  58329. * @param scene defines the scene where you want your assets to be loaded
  58330. * @param onSuccess is a callback called when the task is successfully executed
  58331. * @param onError is a callback called if an error occurs
  58332. */
  58333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58334. }
  58335. /**
  58336. * Define a task used by AssetsManager to load Equirectangular cube textures
  58337. */
  58338. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58339. /**
  58340. * Defines the name of the task
  58341. */
  58342. name: string;
  58343. /**
  58344. * Defines the location of the file to load
  58345. */
  58346. url: string;
  58347. /**
  58348. * Defines the desired size (the more it increases the longer the generation will be)
  58349. */
  58350. size: number;
  58351. /**
  58352. * Defines if mipmaps should not be generated (default is false)
  58353. */
  58354. noMipmap: boolean;
  58355. /**
  58356. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58357. * but the standard material would require them in Gamma space) (default is true)
  58358. */
  58359. gammaSpace: boolean;
  58360. /**
  58361. * Gets the loaded texture
  58362. */
  58363. texture: EquiRectangularCubeTexture;
  58364. /**
  58365. * Callback called when the task is successful
  58366. */
  58367. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58368. /**
  58369. * Callback called when the task is successful
  58370. */
  58371. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58372. /**
  58373. * Creates a new EquiRectangularCubeTextureAssetTask object
  58374. * @param name defines the name of the task
  58375. * @param url defines the location of the file to load
  58376. * @param size defines the desired size (the more it increases the longer the generation will be)
  58377. * If the size is omitted this implies you are using a preprocessed cubemap.
  58378. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58379. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58380. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58381. * (default is true)
  58382. */
  58383. constructor(
  58384. /**
  58385. * Defines the name of the task
  58386. */
  58387. name: string,
  58388. /**
  58389. * Defines the location of the file to load
  58390. */
  58391. url: string,
  58392. /**
  58393. * Defines the desired size (the more it increases the longer the generation will be)
  58394. */
  58395. size: number,
  58396. /**
  58397. * Defines if mipmaps should not be generated (default is false)
  58398. */
  58399. noMipmap?: boolean,
  58400. /**
  58401. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58402. * but the standard material would require them in Gamma space) (default is true)
  58403. */
  58404. gammaSpace?: boolean);
  58405. /**
  58406. * Execute the current task
  58407. * @param scene defines the scene where you want your assets to be loaded
  58408. * @param onSuccess is a callback called when the task is successfully executed
  58409. * @param onError is a callback called if an error occurs
  58410. */
  58411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58412. }
  58413. /**
  58414. * This class can be used to easily import assets into a scene
  58415. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58416. */
  58417. export class AssetsManager {
  58418. private _scene;
  58419. private _isLoading;
  58420. protected _tasks: AbstractAssetTask[];
  58421. protected _waitingTasksCount: number;
  58422. protected _totalTasksCount: number;
  58423. /**
  58424. * Callback called when all tasks are processed
  58425. */
  58426. onFinish: (tasks: AbstractAssetTask[]) => void;
  58427. /**
  58428. * Callback called when a task is successful
  58429. */
  58430. onTaskSuccess: (task: AbstractAssetTask) => void;
  58431. /**
  58432. * Callback called when a task had an error
  58433. */
  58434. onTaskError: (task: AbstractAssetTask) => void;
  58435. /**
  58436. * Callback called when a task is done (whatever the result is)
  58437. */
  58438. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58439. /**
  58440. * Observable called when all tasks are processed
  58441. */
  58442. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58443. /**
  58444. * Observable called when a task had an error
  58445. */
  58446. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58447. /**
  58448. * Observable called when all tasks were executed
  58449. */
  58450. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58451. /**
  58452. * Observable called when a task is done (whatever the result is)
  58453. */
  58454. onProgressObservable: Observable<IAssetsProgressEvent>;
  58455. /**
  58456. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58457. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58458. */
  58459. useDefaultLoadingScreen: boolean;
  58460. /**
  58461. * Creates a new AssetsManager
  58462. * @param scene defines the scene to work on
  58463. */
  58464. constructor(scene: Scene);
  58465. /**
  58466. * Add a MeshAssetTask to the list of active tasks
  58467. * @param taskName defines the name of the new task
  58468. * @param meshesNames defines the name of meshes to load
  58469. * @param rootUrl defines the root url to use to locate files
  58470. * @param sceneFilename defines the filename of the scene file
  58471. * @returns a new MeshAssetTask object
  58472. */
  58473. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58474. /**
  58475. * Add a TextFileAssetTask to the list of active tasks
  58476. * @param taskName defines the name of the new task
  58477. * @param url defines the url of the file to load
  58478. * @returns a new TextFileAssetTask object
  58479. */
  58480. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58481. /**
  58482. * Add a BinaryFileAssetTask to the list of active tasks
  58483. * @param taskName defines the name of the new task
  58484. * @param url defines the url of the file to load
  58485. * @returns a new BinaryFileAssetTask object
  58486. */
  58487. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58488. /**
  58489. * Add a ImageAssetTask to the list of active tasks
  58490. * @param taskName defines the name of the new task
  58491. * @param url defines the url of the file to load
  58492. * @returns a new ImageAssetTask object
  58493. */
  58494. addImageTask(taskName: string, url: string): ImageAssetTask;
  58495. /**
  58496. * Add a TextureAssetTask to the list of active tasks
  58497. * @param taskName defines the name of the new task
  58498. * @param url defines the url of the file to load
  58499. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58500. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58501. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58502. * @returns a new TextureAssetTask object
  58503. */
  58504. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58505. /**
  58506. * Add a CubeTextureAssetTask to the list of active tasks
  58507. * @param taskName defines the name of the new task
  58508. * @param url defines the url of the file to load
  58509. * @param extensions defines the extension to use to load the cube map (can be null)
  58510. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58511. * @param files defines the list of files to load (can be null)
  58512. * @returns a new CubeTextureAssetTask object
  58513. */
  58514. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58515. /**
  58516. *
  58517. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58518. * @param taskName defines the name of the new task
  58519. * @param url defines the url of the file to load
  58520. * @param size defines the size you want for the cubemap (can be null)
  58521. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58522. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58523. * @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)
  58524. * @param reserved Internal use only
  58525. * @returns a new HDRCubeTextureAssetTask object
  58526. */
  58527. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58528. /**
  58529. *
  58530. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58531. * @param taskName defines the name of the new task
  58532. * @param url defines the url of the file to load
  58533. * @param size defines the size you want for the cubemap (can be null)
  58534. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58535. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58536. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58537. * @returns a new EquiRectangularCubeTextureAssetTask object
  58538. */
  58539. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58540. /**
  58541. * Remove a task from the assets manager.
  58542. * @param task the task to remove
  58543. */
  58544. removeTask(task: AbstractAssetTask): void;
  58545. private _decreaseWaitingTasksCount;
  58546. private _runTask;
  58547. /**
  58548. * Reset the AssetsManager and remove all tasks
  58549. * @return the current instance of the AssetsManager
  58550. */
  58551. reset(): AssetsManager;
  58552. /**
  58553. * Start the loading process
  58554. * @return the current instance of the AssetsManager
  58555. */
  58556. load(): AssetsManager;
  58557. /**
  58558. * Start the loading process as an async operation
  58559. * @return a promise returning the list of failed tasks
  58560. */
  58561. loadAsync(): Promise<void>;
  58562. }
  58563. }
  58564. declare module BABYLON {
  58565. /**
  58566. * Wrapper class for promise with external resolve and reject.
  58567. */
  58568. export class Deferred<T> {
  58569. /**
  58570. * The promise associated with this deferred object.
  58571. */
  58572. readonly promise: Promise<T>;
  58573. private _resolve;
  58574. private _reject;
  58575. /**
  58576. * The resolve method of the promise associated with this deferred object.
  58577. */
  58578. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58579. /**
  58580. * The reject method of the promise associated with this deferred object.
  58581. */
  58582. readonly reject: (reason?: any) => void;
  58583. /**
  58584. * Constructor for this deferred object.
  58585. */
  58586. constructor();
  58587. }
  58588. }
  58589. declare module BABYLON {
  58590. /**
  58591. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58592. */
  58593. export class MeshExploder {
  58594. private _centerMesh;
  58595. private _meshes;
  58596. private _meshesOrigins;
  58597. private _toCenterVectors;
  58598. private _scaledDirection;
  58599. private _newPosition;
  58600. private _centerPosition;
  58601. /**
  58602. * Explodes meshes from a center mesh.
  58603. * @param meshes The meshes to explode.
  58604. * @param centerMesh The mesh to be center of explosion.
  58605. */
  58606. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58607. private _setCenterMesh;
  58608. /**
  58609. * Get class name
  58610. * @returns "MeshExploder"
  58611. */
  58612. getClassName(): string;
  58613. /**
  58614. * "Exploded meshes"
  58615. * @returns Array of meshes with the centerMesh at index 0.
  58616. */
  58617. getMeshes(): Array<Mesh>;
  58618. /**
  58619. * Explodes meshes giving a specific direction
  58620. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58621. */
  58622. explode(direction?: number): void;
  58623. }
  58624. }
  58625. declare module BABYLON {
  58626. /**
  58627. * Class used to help managing file picking and drag'n'drop
  58628. */
  58629. export class FilesInput {
  58630. /**
  58631. * List of files ready to be loaded
  58632. */
  58633. static readonly FilesToLoad: {
  58634. [key: string]: File;
  58635. };
  58636. /**
  58637. * Callback called when a file is processed
  58638. */
  58639. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58640. private _engine;
  58641. private _currentScene;
  58642. private _sceneLoadedCallback;
  58643. private _progressCallback;
  58644. private _additionalRenderLoopLogicCallback;
  58645. private _textureLoadingCallback;
  58646. private _startingProcessingFilesCallback;
  58647. private _onReloadCallback;
  58648. private _errorCallback;
  58649. private _elementToMonitor;
  58650. private _sceneFileToLoad;
  58651. private _filesToLoad;
  58652. /**
  58653. * Creates a new FilesInput
  58654. * @param engine defines the rendering engine
  58655. * @param scene defines the hosting scene
  58656. * @param sceneLoadedCallback callback called when scene is loaded
  58657. * @param progressCallback callback called to track progress
  58658. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58659. * @param textureLoadingCallback callback called when a texture is loading
  58660. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58661. * @param onReloadCallback callback called when a reload is requested
  58662. * @param errorCallback callback call if an error occurs
  58663. */
  58664. 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);
  58665. private _dragEnterHandler;
  58666. private _dragOverHandler;
  58667. private _dropHandler;
  58668. /**
  58669. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58670. * @param elementToMonitor defines the DOM element to track
  58671. */
  58672. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58673. /**
  58674. * Release all associated resources
  58675. */
  58676. dispose(): void;
  58677. private renderFunction;
  58678. private drag;
  58679. private drop;
  58680. private _traverseFolder;
  58681. private _processFiles;
  58682. /**
  58683. * Load files from a drop event
  58684. * @param event defines the drop event to use as source
  58685. */
  58686. loadFiles(event: any): void;
  58687. private _processReload;
  58688. /**
  58689. * Reload the current scene from the loaded files
  58690. */
  58691. reload(): void;
  58692. }
  58693. }
  58694. declare module BABYLON {
  58695. /**
  58696. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58698. */
  58699. export class SceneOptimization {
  58700. /**
  58701. * Defines the priority of this optimization (0 by default which means first in the list)
  58702. */
  58703. priority: number;
  58704. /**
  58705. * Gets a string describing the action executed by the current optimization
  58706. * @returns description string
  58707. */
  58708. getDescription(): string;
  58709. /**
  58710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58711. * @param scene defines the current scene where to apply this optimization
  58712. * @param optimizer defines the current optimizer
  58713. * @returns true if everything that can be done was applied
  58714. */
  58715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58716. /**
  58717. * Creates the SceneOptimization object
  58718. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58719. * @param desc defines the description associated with the optimization
  58720. */
  58721. constructor(
  58722. /**
  58723. * Defines the priority of this optimization (0 by default which means first in the list)
  58724. */
  58725. priority?: number);
  58726. }
  58727. /**
  58728. * Defines an optimization used to reduce the size of render target textures
  58729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58730. */
  58731. export class TextureOptimization extends SceneOptimization {
  58732. /**
  58733. * Defines the priority of this optimization (0 by default which means first in the list)
  58734. */
  58735. priority: number;
  58736. /**
  58737. * 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
  58738. */
  58739. maximumSize: number;
  58740. /**
  58741. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58742. */
  58743. step: number;
  58744. /**
  58745. * Gets a string describing the action executed by the current optimization
  58746. * @returns description string
  58747. */
  58748. getDescription(): string;
  58749. /**
  58750. * Creates the TextureOptimization object
  58751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58752. * @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
  58753. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58754. */
  58755. constructor(
  58756. /**
  58757. * Defines the priority of this optimization (0 by default which means first in the list)
  58758. */
  58759. priority?: number,
  58760. /**
  58761. * 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
  58762. */
  58763. maximumSize?: number,
  58764. /**
  58765. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58766. */
  58767. step?: number);
  58768. /**
  58769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58770. * @param scene defines the current scene where to apply this optimization
  58771. * @param optimizer defines the current optimizer
  58772. * @returns true if everything that can be done was applied
  58773. */
  58774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58775. }
  58776. /**
  58777. * Defines an optimization used to increase or decrease the rendering resolution
  58778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58779. */
  58780. export class HardwareScalingOptimization extends SceneOptimization {
  58781. /**
  58782. * Defines the priority of this optimization (0 by default which means first in the list)
  58783. */
  58784. priority: number;
  58785. /**
  58786. * Defines the maximum scale to use (2 by default)
  58787. */
  58788. maximumScale: number;
  58789. /**
  58790. * Defines the step to use between two passes (0.5 by default)
  58791. */
  58792. step: number;
  58793. private _currentScale;
  58794. private _directionOffset;
  58795. /**
  58796. * Gets a string describing the action executed by the current optimization
  58797. * @return description string
  58798. */
  58799. getDescription(): string;
  58800. /**
  58801. * Creates the HardwareScalingOptimization object
  58802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58803. * @param maximumScale defines the maximum scale to use (2 by default)
  58804. * @param step defines the step to use between two passes (0.5 by default)
  58805. */
  58806. constructor(
  58807. /**
  58808. * Defines the priority of this optimization (0 by default which means first in the list)
  58809. */
  58810. priority?: number,
  58811. /**
  58812. * Defines the maximum scale to use (2 by default)
  58813. */
  58814. maximumScale?: number,
  58815. /**
  58816. * Defines the step to use between two passes (0.5 by default)
  58817. */
  58818. step?: number);
  58819. /**
  58820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58821. * @param scene defines the current scene where to apply this optimization
  58822. * @param optimizer defines the current optimizer
  58823. * @returns true if everything that can be done was applied
  58824. */
  58825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58826. }
  58827. /**
  58828. * Defines an optimization used to remove shadows
  58829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58830. */
  58831. export class ShadowsOptimization extends SceneOptimization {
  58832. /**
  58833. * Gets a string describing the action executed by the current optimization
  58834. * @return description string
  58835. */
  58836. getDescription(): string;
  58837. /**
  58838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58839. * @param scene defines the current scene where to apply this optimization
  58840. * @param optimizer defines the current optimizer
  58841. * @returns true if everything that can be done was applied
  58842. */
  58843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58844. }
  58845. /**
  58846. * Defines an optimization used to turn post-processes off
  58847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58848. */
  58849. export class PostProcessesOptimization extends SceneOptimization {
  58850. /**
  58851. * Gets a string describing the action executed by the current optimization
  58852. * @return description string
  58853. */
  58854. getDescription(): string;
  58855. /**
  58856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58857. * @param scene defines the current scene where to apply this optimization
  58858. * @param optimizer defines the current optimizer
  58859. * @returns true if everything that can be done was applied
  58860. */
  58861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58862. }
  58863. /**
  58864. * Defines an optimization used to turn lens flares off
  58865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58866. */
  58867. export class LensFlaresOptimization extends SceneOptimization {
  58868. /**
  58869. * Gets a string describing the action executed by the current optimization
  58870. * @return description string
  58871. */
  58872. getDescription(): string;
  58873. /**
  58874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58875. * @param scene defines the current scene where to apply this optimization
  58876. * @param optimizer defines the current optimizer
  58877. * @returns true if everything that can be done was applied
  58878. */
  58879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58880. }
  58881. /**
  58882. * Defines an optimization based on user defined callback.
  58883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58884. */
  58885. export class CustomOptimization extends SceneOptimization {
  58886. /**
  58887. * Callback called to apply the custom optimization.
  58888. */
  58889. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58890. /**
  58891. * Callback called to get custom description
  58892. */
  58893. onGetDescription: () => string;
  58894. /**
  58895. * Gets a string describing the action executed by the current optimization
  58896. * @returns description string
  58897. */
  58898. getDescription(): string;
  58899. /**
  58900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58901. * @param scene defines the current scene where to apply this optimization
  58902. * @param optimizer defines the current optimizer
  58903. * @returns true if everything that can be done was applied
  58904. */
  58905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58906. }
  58907. /**
  58908. * Defines an optimization used to turn particles off
  58909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58910. */
  58911. export class ParticlesOptimization extends SceneOptimization {
  58912. /**
  58913. * Gets a string describing the action executed by the current optimization
  58914. * @return description string
  58915. */
  58916. getDescription(): string;
  58917. /**
  58918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58919. * @param scene defines the current scene where to apply this optimization
  58920. * @param optimizer defines the current optimizer
  58921. * @returns true if everything that can be done was applied
  58922. */
  58923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58924. }
  58925. /**
  58926. * Defines an optimization used to turn render targets off
  58927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58928. */
  58929. export class RenderTargetsOptimization extends SceneOptimization {
  58930. /**
  58931. * Gets a string describing the action executed by the current optimization
  58932. * @return description string
  58933. */
  58934. getDescription(): string;
  58935. /**
  58936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58937. * @param scene defines the current scene where to apply this optimization
  58938. * @param optimizer defines the current optimizer
  58939. * @returns true if everything that can be done was applied
  58940. */
  58941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58942. }
  58943. /**
  58944. * Defines an optimization used to merge meshes with compatible materials
  58945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58946. */
  58947. export class MergeMeshesOptimization extends SceneOptimization {
  58948. private static _UpdateSelectionTree;
  58949. /**
  58950. * Gets or sets a boolean which defines if optimization octree has to be updated
  58951. */
  58952. /**
  58953. * Gets or sets a boolean which defines if optimization octree has to be updated
  58954. */
  58955. static UpdateSelectionTree: boolean;
  58956. /**
  58957. * Gets a string describing the action executed by the current optimization
  58958. * @return description string
  58959. */
  58960. getDescription(): string;
  58961. private _canBeMerged;
  58962. /**
  58963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58964. * @param scene defines the current scene where to apply this optimization
  58965. * @param optimizer defines the current optimizer
  58966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58967. * @returns true if everything that can be done was applied
  58968. */
  58969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58970. }
  58971. /**
  58972. * Defines a list of options used by SceneOptimizer
  58973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58974. */
  58975. export class SceneOptimizerOptions {
  58976. /**
  58977. * Defines the target frame rate to reach (60 by default)
  58978. */
  58979. targetFrameRate: number;
  58980. /**
  58981. * Defines the interval between two checkes (2000ms by default)
  58982. */
  58983. trackerDuration: number;
  58984. /**
  58985. * Gets the list of optimizations to apply
  58986. */
  58987. optimizations: SceneOptimization[];
  58988. /**
  58989. * Creates a new list of options used by SceneOptimizer
  58990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58992. */
  58993. constructor(
  58994. /**
  58995. * Defines the target frame rate to reach (60 by default)
  58996. */
  58997. targetFrameRate?: number,
  58998. /**
  58999. * Defines the interval between two checkes (2000ms by default)
  59000. */
  59001. trackerDuration?: number);
  59002. /**
  59003. * Add a new optimization
  59004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59005. * @returns the current SceneOptimizerOptions
  59006. */
  59007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59008. /**
  59009. * Add a new custom optimization
  59010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59013. * @returns the current SceneOptimizerOptions
  59014. */
  59015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59016. /**
  59017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59018. * @param targetFrameRate defines the target frame rate (60 by default)
  59019. * @returns a SceneOptimizerOptions object
  59020. */
  59021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59022. /**
  59023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59024. * @param targetFrameRate defines the target frame rate (60 by default)
  59025. * @returns a SceneOptimizerOptions object
  59026. */
  59027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59028. /**
  59029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59030. * @param targetFrameRate defines the target frame rate (60 by default)
  59031. * @returns a SceneOptimizerOptions object
  59032. */
  59033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59034. }
  59035. /**
  59036. * Class used to run optimizations in order to reach a target frame rate
  59037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59038. */
  59039. export class SceneOptimizer implements IDisposable {
  59040. private _isRunning;
  59041. private _options;
  59042. private _scene;
  59043. private _currentPriorityLevel;
  59044. private _targetFrameRate;
  59045. private _trackerDuration;
  59046. private _currentFrameRate;
  59047. private _sceneDisposeObserver;
  59048. private _improvementMode;
  59049. /**
  59050. * Defines an observable called when the optimizer reaches the target frame rate
  59051. */
  59052. onSuccessObservable: Observable<SceneOptimizer>;
  59053. /**
  59054. * Defines an observable called when the optimizer enables an optimization
  59055. */
  59056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59057. /**
  59058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59059. */
  59060. onFailureObservable: Observable<SceneOptimizer>;
  59061. /**
  59062. * Gets a boolean indicating if the optimizer is in improvement mode
  59063. */
  59064. readonly isInImprovementMode: boolean;
  59065. /**
  59066. * Gets the current priority level (0 at start)
  59067. */
  59068. readonly currentPriorityLevel: number;
  59069. /**
  59070. * Gets the current frame rate checked by the SceneOptimizer
  59071. */
  59072. readonly currentFrameRate: number;
  59073. /**
  59074. * Gets or sets the current target frame rate (60 by default)
  59075. */
  59076. /**
  59077. * Gets or sets the current target frame rate (60 by default)
  59078. */
  59079. targetFrameRate: number;
  59080. /**
  59081. * Gets or sets the current interval between two checks (every 2000ms by default)
  59082. */
  59083. /**
  59084. * Gets or sets the current interval between two checks (every 2000ms by default)
  59085. */
  59086. trackerDuration: number;
  59087. /**
  59088. * Gets the list of active optimizations
  59089. */
  59090. readonly optimizations: SceneOptimization[];
  59091. /**
  59092. * Creates a new SceneOptimizer
  59093. * @param scene defines the scene to work on
  59094. * @param options defines the options to use with the SceneOptimizer
  59095. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59096. * @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)
  59097. */
  59098. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59099. /**
  59100. * Stops the current optimizer
  59101. */
  59102. stop(): void;
  59103. /**
  59104. * Reset the optimizer to initial step (current priority level = 0)
  59105. */
  59106. reset(): void;
  59107. /**
  59108. * Start the optimizer. By default it will try to reach a specific framerate
  59109. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59110. */
  59111. start(): void;
  59112. private _checkCurrentState;
  59113. /**
  59114. * Release all resources
  59115. */
  59116. dispose(): void;
  59117. /**
  59118. * Helper function to create a SceneOptimizer with one single line of code
  59119. * @param scene defines the scene to work on
  59120. * @param options defines the options to use with the SceneOptimizer
  59121. * @param onSuccess defines a callback to call on success
  59122. * @param onFailure defines a callback to call on failure
  59123. * @returns the new SceneOptimizer object
  59124. */
  59125. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59126. }
  59127. }
  59128. declare module BABYLON {
  59129. /**
  59130. * Class used to serialize a scene into a string
  59131. */
  59132. export class SceneSerializer {
  59133. /**
  59134. * Clear cache used by a previous serialization
  59135. */
  59136. static ClearCache(): void;
  59137. /**
  59138. * Serialize a scene into a JSON compatible object
  59139. * @param scene defines the scene to serialize
  59140. * @returns a JSON compatible object
  59141. */
  59142. static Serialize(scene: Scene): any;
  59143. /**
  59144. * Serialize a mesh into a JSON compatible object
  59145. * @param toSerialize defines the mesh to serialize
  59146. * @param withParents defines if parents must be serialized as well
  59147. * @param withChildren defines if children must be serialized as well
  59148. * @returns a JSON compatible object
  59149. */
  59150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59151. }
  59152. }
  59153. declare module BABYLON {
  59154. /**
  59155. * Class used to host texture specific utilities
  59156. */
  59157. export class TextureTools {
  59158. /**
  59159. * Uses the GPU to create a copy texture rescaled at a given size
  59160. * @param texture Texture to copy from
  59161. * @param width defines the desired width
  59162. * @param height defines the desired height
  59163. * @param useBilinearMode defines if bilinear mode has to be used
  59164. * @return the generated texture
  59165. */
  59166. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59167. }
  59168. }
  59169. declare module BABYLON {
  59170. /**
  59171. * This represents the different options available for the video capture.
  59172. */
  59173. export interface VideoRecorderOptions {
  59174. /** Defines the mime type of the video. */
  59175. mimeType: string;
  59176. /** Defines the FPS the video should be recorded at. */
  59177. fps: number;
  59178. /** Defines the chunk size for the recording data. */
  59179. recordChunckSize: number;
  59180. /** The audio tracks to attach to the recording. */
  59181. audioTracks?: MediaStreamTrack[];
  59182. }
  59183. /**
  59184. * This can help with recording videos from BabylonJS.
  59185. * This is based on the available WebRTC functionalities of the browser.
  59186. *
  59187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59188. */
  59189. export class VideoRecorder {
  59190. private static readonly _defaultOptions;
  59191. /**
  59192. * Returns whether or not the VideoRecorder is available in your browser.
  59193. * @param engine Defines the Babylon Engine.
  59194. * @returns true if supported otherwise false.
  59195. */
  59196. static IsSupported(engine: Engine): boolean;
  59197. private readonly _options;
  59198. private _canvas;
  59199. private _mediaRecorder;
  59200. private _recordedChunks;
  59201. private _fileName;
  59202. private _resolve;
  59203. private _reject;
  59204. /**
  59205. * True when a recording is already in progress.
  59206. */
  59207. readonly isRecording: boolean;
  59208. /**
  59209. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59210. * @param engine Defines the BabylonJS Engine you wish to record.
  59211. * @param options Defines options that can be used to customize the capture.
  59212. */
  59213. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59214. /**
  59215. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59216. */
  59217. stopRecording(): void;
  59218. /**
  59219. * Starts recording the canvas for a max duration specified in parameters.
  59220. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59221. * If null no automatic download will start and you can rely on the promise to get the data back.
  59222. * @param maxDuration Defines the maximum recording time in seconds.
  59223. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59224. * @return A promise callback at the end of the recording with the video data in Blob.
  59225. */
  59226. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59227. /**
  59228. * Releases internal resources used during the recording.
  59229. */
  59230. dispose(): void;
  59231. private _handleDataAvailable;
  59232. private _handleError;
  59233. private _handleStop;
  59234. }
  59235. }
  59236. declare module BABYLON {
  59237. /**
  59238. * Class containing a set of static utilities functions for screenshots
  59239. */
  59240. export class ScreenshotTools {
  59241. /**
  59242. * Captures a screenshot of the current rendering
  59243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59244. * @param engine defines the rendering engine
  59245. * @param camera defines the source camera
  59246. * @param size This parameter can be set to a single number or to an object with the
  59247. * following (optional) properties: precision, width, height. If a single number is passed,
  59248. * it will be used for both width and height. If an object is passed, the screenshot size
  59249. * will be derived from the parameters. The precision property is a multiplier allowing
  59250. * rendering at a higher or lower resolution
  59251. * @param successCallback defines the callback receives a single parameter which contains the
  59252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59253. * src parameter of an <img> to display it
  59254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59255. * Check your browser for supported MIME types
  59256. */
  59257. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59258. /**
  59259. * Generates an image screenshot from the specified camera.
  59260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59261. * @param engine The engine to use for rendering
  59262. * @param camera The camera to use for rendering
  59263. * @param size This parameter can be set to a single number or to an object with the
  59264. * following (optional) properties: precision, width, height. If a single number is passed,
  59265. * it will be used for both width and height. If an object is passed, the screenshot size
  59266. * will be derived from the parameters. The precision property is a multiplier allowing
  59267. * rendering at a higher or lower resolution
  59268. * @param successCallback The callback receives a single parameter which contains the
  59269. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59270. * src parameter of an <img> to display it
  59271. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59272. * Check your browser for supported MIME types
  59273. * @param samples Texture samples (default: 1)
  59274. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59275. * @param fileName A name for for the downloaded file.
  59276. */
  59277. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59278. }
  59279. }
  59280. declare module BABYLON {
  59281. /**
  59282. * A cursor which tracks a point on a path
  59283. */
  59284. export class PathCursor {
  59285. private path;
  59286. /**
  59287. * Stores path cursor callbacks for when an onchange event is triggered
  59288. */
  59289. private _onchange;
  59290. /**
  59291. * The value of the path cursor
  59292. */
  59293. value: number;
  59294. /**
  59295. * The animation array of the path cursor
  59296. */
  59297. animations: Animation[];
  59298. /**
  59299. * Initializes the path cursor
  59300. * @param path The path to track
  59301. */
  59302. constructor(path: Path2);
  59303. /**
  59304. * Gets the cursor point on the path
  59305. * @returns A point on the path cursor at the cursor location
  59306. */
  59307. getPoint(): Vector3;
  59308. /**
  59309. * Moves the cursor ahead by the step amount
  59310. * @param step The amount to move the cursor forward
  59311. * @returns This path cursor
  59312. */
  59313. moveAhead(step?: number): PathCursor;
  59314. /**
  59315. * Moves the cursor behind by the step amount
  59316. * @param step The amount to move the cursor back
  59317. * @returns This path cursor
  59318. */
  59319. moveBack(step?: number): PathCursor;
  59320. /**
  59321. * Moves the cursor by the step amount
  59322. * If the step amount is greater than one, an exception is thrown
  59323. * @param step The amount to move the cursor
  59324. * @returns This path cursor
  59325. */
  59326. move(step: number): PathCursor;
  59327. /**
  59328. * Ensures that the value is limited between zero and one
  59329. * @returns This path cursor
  59330. */
  59331. private ensureLimits;
  59332. /**
  59333. * Runs onchange callbacks on change (used by the animation engine)
  59334. * @returns This path cursor
  59335. */
  59336. private raiseOnChange;
  59337. /**
  59338. * Executes a function on change
  59339. * @param f A path cursor onchange callback
  59340. * @returns This path cursor
  59341. */
  59342. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59343. }
  59344. }
  59345. declare module BABYLON {
  59346. /** @hidden */
  59347. export var blurPixelShader: {
  59348. name: string;
  59349. shader: string;
  59350. };
  59351. }
  59352. declare module BABYLON {
  59353. /** @hidden */
  59354. export var pointCloudVertexDeclaration: {
  59355. name: string;
  59356. shader: string;
  59357. };
  59358. }
  59359. // Mixins
  59360. interface Window {
  59361. mozIndexedDB: IDBFactory;
  59362. webkitIndexedDB: IDBFactory;
  59363. msIndexedDB: IDBFactory;
  59364. webkitURL: typeof URL;
  59365. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59366. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59367. WebGLRenderingContext: WebGLRenderingContext;
  59368. MSGesture: MSGesture;
  59369. CANNON: any;
  59370. AudioContext: AudioContext;
  59371. webkitAudioContext: AudioContext;
  59372. PointerEvent: any;
  59373. Math: Math;
  59374. Uint8Array: Uint8ArrayConstructor;
  59375. Float32Array: Float32ArrayConstructor;
  59376. mozURL: typeof URL;
  59377. msURL: typeof URL;
  59378. VRFrameData: any; // WebVR, from specs 1.1
  59379. DracoDecoderModule: any;
  59380. setImmediate(handler: (...args: any[]) => void): number;
  59381. }
  59382. interface HTMLCanvasElement {
  59383. requestPointerLock(): void;
  59384. msRequestPointerLock?(): void;
  59385. mozRequestPointerLock?(): void;
  59386. webkitRequestPointerLock?(): void;
  59387. /** Track wether a record is in progress */
  59388. isRecording: boolean;
  59389. /** Capture Stream method defined by some browsers */
  59390. captureStream(fps?: number): MediaStream;
  59391. }
  59392. interface CanvasRenderingContext2D {
  59393. msImageSmoothingEnabled: boolean;
  59394. }
  59395. interface MouseEvent {
  59396. mozMovementX: number;
  59397. mozMovementY: number;
  59398. webkitMovementX: number;
  59399. webkitMovementY: number;
  59400. msMovementX: number;
  59401. msMovementY: number;
  59402. }
  59403. interface Navigator {
  59404. mozGetVRDevices: (any: any) => any;
  59405. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59406. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59407. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59408. webkitGetGamepads(): Gamepad[];
  59409. msGetGamepads(): Gamepad[];
  59410. webkitGamepads(): Gamepad[];
  59411. }
  59412. interface HTMLVideoElement {
  59413. mozSrcObject: any;
  59414. }
  59415. interface Math {
  59416. fround(x: number): number;
  59417. imul(a: number, b: number): number;
  59418. }
  59419. interface WebGLRenderingContext {
  59420. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59421. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59422. vertexAttribDivisor(index: number, divisor: number): void;
  59423. createVertexArray(): any;
  59424. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59425. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59426. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59427. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59428. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59429. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59430. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59431. // Queries
  59432. createQuery(): WebGLQuery;
  59433. deleteQuery(query: WebGLQuery): void;
  59434. beginQuery(target: number, query: WebGLQuery): void;
  59435. endQuery(target: number): void;
  59436. getQueryParameter(query: WebGLQuery, pname: number): any;
  59437. getQuery(target: number, pname: number): any;
  59438. MAX_SAMPLES: number;
  59439. RGBA8: number;
  59440. READ_FRAMEBUFFER: number;
  59441. DRAW_FRAMEBUFFER: number;
  59442. UNIFORM_BUFFER: number;
  59443. HALF_FLOAT_OES: number;
  59444. RGBA16F: number;
  59445. RGBA32F: number;
  59446. R32F: number;
  59447. RG32F: number;
  59448. RGB32F: number;
  59449. R16F: number;
  59450. RG16F: number;
  59451. RGB16F: number;
  59452. RED: number;
  59453. RG: number;
  59454. R8: number;
  59455. RG8: number;
  59456. UNSIGNED_INT_24_8: number;
  59457. DEPTH24_STENCIL8: number;
  59458. /* Multiple Render Targets */
  59459. drawBuffers(buffers: number[]): void;
  59460. readBuffer(src: number): void;
  59461. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59462. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59463. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59464. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59465. // Occlusion Query
  59466. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59467. ANY_SAMPLES_PASSED: number;
  59468. QUERY_RESULT_AVAILABLE: number;
  59469. QUERY_RESULT: number;
  59470. }
  59471. interface WebGLProgram {
  59472. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59473. }
  59474. interface EXT_disjoint_timer_query {
  59475. QUERY_COUNTER_BITS_EXT: number;
  59476. TIME_ELAPSED_EXT: number;
  59477. TIMESTAMP_EXT: number;
  59478. GPU_DISJOINT_EXT: number;
  59479. QUERY_RESULT_EXT: number;
  59480. QUERY_RESULT_AVAILABLE_EXT: number;
  59481. queryCounterEXT(query: WebGLQuery, target: number): void;
  59482. createQueryEXT(): WebGLQuery;
  59483. beginQueryEXT(target: number, query: WebGLQuery): void;
  59484. endQueryEXT(target: number): void;
  59485. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59486. deleteQueryEXT(query: WebGLQuery): void;
  59487. }
  59488. interface WebGLUniformLocation {
  59489. _currentState: any;
  59490. }
  59491. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59492. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59493. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59494. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59495. interface WebGLRenderingContext {
  59496. readonly RASTERIZER_DISCARD: number;
  59497. readonly DEPTH_COMPONENT24: number;
  59498. readonly TEXTURE_3D: number;
  59499. readonly TEXTURE_2D_ARRAY: number;
  59500. readonly TEXTURE_COMPARE_FUNC: number;
  59501. readonly TEXTURE_COMPARE_MODE: number;
  59502. readonly COMPARE_REF_TO_TEXTURE: number;
  59503. readonly TEXTURE_WRAP_R: number;
  59504. readonly HALF_FLOAT: number;
  59505. readonly RGB8: number;
  59506. readonly RED_INTEGER: number;
  59507. readonly RG_INTEGER: number;
  59508. readonly RGB_INTEGER: number;
  59509. readonly RGBA_INTEGER: number;
  59510. readonly R8_SNORM: number;
  59511. readonly RG8_SNORM: number;
  59512. readonly RGB8_SNORM: number;
  59513. readonly RGBA8_SNORM: number;
  59514. readonly R8I: number;
  59515. readonly RG8I: number;
  59516. readonly RGB8I: number;
  59517. readonly RGBA8I: number;
  59518. readonly R8UI: number;
  59519. readonly RG8UI: number;
  59520. readonly RGB8UI: number;
  59521. readonly RGBA8UI: number;
  59522. readonly R16I: number;
  59523. readonly RG16I: number;
  59524. readonly RGB16I: number;
  59525. readonly RGBA16I: number;
  59526. readonly R16UI: number;
  59527. readonly RG16UI: number;
  59528. readonly RGB16UI: number;
  59529. readonly RGBA16UI: number;
  59530. readonly R32I: number;
  59531. readonly RG32I: number;
  59532. readonly RGB32I: number;
  59533. readonly RGBA32I: number;
  59534. readonly R32UI: number;
  59535. readonly RG32UI: number;
  59536. readonly RGB32UI: number;
  59537. readonly RGBA32UI: number;
  59538. readonly RGB10_A2UI: number;
  59539. readonly R11F_G11F_B10F: number;
  59540. readonly RGB9_E5: number;
  59541. readonly RGB10_A2: number;
  59542. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59543. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59544. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59545. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59546. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59547. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59548. 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;
  59549. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59550. readonly TRANSFORM_FEEDBACK: number;
  59551. readonly INTERLEAVED_ATTRIBS: number;
  59552. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59553. createTransformFeedback(): WebGLTransformFeedback;
  59554. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59555. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59556. beginTransformFeedback(primitiveMode: number): void;
  59557. endTransformFeedback(): void;
  59558. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59559. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59560. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59561. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59562. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59563. }
  59564. interface ImageBitmap {
  59565. readonly width: number;
  59566. readonly height: number;
  59567. close(): void;
  59568. }
  59569. interface WebGLQuery extends WebGLObject {
  59570. }
  59571. declare var WebGLQuery: {
  59572. prototype: WebGLQuery;
  59573. new(): WebGLQuery;
  59574. };
  59575. interface WebGLSampler extends WebGLObject {
  59576. }
  59577. declare var WebGLSampler: {
  59578. prototype: WebGLSampler;
  59579. new(): WebGLSampler;
  59580. };
  59581. interface WebGLSync extends WebGLObject {
  59582. }
  59583. declare var WebGLSync: {
  59584. prototype: WebGLSync;
  59585. new(): WebGLSync;
  59586. };
  59587. interface WebGLTransformFeedback extends WebGLObject {
  59588. }
  59589. declare var WebGLTransformFeedback: {
  59590. prototype: WebGLTransformFeedback;
  59591. new(): WebGLTransformFeedback;
  59592. };
  59593. interface WebGLVertexArrayObject extends WebGLObject {
  59594. }
  59595. declare var WebGLVertexArrayObject: {
  59596. prototype: WebGLVertexArrayObject;
  59597. new(): WebGLVertexArrayObject;
  59598. };
  59599. // Type definitions for WebVR API
  59600. // Project: https://w3c.github.io/webvr/
  59601. // Definitions by: six a <https://github.com/lostfictions>
  59602. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59603. interface VRDisplay extends EventTarget {
  59604. /**
  59605. * Dictionary of capabilities describing the VRDisplay.
  59606. */
  59607. readonly capabilities: VRDisplayCapabilities;
  59608. /**
  59609. * z-depth defining the far plane of the eye view frustum
  59610. * enables mapping of values in the render target depth
  59611. * attachment to scene coordinates. Initially set to 10000.0.
  59612. */
  59613. depthFar: number;
  59614. /**
  59615. * z-depth defining the near plane of the eye view frustum
  59616. * enables mapping of values in the render target depth
  59617. * attachment to scene coordinates. Initially set to 0.01.
  59618. */
  59619. depthNear: number;
  59620. /**
  59621. * An identifier for this distinct VRDisplay. Used as an
  59622. * association point in the Gamepad API.
  59623. */
  59624. readonly displayId: number;
  59625. /**
  59626. * A display name, a user-readable name identifying it.
  59627. */
  59628. readonly displayName: string;
  59629. readonly isConnected: boolean;
  59630. readonly isPresenting: boolean;
  59631. /**
  59632. * If this VRDisplay supports room-scale experiences, the optional
  59633. * stage attribute contains details on the room-scale parameters.
  59634. */
  59635. readonly stageParameters: VRStageParameters | null;
  59636. /**
  59637. * Passing the value returned by `requestAnimationFrame` to
  59638. * `cancelAnimationFrame` will unregister the callback.
  59639. * @param handle Define the hanle of the request to cancel
  59640. */
  59641. cancelAnimationFrame(handle: number): void;
  59642. /**
  59643. * Stops presenting to the VRDisplay.
  59644. * @returns a promise to know when it stopped
  59645. */
  59646. exitPresent(): Promise<void>;
  59647. /**
  59648. * Return the current VREyeParameters for the given eye.
  59649. * @param whichEye Define the eye we want the parameter for
  59650. * @returns the eye parameters
  59651. */
  59652. getEyeParameters(whichEye: string): VREyeParameters;
  59653. /**
  59654. * Populates the passed VRFrameData with the information required to render
  59655. * the current frame.
  59656. * @param frameData Define the data structure to populate
  59657. * @returns true if ok otherwise false
  59658. */
  59659. getFrameData(frameData: VRFrameData): boolean;
  59660. /**
  59661. * Get the layers currently being presented.
  59662. * @returns the list of VR layers
  59663. */
  59664. getLayers(): VRLayer[];
  59665. /**
  59666. * Return a VRPose containing the future predicted pose of the VRDisplay
  59667. * when the current frame will be presented. The value returned will not
  59668. * change until JavaScript has returned control to the browser.
  59669. *
  59670. * The VRPose will contain the position, orientation, velocity,
  59671. * and acceleration of each of these properties.
  59672. * @returns the pose object
  59673. */
  59674. getPose(): VRPose;
  59675. /**
  59676. * Return the current instantaneous pose of the VRDisplay, with no
  59677. * prediction applied.
  59678. * @returns the current instantaneous pose
  59679. */
  59680. getImmediatePose(): VRPose;
  59681. /**
  59682. * The callback passed to `requestAnimationFrame` will be called
  59683. * any time a new frame should be rendered. When the VRDisplay is
  59684. * presenting the callback will be called at the native refresh
  59685. * rate of the HMD. When not presenting this function acts
  59686. * identically to how window.requestAnimationFrame acts. Content should
  59687. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59688. * asynchronously from other displays and at differing refresh rates.
  59689. * @param callback Define the eaction to run next frame
  59690. * @returns the request handle it
  59691. */
  59692. requestAnimationFrame(callback: FrameRequestCallback): number;
  59693. /**
  59694. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59695. * Repeat calls while already presenting will update the VRLayers being displayed.
  59696. * @param layers Define the list of layer to present
  59697. * @returns a promise to know when the request has been fulfilled
  59698. */
  59699. requestPresent(layers: VRLayer[]): Promise<void>;
  59700. /**
  59701. * Reset the pose for this display, treating its current position and
  59702. * orientation as the "origin/zero" values. VRPose.position,
  59703. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59704. * updated when calling resetPose(). This should be called in only
  59705. * sitting-space experiences.
  59706. */
  59707. resetPose(): void;
  59708. /**
  59709. * The VRLayer provided to the VRDisplay will be captured and presented
  59710. * in the HMD. Calling this function has the same effect on the source
  59711. * canvas as any other operation that uses its source image, and canvases
  59712. * created without preserveDrawingBuffer set to true will be cleared.
  59713. * @param pose Define the pose to submit
  59714. */
  59715. submitFrame(pose?: VRPose): void;
  59716. }
  59717. declare var VRDisplay: {
  59718. prototype: VRDisplay;
  59719. new(): VRDisplay;
  59720. };
  59721. interface VRLayer {
  59722. leftBounds?: number[] | Float32Array | null;
  59723. rightBounds?: number[] | Float32Array | null;
  59724. source?: HTMLCanvasElement | null;
  59725. }
  59726. interface VRDisplayCapabilities {
  59727. readonly canPresent: boolean;
  59728. readonly hasExternalDisplay: boolean;
  59729. readonly hasOrientation: boolean;
  59730. readonly hasPosition: boolean;
  59731. readonly maxLayers: number;
  59732. }
  59733. interface VREyeParameters {
  59734. /** @deprecated */
  59735. readonly fieldOfView: VRFieldOfView;
  59736. readonly offset: Float32Array;
  59737. readonly renderHeight: number;
  59738. readonly renderWidth: number;
  59739. }
  59740. interface VRFieldOfView {
  59741. readonly downDegrees: number;
  59742. readonly leftDegrees: number;
  59743. readonly rightDegrees: number;
  59744. readonly upDegrees: number;
  59745. }
  59746. interface VRFrameData {
  59747. readonly leftProjectionMatrix: Float32Array;
  59748. readonly leftViewMatrix: Float32Array;
  59749. readonly pose: VRPose;
  59750. readonly rightProjectionMatrix: Float32Array;
  59751. readonly rightViewMatrix: Float32Array;
  59752. readonly timestamp: number;
  59753. }
  59754. interface VRPose {
  59755. readonly angularAcceleration: Float32Array | null;
  59756. readonly angularVelocity: Float32Array | null;
  59757. readonly linearAcceleration: Float32Array | null;
  59758. readonly linearVelocity: Float32Array | null;
  59759. readonly orientation: Float32Array | null;
  59760. readonly position: Float32Array | null;
  59761. readonly timestamp: number;
  59762. }
  59763. interface VRStageParameters {
  59764. sittingToStandingTransform?: Float32Array;
  59765. sizeX?: number;
  59766. sizeY?: number;
  59767. }
  59768. interface Navigator {
  59769. getVRDisplays(): Promise<VRDisplay[]>;
  59770. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59771. }
  59772. interface Window {
  59773. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59774. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59775. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59776. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59777. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59778. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59779. }
  59780. interface Gamepad {
  59781. readonly displayId: number;
  59782. }
  59783. interface XRDevice {
  59784. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59785. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59786. }
  59787. interface XRSession {
  59788. getInputSources(): Array<any>;
  59789. baseLayer: XRWebGLLayer;
  59790. requestFrameOfReference(type: string): Promise<void>;
  59791. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59792. end(): Promise<void>;
  59793. requestAnimationFrame: Function;
  59794. addEventListener: Function;
  59795. }
  59796. interface XRSessionCreationOptions {
  59797. outputContext?: WebGLRenderingContext | null;
  59798. immersive?: boolean;
  59799. environmentIntegration?: boolean;
  59800. }
  59801. interface XRLayer {
  59802. getViewport: Function;
  59803. framebufferWidth: number;
  59804. framebufferHeight: number;
  59805. }
  59806. interface XRView {
  59807. projectionMatrix: Float32Array;
  59808. }
  59809. interface XRFrame {
  59810. getDevicePose: Function;
  59811. getInputPose: Function;
  59812. views: Array<XRView>;
  59813. baseLayer: XRLayer;
  59814. }
  59815. interface XRFrameOfReference {
  59816. }
  59817. interface XRWebGLLayer extends XRLayer {
  59818. framebuffer: WebGLFramebuffer;
  59819. }
  59820. declare var XRWebGLLayer: {
  59821. prototype: XRWebGLLayer;
  59822. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59823. };
  59824. declare module BABYLON.GUI {
  59825. /**
  59826. * Class used to specific a value and its associated unit
  59827. */
  59828. export class ValueAndUnit {
  59829. /** defines the unit to store */
  59830. unit: number;
  59831. /** defines a boolean indicating if the value can be negative */
  59832. negativeValueAllowed: boolean;
  59833. private _value;
  59834. private _originalUnit;
  59835. /**
  59836. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59837. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59838. */
  59839. ignoreAdaptiveScaling: boolean;
  59840. /**
  59841. * Creates a new ValueAndUnit
  59842. * @param value defines the value to store
  59843. * @param unit defines the unit to store
  59844. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59845. */
  59846. constructor(value: number,
  59847. /** defines the unit to store */
  59848. unit?: number,
  59849. /** defines a boolean indicating if the value can be negative */
  59850. negativeValueAllowed?: boolean);
  59851. /** Gets a boolean indicating if the value is a percentage */
  59852. readonly isPercentage: boolean;
  59853. /** Gets a boolean indicating if the value is store as pixel */
  59854. readonly isPixel: boolean;
  59855. /** Gets direct internal value */
  59856. readonly internalValue: number;
  59857. /**
  59858. * Gets value as pixel
  59859. * @param host defines the root host
  59860. * @param refValue defines the reference value for percentages
  59861. * @returns the value as pixel
  59862. */
  59863. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59864. /**
  59865. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59866. * @param value defines the value to store
  59867. * @param unit defines the unit to store
  59868. * @returns the current ValueAndUnit
  59869. */
  59870. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59871. /**
  59872. * Gets the value accordingly to its unit
  59873. * @param host defines the root host
  59874. * @returns the value
  59875. */
  59876. getValue(host: AdvancedDynamicTexture): number;
  59877. /**
  59878. * Gets a string representation of the value
  59879. * @param host defines the root host
  59880. * @param decimals defines an optional number of decimals to display
  59881. * @returns a string
  59882. */
  59883. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59884. /**
  59885. * Store a value parsed from a string
  59886. * @param source defines the source string
  59887. * @returns true if the value was successfully parsed
  59888. */
  59889. fromString(source: string | number): boolean;
  59890. private static _Regex;
  59891. private static _UNITMODE_PERCENTAGE;
  59892. private static _UNITMODE_PIXEL;
  59893. /** UNITMODE_PERCENTAGE */
  59894. static readonly UNITMODE_PERCENTAGE: number;
  59895. /** UNITMODE_PIXEL */
  59896. static readonly UNITMODE_PIXEL: number;
  59897. }
  59898. }
  59899. declare module BABYLON.GUI {
  59900. /**
  59901. * Define a style used by control to automatically setup properties based on a template.
  59902. * Only support font related properties so far
  59903. */
  59904. export class Style implements BABYLON.IDisposable {
  59905. private _fontFamily;
  59906. private _fontStyle;
  59907. private _fontWeight;
  59908. /** @hidden */
  59909. _host: AdvancedDynamicTexture;
  59910. /** @hidden */
  59911. _fontSize: ValueAndUnit;
  59912. /**
  59913. * BABYLON.Observable raised when the style values are changed
  59914. */
  59915. onChangedObservable: BABYLON.Observable<Style>;
  59916. /**
  59917. * Creates a new style object
  59918. * @param host defines the AdvancedDynamicTexture which hosts this style
  59919. */
  59920. constructor(host: AdvancedDynamicTexture);
  59921. /**
  59922. * Gets or sets the font size
  59923. */
  59924. fontSize: string | number;
  59925. /**
  59926. * Gets or sets the font family
  59927. */
  59928. fontFamily: string;
  59929. /**
  59930. * Gets or sets the font style
  59931. */
  59932. fontStyle: string;
  59933. /** Gets or sets font weight */
  59934. fontWeight: string;
  59935. /** Dispose all associated resources */
  59936. dispose(): void;
  59937. }
  59938. }
  59939. declare module BABYLON.GUI {
  59940. /**
  59941. * Class used to transport BABYLON.Vector2 information for pointer events
  59942. */
  59943. export class Vector2WithInfo extends BABYLON.Vector2 {
  59944. /** defines the current mouse button index */
  59945. buttonIndex: number;
  59946. /**
  59947. * Creates a new Vector2WithInfo
  59948. * @param source defines the vector2 data to transport
  59949. * @param buttonIndex defines the current mouse button index
  59950. */
  59951. constructor(source: BABYLON.Vector2,
  59952. /** defines the current mouse button index */
  59953. buttonIndex?: number);
  59954. }
  59955. /** Class used to provide 2D matrix features */
  59956. export class Matrix2D {
  59957. /** Gets the internal array of 6 floats used to store matrix data */
  59958. m: Float32Array;
  59959. /**
  59960. * Creates a new matrix
  59961. * @param m00 defines value for (0, 0)
  59962. * @param m01 defines value for (0, 1)
  59963. * @param m10 defines value for (1, 0)
  59964. * @param m11 defines value for (1, 1)
  59965. * @param m20 defines value for (2, 0)
  59966. * @param m21 defines value for (2, 1)
  59967. */
  59968. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59969. /**
  59970. * Fills the matrix from direct values
  59971. * @param m00 defines value for (0, 0)
  59972. * @param m01 defines value for (0, 1)
  59973. * @param m10 defines value for (1, 0)
  59974. * @param m11 defines value for (1, 1)
  59975. * @param m20 defines value for (2, 0)
  59976. * @param m21 defines value for (2, 1)
  59977. * @returns the current modified matrix
  59978. */
  59979. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59980. /**
  59981. * Gets matrix determinant
  59982. * @returns the determinant
  59983. */
  59984. determinant(): number;
  59985. /**
  59986. * Inverses the matrix and stores it in a target matrix
  59987. * @param result defines the target matrix
  59988. * @returns the current matrix
  59989. */
  59990. invertToRef(result: Matrix2D): Matrix2D;
  59991. /**
  59992. * Multiplies the current matrix with another one
  59993. * @param other defines the second operand
  59994. * @param result defines the target matrix
  59995. * @returns the current matrix
  59996. */
  59997. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59998. /**
  59999. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  60000. * @param x defines the x coordinate to transform
  60001. * @param y defines the x coordinate to transform
  60002. * @param result defines the target vector2
  60003. * @returns the current matrix
  60004. */
  60005. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60006. /**
  60007. * Creates an identity matrix
  60008. * @returns a new matrix
  60009. */
  60010. static Identity(): Matrix2D;
  60011. /**
  60012. * Creates a translation matrix and stores it in a target matrix
  60013. * @param x defines the x coordinate of the translation
  60014. * @param y defines the y coordinate of the translation
  60015. * @param result defines the target matrix
  60016. */
  60017. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60018. /**
  60019. * Creates a scaling matrix and stores it in a target matrix
  60020. * @param x defines the x coordinate of the scaling
  60021. * @param y defines the y coordinate of the scaling
  60022. * @param result defines the target matrix
  60023. */
  60024. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60025. /**
  60026. * Creates a rotation matrix and stores it in a target matrix
  60027. * @param angle defines the rotation angle
  60028. * @param result defines the target matrix
  60029. */
  60030. static RotationToRef(angle: number, result: Matrix2D): void;
  60031. private static _TempPreTranslationMatrix;
  60032. private static _TempPostTranslationMatrix;
  60033. private static _TempRotationMatrix;
  60034. private static _TempScalingMatrix;
  60035. private static _TempCompose0;
  60036. private static _TempCompose1;
  60037. private static _TempCompose2;
  60038. /**
  60039. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60040. * @param tx defines the x coordinate of the translation
  60041. * @param ty defines the y coordinate of the translation
  60042. * @param angle defines the rotation angle
  60043. * @param scaleX defines the x coordinate of the scaling
  60044. * @param scaleY defines the y coordinate of the scaling
  60045. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60046. * @param result defines the target matrix
  60047. */
  60048. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60049. }
  60050. }
  60051. declare module BABYLON.GUI {
  60052. /**
  60053. * Class used to store 2D control sizes
  60054. */
  60055. export class Measure {
  60056. /** defines left coordinate */
  60057. left: number;
  60058. /** defines top coordinate */
  60059. top: number;
  60060. /** defines width dimension */
  60061. width: number;
  60062. /** defines height dimension */
  60063. height: number;
  60064. /**
  60065. * Creates a new measure
  60066. * @param left defines left coordinate
  60067. * @param top defines top coordinate
  60068. * @param width defines width dimension
  60069. * @param height defines height dimension
  60070. */
  60071. constructor(
  60072. /** defines left coordinate */
  60073. left: number,
  60074. /** defines top coordinate */
  60075. top: number,
  60076. /** defines width dimension */
  60077. width: number,
  60078. /** defines height dimension */
  60079. height: number);
  60080. /**
  60081. * Copy from another measure
  60082. * @param other defines the other measure to copy from
  60083. */
  60084. copyFrom(other: Measure): void;
  60085. /**
  60086. * Copy from a group of 4 floats
  60087. * @param left defines left coordinate
  60088. * @param top defines top coordinate
  60089. * @param width defines width dimension
  60090. * @param height defines height dimension
  60091. */
  60092. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60093. /**
  60094. * Computes the axis aligned bounding box measure for two given measures
  60095. * @param a Input measure
  60096. * @param b Input measure
  60097. * @param result the resulting bounding measure
  60098. */
  60099. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60100. /**
  60101. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60102. * @param transform the matrix to transform the measure before computing the AABB
  60103. * @param result the resulting AABB
  60104. */
  60105. transformToRef(transform: Matrix2D, result: Measure): void;
  60106. /**
  60107. * Check equality between this measure and another one
  60108. * @param other defines the other measures
  60109. * @returns true if both measures are equals
  60110. */
  60111. isEqualsTo(other: Measure): boolean;
  60112. /**
  60113. * Creates an empty measure
  60114. * @returns a new measure
  60115. */
  60116. static Empty(): Measure;
  60117. }
  60118. }
  60119. declare module BABYLON.GUI {
  60120. /**
  60121. * Interface used to define a control that can receive focus
  60122. */
  60123. export interface IFocusableControl {
  60124. /**
  60125. * Function called when the control receives the focus
  60126. */
  60127. onFocus(): void;
  60128. /**
  60129. * Function called when the control loses the focus
  60130. */
  60131. onBlur(): void;
  60132. /**
  60133. * Function called to let the control handle keyboard events
  60134. * @param evt defines the current keyboard event
  60135. */
  60136. processKeyboard(evt: KeyboardEvent): void;
  60137. /**
  60138. * Function called to get the list of controls that should not steal the focus from this control
  60139. * @returns an array of controls
  60140. */
  60141. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60142. }
  60143. /**
  60144. * Class used to create texture to support 2D GUI elements
  60145. * @see http://doc.babylonjs.com/how_to/gui
  60146. */
  60147. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60148. private _isDirty;
  60149. private _renderObserver;
  60150. private _resizeObserver;
  60151. private _preKeyboardObserver;
  60152. private _pointerMoveObserver;
  60153. private _pointerObserver;
  60154. private _canvasPointerOutObserver;
  60155. private _background;
  60156. /** @hidden */
  60157. _rootContainer: Container;
  60158. /** @hidden */
  60159. _lastPickedControl: Control;
  60160. /** @hidden */
  60161. _lastControlOver: {
  60162. [pointerId: number]: Control;
  60163. };
  60164. /** @hidden */
  60165. _lastControlDown: {
  60166. [pointerId: number]: Control;
  60167. };
  60168. /** @hidden */
  60169. _capturingControl: {
  60170. [pointerId: number]: Control;
  60171. };
  60172. /** @hidden */
  60173. _shouldBlockPointer: boolean;
  60174. /** @hidden */
  60175. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60176. /** @hidden */
  60177. _linkedControls: Control[];
  60178. private _isFullscreen;
  60179. private _fullscreenViewport;
  60180. private _idealWidth;
  60181. private _idealHeight;
  60182. private _useSmallestIdeal;
  60183. private _renderAtIdealSize;
  60184. private _focusedControl;
  60185. private _blockNextFocusCheck;
  60186. private _renderScale;
  60187. private _rootCanvas;
  60188. private _cursorChanged;
  60189. /**
  60190. * Define type to string to ensure compatibility across browsers
  60191. * Safari doesn't support DataTransfer constructor
  60192. */
  60193. private _clipboardData;
  60194. /**
  60195. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60196. */
  60197. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60198. /**
  60199. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60200. */
  60201. onControlPickedObservable: BABYLON.Observable<Control>;
  60202. /**
  60203. * BABYLON.Observable event triggered before layout is evaluated
  60204. */
  60205. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60206. /**
  60207. * BABYLON.Observable event triggered after the layout was evaluated
  60208. */
  60209. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60210. /**
  60211. * BABYLON.Observable event triggered before the texture is rendered
  60212. */
  60213. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60214. /**
  60215. * BABYLON.Observable event triggered after the texture was rendered
  60216. */
  60217. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60218. /**
  60219. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60220. */
  60221. premulAlpha: boolean;
  60222. /**
  60223. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60224. * Useful when you want more antialiasing
  60225. */
  60226. renderScale: number;
  60227. /** Gets or sets the background color */
  60228. background: string;
  60229. /**
  60230. * Gets or sets the ideal width used to design controls.
  60231. * The GUI will then rescale everything accordingly
  60232. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60233. */
  60234. idealWidth: number;
  60235. /**
  60236. * Gets or sets the ideal height used to design controls.
  60237. * The GUI will then rescale everything accordingly
  60238. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60239. */
  60240. idealHeight: number;
  60241. /**
  60242. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60243. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60244. */
  60245. useSmallestIdeal: boolean;
  60246. /**
  60247. * Gets or sets a boolean indicating if adaptive scaling must be used
  60248. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60249. */
  60250. renderAtIdealSize: boolean;
  60251. /**
  60252. * Gets the underlying layer used to render the texture when in fullscreen mode
  60253. */
  60254. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60255. /**
  60256. * Gets the root container control
  60257. */
  60258. readonly rootContainer: Container;
  60259. /**
  60260. * Returns an array containing the root container.
  60261. * This is mostly used to let the Inspector introspects the ADT
  60262. * @returns an array containing the rootContainer
  60263. */
  60264. getChildren(): Array<Container>;
  60265. /**
  60266. * Will return all controls that are inside this texture
  60267. * @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
  60268. * @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
  60269. * @return all child controls
  60270. */
  60271. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60272. /**
  60273. * Gets or sets the current focused control
  60274. */
  60275. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60276. /**
  60277. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60278. */
  60279. isForeground: boolean;
  60280. /**
  60281. * Gets or set information about clipboardData
  60282. */
  60283. clipboardData: string;
  60284. /**
  60285. * Creates a new AdvancedDynamicTexture
  60286. * @param name defines the name of the texture
  60287. * @param width defines the width of the texture
  60288. * @param height defines the height of the texture
  60289. * @param scene defines the hosting scene
  60290. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60291. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60292. */
  60293. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60294. /**
  60295. * Get the current class name of the texture useful for serialization or dynamic coding.
  60296. * @returns "AdvancedDynamicTexture"
  60297. */
  60298. getClassName(): string;
  60299. /**
  60300. * Function used to execute a function on all controls
  60301. * @param func defines the function to execute
  60302. * @param container defines the container where controls belong. If null the root container will be used
  60303. */
  60304. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60305. private _useInvalidateRectOptimization;
  60306. /**
  60307. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60308. */
  60309. useInvalidateRectOptimization: boolean;
  60310. private _invalidatedRectangle;
  60311. /**
  60312. * Invalidates a rectangle area on the gui texture
  60313. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60314. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60315. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60316. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60317. */
  60318. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60319. /**
  60320. * Marks the texture as dirty forcing a complete update
  60321. */
  60322. markAsDirty(): void;
  60323. /**
  60324. * Helper function used to create a new style
  60325. * @returns a new style
  60326. * @see http://doc.babylonjs.com/how_to/gui#styles
  60327. */
  60328. createStyle(): Style;
  60329. /**
  60330. * Adds a new control to the root container
  60331. * @param control defines the control to add
  60332. * @returns the current texture
  60333. */
  60334. addControl(control: Control): AdvancedDynamicTexture;
  60335. /**
  60336. * Removes a control from the root container
  60337. * @param control defines the control to remove
  60338. * @returns the current texture
  60339. */
  60340. removeControl(control: Control): AdvancedDynamicTexture;
  60341. /**
  60342. * Release all resources
  60343. */
  60344. dispose(): void;
  60345. private _onResize;
  60346. /** @hidden */
  60347. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60348. /**
  60349. * Get screen coordinates for a vector3
  60350. * @param position defines the position to project
  60351. * @param worldMatrix defines the world matrix to use
  60352. * @returns the projected position
  60353. */
  60354. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60355. private _checkUpdate;
  60356. private _clearMeasure;
  60357. private _render;
  60358. /** @hidden */
  60359. _changeCursor(cursor: string): void;
  60360. /** @hidden */
  60361. _registerLastControlDown(control: Control, pointerId: number): void;
  60362. private _doPicking;
  60363. /** @hidden */
  60364. _cleanControlAfterRemovalFromList(list: {
  60365. [pointerId: number]: Control;
  60366. }, control: Control): void;
  60367. /** @hidden */
  60368. _cleanControlAfterRemoval(control: Control): void;
  60369. /** Attach to all scene events required to support pointer events */
  60370. attach(): void;
  60371. /** @hidden */
  60372. private onClipboardCopy;
  60373. /** @hidden */
  60374. private onClipboardCut;
  60375. /** @hidden */
  60376. private onClipboardPaste;
  60377. /**
  60378. * Register the clipboard Events onto the canvas
  60379. */
  60380. registerClipboardEvents(): void;
  60381. /**
  60382. * Unregister the clipboard Events from the canvas
  60383. */
  60384. unRegisterClipboardEvents(): void;
  60385. /**
  60386. * Connect the texture to a hosting mesh to enable interactions
  60387. * @param mesh defines the mesh to attach to
  60388. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60389. */
  60390. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60391. /**
  60392. * Move the focus to a specific control
  60393. * @param control defines the control which will receive the focus
  60394. */
  60395. moveFocusToControl(control: IFocusableControl): void;
  60396. private _manageFocus;
  60397. private _attachToOnPointerOut;
  60398. /**
  60399. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60400. * @param mesh defines the mesh which will receive the texture
  60401. * @param width defines the texture width (1024 by default)
  60402. * @param height defines the texture height (1024 by default)
  60403. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60404. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60405. * @returns a new AdvancedDynamicTexture
  60406. */
  60407. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60408. /**
  60409. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60410. * In this mode the texture will rely on a layer for its rendering.
  60411. * This allows it to be treated like any other layer.
  60412. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60413. * LayerMask is set through advancedTexture.layer.layerMask
  60414. * @param name defines name for the texture
  60415. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60416. * @param scene defines the hsoting scene
  60417. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60418. * @returns a new AdvancedDynamicTexture
  60419. */
  60420. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60421. }
  60422. }
  60423. declare module BABYLON.GUI {
  60424. /**
  60425. * Root class used for all 2D controls
  60426. * @see http://doc.babylonjs.com/how_to/gui#controls
  60427. */
  60428. export class Control {
  60429. /** defines the name of the control */
  60430. name?: string | undefined;
  60431. /**
  60432. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60433. */
  60434. static AllowAlphaInheritance: boolean;
  60435. private _alpha;
  60436. private _alphaSet;
  60437. private _zIndex;
  60438. /** @hidden */
  60439. _host: AdvancedDynamicTexture;
  60440. /** Gets or sets the control parent */
  60441. parent: BABYLON.Nullable<Container>;
  60442. /** @hidden */
  60443. _currentMeasure: Measure;
  60444. private _fontFamily;
  60445. private _fontStyle;
  60446. private _fontWeight;
  60447. private _fontSize;
  60448. private _font;
  60449. /** @hidden */
  60450. _width: ValueAndUnit;
  60451. /** @hidden */
  60452. _height: ValueAndUnit;
  60453. /** @hidden */
  60454. protected _fontOffset: {
  60455. ascent: number;
  60456. height: number;
  60457. descent: number;
  60458. };
  60459. private _color;
  60460. private _style;
  60461. private _styleObserver;
  60462. /** @hidden */
  60463. protected _horizontalAlignment: number;
  60464. /** @hidden */
  60465. protected _verticalAlignment: number;
  60466. /** @hidden */
  60467. protected _isDirty: boolean;
  60468. /** @hidden */
  60469. protected _wasDirty: boolean;
  60470. /** @hidden */
  60471. _tempParentMeasure: Measure;
  60472. /** @hidden */
  60473. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60474. /** @hidden */
  60475. protected _cachedParentMeasure: Measure;
  60476. private _paddingLeft;
  60477. private _paddingRight;
  60478. private _paddingTop;
  60479. private _paddingBottom;
  60480. /** @hidden */
  60481. _left: ValueAndUnit;
  60482. /** @hidden */
  60483. _top: ValueAndUnit;
  60484. private _scaleX;
  60485. private _scaleY;
  60486. private _rotation;
  60487. private _transformCenterX;
  60488. private _transformCenterY;
  60489. /** @hidden */
  60490. _transformMatrix: Matrix2D;
  60491. /** @hidden */
  60492. protected _invertTransformMatrix: Matrix2D;
  60493. /** @hidden */
  60494. protected _transformedPosition: BABYLON.Vector2;
  60495. private _isMatrixDirty;
  60496. private _cachedOffsetX;
  60497. private _cachedOffsetY;
  60498. private _isVisible;
  60499. private _isHighlighted;
  60500. /** @hidden */
  60501. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60502. private _fontSet;
  60503. private _dummyVector2;
  60504. private _downCount;
  60505. private _enterCount;
  60506. private _doNotRender;
  60507. private _downPointerIds;
  60508. protected _isEnabled: boolean;
  60509. protected _disabledColor: string;
  60510. /** @hidden */
  60511. protected _rebuildLayout: boolean;
  60512. /** @hidden */
  60513. _isClipped: boolean;
  60514. /** @hidden */
  60515. _tag: any;
  60516. /**
  60517. * 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
  60518. */
  60519. uniqueId: number;
  60520. /**
  60521. * Gets or sets an object used to store user defined information for the node
  60522. */
  60523. metadata: any;
  60524. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60525. isHitTestVisible: boolean;
  60526. /** Gets or sets a boolean indicating if the control can block pointer events */
  60527. isPointerBlocker: boolean;
  60528. /** Gets or sets a boolean indicating if the control can be focusable */
  60529. isFocusInvisible: boolean;
  60530. /**
  60531. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60532. * 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
  60533. */
  60534. clipChildren: boolean;
  60535. /**
  60536. * Gets or sets a boolean indicating that control content must be clipped
  60537. * 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
  60538. */
  60539. clipContent: boolean;
  60540. /**
  60541. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60542. */
  60543. useBitmapCache: boolean;
  60544. private _cacheData;
  60545. private _shadowOffsetX;
  60546. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60547. shadowOffsetX: number;
  60548. private _shadowOffsetY;
  60549. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60550. shadowOffsetY: number;
  60551. private _shadowBlur;
  60552. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60553. shadowBlur: number;
  60554. private _shadowColor;
  60555. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60556. shadowColor: string;
  60557. /** Gets or sets the cursor to use when the control is hovered */
  60558. hoverCursor: string;
  60559. /** @hidden */
  60560. protected _linkOffsetX: ValueAndUnit;
  60561. /** @hidden */
  60562. protected _linkOffsetY: ValueAndUnit;
  60563. /** Gets the control type name */
  60564. readonly typeName: string;
  60565. /**
  60566. * Get the current class name of the control.
  60567. * @returns current class name
  60568. */
  60569. getClassName(): string;
  60570. /**
  60571. * An event triggered when the pointer move over the control.
  60572. */
  60573. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60574. /**
  60575. * An event triggered when the pointer move out of the control.
  60576. */
  60577. onPointerOutObservable: BABYLON.Observable<Control>;
  60578. /**
  60579. * An event triggered when the pointer taps the control
  60580. */
  60581. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60582. /**
  60583. * An event triggered when pointer up
  60584. */
  60585. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60586. /**
  60587. * An event triggered when a control is clicked on
  60588. */
  60589. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60590. /**
  60591. * An event triggered when pointer enters the control
  60592. */
  60593. onPointerEnterObservable: BABYLON.Observable<Control>;
  60594. /**
  60595. * An event triggered when the control is marked as dirty
  60596. */
  60597. onDirtyObservable: BABYLON.Observable<Control>;
  60598. /**
  60599. * An event triggered before drawing the control
  60600. */
  60601. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60602. /**
  60603. * An event triggered after the control was drawn
  60604. */
  60605. onAfterDrawObservable: BABYLON.Observable<Control>;
  60606. /**
  60607. * Get the hosting AdvancedDynamicTexture
  60608. */
  60609. readonly host: AdvancedDynamicTexture;
  60610. /** Gets or set information about font offsets (used to render and align text) */
  60611. fontOffset: {
  60612. ascent: number;
  60613. height: number;
  60614. descent: number;
  60615. };
  60616. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60617. alpha: number;
  60618. /**
  60619. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60620. */
  60621. isHighlighted: boolean;
  60622. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60623. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60624. */
  60625. scaleX: number;
  60626. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60627. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60628. */
  60629. scaleY: number;
  60630. /** Gets or sets the rotation angle (0 by default)
  60631. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60632. */
  60633. rotation: number;
  60634. /** Gets or sets the transformation center on Y axis (0 by default)
  60635. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60636. */
  60637. transformCenterY: number;
  60638. /** Gets or sets the transformation center on X axis (0 by default)
  60639. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60640. */
  60641. transformCenterX: number;
  60642. /**
  60643. * Gets or sets the horizontal alignment
  60644. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60645. */
  60646. horizontalAlignment: number;
  60647. /**
  60648. * Gets or sets the vertical alignment
  60649. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60650. */
  60651. verticalAlignment: number;
  60652. /**
  60653. * Gets or sets control width
  60654. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60655. */
  60656. width: string | number;
  60657. /**
  60658. * Gets or sets the control width in pixel
  60659. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60660. */
  60661. widthInPixels: number;
  60662. /**
  60663. * Gets or sets control height
  60664. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60665. */
  60666. height: string | number;
  60667. /**
  60668. * Gets or sets control height in pixel
  60669. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60670. */
  60671. heightInPixels: number;
  60672. /** Gets or set font family */
  60673. fontFamily: string;
  60674. /** Gets or sets font style */
  60675. fontStyle: string;
  60676. /** Gets or sets font weight */
  60677. fontWeight: string;
  60678. /**
  60679. * Gets or sets style
  60680. * @see http://doc.babylonjs.com/how_to/gui#styles
  60681. */
  60682. style: BABYLON.Nullable<Style>;
  60683. /** @hidden */
  60684. readonly _isFontSizeInPercentage: boolean;
  60685. /** Gets or sets font size in pixels */
  60686. fontSizeInPixels: number;
  60687. /** Gets or sets font size */
  60688. fontSize: string | number;
  60689. /** Gets or sets foreground color */
  60690. color: string;
  60691. /** Gets or sets z index which is used to reorder controls on the z axis */
  60692. zIndex: number;
  60693. /** Gets or sets a boolean indicating if the control can be rendered */
  60694. notRenderable: boolean;
  60695. /** Gets or sets a boolean indicating if the control is visible */
  60696. isVisible: boolean;
  60697. /** Gets a boolean indicating that the control needs to update its rendering */
  60698. readonly isDirty: boolean;
  60699. /**
  60700. * Gets the current linked mesh (or null if none)
  60701. */
  60702. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60703. /**
  60704. * Gets or sets a value indicating the padding to use on the left of the control
  60705. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60706. */
  60707. paddingLeft: string | number;
  60708. /**
  60709. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60710. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60711. */
  60712. paddingLeftInPixels: number;
  60713. /**
  60714. * Gets or sets a value indicating the padding to use on the right of the control
  60715. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60716. */
  60717. paddingRight: string | number;
  60718. /**
  60719. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60720. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60721. */
  60722. paddingRightInPixels: number;
  60723. /**
  60724. * Gets or sets a value indicating the padding to use on the top of the control
  60725. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60726. */
  60727. paddingTop: string | number;
  60728. /**
  60729. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60730. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60731. */
  60732. paddingTopInPixels: number;
  60733. /**
  60734. * Gets or sets a value indicating the padding to use on the bottom of the control
  60735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60736. */
  60737. paddingBottom: string | number;
  60738. /**
  60739. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60740. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60741. */
  60742. paddingBottomInPixels: number;
  60743. /**
  60744. * Gets or sets a value indicating the left coordinate of the control
  60745. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60746. */
  60747. left: string | number;
  60748. /**
  60749. * Gets or sets a value indicating the left coordinate in pixels of the control
  60750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60751. */
  60752. leftInPixels: number;
  60753. /**
  60754. * Gets or sets a value indicating the top coordinate of the control
  60755. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60756. */
  60757. top: string | number;
  60758. /**
  60759. * Gets or sets a value indicating the top coordinate in pixels of the control
  60760. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60761. */
  60762. topInPixels: number;
  60763. /**
  60764. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60765. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60766. */
  60767. linkOffsetX: string | number;
  60768. /**
  60769. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60770. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60771. */
  60772. linkOffsetXInPixels: number;
  60773. /**
  60774. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60775. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60776. */
  60777. linkOffsetY: string | number;
  60778. /**
  60779. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60780. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60781. */
  60782. linkOffsetYInPixels: number;
  60783. /** Gets the center coordinate on X axis */
  60784. readonly centerX: number;
  60785. /** Gets the center coordinate on Y axis */
  60786. readonly centerY: number;
  60787. /** Gets or sets if control is Enabled*/
  60788. isEnabled: boolean;
  60789. /** Gets or sets background color of control if it's disabled*/
  60790. disabledColor: string;
  60791. /**
  60792. * Creates a new control
  60793. * @param name defines the name of the control
  60794. */
  60795. constructor(
  60796. /** defines the name of the control */
  60797. name?: string | undefined);
  60798. /** @hidden */
  60799. protected _getTypeName(): string;
  60800. /**
  60801. * Gets the first ascendant in the hierarchy of the given type
  60802. * @param className defines the required type
  60803. * @returns the ascendant or null if not found
  60804. */
  60805. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60806. /** @hidden */
  60807. _resetFontCache(): void;
  60808. /**
  60809. * Determines if a container is an ascendant of the current control
  60810. * @param container defines the container to look for
  60811. * @returns true if the container is one of the ascendant of the control
  60812. */
  60813. isAscendant(container: Control): boolean;
  60814. /**
  60815. * Gets coordinates in local control space
  60816. * @param globalCoordinates defines the coordinates to transform
  60817. * @returns the new coordinates in local space
  60818. */
  60819. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60820. /**
  60821. * Gets coordinates in local control space
  60822. * @param globalCoordinates defines the coordinates to transform
  60823. * @param result defines the target vector2 where to store the result
  60824. * @returns the current control
  60825. */
  60826. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60827. /**
  60828. * Gets coordinates in parent local control space
  60829. * @param globalCoordinates defines the coordinates to transform
  60830. * @returns the new coordinates in parent local space
  60831. */
  60832. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60833. /**
  60834. * Move the current control to a vector3 position projected onto the screen.
  60835. * @param position defines the target position
  60836. * @param scene defines the hosting scene
  60837. */
  60838. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60839. /** @hidden */
  60840. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60841. /**
  60842. * Will return all controls that have this control as ascendant
  60843. * @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
  60844. * @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
  60845. * @return all child controls
  60846. */
  60847. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60848. /**
  60849. * Link current control with a target mesh
  60850. * @param mesh defines the mesh to link with
  60851. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60852. */
  60853. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60854. /** @hidden */
  60855. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60856. /** @hidden */
  60857. _offsetLeft(offset: number): void;
  60858. /** @hidden */
  60859. _offsetTop(offset: number): void;
  60860. /** @hidden */
  60861. _markMatrixAsDirty(): void;
  60862. /** @hidden */
  60863. _flagDescendantsAsMatrixDirty(): void;
  60864. /** @hidden */
  60865. _intersectsRect(rect: Measure): boolean;
  60866. /** @hidden */
  60867. protected invalidateRect(): void;
  60868. /** @hidden */
  60869. _markAsDirty(force?: boolean): void;
  60870. /** @hidden */
  60871. _markAllAsDirty(): void;
  60872. /** @hidden */
  60873. _link(host: AdvancedDynamicTexture): void;
  60874. /** @hidden */
  60875. protected _transform(context?: CanvasRenderingContext2D): void;
  60876. /** @hidden */
  60877. _renderHighlight(context: CanvasRenderingContext2D): void;
  60878. /** @hidden */
  60879. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60880. /** @hidden */
  60881. protected _applyStates(context: CanvasRenderingContext2D): void;
  60882. /** @hidden */
  60883. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60884. /** @hidden */
  60885. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60886. protected _evaluateClippingState(parentMeasure: Measure): void;
  60887. /** @hidden */
  60888. _measure(): void;
  60889. /** @hidden */
  60890. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60891. /** @hidden */
  60892. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60893. /** @hidden */
  60894. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60895. /** @hidden */
  60896. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60897. private static _ClipMeasure;
  60898. private _tmpMeasureA;
  60899. private _clip;
  60900. /** @hidden */
  60901. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60902. /** @hidden */
  60903. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60904. /**
  60905. * Tests if a given coordinates belong to the current control
  60906. * @param x defines x coordinate to test
  60907. * @param y defines y coordinate to test
  60908. * @returns true if the coordinates are inside the control
  60909. */
  60910. contains(x: number, y: number): boolean;
  60911. /** @hidden */
  60912. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60913. /** @hidden */
  60914. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60915. /** @hidden */
  60916. _onPointerEnter(target: Control): boolean;
  60917. /** @hidden */
  60918. _onPointerOut(target: Control, force?: boolean): void;
  60919. /** @hidden */
  60920. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60921. /** @hidden */
  60922. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60923. /** @hidden */
  60924. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60925. /** @hidden */
  60926. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60927. private _prepareFont;
  60928. /** Releases associated resources */
  60929. dispose(): void;
  60930. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60931. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60932. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60933. private static _VERTICAL_ALIGNMENT_TOP;
  60934. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60935. private static _VERTICAL_ALIGNMENT_CENTER;
  60936. /** HORIZONTAL_ALIGNMENT_LEFT */
  60937. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60938. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60939. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60940. /** HORIZONTAL_ALIGNMENT_CENTER */
  60941. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60942. /** VERTICAL_ALIGNMENT_TOP */
  60943. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60944. /** VERTICAL_ALIGNMENT_BOTTOM */
  60945. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60946. /** VERTICAL_ALIGNMENT_CENTER */
  60947. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60948. private static _FontHeightSizes;
  60949. /** @hidden */
  60950. static _GetFontOffset(font: string): {
  60951. ascent: number;
  60952. height: number;
  60953. descent: number;
  60954. };
  60955. /**
  60956. * Creates a stack panel that can be used to render headers
  60957. * @param control defines the control to associate with the header
  60958. * @param text defines the text of the header
  60959. * @param size defines the size of the header
  60960. * @param options defines options used to configure the header
  60961. * @returns a new StackPanel
  60962. * @ignore
  60963. * @hidden
  60964. */
  60965. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60966. isHorizontal: boolean;
  60967. controlFirst: boolean;
  60968. }) => any;
  60969. /** @hidden */
  60970. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60971. }
  60972. }
  60973. declare module BABYLON.GUI {
  60974. /**
  60975. * Root class for 2D containers
  60976. * @see http://doc.babylonjs.com/how_to/gui#containers
  60977. */
  60978. export class Container extends Control {
  60979. name?: string | undefined;
  60980. /** @hidden */
  60981. protected _children: Control[];
  60982. /** @hidden */
  60983. protected _measureForChildren: Measure;
  60984. /** @hidden */
  60985. protected _background: string;
  60986. /** @hidden */
  60987. protected _adaptWidthToChildren: boolean;
  60988. /** @hidden */
  60989. protected _adaptHeightToChildren: boolean;
  60990. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60991. adaptHeightToChildren: boolean;
  60992. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60993. adaptWidthToChildren: boolean;
  60994. /** Gets or sets background color */
  60995. background: string;
  60996. /** Gets the list of children */
  60997. readonly children: Control[];
  60998. /**
  60999. * Creates a new Container
  61000. * @param name defines the name of the container
  61001. */
  61002. constructor(name?: string | undefined);
  61003. protected _getTypeName(): string;
  61004. _flagDescendantsAsMatrixDirty(): void;
  61005. /**
  61006. * Gets a child using its name
  61007. * @param name defines the child name to look for
  61008. * @returns the child control if found
  61009. */
  61010. getChildByName(name: string): BABYLON.Nullable<Control>;
  61011. /**
  61012. * Gets a child using its type and its name
  61013. * @param name defines the child name to look for
  61014. * @param type defines the child type to look for
  61015. * @returns the child control if found
  61016. */
  61017. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61018. /**
  61019. * Search for a specific control in children
  61020. * @param control defines the control to look for
  61021. * @returns true if the control is in child list
  61022. */
  61023. containsControl(control: Control): boolean;
  61024. /**
  61025. * Adds a new control to the current container
  61026. * @param control defines the control to add
  61027. * @returns the current container
  61028. */
  61029. addControl(control: BABYLON.Nullable<Control>): Container;
  61030. /**
  61031. * Removes all controls from the current container
  61032. * @returns the current container
  61033. */
  61034. clearControls(): Container;
  61035. /**
  61036. * Removes a control from the current container
  61037. * @param control defines the control to remove
  61038. * @returns the current container
  61039. */
  61040. removeControl(control: Control): Container;
  61041. /** @hidden */
  61042. _reOrderControl(control: Control): void;
  61043. /** @hidden */
  61044. _offsetLeft(offset: number): void;
  61045. /** @hidden */
  61046. _offsetTop(offset: number): void;
  61047. /** @hidden */
  61048. _markAllAsDirty(): void;
  61049. /** @hidden */
  61050. protected _localDraw(context: CanvasRenderingContext2D): void;
  61051. /** @hidden */
  61052. _link(host: AdvancedDynamicTexture): void;
  61053. /** @hidden */
  61054. protected _beforeLayout(): void;
  61055. /** @hidden */
  61056. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61057. /** @hidden */
  61058. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61059. protected _postMeasure(): void;
  61060. /** @hidden */
  61061. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61062. /** @hidden */
  61063. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61064. /** @hidden */
  61065. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61066. /** @hidden */
  61067. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61068. /** Releases associated resources */
  61069. dispose(): void;
  61070. }
  61071. }
  61072. declare module BABYLON.GUI {
  61073. /** Class used to create rectangle container */
  61074. export class Rectangle extends Container {
  61075. name?: string | undefined;
  61076. private _thickness;
  61077. private _cornerRadius;
  61078. /** Gets or sets border thickness */
  61079. thickness: number;
  61080. /** Gets or sets the corner radius angle */
  61081. cornerRadius: number;
  61082. /**
  61083. * Creates a new Rectangle
  61084. * @param name defines the control name
  61085. */
  61086. constructor(name?: string | undefined);
  61087. protected _getTypeName(): string;
  61088. protected _localDraw(context: CanvasRenderingContext2D): void;
  61089. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61090. private _drawRoundedRect;
  61091. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61092. }
  61093. }
  61094. declare module BABYLON.GUI {
  61095. /**
  61096. * Enum that determines the text-wrapping mode to use.
  61097. */
  61098. export enum TextWrapping {
  61099. /**
  61100. * Clip the text when it's larger than Control.width; this is the default mode.
  61101. */
  61102. Clip = 0,
  61103. /**
  61104. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61105. */
  61106. WordWrap = 1,
  61107. /**
  61108. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61109. */
  61110. Ellipsis = 2
  61111. }
  61112. /**
  61113. * Class used to create text block control
  61114. */
  61115. export class TextBlock extends Control {
  61116. /**
  61117. * Defines the name of the control
  61118. */
  61119. name?: string | undefined;
  61120. private _text;
  61121. private _textWrapping;
  61122. private _textHorizontalAlignment;
  61123. private _textVerticalAlignment;
  61124. private _lines;
  61125. private _resizeToFit;
  61126. private _lineSpacing;
  61127. private _outlineWidth;
  61128. private _outlineColor;
  61129. /**
  61130. * An event triggered after the text is changed
  61131. */
  61132. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61133. /**
  61134. * An event triggered after the text was broken up into lines
  61135. */
  61136. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61137. /**
  61138. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61139. */
  61140. readonly lines: any[];
  61141. /**
  61142. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61143. */
  61144. /**
  61145. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61146. */
  61147. resizeToFit: boolean;
  61148. /**
  61149. * Gets or sets a boolean indicating if text must be wrapped
  61150. */
  61151. /**
  61152. * Gets or sets a boolean indicating if text must be wrapped
  61153. */
  61154. textWrapping: TextWrapping | boolean;
  61155. /**
  61156. * Gets or sets text to display
  61157. */
  61158. /**
  61159. * Gets or sets text to display
  61160. */
  61161. text: string;
  61162. /**
  61163. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61164. */
  61165. /**
  61166. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61167. */
  61168. textHorizontalAlignment: number;
  61169. /**
  61170. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61171. */
  61172. /**
  61173. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61174. */
  61175. textVerticalAlignment: number;
  61176. /**
  61177. * Gets or sets line spacing value
  61178. */
  61179. /**
  61180. * Gets or sets line spacing value
  61181. */
  61182. lineSpacing: string | number;
  61183. /**
  61184. * Gets or sets outlineWidth of the text to display
  61185. */
  61186. /**
  61187. * Gets or sets outlineWidth of the text to display
  61188. */
  61189. outlineWidth: number;
  61190. /**
  61191. * Gets or sets outlineColor of the text to display
  61192. */
  61193. /**
  61194. * Gets or sets outlineColor of the text to display
  61195. */
  61196. outlineColor: string;
  61197. /**
  61198. * Creates a new TextBlock object
  61199. * @param name defines the name of the control
  61200. * @param text defines the text to display (emptry string by default)
  61201. */
  61202. constructor(
  61203. /**
  61204. * Defines the name of the control
  61205. */
  61206. name?: string | undefined, text?: string);
  61207. protected _getTypeName(): string;
  61208. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61209. private _drawText;
  61210. /** @hidden */
  61211. _draw(context: CanvasRenderingContext2D): void;
  61212. protected _applyStates(context: CanvasRenderingContext2D): void;
  61213. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61214. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61215. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61216. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61217. protected _renderLines(context: CanvasRenderingContext2D): void;
  61218. /**
  61219. * Given a width constraint applied on the text block, find the expected height
  61220. * @returns expected height
  61221. */
  61222. computeExpectedHeight(): number;
  61223. dispose(): void;
  61224. }
  61225. }
  61226. declare module BABYLON.GUI {
  61227. /**
  61228. * Class used to create 2D images
  61229. */
  61230. export class Image extends Control {
  61231. name?: string | undefined;
  61232. private static _WorkingCanvas;
  61233. private _domImage;
  61234. private _imageWidth;
  61235. private _imageHeight;
  61236. private _loaded;
  61237. private _stretch;
  61238. private _source;
  61239. private _autoScale;
  61240. private _sourceLeft;
  61241. private _sourceTop;
  61242. private _sourceWidth;
  61243. private _sourceHeight;
  61244. private _cellWidth;
  61245. private _cellHeight;
  61246. private _cellId;
  61247. private _populateNinePatchSlicesFromImage;
  61248. private _sliceLeft;
  61249. private _sliceRight;
  61250. private _sliceTop;
  61251. private _sliceBottom;
  61252. private _detectPointerOnOpaqueOnly;
  61253. /**
  61254. * BABYLON.Observable notified when the content is loaded
  61255. */
  61256. onImageLoadedObservable: BABYLON.Observable<Image>;
  61257. /**
  61258. * Gets a boolean indicating that the content is loaded
  61259. */
  61260. readonly isLoaded: boolean;
  61261. /**
  61262. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61263. */
  61264. populateNinePatchSlicesFromImage: boolean;
  61265. /**
  61266. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61267. * Beware using this as this will comsume more memory as the image has to be stored twice
  61268. */
  61269. detectPointerOnOpaqueOnly: boolean;
  61270. /**
  61271. * Gets or sets the left value for slicing (9-patch)
  61272. */
  61273. sliceLeft: number;
  61274. /**
  61275. * Gets or sets the right value for slicing (9-patch)
  61276. */
  61277. sliceRight: number;
  61278. /**
  61279. * Gets or sets the top value for slicing (9-patch)
  61280. */
  61281. sliceTop: number;
  61282. /**
  61283. * Gets or sets the bottom value for slicing (9-patch)
  61284. */
  61285. sliceBottom: number;
  61286. /**
  61287. * Gets or sets the left coordinate in the source image
  61288. */
  61289. sourceLeft: number;
  61290. /**
  61291. * Gets or sets the top coordinate in the source image
  61292. */
  61293. sourceTop: number;
  61294. /**
  61295. * Gets or sets the width to capture in the source image
  61296. */
  61297. sourceWidth: number;
  61298. /**
  61299. * Gets or sets the height to capture in the source image
  61300. */
  61301. sourceHeight: number;
  61302. /**
  61303. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61304. * @see http://doc.babylonjs.com/how_to/gui#image
  61305. */
  61306. autoScale: boolean;
  61307. /** Gets or sets the streching mode used by the image */
  61308. stretch: number;
  61309. /**
  61310. * Gets or sets the internal DOM image used to render the control
  61311. */
  61312. domImage: HTMLImageElement;
  61313. private _onImageLoaded;
  61314. private _extractNinePatchSliceDataFromImage;
  61315. /**
  61316. * Gets or sets image source url
  61317. */
  61318. source: BABYLON.Nullable<string>;
  61319. /**
  61320. * Gets or sets the cell width to use when animation sheet is enabled
  61321. * @see http://doc.babylonjs.com/how_to/gui#image
  61322. */
  61323. cellWidth: number;
  61324. /**
  61325. * Gets or sets the cell height to use when animation sheet is enabled
  61326. * @see http://doc.babylonjs.com/how_to/gui#image
  61327. */
  61328. cellHeight: number;
  61329. /**
  61330. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61331. * @see http://doc.babylonjs.com/how_to/gui#image
  61332. */
  61333. cellId: number;
  61334. /**
  61335. * Creates a new Image
  61336. * @param name defines the control name
  61337. * @param url defines the image url
  61338. */
  61339. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61340. /**
  61341. * Tests if a given coordinates belong to the current control
  61342. * @param x defines x coordinate to test
  61343. * @param y defines y coordinate to test
  61344. * @returns true if the coordinates are inside the control
  61345. */
  61346. contains(x: number, y: number): boolean;
  61347. protected _getTypeName(): string;
  61348. /** Force the control to synchronize with its content */
  61349. synchronizeSizeWithContent(): void;
  61350. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61351. private _prepareWorkingCanvasForOpaqueDetection;
  61352. private _drawImage;
  61353. _draw(context: CanvasRenderingContext2D): void;
  61354. private _renderCornerPatch;
  61355. private _renderNinePatch;
  61356. dispose(): void;
  61357. /** STRETCH_NONE */
  61358. static readonly STRETCH_NONE: number;
  61359. /** STRETCH_FILL */
  61360. static readonly STRETCH_FILL: number;
  61361. /** STRETCH_UNIFORM */
  61362. static readonly STRETCH_UNIFORM: number;
  61363. /** STRETCH_EXTEND */
  61364. static readonly STRETCH_EXTEND: number;
  61365. /** NINE_PATCH */
  61366. static readonly STRETCH_NINE_PATCH: number;
  61367. }
  61368. }
  61369. declare module BABYLON.GUI {
  61370. /**
  61371. * Class used to create 2D buttons
  61372. */
  61373. export class Button extends Rectangle {
  61374. name?: string | undefined;
  61375. /**
  61376. * Function called to generate a pointer enter animation
  61377. */
  61378. pointerEnterAnimation: () => void;
  61379. /**
  61380. * Function called to generate a pointer out animation
  61381. */
  61382. pointerOutAnimation: () => void;
  61383. /**
  61384. * Function called to generate a pointer down animation
  61385. */
  61386. pointerDownAnimation: () => void;
  61387. /**
  61388. * Function called to generate a pointer up animation
  61389. */
  61390. pointerUpAnimation: () => void;
  61391. private _image;
  61392. /**
  61393. * Returns the image part of the button (if any)
  61394. */
  61395. readonly image: BABYLON.Nullable<Image>;
  61396. private _textBlock;
  61397. /**
  61398. * Returns the image part of the button (if any)
  61399. */
  61400. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61401. /**
  61402. * Creates a new Button
  61403. * @param name defines the name of the button
  61404. */
  61405. constructor(name?: string | undefined);
  61406. protected _getTypeName(): string;
  61407. /** @hidden */
  61408. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61409. /** @hidden */
  61410. _onPointerEnter(target: Control): boolean;
  61411. /** @hidden */
  61412. _onPointerOut(target: Control, force?: boolean): void;
  61413. /** @hidden */
  61414. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61415. /** @hidden */
  61416. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61417. /**
  61418. * Creates a new button made with an image and a text
  61419. * @param name defines the name of the button
  61420. * @param text defines the text of the button
  61421. * @param imageUrl defines the url of the image
  61422. * @returns a new Button
  61423. */
  61424. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61425. /**
  61426. * Creates a new button made with an image
  61427. * @param name defines the name of the button
  61428. * @param imageUrl defines the url of the image
  61429. * @returns a new Button
  61430. */
  61431. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61432. /**
  61433. * Creates a new button made with a text
  61434. * @param name defines the name of the button
  61435. * @param text defines the text of the button
  61436. * @returns a new Button
  61437. */
  61438. static CreateSimpleButton(name: string, text: string): Button;
  61439. /**
  61440. * Creates a new button made with an image and a centered text
  61441. * @param name defines the name of the button
  61442. * @param text defines the text of the button
  61443. * @param imageUrl defines the url of the image
  61444. * @returns a new Button
  61445. */
  61446. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61447. }
  61448. }
  61449. declare module BABYLON.GUI {
  61450. /**
  61451. * Class used to create a 2D stack panel container
  61452. */
  61453. export class StackPanel extends Container {
  61454. name?: string | undefined;
  61455. private _isVertical;
  61456. private _manualWidth;
  61457. private _manualHeight;
  61458. private _doNotTrackManualChanges;
  61459. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61460. isVertical: boolean;
  61461. /**
  61462. * Gets or sets panel width.
  61463. * This value should not be set when in horizontal mode as it will be computed automatically
  61464. */
  61465. width: string | number;
  61466. /**
  61467. * Gets or sets panel height.
  61468. * This value should not be set when in vertical mode as it will be computed automatically
  61469. */
  61470. height: string | number;
  61471. /**
  61472. * Creates a new StackPanel
  61473. * @param name defines control name
  61474. */
  61475. constructor(name?: string | undefined);
  61476. protected _getTypeName(): string;
  61477. /** @hidden */
  61478. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61479. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61480. protected _postMeasure(): void;
  61481. }
  61482. }
  61483. declare module BABYLON.GUI {
  61484. /**
  61485. * Class used to represent a 2D checkbox
  61486. */
  61487. export class Checkbox extends Control {
  61488. name?: string | undefined;
  61489. private _isChecked;
  61490. private _background;
  61491. private _checkSizeRatio;
  61492. private _thickness;
  61493. /** Gets or sets border thickness */
  61494. thickness: number;
  61495. /**
  61496. * BABYLON.Observable raised when isChecked property changes
  61497. */
  61498. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61499. /** Gets or sets a value indicating the ratio between overall size and check size */
  61500. checkSizeRatio: number;
  61501. /** Gets or sets background color */
  61502. background: string;
  61503. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61504. isChecked: boolean;
  61505. /**
  61506. * Creates a new CheckBox
  61507. * @param name defines the control name
  61508. */
  61509. constructor(name?: string | undefined);
  61510. protected _getTypeName(): string;
  61511. /** @hidden */
  61512. _draw(context: CanvasRenderingContext2D): void;
  61513. /** @hidden */
  61514. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61515. /**
  61516. * Utility function to easily create a checkbox with a header
  61517. * @param title defines the label to use for the header
  61518. * @param onValueChanged defines the callback to call when value changes
  61519. * @returns a StackPanel containing the checkbox and a textBlock
  61520. */
  61521. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61522. }
  61523. }
  61524. declare module BABYLON.GUI {
  61525. /**
  61526. * Class used to store key control properties
  61527. */
  61528. export class KeyPropertySet {
  61529. /** Width */
  61530. width?: string;
  61531. /** Height */
  61532. height?: string;
  61533. /** Left padding */
  61534. paddingLeft?: string;
  61535. /** Right padding */
  61536. paddingRight?: string;
  61537. /** Top padding */
  61538. paddingTop?: string;
  61539. /** Bottom padding */
  61540. paddingBottom?: string;
  61541. /** Foreground color */
  61542. color?: string;
  61543. /** Background color */
  61544. background?: string;
  61545. }
  61546. /**
  61547. * Class used to create virtual keyboard
  61548. */
  61549. export class VirtualKeyboard extends StackPanel {
  61550. /** BABYLON.Observable raised when a key is pressed */
  61551. onKeyPressObservable: BABYLON.Observable<string>;
  61552. /** Gets or sets default key button width */
  61553. defaultButtonWidth: string;
  61554. /** Gets or sets default key button height */
  61555. defaultButtonHeight: string;
  61556. /** Gets or sets default key button left padding */
  61557. defaultButtonPaddingLeft: string;
  61558. /** Gets or sets default key button right padding */
  61559. defaultButtonPaddingRight: string;
  61560. /** Gets or sets default key button top padding */
  61561. defaultButtonPaddingTop: string;
  61562. /** Gets or sets default key button bottom padding */
  61563. defaultButtonPaddingBottom: string;
  61564. /** Gets or sets default key button foreground color */
  61565. defaultButtonColor: string;
  61566. /** Gets or sets default key button background color */
  61567. defaultButtonBackground: string;
  61568. /** Gets or sets shift button foreground color */
  61569. shiftButtonColor: string;
  61570. /** Gets or sets shift button thickness*/
  61571. selectedShiftThickness: number;
  61572. /** Gets shift key state */
  61573. shiftState: number;
  61574. protected _getTypeName(): string;
  61575. private _createKey;
  61576. /**
  61577. * Adds a new row of keys
  61578. * @param keys defines the list of keys to add
  61579. * @param propertySets defines the associated property sets
  61580. */
  61581. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61582. /**
  61583. * Set the shift key to a specific state
  61584. * @param shiftState defines the new shift state
  61585. */
  61586. applyShiftState(shiftState: number): void;
  61587. private _currentlyConnectedInputText;
  61588. private _connectedInputTexts;
  61589. private _onKeyPressObserver;
  61590. /** Gets the input text control currently attached to the keyboard */
  61591. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61592. /**
  61593. * Connects the keyboard with an input text control
  61594. *
  61595. * @param input defines the target control
  61596. */
  61597. connect(input: InputText): void;
  61598. /**
  61599. * Disconnects the keyboard from connected InputText controls
  61600. *
  61601. * @param input optionally defines a target control, otherwise all are disconnected
  61602. */
  61603. disconnect(input?: InputText): void;
  61604. private _removeConnectedInputObservables;
  61605. /**
  61606. * Release all resources
  61607. */
  61608. dispose(): void;
  61609. /**
  61610. * Creates a new keyboard using a default layout
  61611. *
  61612. * @param name defines control name
  61613. * @returns a new VirtualKeyboard
  61614. */
  61615. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61616. }
  61617. }
  61618. declare module BABYLON.GUI {
  61619. /**
  61620. * Class used to create input text control
  61621. */
  61622. export class InputText extends Control implements IFocusableControl {
  61623. name?: string | undefined;
  61624. private _text;
  61625. private _placeholderText;
  61626. private _background;
  61627. private _focusedBackground;
  61628. private _focusedColor;
  61629. private _placeholderColor;
  61630. private _thickness;
  61631. private _margin;
  61632. private _autoStretchWidth;
  61633. private _maxWidth;
  61634. private _isFocused;
  61635. private _blinkTimeout;
  61636. private _blinkIsEven;
  61637. private _cursorOffset;
  61638. private _scrollLeft;
  61639. private _textWidth;
  61640. private _clickedCoordinate;
  61641. private _deadKey;
  61642. private _addKey;
  61643. private _currentKey;
  61644. private _isTextHighlightOn;
  61645. private _textHighlightColor;
  61646. private _highligherOpacity;
  61647. private _highlightedText;
  61648. private _startHighlightIndex;
  61649. private _endHighlightIndex;
  61650. private _cursorIndex;
  61651. private _onFocusSelectAll;
  61652. private _isPointerDown;
  61653. private _onClipboardObserver;
  61654. private _onPointerDblTapObserver;
  61655. /** @hidden */
  61656. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61657. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61658. promptMessage: string;
  61659. /** BABYLON.Observable raised when the text changes */
  61660. onTextChangedObservable: BABYLON.Observable<InputText>;
  61661. /** BABYLON.Observable raised just before an entered character is to be added */
  61662. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61663. /** BABYLON.Observable raised when the control gets the focus */
  61664. onFocusObservable: BABYLON.Observable<InputText>;
  61665. /** BABYLON.Observable raised when the control loses the focus */
  61666. onBlurObservable: BABYLON.Observable<InputText>;
  61667. /**Observable raised when the text is highlighted */
  61668. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61669. /**Observable raised when copy event is triggered */
  61670. onTextCopyObservable: BABYLON.Observable<InputText>;
  61671. /** BABYLON.Observable raised when cut event is triggered */
  61672. onTextCutObservable: BABYLON.Observable<InputText>;
  61673. /** BABYLON.Observable raised when paste event is triggered */
  61674. onTextPasteObservable: BABYLON.Observable<InputText>;
  61675. /** BABYLON.Observable raised when a key event was processed */
  61676. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61677. /** Gets or sets the maximum width allowed by the control */
  61678. maxWidth: string | number;
  61679. /** Gets the maximum width allowed by the control in pixels */
  61680. readonly maxWidthInPixels: number;
  61681. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61682. highligherOpacity: number;
  61683. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61684. onFocusSelectAll: boolean;
  61685. /** Gets or sets the text hightlight color */
  61686. textHighlightColor: string;
  61687. /** Gets or sets control margin */
  61688. margin: string;
  61689. /** Gets control margin in pixels */
  61690. readonly marginInPixels: number;
  61691. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61692. autoStretchWidth: boolean;
  61693. /** Gets or sets border thickness */
  61694. thickness: number;
  61695. /** Gets or sets the background color when focused */
  61696. focusedBackground: string;
  61697. /** Gets or sets the background color when focused */
  61698. focusedColor: string;
  61699. /** Gets or sets the background color */
  61700. background: string;
  61701. /** Gets or sets the placeholder color */
  61702. placeholderColor: string;
  61703. /** Gets or sets the text displayed when the control is empty */
  61704. placeholderText: string;
  61705. /** Gets or sets the dead key flag */
  61706. deadKey: boolean;
  61707. /** Gets or sets the highlight text */
  61708. highlightedText: string;
  61709. /** Gets or sets if the current key should be added */
  61710. addKey: boolean;
  61711. /** Gets or sets the value of the current key being entered */
  61712. currentKey: string;
  61713. /** Gets or sets the text displayed in the control */
  61714. text: string;
  61715. /** Gets or sets control width */
  61716. width: string | number;
  61717. /**
  61718. * Creates a new InputText
  61719. * @param name defines the control name
  61720. * @param text defines the text of the control
  61721. */
  61722. constructor(name?: string | undefined, text?: string);
  61723. /** @hidden */
  61724. onBlur(): void;
  61725. /** @hidden */
  61726. onFocus(): void;
  61727. protected _getTypeName(): string;
  61728. /**
  61729. * Function called to get the list of controls that should not steal the focus from this control
  61730. * @returns an array of controls
  61731. */
  61732. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61733. /** @hidden */
  61734. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61735. /** @hidden */
  61736. private _updateValueFromCursorIndex;
  61737. /** @hidden */
  61738. private _processDblClick;
  61739. /** @hidden */
  61740. private _selectAllText;
  61741. /**
  61742. * Handles the keyboard event
  61743. * @param evt Defines the KeyboardEvent
  61744. */
  61745. processKeyboard(evt: KeyboardEvent): void;
  61746. /** @hidden */
  61747. private _onCopyText;
  61748. /** @hidden */
  61749. private _onCutText;
  61750. /** @hidden */
  61751. private _onPasteText;
  61752. _draw(context: CanvasRenderingContext2D): void;
  61753. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61754. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61755. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61756. protected _beforeRenderText(text: string): string;
  61757. dispose(): void;
  61758. }
  61759. }
  61760. declare module BABYLON.GUI {
  61761. /**
  61762. * Class used to create a 2D grid container
  61763. */
  61764. export class Grid extends Container {
  61765. name?: string | undefined;
  61766. private _rowDefinitions;
  61767. private _columnDefinitions;
  61768. private _cells;
  61769. private _childControls;
  61770. /**
  61771. * Gets the number of columns
  61772. */
  61773. readonly columnCount: number;
  61774. /**
  61775. * Gets the number of rows
  61776. */
  61777. readonly rowCount: number;
  61778. /** Gets the list of children */
  61779. readonly children: Control[];
  61780. /** Gets the list of cells (e.g. the containers) */
  61781. readonly cells: {
  61782. [key: string]: Container;
  61783. };
  61784. /**
  61785. * Gets the definition of a specific row
  61786. * @param index defines the index of the row
  61787. * @returns the row definition
  61788. */
  61789. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61790. /**
  61791. * Gets the definition of a specific column
  61792. * @param index defines the index of the column
  61793. * @returns the column definition
  61794. */
  61795. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61796. /**
  61797. * Adds a new row to the grid
  61798. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61799. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61800. * @returns the current grid
  61801. */
  61802. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61803. /**
  61804. * Adds a new column to the grid
  61805. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61806. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61807. * @returns the current grid
  61808. */
  61809. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61810. /**
  61811. * Update a row definition
  61812. * @param index defines the index of the row to update
  61813. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61814. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61815. * @returns the current grid
  61816. */
  61817. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61818. /**
  61819. * Update a column definition
  61820. * @param index defines the index of the column to update
  61821. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61822. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61823. * @returns the current grid
  61824. */
  61825. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61826. /**
  61827. * Gets the list of children stored in a specific cell
  61828. * @param row defines the row to check
  61829. * @param column defines the column to check
  61830. * @returns the list of controls
  61831. */
  61832. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61833. /**
  61834. * Gets a string representing the child cell info (row x column)
  61835. * @param child defines the control to get info from
  61836. * @returns a string containing the child cell info (row x column)
  61837. */
  61838. getChildCellInfo(child: Control): string;
  61839. private _removeCell;
  61840. private _offsetCell;
  61841. /**
  61842. * Remove a column definition at specified index
  61843. * @param index defines the index of the column to remove
  61844. * @returns the current grid
  61845. */
  61846. removeColumnDefinition(index: number): Grid;
  61847. /**
  61848. * Remove a row definition at specified index
  61849. * @param index defines the index of the row to remove
  61850. * @returns the current grid
  61851. */
  61852. removeRowDefinition(index: number): Grid;
  61853. /**
  61854. * Adds a new control to the current grid
  61855. * @param control defines the control to add
  61856. * @param row defines the row where to add the control (0 by default)
  61857. * @param column defines the column where to add the control (0 by default)
  61858. * @returns the current grid
  61859. */
  61860. addControl(control: Control, row?: number, column?: number): Grid;
  61861. /**
  61862. * Removes a control from the current container
  61863. * @param control defines the control to remove
  61864. * @returns the current container
  61865. */
  61866. removeControl(control: Control): Container;
  61867. /**
  61868. * Creates a new Grid
  61869. * @param name defines control name
  61870. */
  61871. constructor(name?: string | undefined);
  61872. protected _getTypeName(): string;
  61873. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61874. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61875. _flagDescendantsAsMatrixDirty(): void;
  61876. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61877. /** Releases associated resources */
  61878. dispose(): void;
  61879. }
  61880. }
  61881. declare module BABYLON.GUI {
  61882. /** Class used to create color pickers */
  61883. export class ColorPicker extends Control {
  61884. name?: string | undefined;
  61885. private static _Epsilon;
  61886. private _colorWheelCanvas;
  61887. private _value;
  61888. private _tmpColor;
  61889. private _pointerStartedOnSquare;
  61890. private _pointerStartedOnWheel;
  61891. private _squareLeft;
  61892. private _squareTop;
  61893. private _squareSize;
  61894. private _h;
  61895. private _s;
  61896. private _v;
  61897. private _lastPointerDownID;
  61898. /**
  61899. * BABYLON.Observable raised when the value changes
  61900. */
  61901. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61902. /** Gets or sets the color of the color picker */
  61903. value: BABYLON.Color3;
  61904. /**
  61905. * Gets or sets control width
  61906. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61907. */
  61908. width: string | number;
  61909. /**
  61910. * Gets or sets control height
  61911. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61912. */
  61913. /** Gets or sets control height */
  61914. height: string | number;
  61915. /** Gets or sets control size */
  61916. size: string | number;
  61917. /**
  61918. * Creates a new ColorPicker
  61919. * @param name defines the control name
  61920. */
  61921. constructor(name?: string | undefined);
  61922. protected _getTypeName(): string;
  61923. /** @hidden */
  61924. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61925. private _updateSquareProps;
  61926. private _drawGradientSquare;
  61927. private _drawCircle;
  61928. private _createColorWheelCanvas;
  61929. /** @hidden */
  61930. _draw(context: CanvasRenderingContext2D): void;
  61931. private _pointerIsDown;
  61932. private _updateValueFromPointer;
  61933. private _isPointOnSquare;
  61934. private _isPointOnWheel;
  61935. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61936. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61937. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61938. /**
  61939. * This function expands the color picker by creating a color picker dialog with manual
  61940. * color value input and the ability to save colors into an array to be used later in
  61941. * subsequent launches of the dialogue.
  61942. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61943. * @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.
  61944. * @returns picked color as a hex string and the saved colors array as hex strings.
  61945. */
  61946. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61947. pickerWidth?: string;
  61948. pickerHeight?: string;
  61949. headerHeight?: string;
  61950. lastColor?: string;
  61951. swatchLimit?: number;
  61952. numSwatchesPerLine?: number;
  61953. savedColors?: Array<string>;
  61954. }): Promise<{
  61955. savedColors?: string[];
  61956. pickedColor: string;
  61957. }>;
  61958. }
  61959. }
  61960. declare module BABYLON.GUI {
  61961. /** Class used to create 2D ellipse containers */
  61962. export class Ellipse extends Container {
  61963. name?: string | undefined;
  61964. private _thickness;
  61965. /** Gets or sets border thickness */
  61966. thickness: number;
  61967. /**
  61968. * Creates a new Ellipse
  61969. * @param name defines the control name
  61970. */
  61971. constructor(name?: string | undefined);
  61972. protected _getTypeName(): string;
  61973. protected _localDraw(context: CanvasRenderingContext2D): void;
  61974. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61975. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61976. }
  61977. }
  61978. declare module BABYLON.GUI {
  61979. /**
  61980. * Class used to create a password control
  61981. */
  61982. export class InputPassword extends InputText {
  61983. protected _beforeRenderText(text: string): string;
  61984. }
  61985. }
  61986. declare module BABYLON.GUI {
  61987. /** Class used to render 2D lines */
  61988. export class Line extends Control {
  61989. name?: string | undefined;
  61990. private _lineWidth;
  61991. private _x1;
  61992. private _y1;
  61993. private _x2;
  61994. private _y2;
  61995. private _dash;
  61996. private _connectedControl;
  61997. private _connectedControlDirtyObserver;
  61998. /** Gets or sets the dash pattern */
  61999. dash: Array<number>;
  62000. /** Gets or sets the control connected with the line end */
  62001. connectedControl: Control;
  62002. /** Gets or sets start coordinates on X axis */
  62003. x1: string | number;
  62004. /** Gets or sets start coordinates on Y axis */
  62005. y1: string | number;
  62006. /** Gets or sets end coordinates on X axis */
  62007. x2: string | number;
  62008. /** Gets or sets end coordinates on Y axis */
  62009. y2: string | number;
  62010. /** Gets or sets line width */
  62011. lineWidth: number;
  62012. /** Gets or sets horizontal alignment */
  62013. horizontalAlignment: number;
  62014. /** Gets or sets vertical alignment */
  62015. verticalAlignment: number;
  62016. private readonly _effectiveX2;
  62017. private readonly _effectiveY2;
  62018. /**
  62019. * Creates a new Line
  62020. * @param name defines the control name
  62021. */
  62022. constructor(name?: string | undefined);
  62023. protected _getTypeName(): string;
  62024. _draw(context: CanvasRenderingContext2D): void;
  62025. _measure(): void;
  62026. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62027. /**
  62028. * Move one end of the line given 3D cartesian coordinates.
  62029. * @param position Targeted world position
  62030. * @param scene BABYLON.Scene
  62031. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62032. */
  62033. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62034. /**
  62035. * Move one end of the line to a position in screen absolute space.
  62036. * @param projectedPosition Position in screen absolute space (X, Y)
  62037. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62038. */
  62039. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62040. }
  62041. }
  62042. declare module BABYLON.GUI {
  62043. /**
  62044. * Class used to store a point for a MultiLine object.
  62045. * The point can be pure 2D coordinates, a mesh or a control
  62046. */
  62047. export class MultiLinePoint {
  62048. private _multiLine;
  62049. private _x;
  62050. private _y;
  62051. private _control;
  62052. private _mesh;
  62053. private _controlObserver;
  62054. private _meshObserver;
  62055. /** @hidden */
  62056. _point: BABYLON.Vector2;
  62057. /**
  62058. * Creates a new MultiLinePoint
  62059. * @param multiLine defines the source MultiLine object
  62060. */
  62061. constructor(multiLine: MultiLine);
  62062. /** Gets or sets x coordinate */
  62063. x: string | number;
  62064. /** Gets or sets y coordinate */
  62065. y: string | number;
  62066. /** Gets or sets the control associated with this point */
  62067. control: BABYLON.Nullable<Control>;
  62068. /** Gets or sets the mesh associated with this point */
  62069. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62070. /** Resets links */
  62071. resetLinks(): void;
  62072. /**
  62073. * Gets a translation vector
  62074. * @returns the translation vector
  62075. */
  62076. translate(): BABYLON.Vector2;
  62077. private _translatePoint;
  62078. /** Release associated resources */
  62079. dispose(): void;
  62080. }
  62081. }
  62082. declare module BABYLON.GUI {
  62083. /**
  62084. * Class used to create multi line control
  62085. */
  62086. export class MultiLine extends Control {
  62087. name?: string | undefined;
  62088. private _lineWidth;
  62089. private _dash;
  62090. private _points;
  62091. private _minX;
  62092. private _minY;
  62093. private _maxX;
  62094. private _maxY;
  62095. /**
  62096. * Creates a new MultiLine
  62097. * @param name defines the control name
  62098. */
  62099. constructor(name?: string | undefined);
  62100. /** Gets or sets dash pattern */
  62101. dash: Array<number>;
  62102. /**
  62103. * Gets point stored at specified index
  62104. * @param index defines the index to look for
  62105. * @returns the requested point if found
  62106. */
  62107. getAt(index: number): MultiLinePoint;
  62108. /** Function called when a point is updated */
  62109. onPointUpdate: () => void;
  62110. /**
  62111. * Adds new points to the point collection
  62112. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62113. * @returns the list of created MultiLinePoint
  62114. */
  62115. add(...items: (AbstractMesh | Control | {
  62116. x: string | number;
  62117. y: string | number;
  62118. })[]): MultiLinePoint[];
  62119. /**
  62120. * Adds a new point to the point collection
  62121. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62122. * @returns the created MultiLinePoint
  62123. */
  62124. push(item?: (AbstractMesh | Control | {
  62125. x: string | number;
  62126. y: string | number;
  62127. })): MultiLinePoint;
  62128. /**
  62129. * Remove a specific value or point from the active point collection
  62130. * @param value defines the value or point to remove
  62131. */
  62132. remove(value: number | MultiLinePoint): void;
  62133. /**
  62134. * Resets this object to initial state (no point)
  62135. */
  62136. reset(): void;
  62137. /**
  62138. * Resets all links
  62139. */
  62140. resetLinks(): void;
  62141. /** Gets or sets line width */
  62142. lineWidth: number;
  62143. horizontalAlignment: number;
  62144. verticalAlignment: number;
  62145. protected _getTypeName(): string;
  62146. _draw(context: CanvasRenderingContext2D): void;
  62147. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62148. _measure(): void;
  62149. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62150. dispose(): void;
  62151. }
  62152. }
  62153. declare module BABYLON.GUI {
  62154. /**
  62155. * Class used to create radio button controls
  62156. */
  62157. export class RadioButton extends Control {
  62158. name?: string | undefined;
  62159. private _isChecked;
  62160. private _background;
  62161. private _checkSizeRatio;
  62162. private _thickness;
  62163. /** Gets or sets border thickness */
  62164. thickness: number;
  62165. /** Gets or sets group name */
  62166. group: string;
  62167. /** BABYLON.Observable raised when isChecked is changed */
  62168. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62169. /** Gets or sets a value indicating the ratio between overall size and check size */
  62170. checkSizeRatio: number;
  62171. /** Gets or sets background color */
  62172. background: string;
  62173. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62174. isChecked: boolean;
  62175. /**
  62176. * Creates a new RadioButton
  62177. * @param name defines the control name
  62178. */
  62179. constructor(name?: string | undefined);
  62180. protected _getTypeName(): string;
  62181. _draw(context: CanvasRenderingContext2D): void;
  62182. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62183. /**
  62184. * Utility function to easily create a radio button with a header
  62185. * @param title defines the label to use for the header
  62186. * @param group defines the group to use for the radio button
  62187. * @param isChecked defines the initial state of the radio button
  62188. * @param onValueChanged defines the callback to call when value changes
  62189. * @returns a StackPanel containing the radio button and a textBlock
  62190. */
  62191. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62192. }
  62193. }
  62194. declare module BABYLON.GUI {
  62195. /**
  62196. * Class used to create slider controls
  62197. */
  62198. export class BaseSlider extends Control {
  62199. name?: string | undefined;
  62200. protected _thumbWidth: ValueAndUnit;
  62201. private _minimum;
  62202. private _maximum;
  62203. private _value;
  62204. private _isVertical;
  62205. protected _barOffset: ValueAndUnit;
  62206. private _isThumbClamped;
  62207. protected _displayThumb: boolean;
  62208. private _step;
  62209. private _lastPointerDownID;
  62210. protected _effectiveBarOffset: number;
  62211. protected _renderLeft: number;
  62212. protected _renderTop: number;
  62213. protected _renderWidth: number;
  62214. protected _renderHeight: number;
  62215. protected _backgroundBoxLength: number;
  62216. protected _backgroundBoxThickness: number;
  62217. protected _effectiveThumbThickness: number;
  62218. /** BABYLON.Observable raised when the sldier value changes */
  62219. onValueChangedObservable: BABYLON.Observable<number>;
  62220. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62221. displayThumb: boolean;
  62222. /** Gets or sets a step to apply to values (0 by default) */
  62223. step: number;
  62224. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62225. barOffset: string | number;
  62226. /** Gets main bar offset in pixels*/
  62227. readonly barOffsetInPixels: number;
  62228. /** Gets or sets thumb width */
  62229. thumbWidth: string | number;
  62230. /** Gets thumb width in pixels */
  62231. readonly thumbWidthInPixels: number;
  62232. /** Gets or sets minimum value */
  62233. minimum: number;
  62234. /** Gets or sets maximum value */
  62235. maximum: number;
  62236. /** Gets or sets current value */
  62237. value: number;
  62238. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62239. isVertical: boolean;
  62240. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62241. isThumbClamped: boolean;
  62242. /**
  62243. * Creates a new BaseSlider
  62244. * @param name defines the control name
  62245. */
  62246. constructor(name?: string | undefined);
  62247. protected _getTypeName(): string;
  62248. protected _getThumbPosition(): number;
  62249. protected _getThumbThickness(type: string): number;
  62250. protected _prepareRenderingData(type: string): void;
  62251. private _pointerIsDown;
  62252. /** @hidden */
  62253. protected _updateValueFromPointer(x: number, y: number): void;
  62254. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62255. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62256. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62257. }
  62258. }
  62259. declare module BABYLON.GUI {
  62260. /**
  62261. * Class used to create slider controls
  62262. */
  62263. export class Slider extends BaseSlider {
  62264. name?: string | undefined;
  62265. private _background;
  62266. private _borderColor;
  62267. private _isThumbCircle;
  62268. protected _displayValueBar: boolean;
  62269. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62270. displayValueBar: boolean;
  62271. /** Gets or sets border color */
  62272. borderColor: string;
  62273. /** Gets or sets background color */
  62274. background: string;
  62275. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62276. isThumbCircle: boolean;
  62277. /**
  62278. * Creates a new Slider
  62279. * @param name defines the control name
  62280. */
  62281. constructor(name?: string | undefined);
  62282. protected _getTypeName(): string;
  62283. _draw(context: CanvasRenderingContext2D): void;
  62284. }
  62285. }
  62286. declare module BABYLON.GUI {
  62287. /** Class used to create a RadioGroup
  62288. * which contains groups of radio buttons
  62289. */
  62290. export class SelectorGroup {
  62291. /** name of SelectorGroup */
  62292. name: string;
  62293. private _groupPanel;
  62294. private _selectors;
  62295. private _groupHeader;
  62296. /**
  62297. * Creates a new SelectorGroup
  62298. * @param name of group, used as a group heading
  62299. */
  62300. constructor(
  62301. /** name of SelectorGroup */
  62302. name: string);
  62303. /** Gets the groupPanel of the SelectorGroup */
  62304. readonly groupPanel: StackPanel;
  62305. /** Gets the selectors array */
  62306. readonly selectors: StackPanel[];
  62307. /** Gets and sets the group header */
  62308. header: string;
  62309. /** @hidden */
  62310. private _addGroupHeader;
  62311. /** @hidden*/
  62312. _getSelector(selectorNb: number): StackPanel | undefined;
  62313. /** Removes the selector at the given position
  62314. * @param selectorNb the position of the selector within the group
  62315. */
  62316. removeSelector(selectorNb: number): void;
  62317. }
  62318. /** Class used to create a CheckboxGroup
  62319. * which contains groups of checkbox buttons
  62320. */
  62321. export class CheckboxGroup extends SelectorGroup {
  62322. /** Adds a checkbox as a control
  62323. * @param text is the label for the selector
  62324. * @param func is the function called when the Selector is checked
  62325. * @param checked is true when Selector is checked
  62326. */
  62327. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62328. /** @hidden */
  62329. _setSelectorLabel(selectorNb: number, label: string): void;
  62330. /** @hidden */
  62331. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62332. /** @hidden */
  62333. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62334. /** @hidden */
  62335. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62336. }
  62337. /** Class used to create a RadioGroup
  62338. * which contains groups of radio buttons
  62339. */
  62340. export class RadioGroup extends SelectorGroup {
  62341. private _selectNb;
  62342. /** Adds a radio button as a control
  62343. * @param label is the label for the selector
  62344. * @param func is the function called when the Selector is checked
  62345. * @param checked is true when Selector is checked
  62346. */
  62347. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62348. /** @hidden */
  62349. _setSelectorLabel(selectorNb: number, label: string): void;
  62350. /** @hidden */
  62351. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62352. /** @hidden */
  62353. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62354. /** @hidden */
  62355. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62356. }
  62357. /** Class used to create a SliderGroup
  62358. * which contains groups of slider buttons
  62359. */
  62360. export class SliderGroup extends SelectorGroup {
  62361. /**
  62362. * Adds a slider to the SelectorGroup
  62363. * @param label is the label for the SliderBar
  62364. * @param func is the function called when the Slider moves
  62365. * @param unit is a string describing the units used, eg degrees or metres
  62366. * @param min is the minimum value for the Slider
  62367. * @param max is the maximum value for the Slider
  62368. * @param value is the start value for the Slider between min and max
  62369. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62370. */
  62371. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62372. /** @hidden */
  62373. _setSelectorLabel(selectorNb: number, label: string): void;
  62374. /** @hidden */
  62375. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62376. /** @hidden */
  62377. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62378. /** @hidden */
  62379. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62380. }
  62381. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62382. * @see http://doc.babylonjs.com/how_to/selector
  62383. */
  62384. export class SelectionPanel extends Rectangle {
  62385. /** name of SelectionPanel */
  62386. name: string;
  62387. /** an array of SelectionGroups */
  62388. groups: SelectorGroup[];
  62389. private _panel;
  62390. private _buttonColor;
  62391. private _buttonBackground;
  62392. private _headerColor;
  62393. private _barColor;
  62394. private _barHeight;
  62395. private _spacerHeight;
  62396. private _labelColor;
  62397. private _groups;
  62398. private _bars;
  62399. /**
  62400. * Creates a new SelectionPanel
  62401. * @param name of SelectionPanel
  62402. * @param groups is an array of SelectionGroups
  62403. */
  62404. constructor(
  62405. /** name of SelectionPanel */
  62406. name: string,
  62407. /** an array of SelectionGroups */
  62408. groups?: SelectorGroup[]);
  62409. protected _getTypeName(): string;
  62410. /** Gets or sets the headerColor */
  62411. headerColor: string;
  62412. private _setHeaderColor;
  62413. /** Gets or sets the button color */
  62414. buttonColor: string;
  62415. private _setbuttonColor;
  62416. /** Gets or sets the label color */
  62417. labelColor: string;
  62418. private _setLabelColor;
  62419. /** Gets or sets the button background */
  62420. buttonBackground: string;
  62421. private _setButtonBackground;
  62422. /** Gets or sets the color of separator bar */
  62423. barColor: string;
  62424. private _setBarColor;
  62425. /** Gets or sets the height of separator bar */
  62426. barHeight: string;
  62427. private _setBarHeight;
  62428. /** Gets or sets the height of spacers*/
  62429. spacerHeight: string;
  62430. private _setSpacerHeight;
  62431. /** Adds a bar between groups */
  62432. private _addSpacer;
  62433. /** Add a group to the selection panel
  62434. * @param group is the selector group to add
  62435. */
  62436. addGroup(group: SelectorGroup): void;
  62437. /** Remove the group from the given position
  62438. * @param groupNb is the position of the group in the list
  62439. */
  62440. removeGroup(groupNb: number): void;
  62441. /** Change a group header label
  62442. * @param label is the new group header label
  62443. * @param groupNb is the number of the group to relabel
  62444. * */
  62445. setHeaderName(label: string, groupNb: number): void;
  62446. /** Change selector label to the one given
  62447. * @param label is the new selector label
  62448. * @param groupNb is the number of the groupcontaining the selector
  62449. * @param selectorNb is the number of the selector within a group to relabel
  62450. * */
  62451. relabel(label: string, groupNb: number, selectorNb: number): void;
  62452. /** For a given group position remove the selector at the given position
  62453. * @param groupNb is the number of the group to remove the selector from
  62454. * @param selectorNb is the number of the selector within the group
  62455. */
  62456. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62457. /** For a given group position of correct type add a checkbox button
  62458. * @param groupNb is the number of the group to remove the selector from
  62459. * @param label is the label for the selector
  62460. * @param func is the function called when the Selector is checked
  62461. * @param checked is true when Selector is checked
  62462. */
  62463. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62464. /** For a given group position of correct type add a radio button
  62465. * @param groupNb is the number of the group to remove the selector from
  62466. * @param label is the label for the selector
  62467. * @param func is the function called when the Selector is checked
  62468. * @param checked is true when Selector is checked
  62469. */
  62470. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62471. /**
  62472. * For a given slider group add a slider
  62473. * @param groupNb is the number of the group to add the slider to
  62474. * @param label is the label for the Slider
  62475. * @param func is the function called when the Slider moves
  62476. * @param unit is a string describing the units used, eg degrees or metres
  62477. * @param min is the minimum value for the Slider
  62478. * @param max is the maximum value for the Slider
  62479. * @param value is the start value for the Slider between min and max
  62480. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62481. */
  62482. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62483. }
  62484. }
  62485. declare module BABYLON.GUI {
  62486. /**
  62487. * Class used to hold a the container for ScrollViewer
  62488. * @hidden
  62489. */
  62490. export class _ScrollViewerWindow extends Container {
  62491. parentClientWidth: number;
  62492. parentClientHeight: number;
  62493. /**
  62494. * Creates a new ScrollViewerWindow
  62495. * @param name of ScrollViewerWindow
  62496. */
  62497. constructor(name?: string);
  62498. protected _getTypeName(): string;
  62499. /** @hidden */
  62500. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62501. protected _postMeasure(): void;
  62502. }
  62503. }
  62504. declare module BABYLON.GUI {
  62505. /**
  62506. * Class used to create slider controls
  62507. */
  62508. export class ScrollBar extends BaseSlider {
  62509. name?: string | undefined;
  62510. private _background;
  62511. private _borderColor;
  62512. private _thumbMeasure;
  62513. /** Gets or sets border color */
  62514. borderColor: string;
  62515. /** Gets or sets background color */
  62516. background: string;
  62517. /**
  62518. * Creates a new Slider
  62519. * @param name defines the control name
  62520. */
  62521. constructor(name?: string | undefined);
  62522. protected _getTypeName(): string;
  62523. protected _getThumbThickness(): number;
  62524. _draw(context: CanvasRenderingContext2D): void;
  62525. private _first;
  62526. private _originX;
  62527. private _originY;
  62528. /** @hidden */
  62529. protected _updateValueFromPointer(x: number, y: number): void;
  62530. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62531. }
  62532. }
  62533. declare module BABYLON.GUI {
  62534. /**
  62535. * Class used to hold a viewer window and sliders in a grid
  62536. */
  62537. export class ScrollViewer extends Rectangle {
  62538. private _grid;
  62539. private _horizontalBarSpace;
  62540. private _verticalBarSpace;
  62541. private _dragSpace;
  62542. private _horizontalBar;
  62543. private _verticalBar;
  62544. private _barColor;
  62545. private _barBackground;
  62546. private _barSize;
  62547. private _endLeft;
  62548. private _endTop;
  62549. private _window;
  62550. private _pointerIsOver;
  62551. private _wheelPrecision;
  62552. private _onPointerObserver;
  62553. private _clientWidth;
  62554. private _clientHeight;
  62555. /**
  62556. * Gets the horizontal scrollbar
  62557. */
  62558. readonly horizontalBar: ScrollBar;
  62559. /**
  62560. * Gets the vertical scrollbar
  62561. */
  62562. readonly verticalBar: ScrollBar;
  62563. /**
  62564. * Adds a new control to the current container
  62565. * @param control defines the control to add
  62566. * @returns the current container
  62567. */
  62568. addControl(control: BABYLON.Nullable<Control>): Container;
  62569. /**
  62570. * Removes a control from the current container
  62571. * @param control defines the control to remove
  62572. * @returns the current container
  62573. */
  62574. removeControl(control: Control): Container;
  62575. /** Gets the list of children */
  62576. readonly children: Control[];
  62577. _flagDescendantsAsMatrixDirty(): void;
  62578. /**
  62579. * Creates a new ScrollViewer
  62580. * @param name of ScrollViewer
  62581. */
  62582. constructor(name?: string);
  62583. /** Reset the scroll viewer window to initial size */
  62584. resetWindow(): void;
  62585. protected _getTypeName(): string;
  62586. private _buildClientSizes;
  62587. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62588. protected _postMeasure(): void;
  62589. /**
  62590. * Gets or sets the mouse wheel precision
  62591. * from 0 to 1 with a default value of 0.05
  62592. * */
  62593. wheelPrecision: number;
  62594. /** Gets or sets the bar color */
  62595. barColor: string;
  62596. /** Gets or sets the size of the bar */
  62597. barSize: number;
  62598. /** Gets or sets the bar background */
  62599. barBackground: string;
  62600. /** @hidden */
  62601. private _updateScroller;
  62602. _link(host: AdvancedDynamicTexture): void;
  62603. /** @hidden */
  62604. private _attachWheel;
  62605. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62606. /** Releases associated resources */
  62607. dispose(): void;
  62608. }
  62609. }
  62610. declare module BABYLON.GUI {
  62611. /** Class used to render a grid */
  62612. export class DisplayGrid extends Control {
  62613. name?: string | undefined;
  62614. private _cellWidth;
  62615. private _cellHeight;
  62616. private _minorLineTickness;
  62617. private _minorLineColor;
  62618. private _majorLineTickness;
  62619. private _majorLineColor;
  62620. private _majorLineFrequency;
  62621. private _background;
  62622. private _displayMajorLines;
  62623. private _displayMinorLines;
  62624. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62625. displayMinorLines: boolean;
  62626. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62627. displayMajorLines: boolean;
  62628. /** Gets or sets background color (Black by default) */
  62629. background: string;
  62630. /** Gets or sets the width of each cell (20 by default) */
  62631. cellWidth: number;
  62632. /** Gets or sets the height of each cell (20 by default) */
  62633. cellHeight: number;
  62634. /** Gets or sets the tickness of minor lines (1 by default) */
  62635. minorLineTickness: number;
  62636. /** Gets or sets the color of minor lines (DarkGray by default) */
  62637. minorLineColor: string;
  62638. /** Gets or sets the tickness of major lines (2 by default) */
  62639. majorLineTickness: number;
  62640. /** Gets or sets the color of major lines (White by default) */
  62641. majorLineColor: string;
  62642. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62643. majorLineFrequency: number;
  62644. /**
  62645. * Creates a new GridDisplayRectangle
  62646. * @param name defines the control name
  62647. */
  62648. constructor(name?: string | undefined);
  62649. _draw(context: CanvasRenderingContext2D): void;
  62650. protected _getTypeName(): string;
  62651. }
  62652. }
  62653. declare module BABYLON.GUI {
  62654. /**
  62655. * Class used to create slider controls based on images
  62656. */
  62657. export class ImageBasedSlider extends BaseSlider {
  62658. name?: string | undefined;
  62659. private _backgroundImage;
  62660. private _thumbImage;
  62661. private _valueBarImage;
  62662. private _tempMeasure;
  62663. displayThumb: boolean;
  62664. /**
  62665. * Gets or sets the image used to render the background
  62666. */
  62667. backgroundImage: Image;
  62668. /**
  62669. * Gets or sets the image used to render the value bar
  62670. */
  62671. valueBarImage: Image;
  62672. /**
  62673. * Gets or sets the image used to render the thumb
  62674. */
  62675. thumbImage: Image;
  62676. /**
  62677. * Creates a new ImageBasedSlider
  62678. * @param name defines the control name
  62679. */
  62680. constructor(name?: string | undefined);
  62681. protected _getTypeName(): string;
  62682. _draw(context: CanvasRenderingContext2D): void;
  62683. }
  62684. }
  62685. declare module BABYLON.GUI {
  62686. /**
  62687. * Forcing an export so that this code will execute
  62688. * @hidden
  62689. */
  62690. const name = "Statics";
  62691. }
  62692. declare module BABYLON.GUI {
  62693. /**
  62694. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62695. */
  62696. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62697. /**
  62698. * Define the instrumented AdvancedDynamicTexture.
  62699. */
  62700. texture: AdvancedDynamicTexture;
  62701. private _captureRenderTime;
  62702. private _renderTime;
  62703. private _captureLayoutTime;
  62704. private _layoutTime;
  62705. private _onBeginRenderObserver;
  62706. private _onEndRenderObserver;
  62707. private _onBeginLayoutObserver;
  62708. private _onEndLayoutObserver;
  62709. /**
  62710. * Gets the perf counter used to capture render time
  62711. */
  62712. readonly renderTimeCounter: BABYLON.PerfCounter;
  62713. /**
  62714. * Gets the perf counter used to capture layout time
  62715. */
  62716. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62717. /**
  62718. * Enable or disable the render time capture
  62719. */
  62720. captureRenderTime: boolean;
  62721. /**
  62722. * Enable or disable the layout time capture
  62723. */
  62724. captureLayoutTime: boolean;
  62725. /**
  62726. * Instantiates a new advanced dynamic texture instrumentation.
  62727. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62728. * @param texture Defines the AdvancedDynamicTexture to instrument
  62729. */
  62730. constructor(
  62731. /**
  62732. * Define the instrumented AdvancedDynamicTexture.
  62733. */
  62734. texture: AdvancedDynamicTexture);
  62735. /**
  62736. * Dispose and release associated resources.
  62737. */
  62738. dispose(): void;
  62739. }
  62740. }
  62741. declare module BABYLON.GUI {
  62742. /**
  62743. * Class used to create containers for controls
  62744. */
  62745. export class Container3D extends Control3D {
  62746. private _blockLayout;
  62747. /**
  62748. * Gets the list of child controls
  62749. */
  62750. protected _children: Control3D[];
  62751. /**
  62752. * Gets the list of child controls
  62753. */
  62754. readonly children: Array<Control3D>;
  62755. /**
  62756. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62757. * This is helpful to optimize layout operation when adding multiple children in a row
  62758. */
  62759. blockLayout: boolean;
  62760. /**
  62761. * Creates a new container
  62762. * @param name defines the container name
  62763. */
  62764. constructor(name?: string);
  62765. /**
  62766. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62767. * @returns the current container
  62768. */
  62769. updateLayout(): Container3D;
  62770. /**
  62771. * Gets a boolean indicating if the given control is in the children of this control
  62772. * @param control defines the control to check
  62773. * @returns true if the control is in the child list
  62774. */
  62775. containsControl(control: Control3D): boolean;
  62776. /**
  62777. * Adds a control to the children of this control
  62778. * @param control defines the control to add
  62779. * @returns the current container
  62780. */
  62781. addControl(control: Control3D): Container3D;
  62782. /**
  62783. * This function will be called everytime a new control is added
  62784. */
  62785. protected _arrangeChildren(): void;
  62786. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62787. /**
  62788. * Removes a control from the children of this control
  62789. * @param control defines the control to remove
  62790. * @returns the current container
  62791. */
  62792. removeControl(control: Control3D): Container3D;
  62793. protected _getTypeName(): string;
  62794. /**
  62795. * Releases all associated resources
  62796. */
  62797. dispose(): void;
  62798. /** Control rotation will remain unchanged */
  62799. static readonly UNSET_ORIENTATION: number;
  62800. /** Control will rotate to make it look at sphere central axis */
  62801. static readonly FACEORIGIN_ORIENTATION: number;
  62802. /** Control will rotate to make it look back at sphere central axis */
  62803. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62804. /** Control will rotate to look at z axis (0, 0, 1) */
  62805. static readonly FACEFORWARD_ORIENTATION: number;
  62806. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62807. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62808. }
  62809. }
  62810. declare module BABYLON.GUI {
  62811. /**
  62812. * Class used to manage 3D user interface
  62813. * @see http://doc.babylonjs.com/how_to/gui3d
  62814. */
  62815. export class GUI3DManager implements BABYLON.IDisposable {
  62816. private _scene;
  62817. private _sceneDisposeObserver;
  62818. private _utilityLayer;
  62819. private _rootContainer;
  62820. private _pointerObserver;
  62821. private _pointerOutObserver;
  62822. /** @hidden */
  62823. _lastPickedControl: Control3D;
  62824. /** @hidden */
  62825. _lastControlOver: {
  62826. [pointerId: number]: Control3D;
  62827. };
  62828. /** @hidden */
  62829. _lastControlDown: {
  62830. [pointerId: number]: Control3D;
  62831. };
  62832. /**
  62833. * BABYLON.Observable raised when the point picked by the pointer events changed
  62834. */
  62835. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62836. /** @hidden */
  62837. _sharedMaterials: {
  62838. [key: string]: BABYLON.Material;
  62839. };
  62840. /** Gets the hosting scene */
  62841. readonly scene: BABYLON.Scene;
  62842. /** Gets associated utility layer */
  62843. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62844. /**
  62845. * Creates a new GUI3DManager
  62846. * @param scene
  62847. */
  62848. constructor(scene?: BABYLON.Scene);
  62849. private _handlePointerOut;
  62850. private _doPicking;
  62851. /**
  62852. * Gets the root container
  62853. */
  62854. readonly rootContainer: Container3D;
  62855. /**
  62856. * Gets a boolean indicating if the given control is in the root child list
  62857. * @param control defines the control to check
  62858. * @returns true if the control is in the root child list
  62859. */
  62860. containsControl(control: Control3D): boolean;
  62861. /**
  62862. * Adds a control to the root child list
  62863. * @param control defines the control to add
  62864. * @returns the current manager
  62865. */
  62866. addControl(control: Control3D): GUI3DManager;
  62867. /**
  62868. * Removes a control from the root child list
  62869. * @param control defines the control to remove
  62870. * @returns the current container
  62871. */
  62872. removeControl(control: Control3D): GUI3DManager;
  62873. /**
  62874. * Releases all associated resources
  62875. */
  62876. dispose(): void;
  62877. }
  62878. }
  62879. declare module BABYLON.GUI {
  62880. /**
  62881. * Class used to transport BABYLON.Vector3 information for pointer events
  62882. */
  62883. export class Vector3WithInfo extends BABYLON.Vector3 {
  62884. /** defines the current mouse button index */
  62885. buttonIndex: number;
  62886. /**
  62887. * Creates a new Vector3WithInfo
  62888. * @param source defines the vector3 data to transport
  62889. * @param buttonIndex defines the current mouse button index
  62890. */
  62891. constructor(source: BABYLON.Vector3,
  62892. /** defines the current mouse button index */
  62893. buttonIndex?: number);
  62894. }
  62895. }
  62896. declare module BABYLON.GUI {
  62897. /**
  62898. * Class used as base class for controls
  62899. */
  62900. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62901. /** Defines the control name */
  62902. name?: string | undefined;
  62903. /** @hidden */
  62904. _host: GUI3DManager;
  62905. private _node;
  62906. private _downCount;
  62907. private _enterCount;
  62908. private _downPointerIds;
  62909. private _isVisible;
  62910. /** Gets or sets the control position in world space */
  62911. position: BABYLON.Vector3;
  62912. /** Gets or sets the control scaling in world space */
  62913. scaling: BABYLON.Vector3;
  62914. /** Callback used to start pointer enter animation */
  62915. pointerEnterAnimation: () => void;
  62916. /** Callback used to start pointer out animation */
  62917. pointerOutAnimation: () => void;
  62918. /** Callback used to start pointer down animation */
  62919. pointerDownAnimation: () => void;
  62920. /** Callback used to start pointer up animation */
  62921. pointerUpAnimation: () => void;
  62922. /**
  62923. * An event triggered when the pointer move over the control
  62924. */
  62925. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62926. /**
  62927. * An event triggered when the pointer move out of the control
  62928. */
  62929. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62930. /**
  62931. * An event triggered when the pointer taps the control
  62932. */
  62933. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62934. /**
  62935. * An event triggered when pointer is up
  62936. */
  62937. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62938. /**
  62939. * An event triggered when a control is clicked on (with a mouse)
  62940. */
  62941. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62942. /**
  62943. * An event triggered when pointer enters the control
  62944. */
  62945. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62946. /**
  62947. * Gets or sets the parent container
  62948. */
  62949. parent: BABYLON.Nullable<Container3D>;
  62950. private _behaviors;
  62951. /**
  62952. * Gets the list of attached behaviors
  62953. * @see http://doc.babylonjs.com/features/behaviour
  62954. */
  62955. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62956. /**
  62957. * Attach a behavior to the control
  62958. * @see http://doc.babylonjs.com/features/behaviour
  62959. * @param behavior defines the behavior to attach
  62960. * @returns the current control
  62961. */
  62962. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62963. /**
  62964. * Remove an attached behavior
  62965. * @see http://doc.babylonjs.com/features/behaviour
  62966. * @param behavior defines the behavior to attach
  62967. * @returns the current control
  62968. */
  62969. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62970. /**
  62971. * Gets an attached behavior by name
  62972. * @param name defines the name of the behavior to look for
  62973. * @see http://doc.babylonjs.com/features/behaviour
  62974. * @returns null if behavior was not found else the requested behavior
  62975. */
  62976. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62977. /** Gets or sets a boolean indicating if the control is visible */
  62978. isVisible: boolean;
  62979. /**
  62980. * Creates a new control
  62981. * @param name defines the control name
  62982. */
  62983. constructor(
  62984. /** Defines the control name */
  62985. name?: string | undefined);
  62986. /**
  62987. * Gets a string representing the class name
  62988. */
  62989. readonly typeName: string;
  62990. /**
  62991. * Get the current class name of the control.
  62992. * @returns current class name
  62993. */
  62994. getClassName(): string;
  62995. protected _getTypeName(): string;
  62996. /**
  62997. * Gets the transform node used by this control
  62998. */
  62999. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63000. /**
  63001. * Gets the mesh used to render this control
  63002. */
  63003. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63004. /**
  63005. * Link the control as child of the given node
  63006. * @param node defines the node to link to. Use null to unlink the control
  63007. * @returns the current control
  63008. */
  63009. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63010. /** @hidden **/
  63011. _prepareNode(scene: BABYLON.Scene): void;
  63012. /**
  63013. * Node creation.
  63014. * Can be overriden by children
  63015. * @param scene defines the scene where the node must be attached
  63016. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63017. */
  63018. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63019. /**
  63020. * Affect a material to the given mesh
  63021. * @param mesh defines the mesh which will represent the control
  63022. */
  63023. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63024. /** @hidden */
  63025. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63026. /** @hidden */
  63027. _onPointerEnter(target: Control3D): boolean;
  63028. /** @hidden */
  63029. _onPointerOut(target: Control3D): void;
  63030. /** @hidden */
  63031. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63032. /** @hidden */
  63033. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63034. /** @hidden */
  63035. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63036. /** @hidden */
  63037. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63038. /** @hidden */
  63039. _disposeNode(): void;
  63040. /**
  63041. * Releases all associated resources
  63042. */
  63043. dispose(): void;
  63044. }
  63045. }
  63046. declare module BABYLON.GUI {
  63047. /**
  63048. * Class used as a root to all buttons
  63049. */
  63050. export class AbstractButton3D extends Control3D {
  63051. /**
  63052. * Creates a new button
  63053. * @param name defines the control name
  63054. */
  63055. constructor(name?: string);
  63056. protected _getTypeName(): string;
  63057. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63058. }
  63059. }
  63060. declare module BABYLON.GUI {
  63061. /**
  63062. * Class used to create a button in 3D
  63063. */
  63064. export class Button3D extends AbstractButton3D {
  63065. /** @hidden */
  63066. protected _currentMaterial: BABYLON.Material;
  63067. private _facadeTexture;
  63068. private _content;
  63069. private _contentResolution;
  63070. private _contentScaleRatio;
  63071. /**
  63072. * Gets or sets the texture resolution used to render content (512 by default)
  63073. */
  63074. contentResolution: BABYLON.int;
  63075. /**
  63076. * Gets or sets the texture scale ratio used to render content (2 by default)
  63077. */
  63078. contentScaleRatio: number;
  63079. protected _disposeFacadeTexture(): void;
  63080. protected _resetContent(): void;
  63081. /**
  63082. * Creates a new button
  63083. * @param name defines the control name
  63084. */
  63085. constructor(name?: string);
  63086. /**
  63087. * Gets or sets the GUI 2D content used to display the button's facade
  63088. */
  63089. content: Control;
  63090. /**
  63091. * Apply the facade texture (created from the content property).
  63092. * This function can be overloaded by child classes
  63093. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63094. */
  63095. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63096. protected _getTypeName(): string;
  63097. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63098. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63099. /**
  63100. * Releases all associated resources
  63101. */
  63102. dispose(): void;
  63103. }
  63104. }
  63105. declare module BABYLON.GUI {
  63106. /**
  63107. * Abstract class used to create a container panel deployed on the surface of a volume
  63108. */
  63109. export abstract class VolumeBasedPanel extends Container3D {
  63110. private _columns;
  63111. private _rows;
  63112. private _rowThenColum;
  63113. private _orientation;
  63114. protected _cellWidth: number;
  63115. protected _cellHeight: number;
  63116. /**
  63117. * Gets or sets the distance between elements
  63118. */
  63119. margin: number;
  63120. /**
  63121. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63122. * | Value | Type | Description |
  63123. * | ----- | ----------------------------------- | ----------- |
  63124. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63125. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63126. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63127. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63128. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63129. */
  63130. orientation: number;
  63131. /**
  63132. * Gets or sets the number of columns requested (10 by default).
  63133. * The panel will automatically compute the number of rows based on number of child controls.
  63134. */
  63135. columns: BABYLON.int;
  63136. /**
  63137. * Gets or sets a the number of rows requested.
  63138. * The panel will automatically compute the number of columns based on number of child controls.
  63139. */
  63140. rows: BABYLON.int;
  63141. /**
  63142. * Creates new VolumeBasedPanel
  63143. */
  63144. constructor();
  63145. protected _arrangeChildren(): void;
  63146. /** Child classes must implement this function to provide correct control positioning */
  63147. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63148. /** Child classes can implement this function to provide additional processing */
  63149. protected _finalProcessing(): void;
  63150. }
  63151. }
  63152. declare module BABYLON.GUI {
  63153. /**
  63154. * Class used to create a container panel deployed on the surface of a cylinder
  63155. */
  63156. export class CylinderPanel extends VolumeBasedPanel {
  63157. private _radius;
  63158. /**
  63159. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63160. */
  63161. radius: BABYLON.float;
  63162. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63163. private _cylindricalMapping;
  63164. }
  63165. }
  63166. declare module BABYLON.GUI {
  63167. /** @hidden */
  63168. export var fluentVertexShader: {
  63169. name: string;
  63170. shader: string;
  63171. };
  63172. }
  63173. declare module BABYLON.GUI {
  63174. /** @hidden */
  63175. export var fluentPixelShader: {
  63176. name: string;
  63177. shader: string;
  63178. };
  63179. }
  63180. declare module BABYLON.GUI {
  63181. /** @hidden */
  63182. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63183. INNERGLOW: boolean;
  63184. BORDER: boolean;
  63185. HOVERLIGHT: boolean;
  63186. TEXTURE: boolean;
  63187. constructor();
  63188. }
  63189. /**
  63190. * Class used to render controls with fluent desgin
  63191. */
  63192. export class FluentMaterial extends BABYLON.PushMaterial {
  63193. /**
  63194. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63195. */
  63196. innerGlowColorIntensity: number;
  63197. /**
  63198. * Gets or sets the inner glow color (white by default)
  63199. */
  63200. innerGlowColor: BABYLON.Color3;
  63201. /**
  63202. * Gets or sets alpha value (default is 1.0)
  63203. */
  63204. alpha: number;
  63205. /**
  63206. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63207. */
  63208. albedoColor: BABYLON.Color3;
  63209. /**
  63210. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63211. */
  63212. renderBorders: boolean;
  63213. /**
  63214. * Gets or sets border width (default is 0.5)
  63215. */
  63216. borderWidth: number;
  63217. /**
  63218. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63219. */
  63220. edgeSmoothingValue: number;
  63221. /**
  63222. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63223. */
  63224. borderMinValue: number;
  63225. /**
  63226. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63227. */
  63228. renderHoverLight: boolean;
  63229. /**
  63230. * Gets or sets the radius used to render the hover light (default is 1.0)
  63231. */
  63232. hoverRadius: number;
  63233. /**
  63234. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63235. */
  63236. hoverColor: BABYLON.Color4;
  63237. /**
  63238. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63239. */
  63240. hoverPosition: BABYLON.Vector3;
  63241. private _albedoTexture;
  63242. /** Gets or sets the texture to use for albedo color */
  63243. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63244. /**
  63245. * Creates a new Fluent material
  63246. * @param name defines the name of the material
  63247. * @param scene defines the hosting scene
  63248. */
  63249. constructor(name: string, scene: BABYLON.Scene);
  63250. needAlphaBlending(): boolean;
  63251. needAlphaTesting(): boolean;
  63252. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63253. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63254. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63255. getActiveTextures(): BABYLON.BaseTexture[];
  63256. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63257. dispose(forceDisposeEffect?: boolean): void;
  63258. clone(name: string): FluentMaterial;
  63259. serialize(): any;
  63260. getClassName(): string;
  63261. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63262. }
  63263. }
  63264. declare module BABYLON.GUI {
  63265. /**
  63266. * Class used to create a holographic button in 3D
  63267. */
  63268. export class HolographicButton extends Button3D {
  63269. private _backPlate;
  63270. private _textPlate;
  63271. private _frontPlate;
  63272. private _text;
  63273. private _imageUrl;
  63274. private _shareMaterials;
  63275. private _frontMaterial;
  63276. private _backMaterial;
  63277. private _plateMaterial;
  63278. private _pickedPointObserver;
  63279. private _tooltipFade;
  63280. private _tooltipTextBlock;
  63281. private _tooltipTexture;
  63282. private _tooltipMesh;
  63283. private _tooltipHoverObserver;
  63284. private _tooltipOutObserver;
  63285. private _disposeTooltip;
  63286. /**
  63287. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63288. */
  63289. tooltipText: BABYLON.Nullable<string>;
  63290. /**
  63291. * Gets or sets text for the button
  63292. */
  63293. text: string;
  63294. /**
  63295. * Gets or sets the image url for the button
  63296. */
  63297. imageUrl: string;
  63298. /**
  63299. * Gets the back material used by this button
  63300. */
  63301. readonly backMaterial: FluentMaterial;
  63302. /**
  63303. * Gets the front material used by this button
  63304. */
  63305. readonly frontMaterial: FluentMaterial;
  63306. /**
  63307. * Gets the plate material used by this button
  63308. */
  63309. readonly plateMaterial: BABYLON.StandardMaterial;
  63310. /**
  63311. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63312. */
  63313. readonly shareMaterials: boolean;
  63314. /**
  63315. * Creates a new button
  63316. * @param name defines the control name
  63317. */
  63318. constructor(name?: string, shareMaterials?: boolean);
  63319. protected _getTypeName(): string;
  63320. private _rebuildContent;
  63321. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63322. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63323. private _createBackMaterial;
  63324. private _createFrontMaterial;
  63325. private _createPlateMaterial;
  63326. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63327. /**
  63328. * Releases all associated resources
  63329. */
  63330. dispose(): void;
  63331. }
  63332. }
  63333. declare module BABYLON.GUI {
  63334. /**
  63335. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63336. */
  63337. export class MeshButton3D extends Button3D {
  63338. /** @hidden */
  63339. protected _currentMesh: BABYLON.Mesh;
  63340. /**
  63341. * Creates a new 3D button based on a mesh
  63342. * @param mesh mesh to become a 3D button
  63343. * @param name defines the control name
  63344. */
  63345. constructor(mesh: BABYLON.Mesh, name?: string);
  63346. protected _getTypeName(): string;
  63347. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63348. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63349. }
  63350. }
  63351. declare module BABYLON.GUI {
  63352. /**
  63353. * Class used to create a container panel deployed on the surface of a plane
  63354. */
  63355. export class PlanePanel extends VolumeBasedPanel {
  63356. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63357. }
  63358. }
  63359. declare module BABYLON.GUI {
  63360. /**
  63361. * Class used to create a container panel where items get randomized planar mapping
  63362. */
  63363. export class ScatterPanel extends VolumeBasedPanel {
  63364. private _iteration;
  63365. /**
  63366. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63367. */
  63368. iteration: BABYLON.float;
  63369. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63370. private _scatterMapping;
  63371. protected _finalProcessing(): void;
  63372. }
  63373. }
  63374. declare module BABYLON.GUI {
  63375. /**
  63376. * Class used to create a container panel deployed on the surface of a sphere
  63377. */
  63378. export class SpherePanel extends VolumeBasedPanel {
  63379. private _radius;
  63380. /**
  63381. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63382. */
  63383. radius: BABYLON.float;
  63384. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63385. private _sphericalMapping;
  63386. }
  63387. }
  63388. declare module BABYLON.GUI {
  63389. /**
  63390. * Class used to create a stack panel in 3D on XY plane
  63391. */
  63392. export class StackPanel3D extends Container3D {
  63393. private _isVertical;
  63394. /**
  63395. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63396. */
  63397. isVertical: boolean;
  63398. /**
  63399. * Gets or sets the distance between elements
  63400. */
  63401. margin: number;
  63402. /**
  63403. * Creates new StackPanel
  63404. * @param isVertical
  63405. */
  63406. constructor(isVertical?: boolean);
  63407. protected _arrangeChildren(): void;
  63408. }
  63409. }
  63410. declare module BABYLON {
  63411. /**
  63412. * Mode that determines the coordinate system to use.
  63413. */
  63414. export enum GLTFLoaderCoordinateSystemMode {
  63415. /**
  63416. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63417. */
  63418. AUTO = 0,
  63419. /**
  63420. * Sets the useRightHandedSystem flag on the scene.
  63421. */
  63422. FORCE_RIGHT_HANDED = 1
  63423. }
  63424. /**
  63425. * Mode that determines what animations will start.
  63426. */
  63427. export enum GLTFLoaderAnimationStartMode {
  63428. /**
  63429. * No animation will start.
  63430. */
  63431. NONE = 0,
  63432. /**
  63433. * The first animation will start.
  63434. */
  63435. FIRST = 1,
  63436. /**
  63437. * All animations will start.
  63438. */
  63439. ALL = 2
  63440. }
  63441. /**
  63442. * Interface that contains the data for the glTF asset.
  63443. */
  63444. export interface IGLTFLoaderData {
  63445. /**
  63446. * Object that represents the glTF JSON.
  63447. */
  63448. json: Object;
  63449. /**
  63450. * The BIN chunk of a binary glTF.
  63451. */
  63452. bin: Nullable<ArrayBufferView>;
  63453. }
  63454. /**
  63455. * Interface for extending the loader.
  63456. */
  63457. export interface IGLTFLoaderExtension {
  63458. /**
  63459. * The name of this extension.
  63460. */
  63461. readonly name: string;
  63462. /**
  63463. * Defines whether this extension is enabled.
  63464. */
  63465. enabled: boolean;
  63466. }
  63467. /**
  63468. * Loader state.
  63469. */
  63470. export enum GLTFLoaderState {
  63471. /**
  63472. * The asset is loading.
  63473. */
  63474. LOADING = 0,
  63475. /**
  63476. * The asset is ready for rendering.
  63477. */
  63478. READY = 1,
  63479. /**
  63480. * The asset is completely loaded.
  63481. */
  63482. COMPLETE = 2
  63483. }
  63484. /** @hidden */
  63485. export interface IGLTFLoader extends IDisposable {
  63486. readonly state: Nullable<GLTFLoaderState>;
  63487. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63488. meshes: AbstractMesh[];
  63489. particleSystems: IParticleSystem[];
  63490. skeletons: Skeleton[];
  63491. animationGroups: AnimationGroup[];
  63492. }>;
  63493. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63494. }
  63495. /**
  63496. * File loader for loading glTF files into a scene.
  63497. */
  63498. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63499. /** @hidden */
  63500. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63501. /** @hidden */
  63502. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63503. /**
  63504. * Raised when the asset has been parsed
  63505. */
  63506. onParsedObservable: Observable<IGLTFLoaderData>;
  63507. private _onParsedObserver;
  63508. /**
  63509. * Raised when the asset has been parsed
  63510. */
  63511. onParsed: (loaderData: IGLTFLoaderData) => void;
  63512. /**
  63513. * 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.
  63514. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63515. * Defaults to true.
  63516. * @hidden
  63517. */
  63518. static IncrementalLoading: boolean;
  63519. /**
  63520. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63521. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63522. * @hidden
  63523. */
  63524. static HomogeneousCoordinates: boolean;
  63525. /**
  63526. * The coordinate system mode. Defaults to AUTO.
  63527. */
  63528. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63529. /**
  63530. * The animation start mode. Defaults to FIRST.
  63531. */
  63532. animationStartMode: GLTFLoaderAnimationStartMode;
  63533. /**
  63534. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63535. */
  63536. compileMaterials: boolean;
  63537. /**
  63538. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63539. */
  63540. useClipPlane: boolean;
  63541. /**
  63542. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63543. */
  63544. compileShadowGenerators: boolean;
  63545. /**
  63546. * Defines if the Alpha blended materials are only applied as coverage.
  63547. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63548. * If true, no extra effects are applied to transparent pixels.
  63549. */
  63550. transparencyAsCoverage: boolean;
  63551. /**
  63552. * Function called before loading a url referenced by the asset.
  63553. */
  63554. preprocessUrlAsync: (url: string) => Promise<string>;
  63555. /**
  63556. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63557. */
  63558. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63559. private _onMeshLoadedObserver;
  63560. /**
  63561. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63562. */
  63563. onMeshLoaded: (mesh: AbstractMesh) => void;
  63564. /**
  63565. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63566. */
  63567. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63568. private _onTextureLoadedObserver;
  63569. /**
  63570. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63571. */
  63572. onTextureLoaded: (texture: BaseTexture) => void;
  63573. /**
  63574. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63575. */
  63576. readonly onMaterialLoadedObservable: Observable<Material>;
  63577. private _onMaterialLoadedObserver;
  63578. /**
  63579. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63580. */
  63581. onMaterialLoaded: (material: Material) => void;
  63582. /**
  63583. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63584. */
  63585. readonly onCameraLoadedObservable: Observable<Camera>;
  63586. private _onCameraLoadedObserver;
  63587. /**
  63588. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63589. */
  63590. onCameraLoaded: (camera: Camera) => void;
  63591. /**
  63592. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63593. * For assets with LODs, raised when all of the LODs are complete.
  63594. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63595. */
  63596. readonly onCompleteObservable: Observable<void>;
  63597. private _onCompleteObserver;
  63598. /**
  63599. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63600. * For assets with LODs, raised when all of the LODs are complete.
  63601. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63602. */
  63603. onComplete: () => void;
  63604. /**
  63605. * Observable raised when an error occurs.
  63606. */
  63607. readonly onErrorObservable: Observable<any>;
  63608. private _onErrorObserver;
  63609. /**
  63610. * Callback raised when an error occurs.
  63611. */
  63612. onError: (reason: any) => void;
  63613. /**
  63614. * Observable raised after the loader is disposed.
  63615. */
  63616. readonly onDisposeObservable: Observable<void>;
  63617. private _onDisposeObserver;
  63618. /**
  63619. * Callback raised after the loader is disposed.
  63620. */
  63621. onDispose: () => void;
  63622. /**
  63623. * Observable raised after a loader extension is created.
  63624. * Set additional options for a loader extension in this event.
  63625. */
  63626. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63627. private _onExtensionLoadedObserver;
  63628. /**
  63629. * Callback raised after a loader extension is created.
  63630. */
  63631. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63632. /**
  63633. * Defines if the loader logging is enabled.
  63634. */
  63635. loggingEnabled: boolean;
  63636. /**
  63637. * Defines if the loader should capture performance counters.
  63638. */
  63639. capturePerformanceCounters: boolean;
  63640. /**
  63641. * Defines if the loader should validate the asset.
  63642. */
  63643. validate: boolean;
  63644. /**
  63645. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63646. */
  63647. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63648. private _onValidatedObserver;
  63649. /**
  63650. * Callback raised after a loader extension is created.
  63651. */
  63652. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63653. private _loader;
  63654. /**
  63655. * Name of the loader ("gltf")
  63656. */
  63657. name: string;
  63658. /**
  63659. * Supported file extensions of the loader (.gltf, .glb)
  63660. */
  63661. extensions: ISceneLoaderPluginExtensions;
  63662. /**
  63663. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63664. */
  63665. dispose(): void;
  63666. /** @hidden */
  63667. _clear(): void;
  63668. /**
  63669. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63670. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63671. * @param scene the scene the meshes should be added to
  63672. * @param data the glTF data to load
  63673. * @param rootUrl root url to load from
  63674. * @param onProgress event that fires when loading progress has occured
  63675. * @param fileName Defines the name of the file to load
  63676. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63677. */
  63678. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63679. meshes: AbstractMesh[];
  63680. particleSystems: IParticleSystem[];
  63681. skeletons: Skeleton[];
  63682. animationGroups: AnimationGroup[];
  63683. }>;
  63684. /**
  63685. * Imports all objects from the loaded glTF data and adds them to the scene
  63686. * @param scene the scene the objects should be added to
  63687. * @param data the glTF data to load
  63688. * @param rootUrl root url to load from
  63689. * @param onProgress event that fires when loading progress has occured
  63690. * @param fileName Defines the name of the file to load
  63691. * @returns a promise which completes when objects have been loaded to the scene
  63692. */
  63693. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63694. /**
  63695. * Load into an asset container.
  63696. * @param scene The scene to load into
  63697. * @param data The data to import
  63698. * @param rootUrl The root url for scene and resources
  63699. * @param onProgress The callback when the load progresses
  63700. * @param fileName Defines the name of the file to load
  63701. * @returns The loaded asset container
  63702. */
  63703. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63704. /**
  63705. * If the data string can be loaded directly.
  63706. * @param data string contianing the file data
  63707. * @returns if the data can be loaded directly
  63708. */
  63709. canDirectLoad(data: string): boolean;
  63710. /**
  63711. * Rewrites a url by combining a root url and response url.
  63712. */
  63713. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63714. /**
  63715. * Instantiates a glTF file loader plugin.
  63716. * @returns the created plugin
  63717. */
  63718. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63719. /**
  63720. * The loader state or null if the loader is not active.
  63721. */
  63722. readonly loaderState: Nullable<GLTFLoaderState>;
  63723. /**
  63724. * Returns a promise that resolves when the asset is completely loaded.
  63725. * @returns a promise that resolves when the asset is completely loaded.
  63726. */
  63727. whenCompleteAsync(): Promise<void>;
  63728. private _parseAsync;
  63729. private _validateAsync;
  63730. private _getLoader;
  63731. private _unpackBinary;
  63732. private _unpackBinaryV1;
  63733. private _unpackBinaryV2;
  63734. private static _parseVersion;
  63735. private static _compareVersion;
  63736. private static _decodeBufferToText;
  63737. private static readonly _logSpaces;
  63738. private _logIndentLevel;
  63739. private _loggingEnabled;
  63740. /** @hidden */
  63741. _log: (message: string) => void;
  63742. /** @hidden */
  63743. _logOpen(message: string): void;
  63744. /** @hidden */
  63745. _logClose(): void;
  63746. private _logEnabled;
  63747. private _logDisabled;
  63748. private _capturePerformanceCounters;
  63749. /** @hidden */
  63750. _startPerformanceCounter: (counterName: string) => void;
  63751. /** @hidden */
  63752. _endPerformanceCounter: (counterName: string) => void;
  63753. private _startPerformanceCounterEnabled;
  63754. private _startPerformanceCounterDisabled;
  63755. private _endPerformanceCounterEnabled;
  63756. private _endPerformanceCounterDisabled;
  63757. }
  63758. }
  63759. declare module BABYLON.GLTF1 {
  63760. /**
  63761. * Enums
  63762. * @hidden
  63763. */
  63764. export enum EComponentType {
  63765. BYTE = 5120,
  63766. UNSIGNED_BYTE = 5121,
  63767. SHORT = 5122,
  63768. UNSIGNED_SHORT = 5123,
  63769. FLOAT = 5126
  63770. }
  63771. /** @hidden */
  63772. export enum EShaderType {
  63773. FRAGMENT = 35632,
  63774. VERTEX = 35633
  63775. }
  63776. /** @hidden */
  63777. export enum EParameterType {
  63778. BYTE = 5120,
  63779. UNSIGNED_BYTE = 5121,
  63780. SHORT = 5122,
  63781. UNSIGNED_SHORT = 5123,
  63782. INT = 5124,
  63783. UNSIGNED_INT = 5125,
  63784. FLOAT = 5126,
  63785. FLOAT_VEC2 = 35664,
  63786. FLOAT_VEC3 = 35665,
  63787. FLOAT_VEC4 = 35666,
  63788. INT_VEC2 = 35667,
  63789. INT_VEC3 = 35668,
  63790. INT_VEC4 = 35669,
  63791. BOOL = 35670,
  63792. BOOL_VEC2 = 35671,
  63793. BOOL_VEC3 = 35672,
  63794. BOOL_VEC4 = 35673,
  63795. FLOAT_MAT2 = 35674,
  63796. FLOAT_MAT3 = 35675,
  63797. FLOAT_MAT4 = 35676,
  63798. SAMPLER_2D = 35678
  63799. }
  63800. /** @hidden */
  63801. export enum ETextureWrapMode {
  63802. CLAMP_TO_EDGE = 33071,
  63803. MIRRORED_REPEAT = 33648,
  63804. REPEAT = 10497
  63805. }
  63806. /** @hidden */
  63807. export enum ETextureFilterType {
  63808. NEAREST = 9728,
  63809. LINEAR = 9728,
  63810. NEAREST_MIPMAP_NEAREST = 9984,
  63811. LINEAR_MIPMAP_NEAREST = 9985,
  63812. NEAREST_MIPMAP_LINEAR = 9986,
  63813. LINEAR_MIPMAP_LINEAR = 9987
  63814. }
  63815. /** @hidden */
  63816. export enum ETextureFormat {
  63817. ALPHA = 6406,
  63818. RGB = 6407,
  63819. RGBA = 6408,
  63820. LUMINANCE = 6409,
  63821. LUMINANCE_ALPHA = 6410
  63822. }
  63823. /** @hidden */
  63824. export enum ECullingType {
  63825. FRONT = 1028,
  63826. BACK = 1029,
  63827. FRONT_AND_BACK = 1032
  63828. }
  63829. /** @hidden */
  63830. export enum EBlendingFunction {
  63831. ZERO = 0,
  63832. ONE = 1,
  63833. SRC_COLOR = 768,
  63834. ONE_MINUS_SRC_COLOR = 769,
  63835. DST_COLOR = 774,
  63836. ONE_MINUS_DST_COLOR = 775,
  63837. SRC_ALPHA = 770,
  63838. ONE_MINUS_SRC_ALPHA = 771,
  63839. DST_ALPHA = 772,
  63840. ONE_MINUS_DST_ALPHA = 773,
  63841. CONSTANT_COLOR = 32769,
  63842. ONE_MINUS_CONSTANT_COLOR = 32770,
  63843. CONSTANT_ALPHA = 32771,
  63844. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63845. SRC_ALPHA_SATURATE = 776
  63846. }
  63847. /** @hidden */
  63848. export interface IGLTFProperty {
  63849. extensions?: {
  63850. [key: string]: any;
  63851. };
  63852. extras?: Object;
  63853. }
  63854. /** @hidden */
  63855. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63856. name?: string;
  63857. }
  63858. /** @hidden */
  63859. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63860. bufferView: string;
  63861. byteOffset: number;
  63862. byteStride: number;
  63863. count: number;
  63864. type: string;
  63865. componentType: EComponentType;
  63866. max?: number[];
  63867. min?: number[];
  63868. name?: string;
  63869. }
  63870. /** @hidden */
  63871. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63872. buffer: string;
  63873. byteOffset: number;
  63874. byteLength: number;
  63875. byteStride: number;
  63876. target?: number;
  63877. }
  63878. /** @hidden */
  63879. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63880. uri: string;
  63881. byteLength?: number;
  63882. type?: string;
  63883. }
  63884. /** @hidden */
  63885. export interface IGLTFShader extends IGLTFChildRootProperty {
  63886. uri: string;
  63887. type: EShaderType;
  63888. }
  63889. /** @hidden */
  63890. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63891. attributes: string[];
  63892. fragmentShader: string;
  63893. vertexShader: string;
  63894. }
  63895. /** @hidden */
  63896. export interface IGLTFTechniqueParameter {
  63897. type: number;
  63898. count?: number;
  63899. semantic?: string;
  63900. node?: string;
  63901. value?: number | boolean | string | Array<any>;
  63902. source?: string;
  63903. babylonValue?: any;
  63904. }
  63905. /** @hidden */
  63906. export interface IGLTFTechniqueCommonProfile {
  63907. lightingModel: string;
  63908. texcoordBindings: Object;
  63909. parameters?: Array<any>;
  63910. }
  63911. /** @hidden */
  63912. export interface IGLTFTechniqueStatesFunctions {
  63913. blendColor?: number[];
  63914. blendEquationSeparate?: number[];
  63915. blendFuncSeparate?: number[];
  63916. colorMask: boolean[];
  63917. cullFace: number[];
  63918. }
  63919. /** @hidden */
  63920. export interface IGLTFTechniqueStates {
  63921. enable: number[];
  63922. functions: IGLTFTechniqueStatesFunctions;
  63923. }
  63924. /** @hidden */
  63925. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63926. parameters: {
  63927. [key: string]: IGLTFTechniqueParameter;
  63928. };
  63929. program: string;
  63930. attributes: {
  63931. [key: string]: string;
  63932. };
  63933. uniforms: {
  63934. [key: string]: string;
  63935. };
  63936. states: IGLTFTechniqueStates;
  63937. }
  63938. /** @hidden */
  63939. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63940. technique?: string;
  63941. values: string[];
  63942. }
  63943. /** @hidden */
  63944. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63945. attributes: {
  63946. [key: string]: string;
  63947. };
  63948. indices: string;
  63949. material: string;
  63950. mode?: number;
  63951. }
  63952. /** @hidden */
  63953. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63954. primitives: IGLTFMeshPrimitive[];
  63955. }
  63956. /** @hidden */
  63957. export interface IGLTFImage extends IGLTFChildRootProperty {
  63958. uri: string;
  63959. }
  63960. /** @hidden */
  63961. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63962. magFilter?: number;
  63963. minFilter?: number;
  63964. wrapS?: number;
  63965. wrapT?: number;
  63966. }
  63967. /** @hidden */
  63968. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63969. sampler: string;
  63970. source: string;
  63971. format?: ETextureFormat;
  63972. internalFormat?: ETextureFormat;
  63973. target?: number;
  63974. type?: number;
  63975. babylonTexture?: Texture;
  63976. }
  63977. /** @hidden */
  63978. export interface IGLTFAmbienLight {
  63979. color?: number[];
  63980. }
  63981. /** @hidden */
  63982. export interface IGLTFDirectionalLight {
  63983. color?: number[];
  63984. }
  63985. /** @hidden */
  63986. export interface IGLTFPointLight {
  63987. color?: number[];
  63988. constantAttenuation?: number;
  63989. linearAttenuation?: number;
  63990. quadraticAttenuation?: number;
  63991. }
  63992. /** @hidden */
  63993. export interface IGLTFSpotLight {
  63994. color?: number[];
  63995. constantAttenuation?: number;
  63996. fallOfAngle?: number;
  63997. fallOffExponent?: number;
  63998. linearAttenuation?: number;
  63999. quadraticAttenuation?: number;
  64000. }
  64001. /** @hidden */
  64002. export interface IGLTFLight extends IGLTFChildRootProperty {
  64003. type: string;
  64004. }
  64005. /** @hidden */
  64006. export interface IGLTFCameraOrthographic {
  64007. xmag: number;
  64008. ymag: number;
  64009. zfar: number;
  64010. znear: number;
  64011. }
  64012. /** @hidden */
  64013. export interface IGLTFCameraPerspective {
  64014. aspectRatio: number;
  64015. yfov: number;
  64016. zfar: number;
  64017. znear: number;
  64018. }
  64019. /** @hidden */
  64020. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64021. type: string;
  64022. }
  64023. /** @hidden */
  64024. export interface IGLTFAnimationChannelTarget {
  64025. id: string;
  64026. path: string;
  64027. }
  64028. /** @hidden */
  64029. export interface IGLTFAnimationChannel {
  64030. sampler: string;
  64031. target: IGLTFAnimationChannelTarget;
  64032. }
  64033. /** @hidden */
  64034. export interface IGLTFAnimationSampler {
  64035. input: string;
  64036. output: string;
  64037. interpolation?: string;
  64038. }
  64039. /** @hidden */
  64040. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64041. channels?: IGLTFAnimationChannel[];
  64042. parameters?: {
  64043. [key: string]: string;
  64044. };
  64045. samplers?: {
  64046. [key: string]: IGLTFAnimationSampler;
  64047. };
  64048. }
  64049. /** @hidden */
  64050. export interface IGLTFNodeInstanceSkin {
  64051. skeletons: string[];
  64052. skin: string;
  64053. meshes: string[];
  64054. }
  64055. /** @hidden */
  64056. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64057. bindShapeMatrix: number[];
  64058. inverseBindMatrices: string;
  64059. jointNames: string[];
  64060. babylonSkeleton?: Skeleton;
  64061. }
  64062. /** @hidden */
  64063. export interface IGLTFNode extends IGLTFChildRootProperty {
  64064. camera?: string;
  64065. children: string[];
  64066. skin?: string;
  64067. jointName?: string;
  64068. light?: string;
  64069. matrix: number[];
  64070. mesh?: string;
  64071. meshes?: string[];
  64072. rotation?: number[];
  64073. scale?: number[];
  64074. translation?: number[];
  64075. babylonNode?: Node;
  64076. }
  64077. /** @hidden */
  64078. export interface IGLTFScene extends IGLTFChildRootProperty {
  64079. nodes: string[];
  64080. }
  64081. /** @hidden */
  64082. export interface IGLTFRuntime {
  64083. extensions: {
  64084. [key: string]: any;
  64085. };
  64086. accessors: {
  64087. [key: string]: IGLTFAccessor;
  64088. };
  64089. buffers: {
  64090. [key: string]: IGLTFBuffer;
  64091. };
  64092. bufferViews: {
  64093. [key: string]: IGLTFBufferView;
  64094. };
  64095. meshes: {
  64096. [key: string]: IGLTFMesh;
  64097. };
  64098. lights: {
  64099. [key: string]: IGLTFLight;
  64100. };
  64101. cameras: {
  64102. [key: string]: IGLTFCamera;
  64103. };
  64104. nodes: {
  64105. [key: string]: IGLTFNode;
  64106. };
  64107. images: {
  64108. [key: string]: IGLTFImage;
  64109. };
  64110. textures: {
  64111. [key: string]: IGLTFTexture;
  64112. };
  64113. shaders: {
  64114. [key: string]: IGLTFShader;
  64115. };
  64116. programs: {
  64117. [key: string]: IGLTFProgram;
  64118. };
  64119. samplers: {
  64120. [key: string]: IGLTFSampler;
  64121. };
  64122. techniques: {
  64123. [key: string]: IGLTFTechnique;
  64124. };
  64125. materials: {
  64126. [key: string]: IGLTFMaterial;
  64127. };
  64128. animations: {
  64129. [key: string]: IGLTFAnimation;
  64130. };
  64131. skins: {
  64132. [key: string]: IGLTFSkins;
  64133. };
  64134. currentScene?: Object;
  64135. scenes: {
  64136. [key: string]: IGLTFScene;
  64137. };
  64138. extensionsUsed: string[];
  64139. extensionsRequired?: string[];
  64140. buffersCount: number;
  64141. shaderscount: number;
  64142. scene: Scene;
  64143. rootUrl: string;
  64144. loadedBufferCount: number;
  64145. loadedBufferViews: {
  64146. [name: string]: ArrayBufferView;
  64147. };
  64148. loadedShaderCount: number;
  64149. importOnlyMeshes: boolean;
  64150. importMeshesNames?: string[];
  64151. dummyNodes: Node[];
  64152. }
  64153. /** @hidden */
  64154. export interface INodeToRoot {
  64155. bone: Bone;
  64156. node: IGLTFNode;
  64157. id: string;
  64158. }
  64159. /** @hidden */
  64160. export interface IJointNode {
  64161. node: IGLTFNode;
  64162. id: string;
  64163. }
  64164. }
  64165. declare module BABYLON.GLTF1 {
  64166. /**
  64167. * Utils functions for GLTF
  64168. * @hidden
  64169. */
  64170. export class GLTFUtils {
  64171. /**
  64172. * Sets the given "parameter" matrix
  64173. * @param scene: the Scene object
  64174. * @param source: the source node where to pick the matrix
  64175. * @param parameter: the GLTF technique parameter
  64176. * @param uniformName: the name of the shader's uniform
  64177. * @param shaderMaterial: the shader material
  64178. */
  64179. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64180. /**
  64181. * Sets the given "parameter" matrix
  64182. * @param shaderMaterial: the shader material
  64183. * @param uniform: the name of the shader's uniform
  64184. * @param value: the value of the uniform
  64185. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64186. */
  64187. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64188. /**
  64189. * Returns the wrap mode of the texture
  64190. * @param mode: the mode value
  64191. */
  64192. static GetWrapMode(mode: number): number;
  64193. /**
  64194. * Returns the byte stride giving an accessor
  64195. * @param accessor: the GLTF accessor objet
  64196. */
  64197. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64198. /**
  64199. * Returns the texture filter mode giving a mode value
  64200. * @param mode: the filter mode value
  64201. */
  64202. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64203. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64204. /**
  64205. * Returns a buffer from its accessor
  64206. * @param gltfRuntime: the GLTF runtime
  64207. * @param accessor: the GLTF accessor
  64208. */
  64209. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64210. /**
  64211. * Decodes a buffer view into a string
  64212. * @param view: the buffer view
  64213. */
  64214. static DecodeBufferToText(view: ArrayBufferView): string;
  64215. /**
  64216. * Returns the default material of gltf. Related to
  64217. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64218. * @param scene: the Babylon.js scene
  64219. */
  64220. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64221. private static _DefaultMaterial;
  64222. }
  64223. }
  64224. declare module BABYLON.GLTF1 {
  64225. /**
  64226. * Implementation of the base glTF spec
  64227. * @hidden
  64228. */
  64229. export class GLTFLoaderBase {
  64230. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64231. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64232. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64233. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64234. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64235. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64236. }
  64237. /**
  64238. * glTF V1 Loader
  64239. * @hidden
  64240. */
  64241. export class GLTFLoader implements IGLTFLoader {
  64242. static Extensions: {
  64243. [name: string]: GLTFLoaderExtension;
  64244. };
  64245. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64246. state: Nullable<GLTFLoaderState>;
  64247. dispose(): void;
  64248. private _importMeshAsync;
  64249. /**
  64250. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64251. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64252. * @param scene the scene the meshes should be added to
  64253. * @param data gltf data containing information of the meshes in a loaded file
  64254. * @param rootUrl root url to load from
  64255. * @param onProgress event that fires when loading progress has occured
  64256. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64257. */
  64258. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64259. meshes: AbstractMesh[];
  64260. particleSystems: IParticleSystem[];
  64261. skeletons: Skeleton[];
  64262. animationGroups: AnimationGroup[];
  64263. }>;
  64264. private _loadAsync;
  64265. /**
  64266. * Imports all objects from a loaded gltf file and adds them to the scene
  64267. * @param scene the scene the objects should be added to
  64268. * @param data gltf data containing information of the meshes in a loaded file
  64269. * @param rootUrl root url to load from
  64270. * @param onProgress event that fires when loading progress has occured
  64271. * @returns a promise which completes when objects have been loaded to the scene
  64272. */
  64273. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64274. private _loadShadersAsync;
  64275. private _loadBuffersAsync;
  64276. private _createNodes;
  64277. }
  64278. /** @hidden */
  64279. export abstract class GLTFLoaderExtension {
  64280. private _name;
  64281. constructor(name: string);
  64282. readonly name: string;
  64283. /**
  64284. * Defines an override for loading the runtime
  64285. * Return true to stop further extensions from loading the runtime
  64286. */
  64287. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64288. /**
  64289. * Defines an onverride for creating gltf runtime
  64290. * Return true to stop further extensions from creating the runtime
  64291. */
  64292. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64293. /**
  64294. * Defines an override for loading buffers
  64295. * Return true to stop further extensions from loading this buffer
  64296. */
  64297. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64298. /**
  64299. * Defines an override for loading texture buffers
  64300. * Return true to stop further extensions from loading this texture data
  64301. */
  64302. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64303. /**
  64304. * Defines an override for creating textures
  64305. * Return true to stop further extensions from loading this texture
  64306. */
  64307. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64308. /**
  64309. * Defines an override for loading shader strings
  64310. * Return true to stop further extensions from loading this shader data
  64311. */
  64312. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64313. /**
  64314. * Defines an override for loading materials
  64315. * Return true to stop further extensions from loading this material
  64316. */
  64317. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64318. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64319. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64320. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64321. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64322. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64323. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64324. private static LoadTextureBufferAsync;
  64325. private static CreateTextureAsync;
  64326. private static ApplyExtensions;
  64327. }
  64328. }
  64329. declare module BABYLON.GLTF1 {
  64330. /** @hidden */
  64331. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64332. private _bin;
  64333. constructor();
  64334. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64335. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64336. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64337. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64338. }
  64339. }
  64340. declare module BABYLON.GLTF1 {
  64341. /** @hidden */
  64342. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64343. constructor();
  64344. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64345. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64346. private _loadTexture;
  64347. }
  64348. }
  64349. declare module BABYLON.GLTF2.Loader {
  64350. /**
  64351. * Loader interface with an index field.
  64352. */
  64353. export interface IArrayItem {
  64354. /**
  64355. * The index of this item in the array.
  64356. */
  64357. index: number;
  64358. }
  64359. /**
  64360. * Loader interface with additional members.
  64361. */
  64362. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64363. /** @hidden */
  64364. _data?: Promise<ArrayBufferView>;
  64365. /** @hidden */
  64366. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64367. }
  64368. /**
  64369. * Loader interface with additional members.
  64370. */
  64371. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64372. }
  64373. /** @hidden */
  64374. export interface _IAnimationSamplerData {
  64375. input: Float32Array;
  64376. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64377. output: Float32Array;
  64378. }
  64379. /**
  64380. * Loader interface with additional members.
  64381. */
  64382. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64383. /** @hidden */
  64384. _data?: Promise<_IAnimationSamplerData>;
  64385. }
  64386. /**
  64387. * Loader interface with additional members.
  64388. */
  64389. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64390. channels: IAnimationChannel[];
  64391. samplers: IAnimationSampler[];
  64392. /** @hidden */
  64393. _babylonAnimationGroup?: AnimationGroup;
  64394. }
  64395. /**
  64396. * Loader interface with additional members.
  64397. */
  64398. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64399. /** @hidden */
  64400. _data?: Promise<ArrayBufferView>;
  64401. }
  64402. /**
  64403. * Loader interface with additional members.
  64404. */
  64405. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64406. /** @hidden */
  64407. _data?: Promise<ArrayBufferView>;
  64408. /** @hidden */
  64409. _babylonBuffer?: Promise<Buffer>;
  64410. }
  64411. /**
  64412. * Loader interface with additional members.
  64413. */
  64414. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64415. }
  64416. /**
  64417. * Loader interface with additional members.
  64418. */
  64419. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64420. /** @hidden */
  64421. _data?: Promise<ArrayBufferView>;
  64422. }
  64423. /**
  64424. * Loader interface with additional members.
  64425. */
  64426. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64427. }
  64428. /**
  64429. * Loader interface with additional members.
  64430. */
  64431. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64432. }
  64433. /**
  64434. * Loader interface with additional members.
  64435. */
  64436. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64437. baseColorTexture?: ITextureInfo;
  64438. metallicRoughnessTexture?: ITextureInfo;
  64439. }
  64440. /**
  64441. * Loader interface with additional members.
  64442. */
  64443. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64444. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64445. normalTexture?: IMaterialNormalTextureInfo;
  64446. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64447. emissiveTexture?: ITextureInfo;
  64448. /** @hidden */
  64449. _data?: {
  64450. [babylonDrawMode: number]: {
  64451. babylonMaterial: Material;
  64452. babylonMeshes: AbstractMesh[];
  64453. promise: Promise<void>;
  64454. };
  64455. };
  64456. }
  64457. /**
  64458. * Loader interface with additional members.
  64459. */
  64460. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64461. primitives: IMeshPrimitive[];
  64462. }
  64463. /**
  64464. * Loader interface with additional members.
  64465. */
  64466. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64467. /** @hidden */
  64468. _instanceData?: {
  64469. babylonSourceMesh: Mesh;
  64470. promise: Promise<any>;
  64471. };
  64472. }
  64473. /**
  64474. * Loader interface with additional members.
  64475. */
  64476. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64477. /**
  64478. * The parent glTF node.
  64479. */
  64480. parent?: INode;
  64481. /** @hidden */
  64482. _babylonTransformNode?: TransformNode;
  64483. /** @hidden */
  64484. _primitiveBabylonMeshes?: AbstractMesh[];
  64485. /** @hidden */
  64486. _babylonBones?: Bone[];
  64487. /** @hidden */
  64488. _numMorphTargets?: number;
  64489. }
  64490. /** @hidden */
  64491. export interface _ISamplerData {
  64492. noMipMaps: boolean;
  64493. samplingMode: number;
  64494. wrapU: number;
  64495. wrapV: number;
  64496. }
  64497. /**
  64498. * Loader interface with additional members.
  64499. */
  64500. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64501. /** @hidden */
  64502. _data?: _ISamplerData;
  64503. }
  64504. /**
  64505. * Loader interface with additional members.
  64506. */
  64507. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64508. }
  64509. /**
  64510. * Loader interface with additional members.
  64511. */
  64512. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64513. /** @hidden */
  64514. _data?: {
  64515. babylonSkeleton: Skeleton;
  64516. promise: Promise<void>;
  64517. };
  64518. }
  64519. /**
  64520. * Loader interface with additional members.
  64521. */
  64522. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64523. }
  64524. /**
  64525. * Loader interface with additional members.
  64526. */
  64527. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64528. }
  64529. /**
  64530. * Loader interface with additional members.
  64531. */
  64532. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64533. accessors?: IAccessor[];
  64534. animations?: IAnimation[];
  64535. buffers?: IBuffer[];
  64536. bufferViews?: IBufferView[];
  64537. cameras?: ICamera[];
  64538. images?: IImage[];
  64539. materials?: IMaterial[];
  64540. meshes?: IMesh[];
  64541. nodes?: INode[];
  64542. samplers?: ISampler[];
  64543. scenes?: IScene[];
  64544. skins?: ISkin[];
  64545. textures?: ITexture[];
  64546. }
  64547. }
  64548. declare module BABYLON.GLTF2 {
  64549. /**
  64550. * Interface for a glTF loader extension.
  64551. */
  64552. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64553. /**
  64554. * Called after the loader state changes to LOADING.
  64555. */
  64556. onLoading?(): void;
  64557. /**
  64558. * Called after the loader state changes to READY.
  64559. */
  64560. onReady?(): void;
  64561. /**
  64562. * Define this method to modify the default behavior when loading scenes.
  64563. * @param context The context when loading the asset
  64564. * @param scene The glTF scene property
  64565. * @returns A promise that resolves when the load is complete or null if not handled
  64566. */
  64567. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64568. /**
  64569. * Define this method to modify the default behavior when loading nodes.
  64570. * @param context The context when loading the asset
  64571. * @param node The glTF node property
  64572. * @param assign A function called synchronously after parsing the glTF properties
  64573. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64574. */
  64575. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64576. /**
  64577. * Define this method to modify the default behavior when loading cameras.
  64578. * @param context The context when loading the asset
  64579. * @param camera The glTF camera property
  64580. * @param assign A function called synchronously after parsing the glTF properties
  64581. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64582. */
  64583. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64584. /**
  64585. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64586. * @param context The context when loading the asset
  64587. * @param primitive The glTF mesh primitive property
  64588. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64589. */
  64590. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64591. /**
  64592. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64593. * @param context The context when loading the asset
  64594. * @param name The mesh name when loading the asset
  64595. * @param node The glTF node when loading the asset
  64596. * @param mesh The glTF mesh when loading the asset
  64597. * @param primitive The glTF mesh primitive property
  64598. * @param assign A function called synchronously after parsing the glTF properties
  64599. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64600. */
  64601. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64602. /**
  64603. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64604. * @param context The context when loading the asset
  64605. * @param material The glTF material property
  64606. * @param assign A function called synchronously after parsing the glTF properties
  64607. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64608. */
  64609. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64610. /**
  64611. * Define this method to modify the default behavior when creating materials.
  64612. * @param context The context when loading the asset
  64613. * @param material The glTF material property
  64614. * @param babylonDrawMode The draw mode for the Babylon material
  64615. * @returns The Babylon material or null if not handled
  64616. */
  64617. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64618. /**
  64619. * Define this method to modify the default behavior when loading material properties.
  64620. * @param context The context when loading the asset
  64621. * @param material The glTF material property
  64622. * @param babylonMaterial The Babylon material
  64623. * @returns A promise that resolves when the load is complete or null if not handled
  64624. */
  64625. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64626. /**
  64627. * Define this method to modify the default behavior when loading texture infos.
  64628. * @param context The context when loading the asset
  64629. * @param textureInfo The glTF texture info property
  64630. * @param assign A function called synchronously after parsing the glTF properties
  64631. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64632. */
  64633. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64634. /**
  64635. * Define this method to modify the default behavior when loading animations.
  64636. * @param context The context when loading the asset
  64637. * @param animation The glTF animation property
  64638. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64639. */
  64640. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64641. /**
  64642. * @hidden Define this method to modify the default behavior when loading skins.
  64643. * @param context The context when loading the asset
  64644. * @param node The glTF node property
  64645. * @param skin The glTF skin property
  64646. * @returns A promise that resolves when the load is complete or null if not handled
  64647. */
  64648. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64649. /**
  64650. * @hidden Define this method to modify the default behavior when loading uris.
  64651. * @param context The context when loading the asset
  64652. * @param property The glTF property associated with the uri
  64653. * @param uri The uri to load
  64654. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64655. */
  64656. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64657. }
  64658. }
  64659. declare module BABYLON.GLTF2 {
  64660. /**
  64661. * Helper class for working with arrays when loading the glTF asset
  64662. */
  64663. export class ArrayItem {
  64664. /**
  64665. * Gets an item from the given array.
  64666. * @param context The context when loading the asset
  64667. * @param array The array to get the item from
  64668. * @param index The index to the array
  64669. * @returns The array item
  64670. */
  64671. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64672. /**
  64673. * Assign an `index` field to each item of the given array.
  64674. * @param array The array of items
  64675. */
  64676. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64677. }
  64678. /**
  64679. * The glTF 2.0 loader
  64680. */
  64681. export class GLTFLoader implements IGLTFLoader {
  64682. /** @hidden */
  64683. _completePromises: Promise<any>[];
  64684. private _disposed;
  64685. private _parent;
  64686. private _state;
  64687. private _extensions;
  64688. private _rootUrl;
  64689. private _fileName;
  64690. private _uniqueRootUrl;
  64691. private _gltf;
  64692. private _babylonScene;
  64693. private _rootBabylonMesh;
  64694. private _defaultBabylonMaterialData;
  64695. private _progressCallback?;
  64696. private _requests;
  64697. private static readonly _DefaultSampler;
  64698. private static _ExtensionNames;
  64699. private static _ExtensionFactories;
  64700. /**
  64701. * Registers a loader extension.
  64702. * @param name The name of the loader extension.
  64703. * @param factory The factory function that creates the loader extension.
  64704. */
  64705. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64706. /**
  64707. * Unregisters a loader extension.
  64708. * @param name The name of the loader extenion.
  64709. * @returns A boolean indicating whether the extension has been unregistered
  64710. */
  64711. static UnregisterExtension(name: string): boolean;
  64712. /**
  64713. * Gets the loader state.
  64714. */
  64715. readonly state: Nullable<GLTFLoaderState>;
  64716. /**
  64717. * The glTF object parsed from the JSON.
  64718. */
  64719. readonly gltf: IGLTF;
  64720. /**
  64721. * The Babylon scene when loading the asset.
  64722. */
  64723. readonly babylonScene: Scene;
  64724. /**
  64725. * The root Babylon mesh when loading the asset.
  64726. */
  64727. readonly rootBabylonMesh: Mesh;
  64728. /** @hidden */
  64729. constructor(parent: GLTFFileLoader);
  64730. /** @hidden */
  64731. dispose(): void;
  64732. /** @hidden */
  64733. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64734. meshes: AbstractMesh[];
  64735. particleSystems: IParticleSystem[];
  64736. skeletons: Skeleton[];
  64737. animationGroups: AnimationGroup[];
  64738. }>;
  64739. /** @hidden */
  64740. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64741. private _loadAsync;
  64742. private _loadData;
  64743. private _setupData;
  64744. private _loadExtensions;
  64745. private _checkExtensions;
  64746. private _setState;
  64747. private _createRootNode;
  64748. /**
  64749. * Loads a glTF scene.
  64750. * @param context The context when loading the asset
  64751. * @param scene The glTF scene property
  64752. * @returns A promise that resolves when the load is complete
  64753. */
  64754. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64755. private _forEachPrimitive;
  64756. private _getMeshes;
  64757. private _getSkeletons;
  64758. private _getAnimationGroups;
  64759. private _startAnimations;
  64760. /**
  64761. * Loads a glTF node.
  64762. * @param context The context when loading the asset
  64763. * @param node The glTF node property
  64764. * @param assign A function called synchronously after parsing the glTF properties
  64765. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64766. */
  64767. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64768. private _loadMeshAsync;
  64769. /**
  64770. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64771. * @param context The context when loading the asset
  64772. * @param name The mesh name when loading the asset
  64773. * @param node The glTF node when loading the asset
  64774. * @param mesh The glTF mesh when loading the asset
  64775. * @param primitive The glTF mesh primitive property
  64776. * @param assign A function called synchronously after parsing the glTF properties
  64777. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64778. */
  64779. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64780. private _loadVertexDataAsync;
  64781. private _createMorphTargets;
  64782. private _loadMorphTargetsAsync;
  64783. private _loadMorphTargetVertexDataAsync;
  64784. private static _LoadTransform;
  64785. private _loadSkinAsync;
  64786. private _loadBones;
  64787. private _loadBone;
  64788. private _loadSkinInverseBindMatricesDataAsync;
  64789. private _updateBoneMatrices;
  64790. private _getNodeMatrix;
  64791. /**
  64792. * Loads a glTF camera.
  64793. * @param context The context when loading the asset
  64794. * @param camera The glTF camera property
  64795. * @param assign A function called synchronously after parsing the glTF properties
  64796. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64797. */
  64798. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64799. private _loadAnimationsAsync;
  64800. /**
  64801. * Loads a glTF animation.
  64802. * @param context The context when loading the asset
  64803. * @param animation The glTF animation property
  64804. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64805. */
  64806. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64807. /**
  64808. * @hidden Loads a glTF animation channel.
  64809. * @param context The context when loading the asset
  64810. * @param animationContext The context of the animation when loading the asset
  64811. * @param animation The glTF animation property
  64812. * @param channel The glTF animation channel property
  64813. * @param babylonAnimationGroup The babylon animation group property
  64814. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64815. * @returns A void promise when the channel load is complete
  64816. */
  64817. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64818. private _loadAnimationSamplerAsync;
  64819. private _loadBufferAsync;
  64820. /**
  64821. * Loads a glTF buffer view.
  64822. * @param context The context when loading the asset
  64823. * @param bufferView The glTF buffer view property
  64824. * @returns A promise that resolves with the loaded data when the load is complete
  64825. */
  64826. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64827. private _loadIndicesAccessorAsync;
  64828. private _loadFloatAccessorAsync;
  64829. private _loadVertexBufferViewAsync;
  64830. private _loadVertexAccessorAsync;
  64831. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64832. /** @hidden */
  64833. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64834. private _createDefaultMaterial;
  64835. /**
  64836. * Creates a Babylon material from a glTF material.
  64837. * @param context The context when loading the asset
  64838. * @param material The glTF material property
  64839. * @param babylonDrawMode The draw mode for the Babylon material
  64840. * @returns The Babylon material
  64841. */
  64842. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64843. /**
  64844. * Loads properties from a glTF material into a Babylon material.
  64845. * @param context The context when loading the asset
  64846. * @param material The glTF material property
  64847. * @param babylonMaterial The Babylon material
  64848. * @returns A promise that resolves when the load is complete
  64849. */
  64850. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64851. /**
  64852. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64853. * @param context The context when loading the asset
  64854. * @param material The glTF material property
  64855. * @param babylonMaterial The Babylon material
  64856. * @returns A promise that resolves when the load is complete
  64857. */
  64858. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64859. /**
  64860. * Loads the alpha properties from a glTF material into a Babylon material.
  64861. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64862. * @param context The context when loading the asset
  64863. * @param material The glTF material property
  64864. * @param babylonMaterial The Babylon material
  64865. */
  64866. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64867. /**
  64868. * Loads a glTF texture info.
  64869. * @param context The context when loading the asset
  64870. * @param textureInfo The glTF texture info property
  64871. * @param assign A function called synchronously after parsing the glTF properties
  64872. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64873. */
  64874. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64875. private _loadTextureAsync;
  64876. private _loadSampler;
  64877. /**
  64878. * Loads a glTF image.
  64879. * @param context The context when loading the asset
  64880. * @param image The glTF image property
  64881. * @returns A promise that resolves with the loaded data when the load is complete
  64882. */
  64883. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64884. /**
  64885. * Loads a glTF uri.
  64886. * @param context The context when loading the asset
  64887. * @param property The glTF property associated with the uri
  64888. * @param uri The base64 or relative uri
  64889. * @returns A promise that resolves with the loaded data when the load is complete
  64890. */
  64891. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64892. private _onProgress;
  64893. /**
  64894. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64895. * @param babylonObject the Babylon object with metadata
  64896. * @param pointer the JSON pointer
  64897. */
  64898. static AddPointerMetadata(babylonObject: {
  64899. metadata: any;
  64900. }, pointer: string): void;
  64901. private static _GetTextureWrapMode;
  64902. private static _GetTextureSamplingMode;
  64903. private static _GetTypedArray;
  64904. private static _GetNumComponents;
  64905. private static _ValidateUri;
  64906. private static _GetDrawMode;
  64907. private _compileMaterialsAsync;
  64908. private _compileShadowGeneratorsAsync;
  64909. private _forEachExtensions;
  64910. private _applyExtensions;
  64911. private _extensionsOnLoading;
  64912. private _extensionsOnReady;
  64913. private _extensionsLoadSceneAsync;
  64914. private _extensionsLoadNodeAsync;
  64915. private _extensionsLoadCameraAsync;
  64916. private _extensionsLoadVertexDataAsync;
  64917. private _extensionsLoadMeshPrimitiveAsync;
  64918. private _extensionsLoadMaterialAsync;
  64919. private _extensionsCreateMaterial;
  64920. private _extensionsLoadMaterialPropertiesAsync;
  64921. private _extensionsLoadTextureInfoAsync;
  64922. private _extensionsLoadAnimationAsync;
  64923. private _extensionsLoadSkinAsync;
  64924. private _extensionsLoadUriAsync;
  64925. /**
  64926. * Helper method called by a loader extension to load an glTF extension.
  64927. * @param context The context when loading the asset
  64928. * @param property The glTF property to load the extension from
  64929. * @param extensionName The name of the extension to load
  64930. * @param actionAsync The action to run
  64931. * @returns The promise returned by actionAsync or null if the extension does not exist
  64932. */
  64933. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64934. /**
  64935. * Helper method called by a loader extension to load a glTF extra.
  64936. * @param context The context when loading the asset
  64937. * @param property The glTF property to load the extra from
  64938. * @param extensionName The name of the extension to load
  64939. * @param actionAsync The action to run
  64940. * @returns The promise returned by actionAsync or null if the extra does not exist
  64941. */
  64942. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64943. /**
  64944. * Increments the indentation level and logs a message.
  64945. * @param message The message to log
  64946. */
  64947. logOpen(message: string): void;
  64948. /**
  64949. * Decrements the indentation level.
  64950. */
  64951. logClose(): void;
  64952. /**
  64953. * Logs a message
  64954. * @param message The message to log
  64955. */
  64956. log(message: string): void;
  64957. /**
  64958. * Starts a performance counter.
  64959. * @param counterName The name of the performance counter
  64960. */
  64961. startPerformanceCounter(counterName: string): void;
  64962. /**
  64963. * Ends a performance counter.
  64964. * @param counterName The name of the performance counter
  64965. */
  64966. endPerformanceCounter(counterName: string): void;
  64967. }
  64968. }
  64969. declare module BABYLON.GLTF2.Loader.Extensions {
  64970. /**
  64971. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64972. */
  64973. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64974. /** The name of this extension. */
  64975. readonly name: string;
  64976. /** Defines whether this extension is enabled. */
  64977. enabled: boolean;
  64978. private _loader;
  64979. private _lights?;
  64980. /** @hidden */
  64981. constructor(loader: GLTFLoader);
  64982. /** @hidden */
  64983. dispose(): void;
  64984. /** @hidden */
  64985. onLoading(): void;
  64986. /** @hidden */
  64987. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64988. private _loadLightAsync;
  64989. }
  64990. }
  64991. declare module BABYLON.GLTF2.Loader.Extensions {
  64992. /**
  64993. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64994. */
  64995. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64996. /** The name of this extension. */
  64997. readonly name: string;
  64998. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64999. dracoCompression?: DracoCompression;
  65000. /** Defines whether this extension is enabled. */
  65001. enabled: boolean;
  65002. private _loader;
  65003. /** @hidden */
  65004. constructor(loader: GLTFLoader);
  65005. /** @hidden */
  65006. dispose(): void;
  65007. /** @hidden */
  65008. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65009. }
  65010. }
  65011. declare module BABYLON.GLTF2.Loader.Extensions {
  65012. /**
  65013. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65014. */
  65015. export class KHR_lights implements IGLTFLoaderExtension {
  65016. /** The name of this extension. */
  65017. readonly name: string;
  65018. /** Defines whether this extension is enabled. */
  65019. enabled: boolean;
  65020. private _loader;
  65021. private _lights?;
  65022. /** @hidden */
  65023. constructor(loader: GLTFLoader);
  65024. /** @hidden */
  65025. dispose(): void;
  65026. /** @hidden */
  65027. onLoading(): void;
  65028. /** @hidden */
  65029. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65030. }
  65031. }
  65032. declare module BABYLON.GLTF2.Loader.Extensions {
  65033. /**
  65034. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65035. */
  65036. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65037. /** The name of this extension. */
  65038. readonly name: string;
  65039. /** Defines whether this extension is enabled. */
  65040. enabled: boolean;
  65041. private _loader;
  65042. /** @hidden */
  65043. constructor(loader: GLTFLoader);
  65044. /** @hidden */
  65045. dispose(): void;
  65046. /** @hidden */
  65047. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65048. private _loadSpecularGlossinessPropertiesAsync;
  65049. }
  65050. }
  65051. declare module BABYLON.GLTF2.Loader.Extensions {
  65052. /**
  65053. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65054. */
  65055. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65056. /** The name of this extension. */
  65057. readonly name: string;
  65058. /** Defines whether this extension is enabled. */
  65059. enabled: boolean;
  65060. private _loader;
  65061. /** @hidden */
  65062. constructor(loader: GLTFLoader);
  65063. /** @hidden */
  65064. dispose(): void;
  65065. /** @hidden */
  65066. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65067. private _loadUnlitPropertiesAsync;
  65068. }
  65069. }
  65070. declare module BABYLON.GLTF2.Loader.Extensions {
  65071. /**
  65072. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65073. */
  65074. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65075. /** The name of this extension. */
  65076. readonly name: string;
  65077. /** Defines whether this extension is enabled. */
  65078. enabled: boolean;
  65079. private _loader;
  65080. /** @hidden */
  65081. constructor(loader: GLTFLoader);
  65082. /** @hidden */
  65083. dispose(): void;
  65084. /** @hidden */
  65085. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65086. }
  65087. }
  65088. declare module BABYLON.GLTF2.Loader.Extensions {
  65089. /**
  65090. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65091. */
  65092. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65093. /** The name of this extension. */
  65094. readonly name: string;
  65095. /** Defines whether this extension is enabled. */
  65096. enabled: boolean;
  65097. private _loader;
  65098. private _clips;
  65099. private _emitters;
  65100. /** @hidden */
  65101. constructor(loader: GLTFLoader);
  65102. /** @hidden */
  65103. dispose(): void;
  65104. /** @hidden */
  65105. onLoading(): void;
  65106. /** @hidden */
  65107. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65108. /** @hidden */
  65109. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65110. /** @hidden */
  65111. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65112. private _loadClipAsync;
  65113. private _loadEmitterAsync;
  65114. private _getEventAction;
  65115. private _loadAnimationEventAsync;
  65116. }
  65117. }
  65118. declare module BABYLON.GLTF2.Loader.Extensions {
  65119. /**
  65120. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65121. */
  65122. export class MSFT_lod implements IGLTFLoaderExtension {
  65123. /** The name of this extension. */
  65124. readonly name: string;
  65125. /** Defines whether this extension is enabled. */
  65126. enabled: boolean;
  65127. /**
  65128. * Maximum number of LODs to load, starting from the lowest LOD.
  65129. */
  65130. maxLODsToLoad: number;
  65131. /**
  65132. * Observable raised when all node LODs of one level are loaded.
  65133. * The event data is the index of the loaded LOD starting from zero.
  65134. * Dispose the loader to cancel the loading of the next level of LODs.
  65135. */
  65136. onNodeLODsLoadedObservable: Observable<number>;
  65137. /**
  65138. * Observable raised when all material LODs of one level are loaded.
  65139. * The event data is the index of the loaded LOD starting from zero.
  65140. * Dispose the loader to cancel the loading of the next level of LODs.
  65141. */
  65142. onMaterialLODsLoadedObservable: Observable<number>;
  65143. private _loader;
  65144. private _nodeIndexLOD;
  65145. private _nodeSignalLODs;
  65146. private _nodePromiseLODs;
  65147. private _materialIndexLOD;
  65148. private _materialSignalLODs;
  65149. private _materialPromiseLODs;
  65150. /** @hidden */
  65151. constructor(loader: GLTFLoader);
  65152. /** @hidden */
  65153. dispose(): void;
  65154. /** @hidden */
  65155. onReady(): void;
  65156. /** @hidden */
  65157. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65158. /** @hidden */
  65159. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65160. /** @hidden */
  65161. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65162. /**
  65163. * Gets an array of LOD properties from lowest to highest.
  65164. */
  65165. private _getLODs;
  65166. private _disposeUnusedMaterials;
  65167. }
  65168. }
  65169. declare module BABYLON.GLTF2.Loader.Extensions {
  65170. /** @hidden */
  65171. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65172. readonly name: string;
  65173. enabled: boolean;
  65174. private _loader;
  65175. constructor(loader: GLTFLoader);
  65176. dispose(): void;
  65177. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65178. }
  65179. }
  65180. declare module BABYLON.GLTF2.Loader.Extensions {
  65181. /** @hidden */
  65182. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65183. readonly name: string;
  65184. enabled: boolean;
  65185. private _loader;
  65186. constructor(loader: GLTFLoader);
  65187. dispose(): void;
  65188. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65189. }
  65190. }
  65191. declare module BABYLON.GLTF2.Loader.Extensions {
  65192. /**
  65193. * Store glTF extras (if present) in BJS objects' metadata
  65194. */
  65195. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  65196. /** The name of this extension. */
  65197. readonly name: string;
  65198. /** Defines whether this extension is enabled. */
  65199. enabled: boolean;
  65200. private _loader;
  65201. private _assignExtras;
  65202. /** @hidden */
  65203. constructor(loader: GLTFLoader);
  65204. /** @hidden */
  65205. dispose(): void;
  65206. /** @hidden */
  65207. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65208. /** @hidden */
  65209. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65210. /** @hidden */
  65211. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /**
  65216. * Class reading and parsing the MTL file bundled with the obj file.
  65217. */
  65218. export class MTLFileLoader {
  65219. /**
  65220. * All material loaded from the mtl will be set here
  65221. */
  65222. materials: StandardMaterial[];
  65223. /**
  65224. * This function will read the mtl file and create each material described inside
  65225. * This function could be improve by adding :
  65226. * -some component missing (Ni, Tf...)
  65227. * -including the specific options available
  65228. *
  65229. * @param scene defines the scene the material will be created in
  65230. * @param data defines the mtl data to parse
  65231. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65232. */
  65233. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65234. /**
  65235. * Gets the texture for the material.
  65236. *
  65237. * If the material is imported from input file,
  65238. * We sanitize the url to ensure it takes the textre from aside the material.
  65239. *
  65240. * @param rootUrl The root url to load from
  65241. * @param value The value stored in the mtl
  65242. * @return The Texture
  65243. */
  65244. private static _getTexture;
  65245. }
  65246. /**
  65247. * Options for loading OBJ/MTL files
  65248. */
  65249. type MeshLoadOptions = {
  65250. /**
  65251. * Defines if UVs are optimized by default during load.
  65252. */
  65253. OptimizeWithUV: boolean;
  65254. /**
  65255. * Defines custom scaling of UV coordinates of loaded meshes.
  65256. */
  65257. UVScaling: Vector2;
  65258. /**
  65259. * Invert model on y-axis (does a model scaling inversion)
  65260. */
  65261. InvertY: boolean;
  65262. /**
  65263. * Invert Y-Axis of referenced textures on load
  65264. */
  65265. InvertTextureY: boolean;
  65266. /**
  65267. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65268. */
  65269. ImportVertexColors: boolean;
  65270. /**
  65271. * Compute the normals for the model, even if normals are present in the file.
  65272. */
  65273. ComputeNormals: boolean;
  65274. /**
  65275. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65276. */
  65277. SkipMaterials: boolean;
  65278. /**
  65279. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65280. */
  65281. MaterialLoadingFailsSilently: boolean;
  65282. };
  65283. /**
  65284. * OBJ file type loader.
  65285. * This is a babylon scene loader plugin.
  65286. */
  65287. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65288. /**
  65289. * Defines if UVs are optimized by default during load.
  65290. */
  65291. static OPTIMIZE_WITH_UV: boolean;
  65292. /**
  65293. * Invert model on y-axis (does a model scaling inversion)
  65294. */
  65295. static INVERT_Y: boolean;
  65296. /**
  65297. * Invert Y-Axis of referenced textures on load
  65298. */
  65299. static INVERT_TEXTURE_Y: boolean;
  65300. /**
  65301. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65302. */
  65303. static IMPORT_VERTEX_COLORS: boolean;
  65304. /**
  65305. * Compute the normals for the model, even if normals are present in the file.
  65306. */
  65307. static COMPUTE_NORMALS: boolean;
  65308. /**
  65309. * Defines custom scaling of UV coordinates of loaded meshes.
  65310. */
  65311. static UV_SCALING: Vector2;
  65312. /**
  65313. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65314. */
  65315. static SKIP_MATERIALS: boolean;
  65316. /**
  65317. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65318. *
  65319. * Defaults to true for backwards compatibility.
  65320. */
  65321. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65322. /**
  65323. * Defines the name of the plugin.
  65324. */
  65325. name: string;
  65326. /**
  65327. * Defines the extension the plugin is able to load.
  65328. */
  65329. extensions: string;
  65330. /** @hidden */
  65331. obj: RegExp;
  65332. /** @hidden */
  65333. group: RegExp;
  65334. /** @hidden */
  65335. mtllib: RegExp;
  65336. /** @hidden */
  65337. usemtl: RegExp;
  65338. /** @hidden */
  65339. smooth: RegExp;
  65340. /** @hidden */
  65341. vertexPattern: RegExp;
  65342. /** @hidden */
  65343. normalPattern: RegExp;
  65344. /** @hidden */
  65345. uvPattern: RegExp;
  65346. /** @hidden */
  65347. facePattern1: RegExp;
  65348. /** @hidden */
  65349. facePattern2: RegExp;
  65350. /** @hidden */
  65351. facePattern3: RegExp;
  65352. /** @hidden */
  65353. facePattern4: RegExp;
  65354. /** @hidden */
  65355. facePattern5: RegExp;
  65356. private _meshLoadOptions;
  65357. /**
  65358. * Creates loader for .OBJ files
  65359. *
  65360. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65361. */
  65362. constructor(meshLoadOptions?: MeshLoadOptions);
  65363. private static readonly currentMeshLoadOptions;
  65364. /**
  65365. * Calls synchronously the MTL file attached to this obj.
  65366. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65367. * Without this function materials are not displayed in the first frame (but displayed after).
  65368. * In consequence it is impossible to get material information in your HTML file
  65369. *
  65370. * @param url The URL of the MTL file
  65371. * @param rootUrl
  65372. * @param onSuccess Callback function to be called when the MTL file is loaded
  65373. * @private
  65374. */
  65375. private _loadMTL;
  65376. /**
  65377. * Instantiates a OBJ file loader plugin.
  65378. * @returns the created plugin
  65379. */
  65380. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65381. /**
  65382. * If the data string can be loaded directly.
  65383. *
  65384. * @param data string containing the file data
  65385. * @returns if the data can be loaded directly
  65386. */
  65387. canDirectLoad(data: string): boolean;
  65388. /**
  65389. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65390. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65391. * @param scene the scene the meshes should be added to
  65392. * @param data the OBJ data to load
  65393. * @param rootUrl root url to load from
  65394. * @param onProgress event that fires when loading progress has occured
  65395. * @param fileName Defines the name of the file to load
  65396. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65397. */
  65398. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65399. meshes: AbstractMesh[];
  65400. particleSystems: IParticleSystem[];
  65401. skeletons: Skeleton[];
  65402. animationGroups: AnimationGroup[];
  65403. }>;
  65404. /**
  65405. * Imports all objects from the loaded OBJ data and adds them to the scene
  65406. * @param scene the scene the objects should be added to
  65407. * @param data the OBJ data to load
  65408. * @param rootUrl root url to load from
  65409. * @param onProgress event that fires when loading progress has occured
  65410. * @param fileName Defines the name of the file to load
  65411. * @returns a promise which completes when objects have been loaded to the scene
  65412. */
  65413. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65414. /**
  65415. * Load into an asset container.
  65416. * @param scene The scene to load into
  65417. * @param data The data to import
  65418. * @param rootUrl The root url for scene and resources
  65419. * @param onProgress The callback when the load progresses
  65420. * @param fileName Defines the name of the file to load
  65421. * @returns The loaded asset container
  65422. */
  65423. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65424. /**
  65425. * Read the OBJ file and create an Array of meshes.
  65426. * Each mesh contains all information given by the OBJ and the MTL file.
  65427. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65428. *
  65429. * @param meshesNames
  65430. * @param scene Scene The scene where are displayed the data
  65431. * @param data String The content of the obj file
  65432. * @param rootUrl String The path to the folder
  65433. * @returns Array<AbstractMesh>
  65434. * @private
  65435. */
  65436. private _parseSolid;
  65437. }
  65438. }
  65439. declare module BABYLON {
  65440. /**
  65441. * STL file type loader.
  65442. * This is a babylon scene loader plugin.
  65443. */
  65444. export class STLFileLoader implements ISceneLoaderPlugin {
  65445. /** @hidden */
  65446. solidPattern: RegExp;
  65447. /** @hidden */
  65448. facetsPattern: RegExp;
  65449. /** @hidden */
  65450. normalPattern: RegExp;
  65451. /** @hidden */
  65452. vertexPattern: RegExp;
  65453. /**
  65454. * Defines the name of the plugin.
  65455. */
  65456. name: string;
  65457. /**
  65458. * Defines the extensions the stl loader is able to load.
  65459. * force data to come in as an ArrayBuffer
  65460. * we'll convert to string if it looks like it's an ASCII .stl
  65461. */
  65462. extensions: ISceneLoaderPluginExtensions;
  65463. /**
  65464. * Import meshes into a scene.
  65465. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65466. * @param scene The scene to import into
  65467. * @param data The data to import
  65468. * @param rootUrl The root url for scene and resources
  65469. * @param meshes The meshes array to import into
  65470. * @param particleSystems The particle systems array to import into
  65471. * @param skeletons The skeletons array to import into
  65472. * @param onError The callback when import fails
  65473. * @returns True if successful or false otherwise
  65474. */
  65475. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65476. /**
  65477. * Load into a scene.
  65478. * @param scene The scene to load into
  65479. * @param data The data to import
  65480. * @param rootUrl The root url for scene and resources
  65481. * @param onError The callback when import fails
  65482. * @returns true if successful or false otherwise
  65483. */
  65484. load(scene: Scene, data: any, rootUrl: string): boolean;
  65485. /**
  65486. * Load into an asset container.
  65487. * @param scene The scene to load into
  65488. * @param data The data to import
  65489. * @param rootUrl The root url for scene and resources
  65490. * @param onError The callback when import fails
  65491. * @returns The loaded asset container
  65492. */
  65493. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65494. private _isBinary;
  65495. private _parseBinary;
  65496. private _parseASCII;
  65497. }
  65498. }
  65499. declare module BABYLON {
  65500. /**
  65501. * Class for generating OBJ data from a Babylon scene.
  65502. */
  65503. export class OBJExport {
  65504. /**
  65505. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65506. * @param mesh defines the list of meshes to serialize
  65507. * @param materials defines if materials should be exported
  65508. * @param matlibname defines the name of the associated mtl file
  65509. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65510. * @returns the OBJ content
  65511. */
  65512. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65513. /**
  65514. * Exports the material(s) of a mesh in .MTL file format (text)
  65515. * @param mesh defines the mesh to extract the material from
  65516. * @returns the mtl content
  65517. */
  65518. static MTL(mesh: Mesh): string;
  65519. }
  65520. }
  65521. declare module BABYLON {
  65522. /** @hidden */
  65523. export var __IGLTFExporterExtension: number;
  65524. /**
  65525. * Interface for extending the exporter
  65526. * @hidden
  65527. */
  65528. export interface IGLTFExporterExtension {
  65529. /**
  65530. * The name of this extension
  65531. */
  65532. readonly name: string;
  65533. /**
  65534. * Defines whether this extension is enabled
  65535. */
  65536. enabled: boolean;
  65537. /**
  65538. * Defines whether this extension is required
  65539. */
  65540. required: boolean;
  65541. }
  65542. }
  65543. declare module BABYLON.GLTF2.Exporter {
  65544. /** @hidden */
  65545. export var __IGLTFExporterExtensionV2: number;
  65546. /**
  65547. * Interface for a glTF exporter extension
  65548. * @hidden
  65549. */
  65550. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65551. /**
  65552. * Define this method to modify the default behavior before exporting a texture
  65553. * @param context The context when loading the asset
  65554. * @param babylonTexture The glTF texture info property
  65555. * @param mimeType The mime-type of the generated image
  65556. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65557. */
  65558. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65559. /**
  65560. * Define this method to modify the default behavior when exporting texture info
  65561. * @param context The context when loading the asset
  65562. * @param meshPrimitive glTF mesh primitive
  65563. * @param babylonSubMesh Babylon submesh
  65564. * @param binaryWriter glTF serializer binary writer instance
  65565. * @returns nullable IMeshPrimitive promise
  65566. */
  65567. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65568. /**
  65569. * Define this method to modify the default behavior when exporting a node
  65570. * @param context The context when exporting the node
  65571. * @param node glTF node
  65572. * @param babylonNode BabylonJS node
  65573. * @returns nullable INode promise
  65574. */
  65575. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65576. /**
  65577. * Called after the exporter state changes to EXPORTING
  65578. */
  65579. onExporting?(): void;
  65580. }
  65581. }
  65582. declare module BABYLON.GLTF2.Exporter {
  65583. /**
  65584. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65585. * @hidden
  65586. */
  65587. export class _GLTFMaterialExporter {
  65588. /**
  65589. * Represents the dielectric specular values for R, G and B
  65590. */
  65591. private static readonly _DielectricSpecular;
  65592. /**
  65593. * Allows the maximum specular power to be defined for material calculations
  65594. */
  65595. private static readonly _MaxSpecularPower;
  65596. /**
  65597. * Mapping to store textures
  65598. */
  65599. private _textureMap;
  65600. /**
  65601. * Numeric tolerance value
  65602. */
  65603. private static readonly _Epsilon;
  65604. /**
  65605. * Reference to the glTF Exporter
  65606. */
  65607. private _exporter;
  65608. constructor(exporter: _Exporter);
  65609. /**
  65610. * Specifies if two colors are approximately equal in value
  65611. * @param color1 first color to compare to
  65612. * @param color2 second color to compare to
  65613. * @param epsilon threshold value
  65614. */
  65615. private static FuzzyEquals;
  65616. /**
  65617. * Gets the materials from a Babylon scene and converts them to glTF materials
  65618. * @param scene babylonjs scene
  65619. * @param mimeType texture mime type
  65620. * @param images array of images
  65621. * @param textures array of textures
  65622. * @param materials array of materials
  65623. * @param imageData mapping of texture names to base64 textures
  65624. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65625. */
  65626. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65627. /**
  65628. * Makes a copy of the glTF material without the texture parameters
  65629. * @param originalMaterial original glTF material
  65630. * @returns glTF material without texture parameters
  65631. */
  65632. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65633. /**
  65634. * Specifies if the material has any texture parameters present
  65635. * @param material glTF Material
  65636. * @returns boolean specifying if texture parameters are present
  65637. */
  65638. _hasTexturesPresent(material: IMaterial): boolean;
  65639. /**
  65640. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65641. * @param babylonStandardMaterial
  65642. * @returns glTF Metallic Roughness Material representation
  65643. */
  65644. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65645. /**
  65646. * Computes the metallic factor
  65647. * @param diffuse diffused value
  65648. * @param specular specular value
  65649. * @param oneMinusSpecularStrength one minus the specular strength
  65650. * @returns metallic value
  65651. */
  65652. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65653. /**
  65654. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65655. * @param glTFMaterial glTF material
  65656. * @param babylonMaterial Babylon material
  65657. */
  65658. private static _SetAlphaMode;
  65659. /**
  65660. * Converts a Babylon Standard Material to a glTF Material
  65661. * @param babylonStandardMaterial BJS Standard Material
  65662. * @param mimeType mime type to use for the textures
  65663. * @param images array of glTF image interfaces
  65664. * @param textures array of glTF texture interfaces
  65665. * @param materials array of glTF material interfaces
  65666. * @param imageData map of image file name to data
  65667. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65668. */
  65669. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65670. /**
  65671. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65672. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65673. * @param mimeType mime type to use for the textures
  65674. * @param images array of glTF image interfaces
  65675. * @param textures array of glTF texture interfaces
  65676. * @param materials array of glTF material interfaces
  65677. * @param imageData map of image file name to data
  65678. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65679. */
  65680. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65681. /**
  65682. * Converts an image typed array buffer to a base64 image
  65683. * @param buffer typed array buffer
  65684. * @param width width of the image
  65685. * @param height height of the image
  65686. * @param mimeType mimetype of the image
  65687. * @returns base64 image string
  65688. */
  65689. private _createBase64FromCanvasAsync;
  65690. /**
  65691. * Generates a white texture based on the specified width and height
  65692. * @param width width of the texture in pixels
  65693. * @param height height of the texture in pixels
  65694. * @param scene babylonjs scene
  65695. * @returns white texture
  65696. */
  65697. private _createWhiteTexture;
  65698. /**
  65699. * 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
  65700. * @param texture1 first texture to resize
  65701. * @param texture2 second texture to resize
  65702. * @param scene babylonjs scene
  65703. * @returns resized textures or null
  65704. */
  65705. private _resizeTexturesToSameDimensions;
  65706. /**
  65707. * Converts an array of pixels to a Float32Array
  65708. * Throws an error if the pixel format is not supported
  65709. * @param pixels - array buffer containing pixel values
  65710. * @returns Float32 of pixels
  65711. */
  65712. private _convertPixelArrayToFloat32;
  65713. /**
  65714. * Convert Specular Glossiness Textures to Metallic Roughness
  65715. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65716. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65717. * @param diffuseTexture texture used to store diffuse information
  65718. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65719. * @param factors specular glossiness material factors
  65720. * @param mimeType the mime type to use for the texture
  65721. * @returns pbr metallic roughness interface or null
  65722. */
  65723. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65724. /**
  65725. * Converts specular glossiness material properties to metallic roughness
  65726. * @param specularGlossiness interface with specular glossiness material properties
  65727. * @returns interface with metallic roughness material properties
  65728. */
  65729. private _convertSpecularGlossinessToMetallicRoughness;
  65730. /**
  65731. * Calculates the surface reflectance, independent of lighting conditions
  65732. * @param color Color source to calculate brightness from
  65733. * @returns number representing the perceived brightness, or zero if color is undefined
  65734. */
  65735. private _getPerceivedBrightness;
  65736. /**
  65737. * Returns the maximum color component value
  65738. * @param color
  65739. * @returns maximum color component value, or zero if color is null or undefined
  65740. */
  65741. private _getMaxComponent;
  65742. /**
  65743. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65744. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65745. * @param mimeType mime type to use for the textures
  65746. * @param images array of glTF image interfaces
  65747. * @param textures array of glTF texture interfaces
  65748. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65749. * @param imageData map of image file name to data
  65750. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65751. * @returns glTF PBR Metallic Roughness factors
  65752. */
  65753. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65754. private _getGLTFTextureSampler;
  65755. private _getGLTFTextureWrapMode;
  65756. private _getGLTFTextureWrapModesSampler;
  65757. /**
  65758. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65759. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65760. * @param mimeType mime type to use for the textures
  65761. * @param images array of glTF image interfaces
  65762. * @param textures array of glTF texture interfaces
  65763. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65764. * @param imageData map of image file name to data
  65765. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65766. * @returns glTF PBR Metallic Roughness factors
  65767. */
  65768. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65769. /**
  65770. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65771. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65772. * @param mimeType mime type to use for the textures
  65773. * @param images array of glTF image interfaces
  65774. * @param textures array of glTF texture interfaces
  65775. * @param materials array of glTF material interfaces
  65776. * @param imageData map of image file name to data
  65777. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65778. */
  65779. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65780. private setMetallicRoughnessPbrMaterial;
  65781. private getPixelsFromTexture;
  65782. /**
  65783. * Extracts a texture from a Babylon texture into file data and glTF data
  65784. * @param babylonTexture Babylon texture to extract
  65785. * @param mimeType Mime Type of the babylonTexture
  65786. * @return glTF texture info, or null if the texture format is not supported
  65787. */
  65788. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65789. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65790. /**
  65791. * Builds a texture from base64 string
  65792. * @param base64Texture base64 texture string
  65793. * @param baseTextureName Name to use for the texture
  65794. * @param mimeType image mime type for the texture
  65795. * @param images array of images
  65796. * @param textures array of textures
  65797. * @param imageData map of image data
  65798. * @returns glTF texture info, or null if the texture format is not supported
  65799. */
  65800. private _getTextureInfoFromBase64;
  65801. }
  65802. }
  65803. declare module BABYLON {
  65804. /**
  65805. * Class for holding and downloading glTF file data
  65806. */
  65807. export class GLTFData {
  65808. /**
  65809. * Object which contains the file name as the key and its data as the value
  65810. */
  65811. glTFFiles: {
  65812. [fileName: string]: string | Blob;
  65813. };
  65814. /**
  65815. * Initializes the glTF file object
  65816. */
  65817. constructor();
  65818. /**
  65819. * Downloads the glTF data as files based on their names and data
  65820. */
  65821. downloadFiles(): void;
  65822. }
  65823. }
  65824. declare module BABYLON {
  65825. /**
  65826. * Holds a collection of exporter options and parameters
  65827. */
  65828. export interface IExportOptions {
  65829. /**
  65830. * Function which indicates whether a babylon node should be exported or not
  65831. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65832. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65833. */
  65834. shouldExportNode?(node: Node): boolean;
  65835. /**
  65836. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  65837. * @param metadata source metadata to read from
  65838. * @returns the data to store to glTF node extras
  65839. */
  65840. metadataSelector?(metadata: any): any;
  65841. /**
  65842. * The sample rate to bake animation curves
  65843. */
  65844. animationSampleRate?: number;
  65845. /**
  65846. * Begin serialization without waiting for the scene to be ready
  65847. */
  65848. exportWithoutWaitingForScene?: boolean;
  65849. }
  65850. /**
  65851. * Class for generating glTF data from a Babylon scene.
  65852. */
  65853. export class GLTF2Export {
  65854. /**
  65855. * Exports the geometry of the scene to .gltf file format asynchronously
  65856. * @param scene Babylon scene with scene hierarchy information
  65857. * @param filePrefix File prefix to use when generating the glTF file
  65858. * @param options Exporter options
  65859. * @returns Returns an object with a .gltf file and associates texture names
  65860. * as keys and their data and paths as values
  65861. */
  65862. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65863. private static _PreExportAsync;
  65864. private static _PostExportAsync;
  65865. /**
  65866. * Exports the geometry of the scene to .glb file format asychronously
  65867. * @param scene Babylon scene with scene hierarchy information
  65868. * @param filePrefix File prefix to use when generating glb file
  65869. * @param options Exporter options
  65870. * @returns Returns an object with a .glb filename as key and data as value
  65871. */
  65872. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65873. }
  65874. }
  65875. declare module BABYLON.GLTF2.Exporter {
  65876. /**
  65877. * @hidden
  65878. */
  65879. export class _GLTFUtilities {
  65880. /**
  65881. * Creates a buffer view based on the supplied arguments
  65882. * @param bufferIndex index value of the specified buffer
  65883. * @param byteOffset byte offset value
  65884. * @param byteLength byte length of the bufferView
  65885. * @param byteStride byte distance between conequential elements
  65886. * @param name name of the buffer view
  65887. * @returns bufferView for glTF
  65888. */
  65889. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65890. /**
  65891. * Creates an accessor based on the supplied arguments
  65892. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65893. * @param name The name of the accessor
  65894. * @param type The type of the accessor
  65895. * @param componentType The datatype of components in the attribute
  65896. * @param count The number of attributes referenced by this accessor
  65897. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65898. * @param min Minimum value of each component in this attribute
  65899. * @param max Maximum value of each component in this attribute
  65900. * @returns accessor for glTF
  65901. */
  65902. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65903. /**
  65904. * Calculates the minimum and maximum values of an array of position floats
  65905. * @param positions Positions array of a mesh
  65906. * @param vertexStart Starting vertex offset to calculate min and max values
  65907. * @param vertexCount Number of vertices to check for min and max values
  65908. * @returns min number array and max number array
  65909. */
  65910. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65911. min: number[];
  65912. max: number[];
  65913. };
  65914. /**
  65915. * Converts a new right-handed Vector3
  65916. * @param vector vector3 array
  65917. * @returns right-handed Vector3
  65918. */
  65919. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65920. /**
  65921. * Converts a Vector3 to right-handed
  65922. * @param vector Vector3 to convert to right-handed
  65923. */
  65924. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65925. /**
  65926. * Converts a three element number array to right-handed
  65927. * @param vector number array to convert to right-handed
  65928. */
  65929. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65930. /**
  65931. * Converts a new right-handed Vector3
  65932. * @param vector vector3 array
  65933. * @returns right-handed Vector3
  65934. */
  65935. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65936. /**
  65937. * Converts a Vector3 to right-handed
  65938. * @param vector Vector3 to convert to right-handed
  65939. */
  65940. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65941. /**
  65942. * Converts a three element number array to right-handed
  65943. * @param vector number array to convert to right-handed
  65944. */
  65945. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65946. /**
  65947. * Converts a Vector4 to right-handed
  65948. * @param vector Vector4 to convert to right-handed
  65949. */
  65950. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65951. /**
  65952. * Converts a Vector4 to right-handed
  65953. * @param vector Vector4 to convert to right-handed
  65954. */
  65955. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65956. /**
  65957. * Converts a Quaternion to right-handed
  65958. * @param quaternion Source quaternion to convert to right-handed
  65959. */
  65960. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65961. /**
  65962. * Converts a Quaternion to right-handed
  65963. * @param quaternion Source quaternion to convert to right-handed
  65964. */
  65965. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65966. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65967. }
  65968. }
  65969. declare module BABYLON.GLTF2.Exporter {
  65970. /**
  65971. * Converts Babylon Scene into glTF 2.0.
  65972. * @hidden
  65973. */
  65974. export class _Exporter {
  65975. /**
  65976. * Stores the glTF to export
  65977. */
  65978. _glTF: IGLTF;
  65979. /**
  65980. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65981. */
  65982. _bufferViews: IBufferView[];
  65983. /**
  65984. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65985. */
  65986. _accessors: IAccessor[];
  65987. /**
  65988. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65989. */
  65990. private _nodes;
  65991. /**
  65992. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65993. */
  65994. private _scenes;
  65995. /**
  65996. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65997. */
  65998. private _meshes;
  65999. /**
  66000. * Stores all the generated material information, which represents the appearance of each primitive
  66001. */
  66002. _materials: IMaterial[];
  66003. _materialMap: {
  66004. [materialID: number]: number;
  66005. };
  66006. /**
  66007. * Stores all the generated texture information, which is referenced by glTF materials
  66008. */
  66009. _textures: ITexture[];
  66010. /**
  66011. * Stores all the generated image information, which is referenced by glTF textures
  66012. */
  66013. _images: IImage[];
  66014. /**
  66015. * Stores all the texture samplers
  66016. */
  66017. _samplers: ISampler[];
  66018. /**
  66019. * Stores all the generated animation samplers, which is referenced by glTF animations
  66020. */
  66021. /**
  66022. * Stores the animations for glTF models
  66023. */
  66024. private _animations;
  66025. /**
  66026. * Stores the total amount of bytes stored in the glTF buffer
  66027. */
  66028. private _totalByteLength;
  66029. /**
  66030. * Stores a reference to the Babylon scene containing the source geometry and material information
  66031. */
  66032. _babylonScene: Scene;
  66033. /**
  66034. * Stores a map of the image data, where the key is the file name and the value
  66035. * is the image data
  66036. */
  66037. _imageData: {
  66038. [fileName: string]: {
  66039. data: Uint8Array;
  66040. mimeType: ImageMimeType;
  66041. };
  66042. };
  66043. /**
  66044. * Stores a map of the unique id of a node to its index in the node array
  66045. */
  66046. private _nodeMap;
  66047. /**
  66048. * Specifies if the Babylon scene should be converted to right-handed on export
  66049. */
  66050. _convertToRightHandedSystem: boolean;
  66051. /**
  66052. * Baked animation sample rate
  66053. */
  66054. private _animationSampleRate;
  66055. private _options;
  66056. private _localEngine;
  66057. _glTFMaterialExporter: _GLTFMaterialExporter;
  66058. private _extensions;
  66059. private static _ExtensionNames;
  66060. private static _ExtensionFactories;
  66061. private _applyExtensions;
  66062. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66063. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66064. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66065. private _forEachExtensions;
  66066. private _extensionsOnExporting;
  66067. /**
  66068. * Load glTF serializer extensions
  66069. */
  66070. private _loadExtensions;
  66071. /**
  66072. * Creates a glTF Exporter instance, which can accept optional exporter options
  66073. * @param babylonScene Babylon scene object
  66074. * @param options Options to modify the behavior of the exporter
  66075. */
  66076. constructor(babylonScene: Scene, options?: IExportOptions);
  66077. /**
  66078. * Registers a glTF exporter extension
  66079. * @param name Name of the extension to export
  66080. * @param factory The factory function that creates the exporter extension
  66081. */
  66082. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66083. /**
  66084. * Un-registers an exporter extension
  66085. * @param name The name fo the exporter extension
  66086. * @returns A boolean indicating whether the extension has been un-registered
  66087. */
  66088. static UnregisterExtension(name: string): boolean;
  66089. /**
  66090. * Lazy load a local engine with premultiplied alpha set to false
  66091. */
  66092. _getLocalEngine(): Engine;
  66093. private reorderIndicesBasedOnPrimitiveMode;
  66094. /**
  66095. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66096. * clock-wise during export to glTF
  66097. * @param submesh BabylonJS submesh
  66098. * @param primitiveMode Primitive mode of the mesh
  66099. * @param sideOrientation the winding order of the submesh
  66100. * @param vertexBufferKind The type of vertex attribute
  66101. * @param meshAttributeArray The vertex attribute data
  66102. * @param byteOffset The offset to the binary data
  66103. * @param binaryWriter The binary data for the glTF file
  66104. */
  66105. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66106. /**
  66107. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66108. * clock-wise during export to glTF
  66109. * @param submesh BabylonJS submesh
  66110. * @param primitiveMode Primitive mode of the mesh
  66111. * @param sideOrientation the winding order of the submesh
  66112. * @param vertexBufferKind The type of vertex attribute
  66113. * @param meshAttributeArray The vertex attribute data
  66114. * @param byteOffset The offset to the binary data
  66115. * @param binaryWriter The binary data for the glTF file
  66116. */
  66117. private reorderTriangleFillMode;
  66118. /**
  66119. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66120. * clock-wise during export to glTF
  66121. * @param submesh BabylonJS submesh
  66122. * @param primitiveMode Primitive mode of the mesh
  66123. * @param sideOrientation the winding order of the submesh
  66124. * @param vertexBufferKind The type of vertex attribute
  66125. * @param meshAttributeArray The vertex attribute data
  66126. * @param byteOffset The offset to the binary data
  66127. * @param binaryWriter The binary data for the glTF file
  66128. */
  66129. private reorderTriangleStripDrawMode;
  66130. /**
  66131. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66132. * clock-wise during export to glTF
  66133. * @param submesh BabylonJS submesh
  66134. * @param primitiveMode Primitive mode of the mesh
  66135. * @param sideOrientation the winding order of the submesh
  66136. * @param vertexBufferKind The type of vertex attribute
  66137. * @param meshAttributeArray The vertex attribute data
  66138. * @param byteOffset The offset to the binary data
  66139. * @param binaryWriter The binary data for the glTF file
  66140. */
  66141. private reorderTriangleFanMode;
  66142. /**
  66143. * Writes the vertex attribute data to binary
  66144. * @param vertices The vertices to write to the binary writer
  66145. * @param byteOffset The offset into the binary writer to overwrite binary data
  66146. * @param vertexAttributeKind The vertex attribute type
  66147. * @param meshAttributeArray The vertex attribute data
  66148. * @param binaryWriter The writer containing the binary data
  66149. */
  66150. private writeVertexAttributeData;
  66151. /**
  66152. * Writes mesh attribute data to a data buffer
  66153. * Returns the bytelength of the data
  66154. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66155. * @param meshAttributeArray Array containing the attribute data
  66156. * @param binaryWriter The buffer to write the binary data to
  66157. * @param indices Used to specify the order of the vertex data
  66158. */
  66159. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66160. /**
  66161. * Generates glTF json data
  66162. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66163. * @param glTFPrefix Text to use when prefixing a glTF file
  66164. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66165. * @returns json data as string
  66166. */
  66167. private generateJSON;
  66168. /**
  66169. * Generates data for .gltf and .bin files based on the glTF prefix string
  66170. * @param glTFPrefix Text to use when prefixing a glTF file
  66171. * @returns GLTFData with glTF file data
  66172. */
  66173. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66174. /**
  66175. * Creates a binary buffer for glTF
  66176. * @returns array buffer for binary data
  66177. */
  66178. private _generateBinaryAsync;
  66179. /**
  66180. * Pads the number to a multiple of 4
  66181. * @param num number to pad
  66182. * @returns padded number
  66183. */
  66184. private _getPadding;
  66185. /**
  66186. * Generates a glb file from the json and binary data
  66187. * Returns an object with the glb file name as the key and data as the value
  66188. * @param glTFPrefix
  66189. * @returns object with glb filename as key and data as value
  66190. */
  66191. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66192. /**
  66193. * Sets the TRS for each node
  66194. * @param node glTF Node for storing the transformation data
  66195. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66196. */
  66197. private setNodeTransformation;
  66198. private getVertexBufferFromMesh;
  66199. /**
  66200. * Creates a bufferview based on the vertices type for the Babylon mesh
  66201. * @param kind Indicates the type of vertices data
  66202. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66203. * @param binaryWriter The buffer to write the bufferview data to
  66204. */
  66205. private createBufferViewKind;
  66206. /**
  66207. * The primitive mode of the Babylon mesh
  66208. * @param babylonMesh The BabylonJS mesh
  66209. */
  66210. private getMeshPrimitiveMode;
  66211. /**
  66212. * Sets the primitive mode of the glTF mesh primitive
  66213. * @param meshPrimitive glTF mesh primitive
  66214. * @param primitiveMode The primitive mode
  66215. */
  66216. private setPrimitiveMode;
  66217. /**
  66218. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66219. * @param meshPrimitive glTF mesh primitive
  66220. * @param attributeKind vertex attribute
  66221. * @returns boolean specifying if uv coordinates are present
  66222. */
  66223. private setAttributeKind;
  66224. /**
  66225. * Sets data for the primitive attributes of each submesh
  66226. * @param mesh glTF Mesh object to store the primitive attribute information
  66227. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66228. * @param binaryWriter Buffer to write the attribute data to
  66229. */
  66230. private setPrimitiveAttributesAsync;
  66231. /**
  66232. * Creates a glTF scene based on the array of meshes
  66233. * Returns the the total byte offset
  66234. * @param babylonScene Babylon scene to get the mesh data from
  66235. * @param binaryWriter Buffer to write binary data to
  66236. */
  66237. private createSceneAsync;
  66238. /**
  66239. * Creates a mapping of Node unique id to node index and handles animations
  66240. * @param babylonScene Babylon Scene
  66241. * @param nodes Babylon transform nodes
  66242. * @param binaryWriter Buffer to write binary data to
  66243. * @returns Node mapping of unique id to index
  66244. */
  66245. private createNodeMapAndAnimationsAsync;
  66246. /**
  66247. * Creates a glTF node from a Babylon mesh
  66248. * @param babylonMesh Source Babylon mesh
  66249. * @param binaryWriter Buffer for storing geometry data
  66250. * @returns glTF node
  66251. */
  66252. private createNodeAsync;
  66253. }
  66254. /**
  66255. * @hidden
  66256. *
  66257. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66258. */
  66259. export class _BinaryWriter {
  66260. /**
  66261. * Array buffer which stores all binary data
  66262. */
  66263. private _arrayBuffer;
  66264. /**
  66265. * View of the array buffer
  66266. */
  66267. private _dataView;
  66268. /**
  66269. * byte offset of data in array buffer
  66270. */
  66271. private _byteOffset;
  66272. /**
  66273. * Initialize binary writer with an initial byte length
  66274. * @param byteLength Initial byte length of the array buffer
  66275. */
  66276. constructor(byteLength: number);
  66277. /**
  66278. * Resize the array buffer to the specified byte length
  66279. * @param byteLength
  66280. */
  66281. private resizeBuffer;
  66282. /**
  66283. * Get an array buffer with the length of the byte offset
  66284. * @returns ArrayBuffer resized to the byte offset
  66285. */
  66286. getArrayBuffer(): ArrayBuffer;
  66287. /**
  66288. * Get the byte offset of the array buffer
  66289. * @returns byte offset
  66290. */
  66291. getByteOffset(): number;
  66292. /**
  66293. * Stores an UInt8 in the array buffer
  66294. * @param entry
  66295. * @param byteOffset If defined, specifies where to set the value as an offset.
  66296. */
  66297. setUInt8(entry: number, byteOffset?: number): void;
  66298. /**
  66299. * Gets an UInt32 in the array buffer
  66300. * @param entry
  66301. * @param byteOffset If defined, specifies where to set the value as an offset.
  66302. */
  66303. getUInt32(byteOffset: number): number;
  66304. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66305. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66306. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66307. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66308. /**
  66309. * Stores a Float32 in the array buffer
  66310. * @param entry
  66311. */
  66312. setFloat32(entry: number, byteOffset?: number): void;
  66313. /**
  66314. * Stores an UInt32 in the array buffer
  66315. * @param entry
  66316. * @param byteOffset If defined, specifies where to set the value as an offset.
  66317. */
  66318. setUInt32(entry: number, byteOffset?: number): void;
  66319. }
  66320. }
  66321. declare module BABYLON.GLTF2.Exporter {
  66322. /**
  66323. * @hidden
  66324. * Interface to store animation data.
  66325. */
  66326. export interface _IAnimationData {
  66327. /**
  66328. * Keyframe data.
  66329. */
  66330. inputs: number[];
  66331. /**
  66332. * Value data.
  66333. */
  66334. outputs: number[][];
  66335. /**
  66336. * Animation interpolation data.
  66337. */
  66338. samplerInterpolation: AnimationSamplerInterpolation;
  66339. /**
  66340. * Minimum keyframe value.
  66341. */
  66342. inputsMin: number;
  66343. /**
  66344. * Maximum keyframe value.
  66345. */
  66346. inputsMax: number;
  66347. }
  66348. /**
  66349. * @hidden
  66350. */
  66351. export interface _IAnimationInfo {
  66352. /**
  66353. * The target channel for the animation
  66354. */
  66355. animationChannelTargetPath: AnimationChannelTargetPath;
  66356. /**
  66357. * The glTF accessor type for the data.
  66358. */
  66359. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66360. /**
  66361. * Specifies if quaternions should be used.
  66362. */
  66363. useQuaternion: boolean;
  66364. }
  66365. /**
  66366. * @hidden
  66367. * Utility class for generating glTF animation data from BabylonJS.
  66368. */
  66369. export class _GLTFAnimation {
  66370. /**
  66371. * @ignore
  66372. *
  66373. * Creates glTF channel animation from BabylonJS animation.
  66374. * @param babylonTransformNode - BabylonJS mesh.
  66375. * @param animation - animation.
  66376. * @param animationChannelTargetPath - The target animation channel.
  66377. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66378. * @param useQuaternion - Specifies if quaternions are used.
  66379. * @returns nullable IAnimationData
  66380. */
  66381. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66382. private static _DeduceAnimationInfo;
  66383. /**
  66384. * @ignore
  66385. * Create node animations from the transform node animations
  66386. * @param babylonNode
  66387. * @param runtimeGLTFAnimation
  66388. * @param idleGLTFAnimations
  66389. * @param nodeMap
  66390. * @param nodes
  66391. * @param binaryWriter
  66392. * @param bufferViews
  66393. * @param accessors
  66394. * @param convertToRightHandedSystem
  66395. */
  66396. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66397. [key: number]: number;
  66398. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66399. /**
  66400. * @ignore
  66401. * Create node animations from the animation groups
  66402. * @param babylonScene
  66403. * @param glTFAnimations
  66404. * @param nodeMap
  66405. * @param nodes
  66406. * @param binaryWriter
  66407. * @param bufferViews
  66408. * @param accessors
  66409. * @param convertToRightHandedSystem
  66410. */
  66411. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66412. [key: number]: number;
  66413. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66414. private static AddAnimation;
  66415. /**
  66416. * Create a baked animation
  66417. * @param babylonTransformNode BabylonJS mesh
  66418. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66419. * @param animationChannelTargetPath animation target channel
  66420. * @param minFrame minimum animation frame
  66421. * @param maxFrame maximum animation frame
  66422. * @param fps frames per second of the animation
  66423. * @param inputs input key frames of the animation
  66424. * @param outputs output key frame data of the animation
  66425. * @param convertToRightHandedSystem converts the values to right-handed
  66426. * @param useQuaternion specifies if quaternions should be used
  66427. */
  66428. private static _CreateBakedAnimation;
  66429. private static _ConvertFactorToVector3OrQuaternion;
  66430. private static _SetInterpolatedValue;
  66431. /**
  66432. * Creates linear animation from the animation key frames
  66433. * @param babylonTransformNode BabylonJS mesh
  66434. * @param animation BabylonJS animation
  66435. * @param animationChannelTargetPath The target animation channel
  66436. * @param frameDelta The difference between the last and first frame of the animation
  66437. * @param inputs Array to store the key frame times
  66438. * @param outputs Array to store the key frame data
  66439. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66440. * @param useQuaternion Specifies if quaternions are used in the animation
  66441. */
  66442. private static _CreateLinearOrStepAnimation;
  66443. /**
  66444. * Creates cubic spline animation from the animation key frames
  66445. * @param babylonTransformNode BabylonJS mesh
  66446. * @param animation BabylonJS animation
  66447. * @param animationChannelTargetPath The target animation channel
  66448. * @param frameDelta The difference between the last and first frame of the animation
  66449. * @param inputs Array to store the key frame times
  66450. * @param outputs Array to store the key frame data
  66451. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66452. * @param useQuaternion Specifies if quaternions are used in the animation
  66453. */
  66454. private static _CreateCubicSplineAnimation;
  66455. private static _GetBasePositionRotationOrScale;
  66456. /**
  66457. * Adds a key frame value
  66458. * @param keyFrame
  66459. * @param animation
  66460. * @param outputs
  66461. * @param animationChannelTargetPath
  66462. * @param basePositionRotationOrScale
  66463. * @param convertToRightHandedSystem
  66464. * @param useQuaternion
  66465. */
  66466. private static _AddKeyframeValue;
  66467. /**
  66468. * Determine the interpolation based on the key frames
  66469. * @param keyFrames
  66470. * @param animationChannelTargetPath
  66471. * @param useQuaternion
  66472. */
  66473. private static _DeduceInterpolation;
  66474. /**
  66475. * Adds an input tangent or output tangent to the output data
  66476. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66477. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66478. * @param outputs The animation data by keyframe
  66479. * @param animationChannelTargetPath The target animation channel
  66480. * @param interpolation The interpolation type
  66481. * @param keyFrame The key frame with the animation data
  66482. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66483. * @param useQuaternion Specifies if quaternions are used
  66484. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66485. */
  66486. private static AddSplineTangent;
  66487. /**
  66488. * Get the minimum and maximum key frames' frame values
  66489. * @param keyFrames animation key frames
  66490. * @returns the minimum and maximum key frame value
  66491. */
  66492. private static calculateMinMaxKeyFrames;
  66493. }
  66494. }
  66495. declare module BABYLON.GLTF2.Exporter {
  66496. /** @hidden */
  66497. export var textureTransformPixelShader: {
  66498. name: string;
  66499. shader: string;
  66500. };
  66501. }
  66502. declare module BABYLON.GLTF2.Exporter.Extensions {
  66503. /**
  66504. * @hidden
  66505. */
  66506. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66507. /** Name of this extension */
  66508. readonly name: string;
  66509. /** Defines whether this extension is enabled */
  66510. enabled: boolean;
  66511. /** Defines whether this extension is required */
  66512. required: boolean;
  66513. /** Reference to the glTF exporter */
  66514. private _exporter;
  66515. constructor(exporter: _Exporter);
  66516. dispose(): void;
  66517. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66518. /**
  66519. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66520. * @param babylonTexture
  66521. * @param offset
  66522. * @param rotation
  66523. * @param scale
  66524. * @param scene
  66525. */
  66526. private _textureTransformTextureAsync;
  66527. }
  66528. }
  66529. declare module BABYLON.GLTF2.Exporter.Extensions {
  66530. /**
  66531. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66532. */
  66533. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66534. /** The name of this extension. */
  66535. readonly name: string;
  66536. /** Defines whether this extension is enabled. */
  66537. enabled: boolean;
  66538. /** Defines whether this extension is required */
  66539. required: boolean;
  66540. /** Reference to the glTF exporter */
  66541. private _exporter;
  66542. private _lights;
  66543. /** @hidden */
  66544. constructor(exporter: _Exporter);
  66545. /** @hidden */
  66546. dispose(): void;
  66547. /** @hidden */
  66548. onExporting(): void;
  66549. /**
  66550. * Define this method to modify the default behavior when exporting a node
  66551. * @param context The context when exporting the node
  66552. * @param node glTF node
  66553. * @param babylonNode BabylonJS node
  66554. * @returns nullable INode promise
  66555. */
  66556. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66557. }
  66558. }
  66559. declare module BABYLON {
  66560. /**
  66561. * Class for generating STL data from a Babylon scene.
  66562. */
  66563. export class STLExport {
  66564. /**
  66565. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66566. * @param meshes list defines the mesh to serialize
  66567. * @param download triggers the automatic download of the file.
  66568. * @param fileName changes the downloads fileName.
  66569. * @param binary changes the STL to a binary type.
  66570. * @param isLittleEndian toggle for binary type exporter.
  66571. * @returns the STL as UTF8 string
  66572. */
  66573. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66574. }
  66575. }
  66576. /**
  66577. * @ignoreChildren
  66578. * @ignore
  66579. */
  66580. declare module "babylonjs-gltf2interface" {
  66581. export = BABYLON.GLTF2;
  66582. }
  66583. /**
  66584. * Module for glTF 2.0 Interface
  66585. * @ignoreChildren
  66586. * @ignore
  66587. */
  66588. declare module BABYLON.GLTF2 {
  66589. /**
  66590. * The datatype of the components in the attribute
  66591. */
  66592. const enum AccessorComponentType {
  66593. /**
  66594. * Byte
  66595. */
  66596. BYTE = 5120,
  66597. /**
  66598. * Unsigned Byte
  66599. */
  66600. UNSIGNED_BYTE = 5121,
  66601. /**
  66602. * Short
  66603. */
  66604. SHORT = 5122,
  66605. /**
  66606. * Unsigned Short
  66607. */
  66608. UNSIGNED_SHORT = 5123,
  66609. /**
  66610. * Unsigned Int
  66611. */
  66612. UNSIGNED_INT = 5125,
  66613. /**
  66614. * Float
  66615. */
  66616. FLOAT = 5126,
  66617. }
  66618. /**
  66619. * Specifies if the attirbute is a scalar, vector, or matrix
  66620. */
  66621. const enum AccessorType {
  66622. /**
  66623. * Scalar
  66624. */
  66625. SCALAR = "SCALAR",
  66626. /**
  66627. * Vector2
  66628. */
  66629. VEC2 = "VEC2",
  66630. /**
  66631. * Vector3
  66632. */
  66633. VEC3 = "VEC3",
  66634. /**
  66635. * Vector4
  66636. */
  66637. VEC4 = "VEC4",
  66638. /**
  66639. * Matrix2x2
  66640. */
  66641. MAT2 = "MAT2",
  66642. /**
  66643. * Matrix3x3
  66644. */
  66645. MAT3 = "MAT3",
  66646. /**
  66647. * Matrix4x4
  66648. */
  66649. MAT4 = "MAT4",
  66650. }
  66651. /**
  66652. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66653. */
  66654. const enum AnimationChannelTargetPath {
  66655. /**
  66656. * Translation
  66657. */
  66658. TRANSLATION = "translation",
  66659. /**
  66660. * Rotation
  66661. */
  66662. ROTATION = "rotation",
  66663. /**
  66664. * Scale
  66665. */
  66666. SCALE = "scale",
  66667. /**
  66668. * Weights
  66669. */
  66670. WEIGHTS = "weights",
  66671. }
  66672. /**
  66673. * Interpolation algorithm
  66674. */
  66675. const enum AnimationSamplerInterpolation {
  66676. /**
  66677. * The animated values are linearly interpolated between keyframes
  66678. */
  66679. LINEAR = "LINEAR",
  66680. /**
  66681. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66682. */
  66683. STEP = "STEP",
  66684. /**
  66685. * The animation's interpolation is computed using a cubic spline with specified tangents
  66686. */
  66687. CUBICSPLINE = "CUBICSPLINE",
  66688. }
  66689. /**
  66690. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66691. */
  66692. const enum CameraType {
  66693. /**
  66694. * A perspective camera containing properties to create a perspective projection matrix
  66695. */
  66696. PERSPECTIVE = "perspective",
  66697. /**
  66698. * An orthographic camera containing properties to create an orthographic projection matrix
  66699. */
  66700. ORTHOGRAPHIC = "orthographic",
  66701. }
  66702. /**
  66703. * The mime-type of the image
  66704. */
  66705. const enum ImageMimeType {
  66706. /**
  66707. * JPEG Mime-type
  66708. */
  66709. JPEG = "image/jpeg",
  66710. /**
  66711. * PNG Mime-type
  66712. */
  66713. PNG = "image/png",
  66714. }
  66715. /**
  66716. * The alpha rendering mode of the material
  66717. */
  66718. const enum MaterialAlphaMode {
  66719. /**
  66720. * The alpha value is ignored and the rendered output is fully opaque
  66721. */
  66722. OPAQUE = "OPAQUE",
  66723. /**
  66724. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66725. */
  66726. MASK = "MASK",
  66727. /**
  66728. * 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)
  66729. */
  66730. BLEND = "BLEND",
  66731. }
  66732. /**
  66733. * The type of the primitives to render
  66734. */
  66735. const enum MeshPrimitiveMode {
  66736. /**
  66737. * Points
  66738. */
  66739. POINTS = 0,
  66740. /**
  66741. * Lines
  66742. */
  66743. LINES = 1,
  66744. /**
  66745. * Line Loop
  66746. */
  66747. LINE_LOOP = 2,
  66748. /**
  66749. * Line Strip
  66750. */
  66751. LINE_STRIP = 3,
  66752. /**
  66753. * Triangles
  66754. */
  66755. TRIANGLES = 4,
  66756. /**
  66757. * Triangle Strip
  66758. */
  66759. TRIANGLE_STRIP = 5,
  66760. /**
  66761. * Triangle Fan
  66762. */
  66763. TRIANGLE_FAN = 6,
  66764. }
  66765. /**
  66766. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66767. */
  66768. const enum TextureMagFilter {
  66769. /**
  66770. * Nearest
  66771. */
  66772. NEAREST = 9728,
  66773. /**
  66774. * Linear
  66775. */
  66776. LINEAR = 9729,
  66777. }
  66778. /**
  66779. * Minification filter. All valid values correspond to WebGL enums
  66780. */
  66781. const enum TextureMinFilter {
  66782. /**
  66783. * Nearest
  66784. */
  66785. NEAREST = 9728,
  66786. /**
  66787. * Linear
  66788. */
  66789. LINEAR = 9729,
  66790. /**
  66791. * Nearest Mip-Map Nearest
  66792. */
  66793. NEAREST_MIPMAP_NEAREST = 9984,
  66794. /**
  66795. * Linear Mipmap Nearest
  66796. */
  66797. LINEAR_MIPMAP_NEAREST = 9985,
  66798. /**
  66799. * Nearest Mipmap Linear
  66800. */
  66801. NEAREST_MIPMAP_LINEAR = 9986,
  66802. /**
  66803. * Linear Mipmap Linear
  66804. */
  66805. LINEAR_MIPMAP_LINEAR = 9987,
  66806. }
  66807. /**
  66808. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66809. */
  66810. const enum TextureWrapMode {
  66811. /**
  66812. * Clamp to Edge
  66813. */
  66814. CLAMP_TO_EDGE = 33071,
  66815. /**
  66816. * Mirrored Repeat
  66817. */
  66818. MIRRORED_REPEAT = 33648,
  66819. /**
  66820. * Repeat
  66821. */
  66822. REPEAT = 10497,
  66823. }
  66824. /**
  66825. * glTF Property
  66826. */
  66827. interface IProperty {
  66828. /**
  66829. * Dictionary object with extension-specific objects
  66830. */
  66831. extensions?: {
  66832. [key: string]: any;
  66833. };
  66834. /**
  66835. * Application-Specific data
  66836. */
  66837. extras?: any;
  66838. }
  66839. /**
  66840. * glTF Child of Root Property
  66841. */
  66842. interface IChildRootProperty extends IProperty {
  66843. /**
  66844. * The user-defined name of this object
  66845. */
  66846. name?: string;
  66847. }
  66848. /**
  66849. * Indices of those attributes that deviate from their initialization value
  66850. */
  66851. interface IAccessorSparseIndices extends IProperty {
  66852. /**
  66853. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66854. */
  66855. bufferView: number;
  66856. /**
  66857. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66858. */
  66859. byteOffset?: number;
  66860. /**
  66861. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66862. */
  66863. componentType: AccessorComponentType;
  66864. }
  66865. /**
  66866. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66867. */
  66868. interface IAccessorSparseValues extends IProperty {
  66869. /**
  66870. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66871. */
  66872. bufferView: number;
  66873. /**
  66874. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66875. */
  66876. byteOffset?: number;
  66877. }
  66878. /**
  66879. * Sparse storage of attributes that deviate from their initialization value
  66880. */
  66881. interface IAccessorSparse extends IProperty {
  66882. /**
  66883. * The number of attributes encoded in this sparse accessor
  66884. */
  66885. count: number;
  66886. /**
  66887. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66888. */
  66889. indices: IAccessorSparseIndices;
  66890. /**
  66891. * 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
  66892. */
  66893. values: IAccessorSparseValues;
  66894. }
  66895. /**
  66896. * 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
  66897. */
  66898. interface IAccessor extends IChildRootProperty {
  66899. /**
  66900. * The index of the bufferview
  66901. */
  66902. bufferView?: number;
  66903. /**
  66904. * The offset relative to the start of the bufferView in bytes
  66905. */
  66906. byteOffset?: number;
  66907. /**
  66908. * The datatype of components in the attribute
  66909. */
  66910. componentType: AccessorComponentType;
  66911. /**
  66912. * Specifies whether integer data values should be normalized
  66913. */
  66914. normalized?: boolean;
  66915. /**
  66916. * The number of attributes referenced by this accessor
  66917. */
  66918. count: number;
  66919. /**
  66920. * Specifies if the attribute is a scalar, vector, or matrix
  66921. */
  66922. type: AccessorType;
  66923. /**
  66924. * Maximum value of each component in this attribute
  66925. */
  66926. max?: number[];
  66927. /**
  66928. * Minimum value of each component in this attribute
  66929. */
  66930. min?: number[];
  66931. /**
  66932. * Sparse storage of attributes that deviate from their initialization value
  66933. */
  66934. sparse?: IAccessorSparse;
  66935. }
  66936. /**
  66937. * Targets an animation's sampler at a node's property
  66938. */
  66939. interface IAnimationChannel extends IProperty {
  66940. /**
  66941. * The index of a sampler in this animation used to compute the value for the target
  66942. */
  66943. sampler: number;
  66944. /**
  66945. * The index of the node and TRS property to target
  66946. */
  66947. target: IAnimationChannelTarget;
  66948. }
  66949. /**
  66950. * The index of the node and TRS property that an animation channel targets
  66951. */
  66952. interface IAnimationChannelTarget extends IProperty {
  66953. /**
  66954. * The index of the node to target
  66955. */
  66956. node: number;
  66957. /**
  66958. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66959. */
  66960. path: AnimationChannelTargetPath;
  66961. }
  66962. /**
  66963. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66964. */
  66965. interface IAnimationSampler extends IProperty {
  66966. /**
  66967. * The index of an accessor containing keyframe input values, e.g., time
  66968. */
  66969. input: number;
  66970. /**
  66971. * Interpolation algorithm
  66972. */
  66973. interpolation?: AnimationSamplerInterpolation;
  66974. /**
  66975. * The index of an accessor, containing keyframe output values
  66976. */
  66977. output: number;
  66978. }
  66979. /**
  66980. * A keyframe animation
  66981. */
  66982. interface IAnimation extends IChildRootProperty {
  66983. /**
  66984. * An array of channels, each of which targets an animation's sampler at a node's property
  66985. */
  66986. channels: IAnimationChannel[];
  66987. /**
  66988. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66989. */
  66990. samplers: IAnimationSampler[];
  66991. }
  66992. /**
  66993. * Metadata about the glTF asset
  66994. */
  66995. interface IAsset extends IChildRootProperty {
  66996. /**
  66997. * A copyright message suitable for display to credit the content creator
  66998. */
  66999. copyright?: string;
  67000. /**
  67001. * Tool that generated this glTF model. Useful for debugging
  67002. */
  67003. generator?: string;
  67004. /**
  67005. * The glTF version that this asset targets
  67006. */
  67007. version: string;
  67008. /**
  67009. * The minimum glTF version that this asset targets
  67010. */
  67011. minVersion?: string;
  67012. }
  67013. /**
  67014. * A buffer points to binary geometry, animation, or skins
  67015. */
  67016. interface IBuffer extends IChildRootProperty {
  67017. /**
  67018. * 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
  67019. */
  67020. uri?: string;
  67021. /**
  67022. * The length of the buffer in bytes
  67023. */
  67024. byteLength: number;
  67025. }
  67026. /**
  67027. * A view into a buffer generally representing a subset of the buffer
  67028. */
  67029. interface IBufferView extends IChildRootProperty {
  67030. /**
  67031. * The index of the buffer
  67032. */
  67033. buffer: number;
  67034. /**
  67035. * The offset into the buffer in bytes
  67036. */
  67037. byteOffset?: number;
  67038. /**
  67039. * The lenth of the bufferView in bytes
  67040. */
  67041. byteLength: number;
  67042. /**
  67043. * The stride, in bytes
  67044. */
  67045. byteStride?: number;
  67046. }
  67047. /**
  67048. * An orthographic camera containing properties to create an orthographic projection matrix
  67049. */
  67050. interface ICameraOrthographic extends IProperty {
  67051. /**
  67052. * The floating-point horizontal magnification of the view. Must not be zero
  67053. */
  67054. xmag: number;
  67055. /**
  67056. * The floating-point vertical magnification of the view. Must not be zero
  67057. */
  67058. ymag: number;
  67059. /**
  67060. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67061. */
  67062. zfar: number;
  67063. /**
  67064. * The floating-point distance to the near clipping plane
  67065. */
  67066. znear: number;
  67067. }
  67068. /**
  67069. * A perspective camera containing properties to create a perspective projection matrix
  67070. */
  67071. interface ICameraPerspective extends IProperty {
  67072. /**
  67073. * The floating-point aspect ratio of the field of view
  67074. */
  67075. aspectRatio?: number;
  67076. /**
  67077. * The floating-point vertical field of view in radians
  67078. */
  67079. yfov: number;
  67080. /**
  67081. * The floating-point distance to the far clipping plane
  67082. */
  67083. zfar?: number;
  67084. /**
  67085. * The floating-point distance to the near clipping plane
  67086. */
  67087. znear: number;
  67088. }
  67089. /**
  67090. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67091. */
  67092. interface ICamera extends IChildRootProperty {
  67093. /**
  67094. * An orthographic camera containing properties to create an orthographic projection matrix
  67095. */
  67096. orthographic?: ICameraOrthographic;
  67097. /**
  67098. * A perspective camera containing properties to create a perspective projection matrix
  67099. */
  67100. perspective?: ICameraPerspective;
  67101. /**
  67102. * Specifies if the camera uses a perspective or orthographic projection
  67103. */
  67104. type: CameraType;
  67105. }
  67106. /**
  67107. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67108. */
  67109. interface IImage extends IChildRootProperty {
  67110. /**
  67111. * 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
  67112. */
  67113. uri?: string;
  67114. /**
  67115. * The image's MIME type
  67116. */
  67117. mimeType?: ImageMimeType;
  67118. /**
  67119. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67120. */
  67121. bufferView?: number;
  67122. }
  67123. /**
  67124. * Material Normal Texture Info
  67125. */
  67126. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67127. /**
  67128. * The scalar multiplier applied to each normal vector of the normal texture
  67129. */
  67130. scale?: number;
  67131. }
  67132. /**
  67133. * Material Occlusion Texture Info
  67134. */
  67135. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67136. /**
  67137. * A scalar multiplier controlling the amount of occlusion applied
  67138. */
  67139. strength?: number;
  67140. }
  67141. /**
  67142. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67143. */
  67144. interface IMaterialPbrMetallicRoughness {
  67145. /**
  67146. * The material's base color factor
  67147. */
  67148. baseColorFactor?: number[];
  67149. /**
  67150. * The base color texture
  67151. */
  67152. baseColorTexture?: ITextureInfo;
  67153. /**
  67154. * The metalness of the material
  67155. */
  67156. metallicFactor?: number;
  67157. /**
  67158. * The roughness of the material
  67159. */
  67160. roughnessFactor?: number;
  67161. /**
  67162. * The metallic-roughness texture
  67163. */
  67164. metallicRoughnessTexture?: ITextureInfo;
  67165. }
  67166. /**
  67167. * The material appearance of a primitive
  67168. */
  67169. interface IMaterial extends IChildRootProperty {
  67170. /**
  67171. * 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
  67172. */
  67173. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67174. /**
  67175. * The normal map texture
  67176. */
  67177. normalTexture?: IMaterialNormalTextureInfo;
  67178. /**
  67179. * The occlusion map texture
  67180. */
  67181. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67182. /**
  67183. * The emissive map texture
  67184. */
  67185. emissiveTexture?: ITextureInfo;
  67186. /**
  67187. * 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
  67188. */
  67189. emissiveFactor?: number[];
  67190. /**
  67191. * The alpha rendering mode of the material
  67192. */
  67193. alphaMode?: MaterialAlphaMode;
  67194. /**
  67195. * The alpha cutoff value of the material
  67196. */
  67197. alphaCutoff?: number;
  67198. /**
  67199. * Specifies whether the material is double sided
  67200. */
  67201. doubleSided?: boolean;
  67202. }
  67203. /**
  67204. * Geometry to be rendered with the given material
  67205. */
  67206. interface IMeshPrimitive extends IProperty {
  67207. /**
  67208. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67209. */
  67210. attributes: {
  67211. [name: string]: number;
  67212. };
  67213. /**
  67214. * The index of the accessor that contains the indices
  67215. */
  67216. indices?: number;
  67217. /**
  67218. * The index of the material to apply to this primitive when rendering
  67219. */
  67220. material?: number;
  67221. /**
  67222. * The type of primitives to render. All valid values correspond to WebGL enums
  67223. */
  67224. mode?: MeshPrimitiveMode;
  67225. /**
  67226. * 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
  67227. */
  67228. targets?: {
  67229. [name: string]: number;
  67230. }[];
  67231. }
  67232. /**
  67233. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67234. */
  67235. interface IMesh extends IChildRootProperty {
  67236. /**
  67237. * An array of primitives, each defining geometry to be rendered with a material
  67238. */
  67239. primitives: IMeshPrimitive[];
  67240. /**
  67241. * Array of weights to be applied to the Morph Targets
  67242. */
  67243. weights?: number[];
  67244. }
  67245. /**
  67246. * A node in the node hierarchy
  67247. */
  67248. interface INode extends IChildRootProperty {
  67249. /**
  67250. * The index of the camera referenced by this node
  67251. */
  67252. camera?: number;
  67253. /**
  67254. * The indices of this node's children
  67255. */
  67256. children?: number[];
  67257. /**
  67258. * The index of the skin referenced by this node
  67259. */
  67260. skin?: number;
  67261. /**
  67262. * A floating-point 4x4 transformation matrix stored in column-major order
  67263. */
  67264. matrix?: number[];
  67265. /**
  67266. * The index of the mesh in this node
  67267. */
  67268. mesh?: number;
  67269. /**
  67270. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67271. */
  67272. rotation?: number[];
  67273. /**
  67274. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67275. */
  67276. scale?: number[];
  67277. /**
  67278. * The node's translation along the x, y, and z axes
  67279. */
  67280. translation?: number[];
  67281. /**
  67282. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67283. */
  67284. weights?: number[];
  67285. }
  67286. /**
  67287. * Texture sampler properties for filtering and wrapping modes
  67288. */
  67289. interface ISampler extends IChildRootProperty {
  67290. /**
  67291. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67292. */
  67293. magFilter?: TextureMagFilter;
  67294. /**
  67295. * Minification filter. All valid values correspond to WebGL enums
  67296. */
  67297. minFilter?: TextureMinFilter;
  67298. /**
  67299. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67300. */
  67301. wrapS?: TextureWrapMode;
  67302. /**
  67303. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67304. */
  67305. wrapT?: TextureWrapMode;
  67306. }
  67307. /**
  67308. * The root nodes of a scene
  67309. */
  67310. interface IScene extends IChildRootProperty {
  67311. /**
  67312. * The indices of each root node
  67313. */
  67314. nodes: number[];
  67315. }
  67316. /**
  67317. * Joints and matrices defining a skin
  67318. */
  67319. interface ISkin extends IChildRootProperty {
  67320. /**
  67321. * 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
  67322. */
  67323. inverseBindMatrices?: number;
  67324. /**
  67325. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67326. */
  67327. skeleton?: number;
  67328. /**
  67329. * 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)
  67330. */
  67331. joints: number[];
  67332. }
  67333. /**
  67334. * A texture and its sampler
  67335. */
  67336. interface ITexture extends IChildRootProperty {
  67337. /**
  67338. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67339. */
  67340. sampler?: number;
  67341. /**
  67342. * The index of the image used by this texture
  67343. */
  67344. source: number;
  67345. }
  67346. /**
  67347. * Reference to a texture
  67348. */
  67349. interface ITextureInfo extends IProperty {
  67350. /**
  67351. * The index of the texture
  67352. */
  67353. index: number;
  67354. /**
  67355. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67356. */
  67357. texCoord?: number;
  67358. }
  67359. /**
  67360. * The root object for a glTF asset
  67361. */
  67362. interface IGLTF extends IProperty {
  67363. /**
  67364. * An array of accessors. An accessor is a typed view into a bufferView
  67365. */
  67366. accessors?: IAccessor[];
  67367. /**
  67368. * An array of keyframe animations
  67369. */
  67370. animations?: IAnimation[];
  67371. /**
  67372. * Metadata about the glTF asset
  67373. */
  67374. asset: IAsset;
  67375. /**
  67376. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67377. */
  67378. buffers?: IBuffer[];
  67379. /**
  67380. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67381. */
  67382. bufferViews?: IBufferView[];
  67383. /**
  67384. * An array of cameras
  67385. */
  67386. cameras?: ICamera[];
  67387. /**
  67388. * Names of glTF extensions used somewhere in this asset
  67389. */
  67390. extensionsUsed?: string[];
  67391. /**
  67392. * Names of glTF extensions required to properly load this asset
  67393. */
  67394. extensionsRequired?: string[];
  67395. /**
  67396. * An array of images. An image defines data used to create a texture
  67397. */
  67398. images?: IImage[];
  67399. /**
  67400. * An array of materials. A material defines the appearance of a primitive
  67401. */
  67402. materials?: IMaterial[];
  67403. /**
  67404. * An array of meshes. A mesh is a set of primitives to be rendered
  67405. */
  67406. meshes?: IMesh[];
  67407. /**
  67408. * An array of nodes
  67409. */
  67410. nodes?: INode[];
  67411. /**
  67412. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67413. */
  67414. samplers?: ISampler[];
  67415. /**
  67416. * The index of the default scene
  67417. */
  67418. scene?: number;
  67419. /**
  67420. * An array of scenes
  67421. */
  67422. scenes?: IScene[];
  67423. /**
  67424. * An array of skins. A skin is defined by joints and matrices
  67425. */
  67426. skins?: ISkin[];
  67427. /**
  67428. * An array of textures
  67429. */
  67430. textures?: ITexture[];
  67431. }
  67432. /**
  67433. * The glTF validation results
  67434. */
  67435. interface IGLTFValidationResults {
  67436. info: {
  67437. generator: string;
  67438. hasAnimations: boolean;
  67439. hasDefaultScene: boolean;
  67440. hasMaterials: boolean;
  67441. hasMorphTargets: boolean;
  67442. hasSkins: boolean;
  67443. hasTextures: boolean;
  67444. maxAttributesUsed: number;
  67445. primitivesCount: number
  67446. };
  67447. issues: {
  67448. messages: Array<string>;
  67449. numErrors: number;
  67450. numHints: number;
  67451. numInfos: number;
  67452. numWarnings: number;
  67453. truncated: boolean
  67454. };
  67455. mimeType: string;
  67456. uri: string;
  67457. validatedAt: string;
  67458. validatorVersion: string;
  67459. }
  67460. /**
  67461. * The glTF validation options
  67462. */
  67463. interface IGLTFValidationOptions {
  67464. uri?: string;
  67465. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67466. validateAccessorData?: boolean;
  67467. maxIssues?: number;
  67468. ignoredIssues?: Array<string>;
  67469. severityOverrides?: Object;
  67470. }
  67471. /**
  67472. * The glTF validator object
  67473. */
  67474. interface IGLTFValidator {
  67475. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67476. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67477. }
  67478. }
  67479. declare module BABYLON {
  67480. /** @hidden */
  67481. export var cellPixelShader: {
  67482. name: string;
  67483. shader: string;
  67484. };
  67485. }
  67486. declare module BABYLON {
  67487. /** @hidden */
  67488. export var cellVertexShader: {
  67489. name: string;
  67490. shader: string;
  67491. };
  67492. }
  67493. declare module BABYLON {
  67494. export class CellMaterial extends BABYLON.PushMaterial {
  67495. private _diffuseTexture;
  67496. diffuseTexture: BABYLON.BaseTexture;
  67497. diffuseColor: BABYLON.Color3;
  67498. _computeHighLevel: boolean;
  67499. computeHighLevel: boolean;
  67500. private _disableLighting;
  67501. disableLighting: boolean;
  67502. private _maxSimultaneousLights;
  67503. maxSimultaneousLights: number;
  67504. private _renderId;
  67505. constructor(name: string, scene: BABYLON.Scene);
  67506. needAlphaBlending(): boolean;
  67507. needAlphaTesting(): boolean;
  67508. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67511. getAnimatables(): BABYLON.IAnimatable[];
  67512. getActiveTextures(): BABYLON.BaseTexture[];
  67513. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67514. dispose(forceDisposeEffect?: boolean): void;
  67515. getClassName(): string;
  67516. clone(name: string): CellMaterial;
  67517. serialize(): any;
  67518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67519. }
  67520. }
  67521. declare module BABYLON {
  67522. export class CustomShaderStructure {
  67523. FragmentStore: string;
  67524. VertexStore: string;
  67525. constructor();
  67526. }
  67527. export class ShaderSpecialParts {
  67528. constructor();
  67529. Fragment_Begin: string;
  67530. Fragment_Definitions: string;
  67531. Fragment_MainBegin: string;
  67532. Fragment_Custom_Diffuse: string;
  67533. Fragment_Before_Lights: string;
  67534. Fragment_Before_Fog: string;
  67535. Fragment_Custom_Alpha: string;
  67536. Fragment_Before_FragColor: string;
  67537. Vertex_Begin: string;
  67538. Vertex_Definitions: string;
  67539. Vertex_MainBegin: string;
  67540. Vertex_Before_PositionUpdated: string;
  67541. Vertex_Before_NormalUpdated: string;
  67542. Vertex_MainEnd: string;
  67543. }
  67544. export class CustomMaterial extends BABYLON.StandardMaterial {
  67545. static ShaderIndexer: number;
  67546. CustomParts: ShaderSpecialParts;
  67547. _isCreatedShader: boolean;
  67548. _createdShaderName: string;
  67549. _customUniform: string[];
  67550. _newUniforms: string[];
  67551. _newUniformInstances: any[];
  67552. _newSamplerInstances: BABYLON.Texture[];
  67553. FragmentShader: string;
  67554. VertexShader: string;
  67555. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67556. ReviewUniform(name: string, arr: string[]): string[];
  67557. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67558. constructor(name: string, scene: BABYLON.Scene);
  67559. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67560. Fragment_Begin(shaderPart: string): CustomMaterial;
  67561. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67562. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67563. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67564. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67565. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67566. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67567. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67568. Vertex_Begin(shaderPart: string): CustomMaterial;
  67569. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67570. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67571. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67572. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67573. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67574. }
  67575. }
  67576. declare module BABYLON {
  67577. export class ShaderAlebdoParts {
  67578. constructor();
  67579. Fragment_Begin: string;
  67580. Fragment_Definitions: string;
  67581. Fragment_MainBegin: string;
  67582. Fragment_Custom_Albedo: string;
  67583. Fragment_Before_Lights: string;
  67584. Fragment_Custom_MetallicRoughness: string;
  67585. Fragment_Custom_MicroSurface: string;
  67586. Fragment_Before_Fog: string;
  67587. Fragment_Custom_Alpha: string;
  67588. Fragment_Before_FragColor: string;
  67589. Vertex_Begin: string;
  67590. Vertex_Definitions: string;
  67591. Vertex_MainBegin: string;
  67592. Vertex_Before_PositionUpdated: string;
  67593. Vertex_Before_NormalUpdated: string;
  67594. Vertex_MainEnd: string;
  67595. }
  67596. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67597. static ShaderIndexer: number;
  67598. CustomParts: ShaderAlebdoParts;
  67599. _isCreatedShader: boolean;
  67600. _createdShaderName: string;
  67601. _customUniform: string[];
  67602. _newUniforms: string[];
  67603. _newUniformInstances: any[];
  67604. _newSamplerInstances: BABYLON.Texture[];
  67605. FragmentShader: string;
  67606. VertexShader: string;
  67607. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67608. ReviewUniform(name: string, arr: string[]): string[];
  67609. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67610. constructor(name: string, scene: BABYLON.Scene);
  67611. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67612. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67613. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67614. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67615. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67616. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67617. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67618. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67619. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67620. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67621. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67622. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67623. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67624. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67625. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67626. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67627. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67628. }
  67629. }
  67630. declare module BABYLON {
  67631. /** @hidden */
  67632. export var firePixelShader: {
  67633. name: string;
  67634. shader: string;
  67635. };
  67636. }
  67637. declare module BABYLON {
  67638. /** @hidden */
  67639. export var fireVertexShader: {
  67640. name: string;
  67641. shader: string;
  67642. };
  67643. }
  67644. declare module BABYLON {
  67645. export class FireMaterial extends BABYLON.PushMaterial {
  67646. private _diffuseTexture;
  67647. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67648. private _distortionTexture;
  67649. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67650. private _opacityTexture;
  67651. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67652. diffuseColor: BABYLON.Color3;
  67653. speed: number;
  67654. private _scaledDiffuse;
  67655. private _renderId;
  67656. private _lastTime;
  67657. constructor(name: string, scene: BABYLON.Scene);
  67658. needAlphaBlending(): boolean;
  67659. needAlphaTesting(): boolean;
  67660. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67661. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67663. getAnimatables(): BABYLON.IAnimatable[];
  67664. getActiveTextures(): BABYLON.BaseTexture[];
  67665. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67666. getClassName(): string;
  67667. dispose(forceDisposeEffect?: boolean): void;
  67668. clone(name: string): FireMaterial;
  67669. serialize(): any;
  67670. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67671. }
  67672. }
  67673. declare module BABYLON {
  67674. /** @hidden */
  67675. export var furPixelShader: {
  67676. name: string;
  67677. shader: string;
  67678. };
  67679. }
  67680. declare module BABYLON {
  67681. /** @hidden */
  67682. export var furVertexShader: {
  67683. name: string;
  67684. shader: string;
  67685. };
  67686. }
  67687. declare module BABYLON {
  67688. export class FurMaterial extends BABYLON.PushMaterial {
  67689. private _diffuseTexture;
  67690. diffuseTexture: BABYLON.BaseTexture;
  67691. private _heightTexture;
  67692. heightTexture: BABYLON.BaseTexture;
  67693. diffuseColor: BABYLON.Color3;
  67694. furLength: number;
  67695. furAngle: number;
  67696. furColor: BABYLON.Color3;
  67697. furOffset: number;
  67698. furSpacing: number;
  67699. furGravity: BABYLON.Vector3;
  67700. furSpeed: number;
  67701. furDensity: number;
  67702. furOcclusion: number;
  67703. furTexture: BABYLON.DynamicTexture;
  67704. private _disableLighting;
  67705. disableLighting: boolean;
  67706. private _maxSimultaneousLights;
  67707. maxSimultaneousLights: number;
  67708. highLevelFur: boolean;
  67709. _meshes: BABYLON.AbstractMesh[];
  67710. private _renderId;
  67711. private _furTime;
  67712. constructor(name: string, scene: BABYLON.Scene);
  67713. furTime: number;
  67714. needAlphaBlending(): boolean;
  67715. needAlphaTesting(): boolean;
  67716. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67717. updateFur(): void;
  67718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67720. getAnimatables(): BABYLON.IAnimatable[];
  67721. getActiveTextures(): BABYLON.BaseTexture[];
  67722. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67723. dispose(forceDisposeEffect?: boolean): void;
  67724. clone(name: string): FurMaterial;
  67725. serialize(): any;
  67726. getClassName(): string;
  67727. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67728. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67729. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67730. }
  67731. }
  67732. declare module BABYLON {
  67733. /** @hidden */
  67734. export var gradientPixelShader: {
  67735. name: string;
  67736. shader: string;
  67737. };
  67738. }
  67739. declare module BABYLON {
  67740. /** @hidden */
  67741. export var gradientVertexShader: {
  67742. name: string;
  67743. shader: string;
  67744. };
  67745. }
  67746. declare module BABYLON {
  67747. export class GradientMaterial extends BABYLON.PushMaterial {
  67748. private _maxSimultaneousLights;
  67749. maxSimultaneousLights: number;
  67750. topColor: BABYLON.Color3;
  67751. topColorAlpha: number;
  67752. bottomColor: BABYLON.Color3;
  67753. bottomColorAlpha: number;
  67754. offset: number;
  67755. scale: number;
  67756. smoothness: number;
  67757. private _disableLighting;
  67758. disableLighting: boolean;
  67759. private _renderId;
  67760. constructor(name: string, scene: BABYLON.Scene);
  67761. needAlphaBlending(): boolean;
  67762. needAlphaTesting(): boolean;
  67763. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67765. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67766. getAnimatables(): BABYLON.IAnimatable[];
  67767. dispose(forceDisposeEffect?: boolean): void;
  67768. clone(name: string): GradientMaterial;
  67769. serialize(): any;
  67770. getClassName(): string;
  67771. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67772. }
  67773. }
  67774. declare module BABYLON {
  67775. /** @hidden */
  67776. export var gridPixelShader: {
  67777. name: string;
  67778. shader: string;
  67779. };
  67780. }
  67781. declare module BABYLON {
  67782. /** @hidden */
  67783. export var gridVertexShader: {
  67784. name: string;
  67785. shader: string;
  67786. };
  67787. }
  67788. declare module BABYLON {
  67789. /**
  67790. * The grid materials allows you to wrap any shape with a grid.
  67791. * Colors are customizable.
  67792. */
  67793. export class GridMaterial extends BABYLON.PushMaterial {
  67794. /**
  67795. * Main color of the grid (e.g. between lines)
  67796. */
  67797. mainColor: BABYLON.Color3;
  67798. /**
  67799. * Color of the grid lines.
  67800. */
  67801. lineColor: BABYLON.Color3;
  67802. /**
  67803. * The scale of the grid compared to unit.
  67804. */
  67805. gridRatio: number;
  67806. /**
  67807. * Allows setting an offset for the grid lines.
  67808. */
  67809. gridOffset: BABYLON.Vector3;
  67810. /**
  67811. * The frequency of thicker lines.
  67812. */
  67813. majorUnitFrequency: number;
  67814. /**
  67815. * The visibility of minor units in the grid.
  67816. */
  67817. minorUnitVisibility: number;
  67818. /**
  67819. * The grid opacity outside of the lines.
  67820. */
  67821. opacity: number;
  67822. /**
  67823. * Determine RBG output is premultiplied by alpha value.
  67824. */
  67825. preMultiplyAlpha: boolean;
  67826. private _opacityTexture;
  67827. opacityTexture: BABYLON.BaseTexture;
  67828. private _gridControl;
  67829. private _renderId;
  67830. /**
  67831. * constructor
  67832. * @param name The name given to the material in order to identify it afterwards.
  67833. * @param scene The scene the material is used in.
  67834. */
  67835. constructor(name: string, scene: BABYLON.Scene);
  67836. /**
  67837. * Returns wehter or not the grid requires alpha blending.
  67838. */
  67839. needAlphaBlending(): boolean;
  67840. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67843. /**
  67844. * Dispose the material and its associated resources.
  67845. * @param forceDisposeEffect will also dispose the used effect when true
  67846. */
  67847. dispose(forceDisposeEffect?: boolean): void;
  67848. clone(name: string): GridMaterial;
  67849. serialize(): any;
  67850. getClassName(): string;
  67851. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67852. }
  67853. }
  67854. declare module BABYLON {
  67855. /** @hidden */
  67856. export var lavaPixelShader: {
  67857. name: string;
  67858. shader: string;
  67859. };
  67860. }
  67861. declare module BABYLON {
  67862. /** @hidden */
  67863. export var lavaVertexShader: {
  67864. name: string;
  67865. shader: string;
  67866. };
  67867. }
  67868. declare module BABYLON {
  67869. export class LavaMaterial extends BABYLON.PushMaterial {
  67870. private _diffuseTexture;
  67871. diffuseTexture: BABYLON.BaseTexture;
  67872. noiseTexture: BABYLON.BaseTexture;
  67873. fogColor: BABYLON.Color3;
  67874. speed: number;
  67875. movingSpeed: number;
  67876. lowFrequencySpeed: number;
  67877. fogDensity: number;
  67878. private _lastTime;
  67879. diffuseColor: BABYLON.Color3;
  67880. private _disableLighting;
  67881. disableLighting: boolean;
  67882. private _unlit;
  67883. unlit: boolean;
  67884. private _maxSimultaneousLights;
  67885. maxSimultaneousLights: number;
  67886. private _scaledDiffuse;
  67887. private _renderId;
  67888. constructor(name: string, scene: BABYLON.Scene);
  67889. needAlphaBlending(): boolean;
  67890. needAlphaTesting(): boolean;
  67891. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67892. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67893. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67894. getAnimatables(): BABYLON.IAnimatable[];
  67895. getActiveTextures(): BABYLON.BaseTexture[];
  67896. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67897. dispose(forceDisposeEffect?: boolean): void;
  67898. clone(name: string): LavaMaterial;
  67899. serialize(): any;
  67900. getClassName(): string;
  67901. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67902. }
  67903. }
  67904. declare module BABYLON {
  67905. /** @hidden */
  67906. export var mixPixelShader: {
  67907. name: string;
  67908. shader: string;
  67909. };
  67910. }
  67911. declare module BABYLON {
  67912. /** @hidden */
  67913. export var mixVertexShader: {
  67914. name: string;
  67915. shader: string;
  67916. };
  67917. }
  67918. declare module BABYLON {
  67919. export class MixMaterial extends BABYLON.PushMaterial {
  67920. /**
  67921. * Mix textures
  67922. */
  67923. private _mixTexture1;
  67924. mixTexture1: BABYLON.BaseTexture;
  67925. private _mixTexture2;
  67926. mixTexture2: BABYLON.BaseTexture;
  67927. /**
  67928. * Diffuse textures
  67929. */
  67930. private _diffuseTexture1;
  67931. diffuseTexture1: BABYLON.Texture;
  67932. private _diffuseTexture2;
  67933. diffuseTexture2: BABYLON.Texture;
  67934. private _diffuseTexture3;
  67935. diffuseTexture3: BABYLON.Texture;
  67936. private _diffuseTexture4;
  67937. diffuseTexture4: BABYLON.Texture;
  67938. private _diffuseTexture5;
  67939. diffuseTexture5: BABYLON.Texture;
  67940. private _diffuseTexture6;
  67941. diffuseTexture6: BABYLON.Texture;
  67942. private _diffuseTexture7;
  67943. diffuseTexture7: BABYLON.Texture;
  67944. private _diffuseTexture8;
  67945. diffuseTexture8: BABYLON.Texture;
  67946. /**
  67947. * Uniforms
  67948. */
  67949. diffuseColor: BABYLON.Color3;
  67950. specularColor: BABYLON.Color3;
  67951. specularPower: number;
  67952. private _disableLighting;
  67953. disableLighting: boolean;
  67954. private _maxSimultaneousLights;
  67955. maxSimultaneousLights: number;
  67956. private _renderId;
  67957. constructor(name: string, scene: BABYLON.Scene);
  67958. needAlphaBlending(): boolean;
  67959. needAlphaTesting(): boolean;
  67960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67963. getAnimatables(): BABYLON.IAnimatable[];
  67964. getActiveTextures(): BABYLON.BaseTexture[];
  67965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67966. dispose(forceDisposeEffect?: boolean): void;
  67967. clone(name: string): MixMaterial;
  67968. serialize(): any;
  67969. getClassName(): string;
  67970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67971. }
  67972. }
  67973. declare module BABYLON {
  67974. /** @hidden */
  67975. export var normalPixelShader: {
  67976. name: string;
  67977. shader: string;
  67978. };
  67979. }
  67980. declare module BABYLON {
  67981. /** @hidden */
  67982. export var normalVertexShader: {
  67983. name: string;
  67984. shader: string;
  67985. };
  67986. }
  67987. declare module BABYLON {
  67988. export class NormalMaterial extends BABYLON.PushMaterial {
  67989. private _diffuseTexture;
  67990. diffuseTexture: BABYLON.BaseTexture;
  67991. diffuseColor: BABYLON.Color3;
  67992. private _disableLighting;
  67993. disableLighting: boolean;
  67994. private _maxSimultaneousLights;
  67995. maxSimultaneousLights: number;
  67996. private _renderId;
  67997. constructor(name: string, scene: BABYLON.Scene);
  67998. needAlphaBlending(): boolean;
  67999. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68000. needAlphaTesting(): boolean;
  68001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68002. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68003. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68004. getAnimatables(): BABYLON.IAnimatable[];
  68005. getActiveTextures(): BABYLON.BaseTexture[];
  68006. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68007. dispose(forceDisposeEffect?: boolean): void;
  68008. clone(name: string): NormalMaterial;
  68009. serialize(): any;
  68010. getClassName(): string;
  68011. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68012. }
  68013. }
  68014. declare module BABYLON {
  68015. /** @hidden */
  68016. export var shadowOnlyPixelShader: {
  68017. name: string;
  68018. shader: string;
  68019. };
  68020. }
  68021. declare module BABYLON {
  68022. /** @hidden */
  68023. export var shadowOnlyVertexShader: {
  68024. name: string;
  68025. shader: string;
  68026. };
  68027. }
  68028. declare module BABYLON {
  68029. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68030. private _renderId;
  68031. private _activeLight;
  68032. constructor(name: string, scene: BABYLON.Scene);
  68033. shadowColor: BABYLON.Color3;
  68034. needAlphaBlending(): boolean;
  68035. needAlphaTesting(): boolean;
  68036. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68037. activeLight: BABYLON.IShadowLight;
  68038. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68039. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68040. clone(name: string): ShadowOnlyMaterial;
  68041. serialize(): any;
  68042. getClassName(): string;
  68043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68044. }
  68045. }
  68046. declare module BABYLON {
  68047. /** @hidden */
  68048. export var simplePixelShader: {
  68049. name: string;
  68050. shader: string;
  68051. };
  68052. }
  68053. declare module BABYLON {
  68054. /** @hidden */
  68055. export var simpleVertexShader: {
  68056. name: string;
  68057. shader: string;
  68058. };
  68059. }
  68060. declare module BABYLON {
  68061. export class SimpleMaterial extends BABYLON.PushMaterial {
  68062. private _diffuseTexture;
  68063. diffuseTexture: BABYLON.BaseTexture;
  68064. diffuseColor: BABYLON.Color3;
  68065. private _disableLighting;
  68066. disableLighting: boolean;
  68067. private _maxSimultaneousLights;
  68068. maxSimultaneousLights: number;
  68069. private _renderId;
  68070. constructor(name: string, scene: BABYLON.Scene);
  68071. needAlphaBlending(): boolean;
  68072. needAlphaTesting(): boolean;
  68073. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68074. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68075. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68076. getAnimatables(): BABYLON.IAnimatable[];
  68077. getActiveTextures(): BABYLON.BaseTexture[];
  68078. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68079. dispose(forceDisposeEffect?: boolean): void;
  68080. clone(name: string): SimpleMaterial;
  68081. serialize(): any;
  68082. getClassName(): string;
  68083. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68084. }
  68085. }
  68086. declare module BABYLON {
  68087. /** @hidden */
  68088. export var skyPixelShader: {
  68089. name: string;
  68090. shader: string;
  68091. };
  68092. }
  68093. declare module BABYLON {
  68094. /** @hidden */
  68095. export var skyVertexShader: {
  68096. name: string;
  68097. shader: string;
  68098. };
  68099. }
  68100. declare module BABYLON {
  68101. /**
  68102. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68103. * @see https://doc.babylonjs.com/extensions/sky
  68104. */
  68105. export class SkyMaterial extends BABYLON.PushMaterial {
  68106. /**
  68107. * Defines the overall luminance of sky in interval ]0, 1[.
  68108. */
  68109. luminance: number;
  68110. /**
  68111. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68112. */
  68113. turbidity: number;
  68114. /**
  68115. * Defines the sky appearance (light intensity).
  68116. */
  68117. rayleigh: number;
  68118. /**
  68119. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68120. */
  68121. mieCoefficient: number;
  68122. /**
  68123. * Defines the amount of haze particles following the Mie scattering theory.
  68124. */
  68125. mieDirectionalG: number;
  68126. /**
  68127. * Defines the distance of the sun according to the active scene camera.
  68128. */
  68129. distance: number;
  68130. /**
  68131. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68132. * "inclined".
  68133. */
  68134. inclination: number;
  68135. /**
  68136. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68137. * an object direction and a reference direction.
  68138. */
  68139. azimuth: number;
  68140. /**
  68141. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68142. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68143. */
  68144. sunPosition: BABYLON.Vector3;
  68145. /**
  68146. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68147. * .sunPosition property.
  68148. */
  68149. useSunPosition: boolean;
  68150. /**
  68151. * Defines an offset vector used to get a horizon offset.
  68152. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68153. */
  68154. cameraOffset: BABYLON.Vector3;
  68155. private _cameraPosition;
  68156. private _renderId;
  68157. /**
  68158. * Instantiates a new sky material.
  68159. * This material allows to create dynamic and texture free
  68160. * effects for skyboxes by taking care of the atmosphere state.
  68161. * @see https://doc.babylonjs.com/extensions/sky
  68162. * @param name Define the name of the material in the scene
  68163. * @param scene Define the scene the material belong to
  68164. */
  68165. constructor(name: string, scene: BABYLON.Scene);
  68166. /**
  68167. * Specifies if the material will require alpha blending
  68168. * @returns a boolean specifying if alpha blending is needed
  68169. */
  68170. needAlphaBlending(): boolean;
  68171. /**
  68172. * Specifies if this material should be rendered in alpha test mode
  68173. * @returns false as the sky material doesn't need alpha testing.
  68174. */
  68175. needAlphaTesting(): boolean;
  68176. /**
  68177. * Get the texture used for alpha test purpose.
  68178. * @returns null as the sky material has no texture.
  68179. */
  68180. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68181. /**
  68182. * Get if the submesh is ready to be used and all its information available.
  68183. * Child classes can use it to update shaders
  68184. * @param mesh defines the mesh to check
  68185. * @param subMesh defines which submesh to check
  68186. * @param useInstances specifies that instances should be used
  68187. * @returns a boolean indicating that the submesh is ready or not
  68188. */
  68189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68190. /**
  68191. * Binds the submesh to this material by preparing the effect and shader to draw
  68192. * @param world defines the world transformation matrix
  68193. * @param mesh defines the mesh containing the submesh
  68194. * @param subMesh defines the submesh to bind the material to
  68195. */
  68196. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68197. /**
  68198. * Get the list of animatables in the material.
  68199. * @returns the list of animatables object used in the material
  68200. */
  68201. getAnimatables(): BABYLON.IAnimatable[];
  68202. /**
  68203. * Disposes the material
  68204. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68205. */
  68206. dispose(forceDisposeEffect?: boolean): void;
  68207. /**
  68208. * Makes a duplicate of the material, and gives it a new name
  68209. * @param name defines the new name for the duplicated material
  68210. * @returns the cloned material
  68211. */
  68212. clone(name: string): SkyMaterial;
  68213. /**
  68214. * Serializes this material in a JSON representation
  68215. * @returns the serialized material object
  68216. */
  68217. serialize(): any;
  68218. /**
  68219. * Gets the current class name of the material e.g. "SkyMaterial"
  68220. * Mainly use in serialization.
  68221. * @returns the class name
  68222. */
  68223. getClassName(): string;
  68224. /**
  68225. * Creates a sky material from parsed material data
  68226. * @param source defines the JSON representation of the material
  68227. * @param scene defines the hosting scene
  68228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68229. * @returns a new sky material
  68230. */
  68231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68232. }
  68233. }
  68234. declare module BABYLON {
  68235. /** @hidden */
  68236. export var terrainPixelShader: {
  68237. name: string;
  68238. shader: string;
  68239. };
  68240. }
  68241. declare module BABYLON {
  68242. /** @hidden */
  68243. export var terrainVertexShader: {
  68244. name: string;
  68245. shader: string;
  68246. };
  68247. }
  68248. declare module BABYLON {
  68249. export class TerrainMaterial extends BABYLON.PushMaterial {
  68250. private _mixTexture;
  68251. mixTexture: BABYLON.BaseTexture;
  68252. private _diffuseTexture1;
  68253. diffuseTexture1: BABYLON.Texture;
  68254. private _diffuseTexture2;
  68255. diffuseTexture2: BABYLON.Texture;
  68256. private _diffuseTexture3;
  68257. diffuseTexture3: BABYLON.Texture;
  68258. private _bumpTexture1;
  68259. bumpTexture1: BABYLON.Texture;
  68260. private _bumpTexture2;
  68261. bumpTexture2: BABYLON.Texture;
  68262. private _bumpTexture3;
  68263. bumpTexture3: BABYLON.Texture;
  68264. diffuseColor: BABYLON.Color3;
  68265. specularColor: BABYLON.Color3;
  68266. specularPower: number;
  68267. private _disableLighting;
  68268. disableLighting: boolean;
  68269. private _maxSimultaneousLights;
  68270. maxSimultaneousLights: number;
  68271. private _renderId;
  68272. constructor(name: string, scene: BABYLON.Scene);
  68273. needAlphaBlending(): boolean;
  68274. needAlphaTesting(): boolean;
  68275. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68276. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68277. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68278. getAnimatables(): BABYLON.IAnimatable[];
  68279. getActiveTextures(): BABYLON.BaseTexture[];
  68280. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68281. dispose(forceDisposeEffect?: boolean): void;
  68282. clone(name: string): TerrainMaterial;
  68283. serialize(): any;
  68284. getClassName(): string;
  68285. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68286. }
  68287. }
  68288. declare module BABYLON {
  68289. /** @hidden */
  68290. export var triplanarPixelShader: {
  68291. name: string;
  68292. shader: string;
  68293. };
  68294. }
  68295. declare module BABYLON {
  68296. /** @hidden */
  68297. export var triplanarVertexShader: {
  68298. name: string;
  68299. shader: string;
  68300. };
  68301. }
  68302. declare module BABYLON {
  68303. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68304. mixTexture: BABYLON.BaseTexture;
  68305. private _diffuseTextureX;
  68306. diffuseTextureX: BABYLON.BaseTexture;
  68307. private _diffuseTextureY;
  68308. diffuseTextureY: BABYLON.BaseTexture;
  68309. private _diffuseTextureZ;
  68310. diffuseTextureZ: BABYLON.BaseTexture;
  68311. private _normalTextureX;
  68312. normalTextureX: BABYLON.BaseTexture;
  68313. private _normalTextureY;
  68314. normalTextureY: BABYLON.BaseTexture;
  68315. private _normalTextureZ;
  68316. normalTextureZ: BABYLON.BaseTexture;
  68317. tileSize: number;
  68318. diffuseColor: BABYLON.Color3;
  68319. specularColor: BABYLON.Color3;
  68320. specularPower: number;
  68321. private _disableLighting;
  68322. disableLighting: boolean;
  68323. private _maxSimultaneousLights;
  68324. maxSimultaneousLights: number;
  68325. private _renderId;
  68326. constructor(name: string, scene: BABYLON.Scene);
  68327. needAlphaBlending(): boolean;
  68328. needAlphaTesting(): boolean;
  68329. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68330. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68331. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68332. getAnimatables(): BABYLON.IAnimatable[];
  68333. getActiveTextures(): BABYLON.BaseTexture[];
  68334. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68335. dispose(forceDisposeEffect?: boolean): void;
  68336. clone(name: string): TriPlanarMaterial;
  68337. serialize(): any;
  68338. getClassName(): string;
  68339. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68340. }
  68341. }
  68342. declare module BABYLON {
  68343. /** @hidden */
  68344. export var waterPixelShader: {
  68345. name: string;
  68346. shader: string;
  68347. };
  68348. }
  68349. declare module BABYLON {
  68350. /** @hidden */
  68351. export var waterVertexShader: {
  68352. name: string;
  68353. shader: string;
  68354. };
  68355. }
  68356. declare module BABYLON {
  68357. export class WaterMaterial extends BABYLON.PushMaterial {
  68358. renderTargetSize: BABYLON.Vector2;
  68359. private _bumpTexture;
  68360. bumpTexture: BABYLON.BaseTexture;
  68361. diffuseColor: BABYLON.Color3;
  68362. specularColor: BABYLON.Color3;
  68363. specularPower: number;
  68364. private _disableLighting;
  68365. disableLighting: boolean;
  68366. private _maxSimultaneousLights;
  68367. maxSimultaneousLights: number;
  68368. /**
  68369. * @param {number}: Represents the wind force
  68370. */
  68371. windForce: number;
  68372. /**
  68373. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68374. */
  68375. windDirection: BABYLON.Vector2;
  68376. /**
  68377. * @param {number}: Wave height, represents the height of the waves
  68378. */
  68379. waveHeight: number;
  68380. /**
  68381. * @param {number}: Bump height, represents the bump height related to the bump map
  68382. */
  68383. bumpHeight: number;
  68384. /**
  68385. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68386. */
  68387. private _bumpSuperimpose;
  68388. bumpSuperimpose: boolean;
  68389. /**
  68390. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68391. */
  68392. private _fresnelSeparate;
  68393. fresnelSeparate: boolean;
  68394. /**
  68395. * @param {boolean}: bump Waves modify the reflection.
  68396. */
  68397. private _bumpAffectsReflection;
  68398. bumpAffectsReflection: boolean;
  68399. /**
  68400. * @param {number}: The water color blended with the refraction (near)
  68401. */
  68402. waterColor: BABYLON.Color3;
  68403. /**
  68404. * @param {number}: The blend factor related to the water color
  68405. */
  68406. colorBlendFactor: number;
  68407. /**
  68408. * @param {number}: The water color blended with the reflection (far)
  68409. */
  68410. waterColor2: BABYLON.Color3;
  68411. /**
  68412. * @param {number}: The blend factor related to the water color (reflection, far)
  68413. */
  68414. colorBlendFactor2: number;
  68415. /**
  68416. * @param {number}: Represents the maximum length of a wave
  68417. */
  68418. waveLength: number;
  68419. /**
  68420. * @param {number}: Defines the waves speed
  68421. */
  68422. waveSpeed: number;
  68423. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68424. private _mesh;
  68425. private _refractionRTT;
  68426. private _reflectionRTT;
  68427. private _reflectionTransform;
  68428. private _lastTime;
  68429. private _lastDeltaTime;
  68430. private _renderId;
  68431. private _useLogarithmicDepth;
  68432. private _waitingRenderList;
  68433. /**
  68434. * Gets a boolean indicating that current material needs to register RTT
  68435. */
  68436. readonly hasRenderTargetTextures: boolean;
  68437. /**
  68438. * Constructor
  68439. */
  68440. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68441. useLogarithmicDepth: boolean;
  68442. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68443. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68444. addToRenderList(node: any): void;
  68445. enableRenderTargets(enable: boolean): void;
  68446. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68447. readonly renderTargetsEnabled: boolean;
  68448. needAlphaBlending(): boolean;
  68449. needAlphaTesting(): boolean;
  68450. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68451. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68452. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68453. private _createRenderTargets;
  68454. getAnimatables(): BABYLON.IAnimatable[];
  68455. getActiveTextures(): BABYLON.BaseTexture[];
  68456. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68457. dispose(forceDisposeEffect?: boolean): void;
  68458. clone(name: string): WaterMaterial;
  68459. serialize(): any;
  68460. getClassName(): string;
  68461. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68462. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68463. }
  68464. }
  68465. declare module BABYLON {
  68466. /** @hidden */
  68467. export var asciiartPixelShader: {
  68468. name: string;
  68469. shader: string;
  68470. };
  68471. }
  68472. declare module BABYLON {
  68473. /**
  68474. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68475. *
  68476. * It basically takes care rendering the font front the given font size to a texture.
  68477. * This is used later on in the postprocess.
  68478. */
  68479. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68480. private _font;
  68481. private _text;
  68482. private _charSize;
  68483. /**
  68484. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68485. */
  68486. readonly charSize: number;
  68487. /**
  68488. * Create a new instance of the Ascii Art FontTexture class
  68489. * @param name the name of the texture
  68490. * @param font the font to use, use the W3C CSS notation
  68491. * @param text the caracter set to use in the rendering.
  68492. * @param scene the scene that owns the texture
  68493. */
  68494. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68495. /**
  68496. * Gets the max char width of a font.
  68497. * @param font the font to use, use the W3C CSS notation
  68498. * @return the max char width
  68499. */
  68500. private getFontWidth;
  68501. /**
  68502. * Gets the max char height of a font.
  68503. * @param font the font to use, use the W3C CSS notation
  68504. * @return the max char height
  68505. */
  68506. private getFontHeight;
  68507. /**
  68508. * Clones the current AsciiArtTexture.
  68509. * @return the clone of the texture.
  68510. */
  68511. clone(): AsciiArtFontTexture;
  68512. /**
  68513. * Parses a json object representing the texture and returns an instance of it.
  68514. * @param source the source JSON representation
  68515. * @param scene the scene to create the texture for
  68516. * @return the parsed texture
  68517. */
  68518. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68519. }
  68520. /**
  68521. * Option available in the Ascii Art Post Process.
  68522. */
  68523. export interface IAsciiArtPostProcessOptions {
  68524. /**
  68525. * The font to use following the w3c font definition.
  68526. */
  68527. font?: string;
  68528. /**
  68529. * The character set to use in the postprocess.
  68530. */
  68531. characterSet?: string;
  68532. /**
  68533. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68534. * This number is defined between 0 and 1;
  68535. */
  68536. mixToTile?: number;
  68537. /**
  68538. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68539. * This number is defined between 0 and 1;
  68540. */
  68541. mixToNormal?: number;
  68542. }
  68543. /**
  68544. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68545. *
  68546. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68547. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68548. */
  68549. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68550. /**
  68551. * The font texture used to render the char in the post process.
  68552. */
  68553. private _asciiArtFontTexture;
  68554. /**
  68555. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68556. * This number is defined between 0 and 1;
  68557. */
  68558. mixToTile: number;
  68559. /**
  68560. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68561. * This number is defined between 0 and 1;
  68562. */
  68563. mixToNormal: number;
  68564. /**
  68565. * Instantiates a new Ascii Art Post Process.
  68566. * @param name the name to give to the postprocess
  68567. * @camera the camera to apply the post process to.
  68568. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68569. */
  68570. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68571. }
  68572. }
  68573. declare module BABYLON {
  68574. /** @hidden */
  68575. export var digitalrainPixelShader: {
  68576. name: string;
  68577. shader: string;
  68578. };
  68579. }
  68580. declare module BABYLON {
  68581. /**
  68582. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68583. *
  68584. * It basically takes care rendering the font front the given font size to a texture.
  68585. * This is used later on in the postprocess.
  68586. */
  68587. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68588. private _font;
  68589. private _text;
  68590. private _charSize;
  68591. /**
  68592. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68593. */
  68594. readonly charSize: number;
  68595. /**
  68596. * Create a new instance of the Digital Rain FontTexture class
  68597. * @param name the name of the texture
  68598. * @param font the font to use, use the W3C CSS notation
  68599. * @param text the caracter set to use in the rendering.
  68600. * @param scene the scene that owns the texture
  68601. */
  68602. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68603. /**
  68604. * Gets the max char width of a font.
  68605. * @param font the font to use, use the W3C CSS notation
  68606. * @return the max char width
  68607. */
  68608. private getFontWidth;
  68609. /**
  68610. * Gets the max char height of a font.
  68611. * @param font the font to use, use the W3C CSS notation
  68612. * @return the max char height
  68613. */
  68614. private getFontHeight;
  68615. /**
  68616. * Clones the current DigitalRainFontTexture.
  68617. * @return the clone of the texture.
  68618. */
  68619. clone(): DigitalRainFontTexture;
  68620. /**
  68621. * Parses a json object representing the texture and returns an instance of it.
  68622. * @param source the source JSON representation
  68623. * @param scene the scene to create the texture for
  68624. * @return the parsed texture
  68625. */
  68626. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68627. }
  68628. /**
  68629. * Option available in the Digital Rain Post Process.
  68630. */
  68631. export interface IDigitalRainPostProcessOptions {
  68632. /**
  68633. * The font to use following the w3c font definition.
  68634. */
  68635. font?: string;
  68636. /**
  68637. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68638. * This number is defined between 0 and 1;
  68639. */
  68640. mixToTile?: number;
  68641. /**
  68642. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68643. * This number is defined between 0 and 1;
  68644. */
  68645. mixToNormal?: number;
  68646. }
  68647. /**
  68648. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68649. *
  68650. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68651. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68652. */
  68653. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68654. /**
  68655. * The font texture used to render the char in the post process.
  68656. */
  68657. private _digitalRainFontTexture;
  68658. /**
  68659. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68660. * This number is defined between 0 and 1;
  68661. */
  68662. mixToTile: number;
  68663. /**
  68664. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68665. * This number is defined between 0 and 1;
  68666. */
  68667. mixToNormal: number;
  68668. /**
  68669. * Instantiates a new Digital Rain Post Process.
  68670. * @param name the name to give to the postprocess
  68671. * @camera the camera to apply the post process to.
  68672. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68673. */
  68674. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68675. }
  68676. }
  68677. declare module BABYLON {
  68678. /** @hidden */
  68679. export var oceanPostProcessPixelShader: {
  68680. name: string;
  68681. shader: string;
  68682. };
  68683. }
  68684. declare module BABYLON {
  68685. /**
  68686. * Option available in the Ocean Post Process.
  68687. */
  68688. export interface IOceanPostProcessOptions {
  68689. /**
  68690. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68691. */
  68692. reflectionSize?: number | {
  68693. width: number;
  68694. height: number;
  68695. } | {
  68696. ratio: number;
  68697. };
  68698. /**
  68699. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68700. */
  68701. refractionSize?: number | {
  68702. width: number;
  68703. height: number;
  68704. } | {
  68705. ratio: number;
  68706. };
  68707. }
  68708. /**
  68709. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68710. *
  68711. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68712. * Example usage:
  68713. * var pp = new OceanPostProcess("myOcean", camera);
  68714. * pp.reflectionEnabled = true;
  68715. * pp.refractionEnabled = true;
  68716. */
  68717. export class OceanPostProcess extends BABYLON.PostProcess {
  68718. /**
  68719. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68720. */
  68721. /**
  68722. * Sets weither or not the real-time reflection is enabled on the ocean.
  68723. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68724. */
  68725. reflectionEnabled: boolean;
  68726. /**
  68727. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68728. */
  68729. /**
  68730. * Sets weither or not the real-time refraction is enabled on the ocean.
  68731. * Is set to true, the refraction render target texture will be used as refraction texture.
  68732. */
  68733. refractionEnabled: boolean;
  68734. /**
  68735. * Gets wether or not the post-processes is supported by the running hardware.
  68736. * This requires draw buffer supports.
  68737. */
  68738. readonly isSupported: boolean;
  68739. /**
  68740. * This is the reflection mirror texture used to display reflections on the ocean.
  68741. * By default, render list is empty.
  68742. */
  68743. reflectionTexture: BABYLON.MirrorTexture;
  68744. /**
  68745. * This is the refraction render target texture used to display refraction on the ocean.
  68746. * By default, render list is empty.
  68747. */
  68748. refractionTexture: BABYLON.RenderTargetTexture;
  68749. private _time;
  68750. private _cameraRotation;
  68751. private _cameraViewMatrix;
  68752. private _reflectionEnabled;
  68753. private _refractionEnabled;
  68754. private _geometryRenderer;
  68755. /**
  68756. * Instantiates a new Ocean Post Process.
  68757. * @param name the name to give to the postprocess.
  68758. * @camera the camera to apply the post process to.
  68759. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68760. */
  68761. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68762. /**
  68763. * Returns the appropriate defines according to the current configuration.
  68764. */
  68765. private _getDefines;
  68766. /**
  68767. * Computes the current camera rotation as the shader requires a camera rotation.
  68768. */
  68769. private _computeCameraRotation;
  68770. }
  68771. }
  68772. declare module BABYLON {
  68773. /** @hidden */
  68774. export var brickProceduralTexturePixelShader: {
  68775. name: string;
  68776. shader: string;
  68777. };
  68778. }
  68779. declare module BABYLON {
  68780. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68781. private _numberOfBricksHeight;
  68782. private _numberOfBricksWidth;
  68783. private _jointColor;
  68784. private _brickColor;
  68785. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68786. updateShaderUniforms(): void;
  68787. numberOfBricksHeight: number;
  68788. numberOfBricksWidth: number;
  68789. jointColor: BABYLON.Color3;
  68790. brickColor: BABYLON.Color3;
  68791. /**
  68792. * Serializes this brick procedural texture
  68793. * @returns a serialized brick procedural texture object
  68794. */
  68795. serialize(): any;
  68796. /**
  68797. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68798. * @param parsedTexture defines parsed texture data
  68799. * @param scene defines the current scene
  68800. * @param rootUrl defines the root URL containing brick procedural texture information
  68801. * @returns a parsed Brick Procedural BABYLON.Texture
  68802. */
  68803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68804. }
  68805. }
  68806. declare module BABYLON {
  68807. /** @hidden */
  68808. export var cloudProceduralTexturePixelShader: {
  68809. name: string;
  68810. shader: string;
  68811. };
  68812. }
  68813. declare module BABYLON {
  68814. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68815. private _skyColor;
  68816. private _cloudColor;
  68817. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68818. updateShaderUniforms(): void;
  68819. skyColor: BABYLON.Color4;
  68820. cloudColor: BABYLON.Color4;
  68821. /**
  68822. * Serializes this cloud procedural texture
  68823. * @returns a serialized cloud procedural texture object
  68824. */
  68825. serialize(): any;
  68826. /**
  68827. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68828. * @param parsedTexture defines parsed texture data
  68829. * @param scene defines the current scene
  68830. * @param rootUrl defines the root URL containing cloud procedural texture information
  68831. * @returns a parsed Cloud Procedural BABYLON.Texture
  68832. */
  68833. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68834. }
  68835. }
  68836. declare module BABYLON {
  68837. /** @hidden */
  68838. export var fireProceduralTexturePixelShader: {
  68839. name: string;
  68840. shader: string;
  68841. };
  68842. }
  68843. declare module BABYLON {
  68844. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68845. private _time;
  68846. private _speed;
  68847. private _autoGenerateTime;
  68848. private _fireColors;
  68849. private _alphaThreshold;
  68850. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68851. updateShaderUniforms(): void;
  68852. render(useCameraPostProcess?: boolean): void;
  68853. static readonly PurpleFireColors: BABYLON.Color3[];
  68854. static readonly GreenFireColors: BABYLON.Color3[];
  68855. static readonly RedFireColors: BABYLON.Color3[];
  68856. static readonly BlueFireColors: BABYLON.Color3[];
  68857. autoGenerateTime: boolean;
  68858. fireColors: BABYLON.Color3[];
  68859. time: number;
  68860. speed: BABYLON.Vector2;
  68861. alphaThreshold: number;
  68862. /**
  68863. * Serializes this fire procedural texture
  68864. * @returns a serialized fire procedural texture object
  68865. */
  68866. serialize(): any;
  68867. /**
  68868. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68869. * @param parsedTexture defines parsed texture data
  68870. * @param scene defines the current scene
  68871. * @param rootUrl defines the root URL containing fire procedural texture information
  68872. * @returns a parsed Fire Procedural BABYLON.Texture
  68873. */
  68874. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68875. }
  68876. }
  68877. declare module BABYLON {
  68878. /** @hidden */
  68879. export var grassProceduralTexturePixelShader: {
  68880. name: string;
  68881. shader: string;
  68882. };
  68883. }
  68884. declare module BABYLON {
  68885. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68886. private _grassColors;
  68887. private _groundColor;
  68888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68889. updateShaderUniforms(): void;
  68890. grassColors: BABYLON.Color3[];
  68891. groundColor: BABYLON.Color3;
  68892. /**
  68893. * Serializes this grass procedural texture
  68894. * @returns a serialized grass procedural texture object
  68895. */
  68896. serialize(): any;
  68897. /**
  68898. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68899. * @param parsedTexture defines parsed texture data
  68900. * @param scene defines the current scene
  68901. * @param rootUrl defines the root URL containing grass procedural texture information
  68902. * @returns a parsed Grass Procedural BABYLON.Texture
  68903. */
  68904. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68905. }
  68906. }
  68907. declare module BABYLON {
  68908. /** @hidden */
  68909. export var marbleProceduralTexturePixelShader: {
  68910. name: string;
  68911. shader: string;
  68912. };
  68913. }
  68914. declare module BABYLON {
  68915. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68916. private _numberOfTilesHeight;
  68917. private _numberOfTilesWidth;
  68918. private _amplitude;
  68919. private _jointColor;
  68920. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68921. updateShaderUniforms(): void;
  68922. numberOfTilesHeight: number;
  68923. amplitude: number;
  68924. numberOfTilesWidth: number;
  68925. jointColor: BABYLON.Color3;
  68926. /**
  68927. * Serializes this marble procedural texture
  68928. * @returns a serialized marble procedural texture object
  68929. */
  68930. serialize(): any;
  68931. /**
  68932. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68933. * @param parsedTexture defines parsed texture data
  68934. * @param scene defines the current scene
  68935. * @param rootUrl defines the root URL containing marble procedural texture information
  68936. * @returns a parsed Marble Procedural BABYLON.Texture
  68937. */
  68938. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68939. }
  68940. }
  68941. declare module BABYLON {
  68942. /** @hidden */
  68943. export var normalMapProceduralTexturePixelShader: {
  68944. name: string;
  68945. shader: string;
  68946. };
  68947. }
  68948. declare module BABYLON {
  68949. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68950. private _baseTexture;
  68951. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68952. updateShaderUniforms(): void;
  68953. render(useCameraPostProcess?: boolean): void;
  68954. resize(size: any, generateMipMaps: any): void;
  68955. baseTexture: BABYLON.Texture;
  68956. /**
  68957. * Serializes this normal map procedural texture
  68958. * @returns a serialized normal map procedural texture object
  68959. */
  68960. serialize(): any;
  68961. /**
  68962. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68963. * @param parsedTexture defines parsed texture data
  68964. * @param scene defines the current scene
  68965. * @param rootUrl defines the root URL containing normal map procedural texture information
  68966. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68967. */
  68968. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68969. }
  68970. }
  68971. declare module BABYLON {
  68972. /** @hidden */
  68973. export var perlinNoiseProceduralTexturePixelShader: {
  68974. name: string;
  68975. shader: string;
  68976. };
  68977. }
  68978. declare module BABYLON {
  68979. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68980. time: number;
  68981. timeScale: number;
  68982. translationSpeed: number;
  68983. private _currentTranslation;
  68984. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68985. updateShaderUniforms(): void;
  68986. render(useCameraPostProcess?: boolean): void;
  68987. resize(size: any, generateMipMaps: any): void;
  68988. /**
  68989. * Serializes this perlin noise procedural texture
  68990. * @returns a serialized perlin noise procedural texture object
  68991. */
  68992. serialize(): any;
  68993. /**
  68994. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68995. * @param parsedTexture defines parsed texture data
  68996. * @param scene defines the current scene
  68997. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68998. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68999. */
  69000. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69001. }
  69002. }
  69003. declare module BABYLON {
  69004. /** @hidden */
  69005. export var roadProceduralTexturePixelShader: {
  69006. name: string;
  69007. shader: string;
  69008. };
  69009. }
  69010. declare module BABYLON {
  69011. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69012. private _roadColor;
  69013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69014. updateShaderUniforms(): void;
  69015. roadColor: BABYLON.Color3;
  69016. /**
  69017. * Serializes this road procedural texture
  69018. * @returns a serialized road procedural texture object
  69019. */
  69020. serialize(): any;
  69021. /**
  69022. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69023. * @param parsedTexture defines parsed texture data
  69024. * @param scene defines the current scene
  69025. * @param rootUrl defines the root URL containing road procedural texture information
  69026. * @returns a parsed Road Procedural BABYLON.Texture
  69027. */
  69028. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69029. }
  69030. }
  69031. declare module BABYLON {
  69032. /** @hidden */
  69033. export var starfieldProceduralTexturePixelShader: {
  69034. name: string;
  69035. shader: string;
  69036. };
  69037. }
  69038. declare module BABYLON {
  69039. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69040. private _time;
  69041. private _alpha;
  69042. private _beta;
  69043. private _zoom;
  69044. private _formuparam;
  69045. private _stepsize;
  69046. private _tile;
  69047. private _brightness;
  69048. private _darkmatter;
  69049. private _distfading;
  69050. private _saturation;
  69051. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69052. updateShaderUniforms(): void;
  69053. time: number;
  69054. alpha: number;
  69055. beta: number;
  69056. formuparam: number;
  69057. stepsize: number;
  69058. zoom: number;
  69059. tile: number;
  69060. brightness: number;
  69061. darkmatter: number;
  69062. distfading: number;
  69063. saturation: number;
  69064. /**
  69065. * Serializes this starfield procedural texture
  69066. * @returns a serialized starfield procedural texture object
  69067. */
  69068. serialize(): any;
  69069. /**
  69070. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69071. * @param parsedTexture defines parsed texture data
  69072. * @param scene defines the current scene
  69073. * @param rootUrl defines the root URL containing startfield procedural texture information
  69074. * @returns a parsed Starfield Procedural BABYLON.Texture
  69075. */
  69076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69077. }
  69078. }
  69079. declare module BABYLON {
  69080. /** @hidden */
  69081. export var woodProceduralTexturePixelShader: {
  69082. name: string;
  69083. shader: string;
  69084. };
  69085. }
  69086. declare module BABYLON {
  69087. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69088. private _ampScale;
  69089. private _woodColor;
  69090. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69091. updateShaderUniforms(): void;
  69092. ampScale: number;
  69093. woodColor: BABYLON.Color3;
  69094. /**
  69095. * Serializes this wood procedural texture
  69096. * @returns a serialized wood procedural texture object
  69097. */
  69098. serialize(): any;
  69099. /**
  69100. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69101. * @param parsedTexture defines parsed texture data
  69102. * @param scene defines the current scene
  69103. * @param rootUrl defines the root URL containing wood procedural texture information
  69104. * @returns a parsed Wood Procedural BABYLON.Texture
  69105. */
  69106. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69107. }
  69108. }